head	1.15;
access;
symbols
	TIGRIS_1_1_0RC2:1.11
	TIGRIS_1_1_0RC1:1.11
	TIGRIS_1_1:1.11.0.4
	TIGRIS_1_0_8:1.11
	TIGRIS_1_0_8RC3:1.11
	TIGRIS_1_0_8RC2:1.11
	TIGRIS_1_0_8RC1:1.11
	TIGRIS_1_0_7:1.11
	TIGRIS_1_0_7RC3:1.11
	TIGRIS_1_0_7RC2:1.11
	TIGRIS_1_0_7RC1:1.11
	TIGRIS_1_0_6:1.11
	TIGRIS_1_0_6RC5:1.11
	TIGRIS_1_0_6RC4:1.11
	TIGRIS_1_0_6RC3:1.11
	TIGRIS_1_0_6RC2:1.11
	TIGRIS_1_0_6RC1:1.11
	TIGRIS_1_0_5:1.11
	TIGRIS_1_0_5RC6:1.11
	TIGRIS_1_0_5RC5:1.11
	TIGRIS_1_0_5RC4:1.11
	TIGRIS_1_0_5RC3:1.11
	TIGRIS_1_0_5RC2:1.11
	TIGRIS_1_0_5RC1:1.11
	TIGRIS_1_0_4:1.11
	TIGRIS_1_0_3:1.11
	TIGRIS_1_0_2:1.11
	TIGRIS_1_0_1:1.11
	TIGRIS_1_0:1.11.0.6
	TIGRIS_1_0_0:1.11
	TIGRIS_1_0_0_RC1:1.11.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.1
	TIGRIS_0_9_2_3:1.1
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.6
	TIGRIS_0_9_2_1:1.6
	TIGRIS_0_9_2:1.1.0.2;
locks; strict;
comment	@# @;


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

1.14
date	2001.07.13.19.47.34;	author leonardr;	state Exp;
branches;
next	1.13;

1.13
date	2001.05.31.19.12.28;	author elicia;	state Exp;
branches;
next	1.12;

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

1.11
date	2001.03.07.01.53.25;	author lucas;	state Exp;
branches;
next	1.10;

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

1.9
date	2001.02.01.21.59.37;	author elicia;	state Exp;
branches;
next	1.8;

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

1.7
date	2001.01.30.03.40.25;	author jrobbins;	state Exp;
branches;
next	1.6;

1.6
date	2001.01.26.18.29.05;	author edk;	state Exp;
branches
	1.6.2.1;
next	1.5;

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

1.4
date	2001.01.26.02.01.31;	author elicia;	state Exp;
branches;
next	1.3;

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

1.2
date	2001.01.23.02.23.26;	author elicia;	state Exp;
branches;
next	1.1;

1.1
date	2001.01.12.22.11.10;	author elicia;	state Exp;
branches
	1.1.1.1;
next	;

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

1.6.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	1.6.2.2;

1.6.2.2
date	2001.02.17.00.19.47;	author elicia;	state Exp;
branches;
next	1.6.2.3;

1.6.2.3
date	2001.02.17.00.40.16;	author elicia;	state Exp;
branches;
next	1.6.2.4;

1.6.2.4
date	2001.02.18.00.54.34;	author elicia;	state Exp;
branches;
next	1.6.2.5;

1.6.2.5
date	2001.02.20.02.24.59;	author dlr;	state Exp;
branches;
next	1.6.2.6;

1.6.2.6
date	2001.02.20.02.28.16;	author dlr;	state Exp;
branches;
next	1.6.2.7;

1.6.2.7
date	2001.02.20.04.45.49;	author elicia;	state Exp;
branches;
next	;


desc
@@


1.15
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 java.io.*;
import java.util.*;
import java.sql.*;

import org.apache.turbine.util.Log;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
import org.apache.velocity.context.Context;

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

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


public class ProjectSectionDelete extends HelmServlet
{
    protected String processRequest(Context ctx)
        throws TurbineException, RedirectException
    {
    
        String templateName = super.processRequest(ctx);
        String htURL = URL.schemeAndServer(getRequest(ctx))
            + "/servlets/ProjectDocumentList";

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

        try
        {
            User loginUser = getLoginUser(ctx);
            AccessControlList acl = loginUser.getACL();
            Project currentProject = getCurrentProject(ctx);
            ProjectSection section = getCurrentSection(ctx);
            String redirectURL = currentProject.getProjectPageURL
                ("ProjectDocumentList");
            List subsections = section.getSubsections();
            List documents = section.getDocuments();
            boolean deleteFromFilesystem;

            ctx.put("orphans", "no");
      
            if (action.equals("Confirm Delete"))
            {                        
                if (!section.getSubsections().isEmpty()
                    || !section.getDocuments().isEmpty()) 
                {
                    appendToMessage(ctx, "This folder has subfolders or documents. Delete subfolders and documents, or move them up to the top level?");
                    ctx.put("orphans", "yes");
                }
                else
                {
                    section.delete(acl);
                    redirectToURL(ctx, redirectURL);
                }
            } 

            else if (action.equals("Delete All"))
            {
                if (!subsections.isEmpty())
                {
                    for (int i = 0; i < subsections.size(); i++)
                    {
                        ProjectSection subsection =
                            (ProjectSection)subsections.get(i); 
                        List subdocuments = subsection.getDocuments();
                        if (!subdocuments.isEmpty())
                        {
                            for (i = 0; i < subdocuments.size(); i++)
                            {
                                ProjectDocument document =  
                                    (ProjectDocument)subdocuments.get(i); 
                                deleteFromFilesystem =
                                    (!document.getFileName().equals(""));
                                document.delete(acl, deleteFromFilesystem,
                                                htURL);
                            }
                        }
                        section.delete(acl);
                    }
                }
                if (!documents.isEmpty())
                {
                    for (int i = 0; i < documents.size(); i++)
                    {
                        ProjectDocument document = 
                            (ProjectDocument)documents.get(i); 
                        deleteFromFilesystem =
                            (!document.getFileName().equals(""));
                        document.delete(acl, deleteFromFilesystem, htURL);
                    }
                }
                section.delete(acl);
                redirectToURL(ctx, redirectURL);
            } 

            else if (action.equals("Move to top"))
            {
                if (!subsections.isEmpty())
                {
                    for (int i = 0; i < subsections.size(); i++)
                    {
                        ProjectSection subsection = 
                            (ProjectSection)subsections.get(i); 
                        subsection.edit(acl,"0",null,null);    
                    }
                }
                if (!documents.isEmpty())
                {
                    for (int i = 0; i < documents.size(); i++)
                    {
                        ProjectDocument document = 
                            (ProjectDocument)documents.get(i); 
                        document.moveToTop();
                    }
                }
                section.delete(acl);
                redirectToURL(ctx, redirectURL);
            } 
        } 
        catch (RedirectException e) {
            throw new TurbineException(e);
        }
        catch (Exception e) {
            throw new TurbineException(e);
        }
        return templateName;
    } 
}

@


1.14
log
@Minor new functionality avaliable to servlets to automatically check for the presence of 'current' values for business objects.
@
text
@@


1.13
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
@a74 1
        String sectionID = getParameter(ctx, "sectionID");
d76 2
a77 2
        if (sectionID == null)
            appendToMessage(ctx, "No section specified");
d79 1
a79 1
        else 
d81 9
a89 2
            // Determine which button was pushed
            String action = (String) ctx.get("action");
d91 1
a91 15
            try
            {
                User loginUser = getLoginUser(ctx);
                AccessControlList acl = loginUser.getACL();
                Project currentProject = getCurrentProject(ctx);
                ProjectSection section = 
                    (ProjectSection)ProjectSectionPeer.getInstance(sectionID);
                String redirectURL = currentProject.getProjectPageURL
                    ("ProjectDocumentList");
                List subsections = section.getSubsections();
                List documents = section.getDocuments();
                boolean deleteFromFilesystem;

                ctx.put("section", section);
                ctx.put("orphans", "no");
d93 14
a106 14
                if (action.equals("Confirm Delete"))
                {                        
                    if (!section.getSubsections().isEmpty()
                        || !section.getDocuments().isEmpty()) 
                    {
                        appendToMessage(ctx, "This folder has subfolders or documents. Delete subfolders and documents, or move them up to the top level?");
                        ctx.put("orphans", "yes");
                    }
                    else
                    {
                        section.delete(acl);
                        redirectToURL(ctx, redirectURL);
                    }
                } 
d108 3
a110 1
                else if (action.equals("Delete All"))
d112 1
a112 1
                    if (!subsections.isEmpty())
d114 4
a117 1
                        for (int i = 0; i < subsections.size(); i++)
d119 1
a119 4
                            ProjectSection subsection =
                                (ProjectSection)subsections.get(i); 
                            List subdocuments = subsection.getDocuments();
                            if (!subdocuments.isEmpty())
d121 6
a126 9
                                for (i = 0; i < subdocuments.size(); i++)
                                {
                                    ProjectDocument document =  
                                        (ProjectDocument)subdocuments.get(i); 
                                    deleteFromFilesystem =
                                        (!document.getFileName().equals(""));
                                    document.delete(acl, deleteFromFilesystem,
                                                    htURL);
                                }
a127 1
                            section.delete(acl);
d129 1
d131 4
a134 1
                    if (!documents.isEmpty())
d136 10
a145 12
                        for (int i = 0; i < documents.size(); i++)
                        {
                            ProjectDocument document = 
                                (ProjectDocument)documents.get(i); 
                            deleteFromFilesystem =
                                (!document.getFileName().equals(""));
                            document.delete(acl, deleteFromFilesystem, htURL);
                        }
                    }
                    section.delete(acl);
                    redirectToURL(ctx, redirectURL);
                } 
d147 3
a149 1
                else if (action.equals("Move to top"))
d151 1
a151 1
                    if (!subsections.isEmpty())
d153 3
a155 6
                        for (int i = 0; i < subsections.size(); i++)
                        {
                            ProjectSection subsection = 
                                (ProjectSection)subsections.get(i); 
                            subsection.edit(acl,"0",null,null);    
                        }
d157 4
a160 1
                    if (!documents.isEmpty())
d162 7
a168 10
                        for (int i = 0; i < documents.size(); i++)
                        {
                            ProjectDocument document = 
                                (ProjectDocument)documents.get(i); 
                            document.moveToTop();
                        }
                    }
                    section.delete(acl);
                    redirectToURL(ctx, redirectURL);
                } 
a169 6
            catch (RedirectException e) {
                throw new TurbineException(e);
            }
            catch (Exception e) {
                throw new TurbineException(e);
            }
d171 6
a176 1

d178 1
a178 1
    }
d180 1
@


1.12
log
@Ported Helm from WebMacro to Velocity.
@
text
@d106 1
a106 1
                        appendToMessage(ctx, "This section has subsections or documents. Delete subsections and documents, or move them up to the top level?");
d132 1
a132 1
                                        document.getType().equals("upload");
d147 1
a147 1
                                (document.getType().equals("upload"));
@


1.11
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d55 3
a57 1
import org.webmacro.servlet.*;
d68 2
a69 2
    protected String processRequest (Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
d72 2
a73 2
        String templateName = super.processRequest (conn, ctx);
        String htURL = URL.schemeAndServer(ctx)
d75 1
a75 1
        String sectionID = ctx.getForm("sectionID");
d103 2
a104 1
                    if ((!section.getSubsections().isEmpty()) || (!section.getDocuments().isEmpty())) 
d180 1
a180 1
                throw new HandlerException(e.getMessage());
d183 1
a183 1
                throw new HandlerException(e.getMessage());
@


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


1.9
log
@fixed bug in dealing with documents of deleted sections
@
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;
a55 1
import com.workingdogs.village.*;
d57 1
a57 1
import org.joist.*;
a58 2
import org.joist.session.*;
import org.joist.database.JoistDatabaseException;
d60 2
a62 2
import org.tigris.helm.database.*;
import org.joist.security.RedirectException;
d67 3
a69 8
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.8 2001/02/01 00:29:56 elicia Exp $";
  private static Log log = new Log("PjtSecDlt", "ProjectSectionDelete");
  private static boolean debug = true;


  protected String processRequest (Connection conn, WebContext ctx)
      throws HandlerException, RedirectException
  {
d71 25
a95 22
      String templateName = super.processRequest (conn, ctx);
     
      String sectionID = ctx.getForm("sectionID");

      if (sectionID == null)
          appendToMessage(ctx, "No section specified");

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

          try
          {
             AccessControlList acl = getACL(ctx, conn);
             Project currentProject = getCurrentProject(ctx);
             Section section = new Section(conn, dMgr, sectionID);
             String redirectURL = currentProject.getProjectPageURL
                                  ("ProjectDocuments");
             List subsections = section.getSubsections();
             List documents = section.getDocuments();
             boolean deleteFromFilesystem;
d97 2
a98 2
             ctx.put("section", section);
             ctx.put("orphans", "no");
d100 13
a112 11
             if (action.equals("Confirm Delete"))
             {                        
                if ((!section.getSubsections().isEmpty()) || (!section.getDocuments().isEmpty())) 
                {
                    appendToMessage(ctx, "This section has subsections or documents. Delete subsections and documents, or move them up to the top level?");
                    ctx.put("orphans", "yes");
                } else {
                    section.delete(acl);
                    redirectToURL(ctx, redirectURL);
                }
             } 
d114 1
a114 3
             else if (action.equals("Delete All"))
             {
                if (!subsections.isEmpty())
d116 1
a116 1
                    for (int i = 0; i < subsections.size(); i++)
d118 1
a118 3
                        Section subsection = (Section)subsections.get(i); 
                        List subdocuments = subsection.getDocuments();
                        if (!subdocuments.isEmpty())
d120 4
a123 1
                            for (i = 0; i < subdocuments.size(); i++)
d125 9
a133 5
                               Document document =  
                                   (Document)subdocuments.get(i); 
                               deleteFromFilesystem =
                                   (document.getType().equals("upload"));
                               document.delete(acl, deleteFromFilesystem, ctx);
d135 1
a136 1
                        section.delete(acl);
d138 1
a138 4
                }
                if (!documents.isEmpty())
                {
                    for (int i = 0; i < documents.size(); i++)
d140 14
a153 13
                        Document document = (Document)documents.get(i); 
                        deleteFromFilesystem =
                            (document.getType().equals("upload"));
                        document.delete(acl, deleteFromFilesystem, ctx);
                    }
                }
                section.delete(acl);
                redirectToURL(ctx, redirectURL);
             } 

             else if (action.equals("Move to top"))
             {
                if (!subsections.isEmpty())
d155 1
a155 1
                    for (int i = 0; i < subsections.size(); i++)
d157 6
a162 2
                        Section subsection = (Section)subsections.get(i); 
                        subsection.moveToTop(acl);    
d164 1
a164 4
                }
                if (!documents.isEmpty())
                {
                    for (int i = 0; i < documents.size(); i++)
d166 6
a171 2
                        Document document = (Document)documents.get(i); 
                        document.moveToTop();
d173 15
a187 17
                }
                section.delete(acl);
                redirectToURL(ctx, redirectURL);
             } 
          } 
          catch (RedirectException e) {
             throw new HandlerException(e.getMessage());
          }
          catch (Exception e) {
             throw new HandlerException(e.getMessage());
          }
      } 

      return templateName;
  }

} /* end class ProjectSectionDelete */
@


1.8
log
@passing context to Document to determine url for .htaccess file
@
text
@d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.7 2001/01/30 03:40:25 jrobbins Exp $";
d165 1
a165 1
                    for (int i = 0; i < subsections.size(); i++)
@


1.7
log
@filled in missing argument to make this code compile
@
text
@d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.6 2001/01/26 18:29:05 edk Exp $";
a82 10
      ProjectSectionManager secMgr = (ProjectSectionManager)
         getDataManager (ctx).getManager
         ("org.tigris.helm.database.ProjectSectionManager");
      ProjectDocumentManager docMgr = (ProjectDocumentManager)
         getDataManager (ctx).getManager
         ("org.tigris.helm.database.ProjectDocumentManager");
      ProjectDocumentSectionManager pdsMgr = (ProjectDocumentSectionManager)
         getDataManager (ctx).getManager
         ("org.tigris.helm.database.ProjectDocumentSectionManager");

d100 1
d112 1
a112 1
                    secMgr.deleteSection(conn, sectionID);   
d129 5
a133 2
                               Document document = (Document)subdocuments.get(i); 
                               docMgr.deleteDocument(conn, document.getID());
d144 3
a146 1
                        document.delete(acl, true, null);
d168 1
a168 1
                        pdsMgr.deleteRecord(conn, document.getID());
@


1.6
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.3 2001/01/23 02:31:52 elicia Exp $";
d150 1
a150 1
                        document.delete(acl, true);
@


1.6.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.6 2001/01/26 18:29:05 edk Exp $";
@


1.6.2.2
log
@ported to turbine
@
text
@d54 1
a54 1
import org.apache.turbine.util.Log;
d56 1
d58 4
a61 1
import org.joist.security.RedirectException;
a62 2
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d64 2
d70 2
d74 1
d83 10
d103 1
a103 2
             User loginUser = getLoginUser(ctx);
             AccessControlList acl = loginUser.getACL();
d105 1
a105 2
             ProjectSection section = 
                 (ProjectSection)ProjectSectionPeer.getInstance(sectionID);
d107 1
a107 1
                                  ("ProjectDocumentList");
a109 1
             boolean deleteFromFilesystem;
d121 1
a121 1
                    section.delete(acl);
d132 1
a132 1
                        ProjectSection subsection = (ProjectSection)subsections.get(i); 
d138 2
a139 5
                               ProjectDocument document =  
                                   (ProjectDocument)subdocuments.get(i); 
                               deleteFromFilesystem =
                                   (document.getType().equals("upload"));
                               document.delete(acl, deleteFromFilesystem, ctx);
d149 2
a150 5
                        ProjectDocument document = 
                            (ProjectDocument)documents.get(i); 
                        deleteFromFilesystem =
                            (document.getType().equals("upload"));
                        document.delete(acl, deleteFromFilesystem, ctx);
d163 2
a164 3
                        ProjectSection subsection = 
                            (ProjectSection)subsections.get(i); 
                        subsection.edit(acl,"0",null,null);    
d169 1
a169 1
                    for (int i = 0; i < documents.size(); i++)
d171 2
a172 3
                        ProjectDocument document = 
                            (ProjectDocument)documents.get(i); 
                        //document.moveToTop();
@


1.6.2.3
log
@passing URL to which to write .htaccess file
@
text
@a57 1
import org.joist.util.*;
d73 1
a73 2
      String htURL = URL.schemeAndServer(ctx)
                     + "/servlets/ProjectDocumentList";
d128 1
a128 1
                               document.delete(acl, deleteFromFilesystem, htURL);
d142 1
a142 1
                        document.delete(acl, deleteFromFilesystem, htURL);
@


1.6.2.4
log
@added code to delete subdocuments under deleted section
@
text
@d168 1
a168 1
                        document.deleteFromSection();
@


1.6.2.5
log
@Corrected indentation and copyright.
@
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
d67 5
a71 3
    protected String processRequest (Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
    {
d73 25
a97 25
        String templateName = super.processRequest (conn, ctx);
        String htURL = URL.schemeAndServer(ctx)
            + "/servlets/ProjectDocumentList";
        String sectionID = ctx.getForm("sectionID");

        if (sectionID == null)
            appendToMessage(ctx, "No section 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);
                ProjectSection section = 
                    (ProjectSection)ProjectSectionPeer.getInstance(sectionID);
                String redirectURL = currentProject.getProjectPageURL
                    ("ProjectDocumentList");
                List subsections = section.getSubsections();
                List documents = section.getDocuments();
                boolean deleteFromFilesystem;
d99 2
a100 2
                ctx.put("section", section);
                ctx.put("orphans", "no");
d102 11
a112 11
                if (action.equals("Confirm Delete"))
                {                        
                    if ((!section.getSubsections().isEmpty()) || (!section.getDocuments().isEmpty())) 
                    {
                        appendToMessage(ctx, "This section has subsections or documents. Delete subsections and documents, or move them up to the top level?");
                        ctx.put("orphans", "yes");
                    } else {
                        section.delete(acl);
                        redirectToURL(ctx, redirectURL);
                    }
                } 
d114 3
a116 1
                else if (action.equals("Delete All"))
d118 1
a118 1
                    if (!subsections.isEmpty())
d120 3
a122 1
                        for (int i = 0; i < subsections.size(); i++)
d124 1
a124 3
                            ProjectSection subsection = (ProjectSection)subsections.get(i); 
                            List subdocuments = subsection.getDocuments();
                            if (!subdocuments.isEmpty())
d126 5
a130 8
                                for (i = 0; i < subdocuments.size(); i++)
                                {
                                    ProjectDocument document =  
                                        (ProjectDocument)subdocuments.get(i); 
                                    deleteFromFilesystem =
                                        (document.getType().equals("upload"));
                                    document.delete(acl, deleteFromFilesystem, htURL);
                                }
a131 1
                            section.delete(acl);
d133 1
d135 4
a138 1
                    if (!documents.isEmpty())
d140 5
a144 8
                        for (int i = 0; i < documents.size(); i++)
                        {
                            ProjectDocument document = 
                                (ProjectDocument)documents.get(i); 
                            deleteFromFilesystem =
                                (document.getType().equals("upload"));
                            document.delete(acl, deleteFromFilesystem, htURL);
                        }
d146 8
a153 5
                    section.delete(acl);
                    redirectToURL(ctx, redirectURL);
                } 

                else if (action.equals("Move to top"))
d155 1
a155 1
                    if (!subsections.isEmpty())
d157 3
a159 6
                        for (int i = 0; i < subsections.size(); i++)
                        {
                            ProjectSection subsection = 
                                (ProjectSection)subsections.get(i); 
                            subsection.edit(acl,"0",null,null);    
                        }
d161 4
a164 1
                    if (!documents.isEmpty())
d166 3
a168 6
                        for (int i = 0; i < documents.size(); i++)
                        {
                            ProjectDocument document = 
                                (ProjectDocument)documents.get(i); 
                            document.deleteFromSection();
                        }
d170 17
a186 15
                    section.delete(acl);
                    redirectToURL(ctx, redirectURL);
                } 
            } 
            catch (RedirectException e) {
                throw new HandlerException(e.getMessage());
            }
            catch (Exception e) {
                throw new HandlerException(e.getMessage());
            }
        } 

        return templateName;
    }
}
@


1.6.2.6
log
@Clean up.
@
text
@d106 1
a106 3
                    }
                    else
                    {
d118 1
a118 2
                            ProjectSection subsection =
                                (ProjectSection)subsections.get(i); 
d127 2
a128 3
                                        document.getType().equals("upload");
                                    document.delete(acl, deleteFromFilesystem,
                                                    htURL);
@


1.6.2.7
log
@added method moveToTop to make a document top level
@
text
@d170 1
a170 1
                            document.moveToTop();
@


1.5
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
@d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.4 2001/01/26 02:01:31 elicia Exp $";
d105 1
a105 1
             Section section = new Section(dMgr, sectionID);
d121 1
a121 1
                    secMgr.deleteSection(sectionID);   
d139 1
a139 1
                               docMgr.deleteDocument(document.getID());
d172 1
a172 1
                        pdsMgr.deleteRecord(document.getID());
@


1.4
log
@no longer passing connection
@
text
@d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.3 2001/01/23 02:31:52 elicia Exp $";
@


1.3
log
@added argument to document delete method
@
text
@d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.2 2001/01/23 02:23:26 elicia Exp $";
d105 1
a105 1
             Section section = new Section(conn, dMgr, sectionID);
d121 1
a121 1
                    secMgr.deleteSection(conn, sectionID);   
d139 1
a139 1
                               docMgr.deleteDocument(conn, document.getID());
d172 1
a172 1
                        pdsMgr.deleteRecord(conn, document.getID());
@


1.2
log
@give user the option to delete sub-sections and sub-documents when the parent section is deleted, or to move them up a level
@
text
@d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.1 2001/01/12 22:11:10 elicia Exp $";
d150 1
a150 1
                        document.delete(acl);
@


1.1
log
@initial revisions
@
text
@d63 1
a63 2
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.DoesNotExist;
d70 1
a70 1
  public static final  String versionID = "$Id: ProjectSectionDelete.java,v 1.2 2000/12/30 05:01:29 elicia Exp $";
d75 1
a75 1
  protected String processRequest (Connection conn, WebContext context)
d79 1
a79 1
      String templateName = super.processRequest (conn, context);
d81 11
a91 1
      String sectionID = context.getForm("sectionID");
d94 1
a94 1
          appendToMessage(context, "No document specified");
d99 1
a99 1
          String action = (String) context.get("action");
d103 7
a109 4
             Project currentProject = getCurrentProject(context);
             ProjectSectionManager secMgr = (ProjectSectionManager)
                getDataManager (context).getManager
                ("org.tigris.helm.database.ProjectSectionManager");
d111 2
a112 2
             Section section = new Section(conn, dMgr, sectionID);
             context.put("section", section);
d116 62
a177 4
                secMgr.deleteSection(conn, sectionID);   
                redirectToURL(context, currentProject.getProjectPageURL("ProjectDocuments"));
             }          

d179 1
a179 3
          catch (DoesNotExist e) {
             throw new HandlerException(e.getMessage());
          } catch (SQLException e) {
d181 2
a182 1
          } catch (DataSetException e) {
@


1.1.1.1
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
d54 1
a54 1
import org.apache.turbine.util.Log;
d56 1
d58 1
a58 1
import org.joist.security.RedirectException;
d60 2
d63 4
a66 3
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.security.*;
d71 8
a78 3
    protected String processRequest (Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
    {
d80 18
a97 25
        String templateName = super.processRequest (conn, ctx);
        String htURL = URL.schemeAndServer(ctx)
            + "/servlets/ProjectDocumentList";
        String sectionID = ctx.getForm("sectionID");

        if (sectionID == null)
            appendToMessage(ctx, "No section 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);
                ProjectSection section = 
                    (ProjectSection)ProjectSectionPeer.getInstance(sectionID);
                String redirectURL = currentProject.getProjectPageURL
                    ("ProjectDocumentList");
                List subsections = section.getSubsections();
                List documents = section.getDocuments();
                boolean deleteFromFilesystem;
d99 2
a100 2
                ctx.put("section", section);
                ctx.put("orphans", "no");
d102 20
a121 88
                if (action.equals("Confirm Delete"))
                {                        
                    if ((!section.getSubsections().isEmpty()) || (!section.getDocuments().isEmpty())) 
                    {
                        appendToMessage(ctx, "This section has subsections or documents. Delete subsections and documents, or move them up to the top level?");
                        ctx.put("orphans", "yes");
                    }
                    else
                    {
                        section.delete(acl);
                        redirectToURL(ctx, redirectURL);
                    }
                } 

                else if (action.equals("Delete All"))
                {
                    if (!subsections.isEmpty())
                    {
                        for (int i = 0; i < subsections.size(); i++)
                        {
                            ProjectSection subsection =
                                (ProjectSection)subsections.get(i); 
                            List subdocuments = subsection.getDocuments();
                            if (!subdocuments.isEmpty())
                            {
                                for (i = 0; i < subdocuments.size(); i++)
                                {
                                    ProjectDocument document =  
                                        (ProjectDocument)subdocuments.get(i); 
                                    deleteFromFilesystem =
                                        document.getType().equals("upload");
                                    document.delete(acl, deleteFromFilesystem,
                                                    htURL);
                                }
                            }
                            section.delete(acl);
                        }
                    }
                    if (!documents.isEmpty())
                    {
                        for (int i = 0; i < documents.size(); i++)
                        {
                            ProjectDocument document = 
                                (ProjectDocument)documents.get(i); 
                            deleteFromFilesystem =
                                (document.getType().equals("upload"));
                            document.delete(acl, deleteFromFilesystem, htURL);
                        }
                    }
                    section.delete(acl);
                    redirectToURL(ctx, redirectURL);
                } 

                else if (action.equals("Move to top"))
                {
                    if (!subsections.isEmpty())
                    {
                        for (int i = 0; i < subsections.size(); i++)
                        {
                            ProjectSection subsection = 
                                (ProjectSection)subsections.get(i); 
                            subsection.edit(acl,"0",null,null);    
                        }
                    }
                    if (!documents.isEmpty())
                    {
                        for (int i = 0; i < documents.size(); i++)
                        {
                            ProjectDocument document = 
                                (ProjectDocument)documents.get(i); 
                            document.moveToTop();
                        }
                    }
                    section.delete(acl);
                    redirectToURL(ctx, redirectURL);
                } 
            } 
            catch (RedirectException e) {
                throw new HandlerException(e.getMessage());
            }
            catch (Exception e) {
                throw new HandlerException(e.getMessage());
            }
        } 

        return templateName;
    }
}
@


