head	1.14;
access;
symbols
	TIGRIS_1_1_0RC2:1.9
	TIGRIS_1_1_0RC1:1.9
	TIGRIS_1_1:1.9.0.4
	TIGRIS_1_0_8:1.9
	TIGRIS_1_0_8RC3:1.9
	TIGRIS_1_0_8RC2:1.9
	TIGRIS_1_0_8RC1:1.9
	TIGRIS_1_0_7:1.9
	TIGRIS_1_0_7RC3:1.9
	TIGRIS_1_0_7RC2:1.9
	TIGRIS_1_0_7RC1:1.9
	TIGRIS_1_0_6:1.9
	TIGRIS_1_0_6RC5:1.9
	TIGRIS_1_0_6RC4:1.9
	TIGRIS_1_0_6RC3:1.9
	TIGRIS_1_0_6RC2:1.9
	TIGRIS_1_0_6RC1:1.9
	TIGRIS_1_0_5:1.9
	TIGRIS_1_0_5RC6:1.9
	TIGRIS_1_0_5RC5:1.9
	TIGRIS_1_0_5RC4:1.9
	TIGRIS_1_0_5RC3:1.9
	TIGRIS_1_0_5RC2:1.9
	TIGRIS_1_0_5RC1:1.9
	TIGRIS_1_0_4:1.9
	TIGRIS_1_0_3:1.9
	TIGRIS_1_0_2:1.9
	TIGRIS_1_0_1:1.9
	TIGRIS_1_0:1.9.0.6
	TIGRIS_1_0_0:1.9
	TIGRIS_1_0_0_RC1:1.9.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.2.2.1
	TIGRIS_0_9_2_3:1.2
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.5
	TIGRIS_0_9_2_1:1.5
	TIGRIS_0_9_2:1.2.0.2
	TIGRIS_0_9_0:1.1.1.1.0.4
	TIGRIS_0_8_4:1.1.1.1.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.14
date	2001.07.16.02.23.42;	author jrobbins;	state dead;
branches;
next	1.13;

1.13
date	2001.06.04.00.28.09;	author dlr;	state Exp;
branches;
next	1.12;

1.12
date	2001.06.04.00.26.12;	author dlr;	state Exp;
branches;
next	1.11;

1.11
date	2001.05.31.19.12.28;	author elicia;	state Exp;
branches;
next	1.10;

1.10
date	2001.05.23.01.50.15;	author dlr;	state Exp;
branches;
next	1.9;

1.9
date	2001.03.07.01.53.24;	author lucas;	state Exp;
branches;
next	1.8;

1.8
date	2001.02.21.01.08.23;	author dlr;	state Exp;
branches;
next	1.7;

1.7
date	2001.02.01.00.29.56;	author elicia;	state Exp;
branches;
next	1.6;

1.6
date	2001.01.30.02.59.47;	author elicia;	state Exp;
branches;
next	1.5;

1.5
date	2001.01.26.18.29.04;	author edk;	state Exp;
branches
	1.5.2.1;
next	1.4;

1.4
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.3;

1.3
date	2001.01.23.02.24.06;	author elicia;	state Exp;
branches;
next	1.2;

1.2
date	2001.01.12.22.11.10;	author elicia;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2000.11.12.21.16.00;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.16.00;	author dlr;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2001.02.21.00.35.07;	author dlr;	state Exp;
branches;
next	;

1.2.2.1
date	2001.02.01.18.49.24;	author jrobbins;	state Exp;
branches;
next	;

1.5.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	1.5.2.2;

1.5.2.2
date	2001.02.17.00.51.09;	author elicia;	state Exp;
branches;
next	1.5.2.3;

1.5.2.3
date	2001.02.20.01.30.05;	author dlr;	state Exp;
branches;
next	1.5.2.4;

1.5.2.4
date	2001.02.20.01.33.03;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.14
log
@factoring project documents out to project nidaba.tigris.org
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by Collab.Net (http://www.collab.net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of Collab.Net.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */


package org.tigris.helm.project;

import org.apache.turbine.util.Log;
import org.apache.turbine.util.StringUtils;
import org.apache.turbine.util.TurbineException;

import org.apache.velocity.context.Context;

import org.joist.*;
import org.joist.util.*;
import org.joist.security.RedirectException;

import org.tigris.helm.security.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.*;

/**
 * Handles deletes of documents.
 */
public class ProjectDocumentDelete extends HelmServlet
{
    protected String processRequest(Context ctx)
        throws TurbineException, RedirectException
    {
        String templateName = super.processRequest(ctx);
     
        String type = null;
        String documentID = getParameter(ctx, "documentID");

        if (StringUtils.isEmpty(documentID))
        {
            appendToMessage(ctx, "No document specified");
        }
        else 
        {
            // Determine which button was pushed
            String action = (String) ctx.get("action");

            try
            {
                User loginUser = getLoginUser(ctx);
                AccessControlList acl = loginUser.getACL();
                Project currentProject = getCurrentProject(ctx);
                ProjectDocument document = (ProjectDocument)ProjectDocumentPeer
                    .getInstance(documentID);
                ctx.put("document", document);

                if (action.equals("Confirm Delete"))
                {                        
                    // If the doc was uploaded, deletefromFilesystem is true.
                    String sectionID = Integer.toString(document.getSectionID());
                    boolean deleteFromFilesystem =
                        document.getFileName() != null;
                    String htURL = URL.schemeAndServer(getRequest(ctx))
                        + "/servlets/ProjectDocumentList";
                    document.delete(acl, deleteFromFilesystem, htURL);
                    StringBuffer urlBuf = new StringBuffer(
                                 "ProjectDocumentList?rootSectionID=");
                    urlBuf.append(sectionID);
                    redirectToURL(ctx, urlBuf.toString());
                }
            }
            catch (RedirectException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new TurbineException(e);
            }
        }

        return templateName;
    }
}
@


1.13
log
@More rigorous document ID check and misc. cleanup of unused code.
@
text
@@


1.12
log
@Properly rethrown RedirectExceptions (do not wrap w/ TurbineException).
@
text
@a49 4
import java.io.*;
import java.util.*;
import java.sql.*;

d51 1
d53 1
a53 1
import org.apache.turbine.util.TurbineException;
a54 1
import com.workingdogs.village.*;
a57 1
import org.tigris.helm.tool.SessionManager;
a62 1
import org.tigris.helm.om.*;
d64 3
d77 2
a78 1
        if (documentID == null) {
@


1.11
log
@Many changes to the Project Documents component.  It is now replacing ProjectDownloads (will remove it from cvs after a while). Took out the "type" variable so that a Document can have a file upload attachment and/or a remote URL and/or pasted text, instead of only one of the three. Added fields for modified by and modified date. Also added isPublic field for file uploads, and a status field.

Document file uploads are now being saved in helm/data/fileserv/documents/[document_id]. Refactored htAccess file code to reflect that and to fix other bugs.
Dropped $type parameter from URL arguments."

UI has changed: ProjectDocumentList now has a 2-pane UI with a folder tree on the left pane and the document list on the right.  When in the list you have a "root folder" that is the root of the tree.  Folders can now be infinitely nested instead of just two levels deep.  You add a document or subfolder directly to the root section.
@
text
@d112 3
a114 2
            catch (RedirectException e) {
                throw new TurbineException(e);
d116 2
a117 1
            catch (Exception e) {
@


1.10
log
@Ported Helm from WebMacro to Velocity.
@
text
@a78 1
        String sectionID = getParameter(ctx, "sectionID");
a79 2
        // Determine whether the selected item to delete is a document or
        // section.
d100 1
d102 1
a102 1
                        document.getType().equals("upload");
d106 4
a109 2
                    redirectToURL(ctx, currentProject.getProjectPageURL
                                  ("ProjectDocumentList"));
@


1.9
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d55 3
a57 1
import org.webmacro.servlet.*;
d62 1
a62 1
import org.joist.session.*;
d72 2
a73 2
    protected String processRequest (Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
d75 1
a75 1
        String templateName = super.processRequest (conn, ctx);
d78 2
a79 2
        String documentID = ctx.getForm("documentID");
        String sectionID = ctx.getForm("sectionID");
d105 1
a105 1
                    String htURL = URL.schemeAndServer(ctx)
d113 1
a113 1
                throw new HandlerException(e.getMessage());
d116 1
a116 1
                throw new HandlerException(e.getMessage());
@


1.8
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d66 1
a66 2
import org.tigris.helm.om.peer.*;

@


1.7
log
@passing context to Document to determine url for .htaccess file
@
text
@d2 1
a2 1
 * Copyright (c) 2000 CollabNet.  All rights reserved.
d17 1
a17 1
 * software developed by Collab.Net (http://www.Collab.Net/)."
d32 1
a32 1
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d54 1
a54 1
import org.webmacro.util.Log;
a60 1
import org.joist.database.JoistDatabaseException;
d65 2
a66 1
import org.tigris.helm.database.*;
d71 4
a74 9
  public static final  String versionID = "$Id: ProjectDocumentDelete.java,v 1.6 2001/01/30 02:59:47 elicia Exp $";
  private static Log log = new Log("PjtDocDlt", "ProjectDocumentDelete");
  private static boolean debug = true;


  protected String processRequest (Connection conn, WebContext ctx)
      throws HandlerException, RedirectException
  {
      String templateName = super.processRequest (conn, ctx);
d76 46
a121 43
      String type = null;
      String documentID = ctx.getForm("documentID");
      String sectionID = ctx.getForm("sectionID");

      // Determine whether the selected item to delete is a document or section
      if (documentID == null)
          appendToMessage(ctx, "No document specified");
      else 
      {

          // Determine which button was pushed
          String action = (String) ctx.get("action");

          try
          {
             AccessControlList acl = getACL(ctx, conn);
             Project currentProject = getCurrentProject(ctx);
             ProjectDocumentManager docMgr = (ProjectDocumentManager)
                getDataManager (ctx).getManager
                ("org.tigris.helm.database.ProjectDocumentManager");

             Document document = new Document(conn, dMgr, documentID);
             ctx.put("document", document);

             if (action.equals("Confirm Delete"))
             {                        
                // If the doc was uploaded, deletefromFilesystem is true
                boolean deleteFromFilesystem = (document.getType().equals("upload"));
                document.delete(acl, deleteFromFilesystem, ctx);
                redirectToURL(ctx, currentProject.getProjectPageURL("ProjectDocuments"));
             }          

          } catch (RedirectException e) {
             throw new HandlerException(e.getMessage());
          } catch (Exception e) {
             throw new HandlerException(e.getMessage());
          }
     }

     return templateName;
  }

} /* end class ProjectDocumentDelete */
@


1.6
log
@added editing of .htaccess file on edit and deleting of a file
@
text
@d71 1
a71 1
  public static final  String versionID = "$Id: ProjectDocumentDelete.java,v 1.5 2001/01/26 18:29:04 edk Exp $";
d107 3
a109 3
                String htURL = URL.schemeAndServer(ctx)
                               + "/servlets/ProjectDocuments";
                document.delete(acl, true, htURL);
@


1.5
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d71 1
a71 1
  public static final  String versionID = "$Id: ProjectDocumentDelete.java,v 1.3 2001/01/23 02:24:06 elicia Exp $";
d107 3
a109 1
                document.delete(acl, true);
@


1.5.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d71 1
a71 1
  public static final  String versionID = "$Id: ProjectDocumentDelete.java,v 1.5 2001/01/26 18:29:04 edk Exp $";
@


1.5.2.2
log
@ported to turbine
@
text
@d54 1
a54 1
import org.apache.turbine.util.Log;
d61 1
d66 1
a66 2
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d71 2
d96 1
a96 2
             User loginUser = getLoginUser(ctx);
             AccessControlList acl = loginUser.getACL();
d98 5
a102 2
             ProjectDocument document = (ProjectDocument)ProjectDocumentPeer
                                        .getInstance(documentID);
d107 2
a108 6
                // If the doc was uploaded, deletefromFilesystem is true
                boolean deleteFromFilesystem = (document.getType().equals("upload"));
                String htURL = URL.schemeAndServer(ctx)
                               + "/servlets/ProjectDocumentList";
                document.delete(acl, deleteFromFilesystem, htURL);
                redirectToURL(ctx, currentProject.getProjectPageURL("ProjectDocumentList"));
@


1.5.2.3
log
@Formatting and copyright changes.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d17 1
a17 1
 * software developed by Collab.Net (http://www.collab.net/)."
d32 1
a32 1
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d71 7
a77 4
    protected String processRequest (Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
    {
        String templateName = super.processRequest (conn, ctx);
d79 43
a121 42
        String type = null;
        String documentID = ctx.getForm("documentID");
        String sectionID = ctx.getForm("sectionID");

        // Determine whether the selected item to delete is a document or section
        if (documentID == null)
            appendToMessage(ctx, "No document specified");
        else 
        {

            // Determine which button was pushed
            String action = (String) ctx.get("action");

            try
            {
                User loginUser = getLoginUser(ctx);
                AccessControlList acl = loginUser.getACL();
                Project currentProject = getCurrentProject(ctx);
                ProjectDocument document = (ProjectDocument)ProjectDocumentPeer
                    .getInstance(documentID);
                ctx.put("document", document);

                if (action.equals("Confirm Delete"))
                {                        
                    // If the doc was uploaded, deletefromFilesystem is true
                    boolean deleteFromFilesystem = (document.getType().equals("upload"));
                    String htURL = URL.schemeAndServer(ctx)
                        + "/servlets/ProjectDocumentList";
                    document.delete(acl, deleteFromFilesystem, htURL);
                    redirectToURL(ctx, currentProject.getProjectPageURL("ProjectDocumentList"));
                }          

            } catch (RedirectException e) {
                throw new HandlerException(e.getMessage());
            } catch (Exception e) {
                throw new HandlerException(e.getMessage());
            }
        }

        return templateName;
    }
}
@


1.5.2.4
log
@A bit more clean up.
@
text
@d80 2
a81 3
        // Determine whether the selected item to delete is a document or
        // section.
        if (documentID == null) {
a82 1
        }
d85 1
d100 2
a101 3
                    // If the doc was uploaded, deletefromFilesystem is true.
                    boolean deleteFromFilesystem =
                        document.getType().equals("upload");
d105 4
a108 5
                    redirectToURL(ctx, currentProject.getProjectPageURL
                                  ("ProjectDocumentList"));
                }
            }
            catch (RedirectException e) {
d110 1
a110 2
            }
            catch (Exception e) {
@


1.4
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@@


1.3
log
@cleanup
@
text
@d71 1
a71 1
  public static final  String versionID = "$Id: ProjectDocumentDelete.java,v 1.2 2001/01/12 22:11:10 elicia Exp $";
@


1.2
log
@initial revisions
@
text
@d62 1
d64 1
a64 1
import org.tigris.helm.security.HelmServlet;
a66 1
import org.joist.security.RedirectException;
d71 1
a71 1
  public static final  String versionID = "$Id: ProjectDocuments.java,v 1.2 2000/12/30 05:01:29 elicia Exp $";
d76 1
a76 1
  protected String processRequest (Connection conn, WebContext context)
d79 1
a79 1
      String templateName = super.processRequest (conn, context);
d82 2
a83 2
      String documentID = context.getForm("documentID");
      String sectionID = context.getForm("sectionID");
d87 1
a87 1
          appendToMessage(context, "No document specified");
d92 1
a92 1
          String action = (String) context.get("action");
d96 2
a97 1
             Project currentProject = getCurrentProject(context);
d99 1
a99 1
                getDataManager (context).getManager
d103 1
a103 1
             context.put("document", document);
d107 2
a108 2
                docMgr.deleteDocument(conn, documentID);   
                redirectToURL(context, currentProject.getProjectPageURL("ProjectDocuments"));
d111 1
a111 6
          }
          catch (DoesNotExist e) {
             throw new HandlerException(e.getMessage());
          } catch (SQLException e) {
             throw new HandlerException(e.getMessage());
          } catch (JoistDatabaseException e) {
d113 1
a113 1
          } catch (DataSetException e) {
@


1.2.2.1
log
@moved changed from HEAD for ProjectDocuments and ProjectDownloads
@
text
@a61 1
import org.joist.security.RedirectException;
d63 1
a63 1
import org.tigris.helm.security.*;
d66 1
d71 1
a71 1
  public static final  String versionID = "$Id: ProjectDocumentDelete.java,v 1.7 2001/02/01 00:29:56 elicia Exp $";
d76 1
a76 1
  protected String processRequest (Connection conn, WebContext ctx)
d79 1
a79 1
      String templateName = super.processRequest (conn, ctx);
d82 2
a83 2
      String documentID = ctx.getForm("documentID");
      String sectionID = ctx.getForm("sectionID");
d87 1
a87 1
          appendToMessage(ctx, "No document specified");
d92 1
a92 1
          String action = (String) ctx.get("action");
d96 1
a96 2
             AccessControlList acl = getACL(ctx, conn);
             Project currentProject = getCurrentProject(ctx);
d98 1
a98 1
                getDataManager (ctx).getManager
d102 1
a102 1
             ctx.put("document", document);
d106 2
a107 4
                // If the doc was uploaded, deletefromFilesystem is true
                boolean deleteFromFilesystem = (document.getType().equals("upload"));
                document.delete(acl, deleteFromFilesystem, ctx);
                redirectToURL(ctx, currentProject.getProjectPageURL("ProjectDocuments"));
d110 6
a115 1
          } catch (RedirectException e) {
d117 1
a117 1
          } catch (Exception e) {
@


1.1
log
@Initial revision
@
text
@a52 2
import javax.servlet.*;
import javax.servlet.http.*;
d54 1
a54 1
import org.webmacro.util.*;
d56 1
a56 3
import org.webmacro.engine.*;
import org.webmacro.broker.*;
import org.webmacro.resource.*;
d61 1
d64 2
a66 1
import org.joist.database.DataManager;
d69 52
d122 2
a124 53
public class ProjectDocumentDelete extends org.tigris.helm.security.HelmServlet {
    public static final  String versionID = "$Id: ProjectDocumentDelete.java,v 1.4 2000/11/06 06:15:31 edk Exp $";
    private static Log log = new Log("ProjectDocumentDelete", "Tigris StartPage");
    private static boolean debug = true;

    /**
     *  Display and process the login screen.
     */
    protected String
	processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
    {
	if (debug) log.debug("ProjectDocumentDelete: started!");

	String templateName = super.processRequest(connection, context);
	

	if (debug) log.debug("ProjectDocumentDelete: step 1");

	HttpServletRequest request = context.getRequest();
	HttpServletResponse response = context.getResponse();
	HttpSession session = context.getSession();
	SessionManager sMgr = getSessionManager(context);
	DataManager dMgr = sMgr.getDataManager();

	if (debug) log.debug("ProjectDocumentDelete: step 2");

	String action = (String)context.get("action");

        if (debug) log.debug("ProjectDocumentDelete: step 3");

	try {
	    String userID = sMgr.getUserID();
	    if (debug) log.debug("ProjectDocumentDelete: userID=" + userID );
	    String loginID = sMgr.getLoginID();
	    context.put("loginID", loginID);
	    if (debug) log.debug("ProjectDocumentDelete: loginID=" + loginID );
	}
	catch (Exception e) {
	    log.exception(e);
	    String message = "ProjectDocumentDelete: " + e.getMessage();
	    if (debug) log.debug(message);
	    context.put("message", message);
	}
	
	
	if (debug) log.debug("ProjectDocumentDelete: action=" + action );

	if (debug) log.debug("ProjectDocumentDelete:  done");

        return templateName;
    }
  
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@


1.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d17 1
a17 1
 * software developed by Collab.Net (http://www.collab.net/)."
d32 1
a32 1
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d53 2
d56 1
a56 1
import org.apache.turbine.util.Log;
d58 3
a60 1
import com.workingdogs.village.*;
d65 2
d68 2
a70 4
import org.tigris.helm.security.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d73 11
a83 4
public class ProjectDocumentDelete extends HelmServlet
{
    protected String processRequest (Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
d85 37
a121 44
        String templateName = super.processRequest (conn, ctx);
     
        String type = null;
        String documentID = ctx.getForm("documentID");
        String sectionID = ctx.getForm("sectionID");

        // Determine whether the selected item to delete is a document or
        // section.
        if (documentID == null) {
            appendToMessage(ctx, "No document specified");
        }
        else 
        {
            // Determine which button was pushed
            String action = (String) ctx.get("action");

            try
            {
                User loginUser = getLoginUser(ctx);
                AccessControlList acl = loginUser.getACL();
                Project currentProject = getCurrentProject(ctx);
                ProjectDocument document = (ProjectDocument)ProjectDocumentPeer
                    .getInstance(documentID);
                ctx.put("document", document);

                if (action.equals("Confirm Delete"))
                {                        
                    // If the doc was uploaded, deletefromFilesystem is true.
                    boolean deleteFromFilesystem =
                        document.getType().equals("upload");
                    String htURL = URL.schemeAndServer(ctx)
                        + "/servlets/ProjectDocumentList";
                    document.delete(acl, deleteFromFilesystem, htURL);
                    redirectToURL(ctx, currentProject.getProjectPageURL
                                  ("ProjectDocumentList"));
                }
            }
            catch (RedirectException e) {
                throw new HandlerException(e.getMessage());
            }
            catch (Exception e) {
                throw new HandlerException(e.getMessage());
            }
        }
d125 2
a126 1
}
@

