head	1.26;
access;
symbols
	TIGRIS_1_1_0RC2:1.21.6.2
	TIGRIS_1_1_0RC1:1.21.6.2
	TIGRIS_1_1:1.21.6.2.0.2
	TIGRIS_1_0_8:1.21.6.2
	TIGRIS_1_0_8RC3:1.21.6.2
	TIGRIS_1_0_8RC2:1.21.6.2
	TIGRIS_1_0_8RC1:1.21.6.2
	TIGRIS_1_0_7:1.21.6.2
	TIGRIS_1_0_7RC3:1.21.6.2
	TIGRIS_1_0_7RC2:1.21.6.2
	TIGRIS_1_0_7RC1:1.21.6.2
	TIGRIS_1_0_6:1.21.6.2
	TIGRIS_1_0_6RC5:1.21.6.2
	TIGRIS_1_0_6RC4:1.21.6.2
	TIGRIS_1_0_6RC3:1.21.6.2
	TIGRIS_1_0_6RC2:1.21.6.2
	TIGRIS_1_0_6RC1:1.21.6.2
	TIGRIS_1_0_5:1.21.6.2
	TIGRIS_1_0_5RC6:1.21.6.2
	TIGRIS_1_0_5RC5:1.21.6.2
	TIGRIS_1_0_5RC4:1.21.6.2
	TIGRIS_1_0_5RC3:1.21.6.2
	TIGRIS_1_0_5RC2:1.21.6.2
	TIGRIS_1_0_5RC1:1.21.6.2
	TIGRIS_1_0_4:1.21.6.2
	TIGRIS_1_0_3:1.21.6.2
	TIGRIS_1_0_2:1.21.6.2
	TIGRIS_1_0_1:1.21
	TIGRIS_1_0:1.21.0.6
	TIGRIS_1_0_0:1.21
	TIGRIS_1_0_0_RC1:1.21.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.15.2.1
	TIGRIS_0_9_2_3:1.15
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.18
	TIGRIS_0_9_2_1:1.18
	TIGRIS_0_9_2:1.15.0.2
	TIGRIS_0_9_0:1.13.0.2
	TIGRIS_0_8_4:1.10.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.26
date	2001.06.13.19.55.10;	author elicia;	state dead;
branches;
next	1.25;

1.25
date	2001.05.23.01.50.15;	author dlr;	state Exp;
branches;
next	1.24;

1.24
date	2001.04.24.16.03.28;	author dlr;	state Exp;
branches;
next	1.23;

1.23
date	2001.04.24.02.18.41;	author dlr;	state Exp;
branches;
next	1.22;

1.22
date	2001.04.12.00.37.47;	author elicia;	state Exp;
branches;
next	1.21;

1.21
date	2001.03.07.01.53.24;	author lucas;	state Exp;
branches
	1.21.6.1;
next	1.20;

1.20
date	2001.02.21.01.08.23;	author dlr;	state Exp;
branches;
next	1.19;

1.19
date	2001.02.08.02.38.38;	author elicia;	state Exp;
branches;
next	1.18;

1.18
date	2001.01.26.18.29.04;	author edk;	state Exp;
branches
	1.18.2.1;
next	1.17;

1.17
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.16;

1.16
date	2001.01.26.02.02.08;	author elicia;	state Exp;
branches;
next	1.15;

1.15
date	2001.01.08.23.25.03;	author dlr;	state Exp;
branches
	1.15.2.1;
next	1.14;

1.14
date	2000.12.29.03.37.33;	author dlr;	state Exp;
branches;
next	1.13;

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

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

1.11
date	2000.12.13.00.05.43;	author dlr;	state Exp;
branches;
next	1.10;

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

1.9
date	2000.11.18.10.33.35;	author dlr;	state Exp;
branches;
next	1.8;

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

1.7
date	2000.11.18.09.57.01;	author dlr;	state Exp;
branches;
next	1.6;

1.6
date	2000.11.18.09.25.19;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2000.11.17.23.20.06;	author dlr;	state Exp;
branches;
next	1.4;

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

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

1.2
date	2000.11.15.00.27.10;	author dlr;	state Exp;
branches;
next	1.1;

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

1.1.1.1
date	2000.11.12.21.16.05;	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.15.2.1
date	2001.02.01.18.49.24;	author jrobbins;	state Exp;
branches;
next	;

1.18.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	1.18.2.2;

1.18.2.2
date	2001.02.20.02.19.56;	author dlr;	state Exp;
branches;
next	1.18.2.3;

1.18.2.3
date	2001.02.20.22.51.50;	author elicia;	state Exp;
branches;
next	1.18.2.4;

1.18.2.4
date	2001.02.20.23.34.28;	author elicia;	state Exp;
branches;
next	;

1.21.6.1
date	2001.04.24.16.08.24;	author dlr;	state Exp;
branches;
next	1.21.6.2;

1.21.6.2
date	2001.04.24.20.57.40;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.26
log
@Deleting the deprecated ProjectDownload servlets. Pointing them at their ProjectDocument counterparts
@
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.List;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.sql.*;
import javax.servlet.http.*;

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 com.workingdogs.village.*;

import org.joist.*;
import org.joist.util.*;
import org.tigris.helm.tool.SessionManager;
import org.joist.security.RedirectException;

import org.tigris.helm.om.ProjectDownloadPeer;import org.tigris.helm.om.*;
import org.tigris.helm.security.*;
import org.tigris.helm.tool.DBFlag;

/**
 * Allows edits of multiple file downloads.
 *
 * @@author <a href="mailto:elicia@@collab.net">Elicia David</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: ProjectDownloadEdit.java,v 1.25 2001/05/23 01:50:15 dlr Exp $
 */
public class ProjectDownloadEdit extends HelmServlet
{
    private static final boolean DEBUG = true;

    private static final String EDIT_DOWNLOADS = "Edit Downloads";

    /**
     * Handles UI and form processing.
     */
    protected String processRequest(Context context)
        throws TurbineException, RedirectException
    {
        String templateName = super.processRequest(context);
        HttpServletRequest request = getRequest(context);
        String action = getAction(context);
        if (DEBUG) Log.debug("action=" + action);

        try
        {
            String loginUserID = getLoginUser(context).getID();
            Project project = getCurrentProject(context);
            AccessControlList acl = getACL(context, loginUserID);

            if (action.equals(EDIT_DOWNLOADS))
            {
                Enumeration paramNames = request.getParameterNames();
                List editSet = new ArrayList();
                List deleteSet = new ArrayList();
                String paramName;
                while (paramNames.hasMoreElements ())
                {
                    paramName = (String) paramNames.nextElement ();
                    if (paramName.startsWith("edit"))
                        editSet.add(paramName);
                    else if (paramName.startsWith("delete"))
                        deleteSet.add(paramName);
                }

                String dlURL = URL.schemeAndServer(getRequest(context))
                    + "/servlets/ProjectDownload";

                // Do edits.
                for (int i = 0; i < editSet.size(); i++)
                {
                    String element = (String) editSet.get(i);
                    StringTokenizer tok = new StringTokenizer (element);
                    String whichAction = tok.nextToken();
                    String downloadID = tok.nextToken();
                    ProjectDownload dl =
                        ProjectDownloadPeer.getInstance(downloadID);
                    String isPublic =
                        DBFlag.flagValueOf(request.getParameter
                                           ("public " + downloadID));
                    if (whichAction.equals("edit"))
                    {
                        String description = getParameter(context, element);
                        dl.edit(acl, description, getLoginUser(context),
                               isPublic, dlURL, null);
                    }
                }

                // Do deletes.
                for (int i = 0; i < deleteSet.size(); i++)
                {
                    String element = (String) deleteSet.get(i);
                    StringTokenizer tok = new StringTokenizer(element);
                    String whichAction = tok.nextToken();
                    String downloadID = tok.nextToken ();
                    ProjectDownload dl =
                        ProjectDownloadPeer.getInstance(downloadID);
                      Log.debug("delete action");
                    if (whichAction.equals("delete"))
                    {
                        dl.delete(acl, true, dlURL);
                    }
                }

                // Redirect back to ProjectDownload
                StringBuffer url = new StringBuffer("ProjectDownloadList");
                url.append("?projectID=").append(project.getID());
                redirectToURL(context, url.toString());
            }

            List downloads = project.getProjectDownloads();
            if (downloads.size() > 0)
            {
                context.put ("downloads", downloads);
            }
        }
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            String errMsg = "Error editing download: " + e.getMessage();
            Log.error(errMsg, e);
            appendToError(context, errMsg);
            throw new TurbineException(e);
        }    
    
        return templateName;
    }
}
@


1.25
log
@Ported Helm from WebMacro to Velocity.
@
text
@d80 1
a80 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.24 2001/04/24 16:03:28 dlr Exp $
@


1.24
log
@Corrected call to disapprove().  Called delete() instead (deleting
from the file system), as per IZ #3757.
@
text
@d59 2
d62 1
a62 1
import org.webmacro.servlet.*;
d68 1
a68 1
import org.joist.session.*;
d80 1
a80 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.23 2001/04/24 02:18:41 dlr Exp $
d91 2
a92 2
    protected String processRequest (Connection conn, WebContext context)
        throws HandlerException, RedirectException
d94 2
a95 2
        String templateName = super.processRequest(conn, context);
        HttpServletRequest request = context.getRequest ();
d120 2
a121 2
                String dlURL = 
                    URL.schemeAndServer(context) + "/servlets/ProjectDownload";
d137 1
a137 1
                        String description = context.getForm(element);
d180 1
a180 1
            throw new HandlerException(errMsg);
@


1.23
log
@Sync'd with change to edit()'s signature.
@
text
@d78 1
a78 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.22 2001/04/12 00:37:47 elicia Exp $
d152 3
a154 1
                        dl.disapprove(acl, "", dlURL);
@


1.22
log
@removed duplicate important statements
@
text
@d78 1
a78 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.21 2001/03/07 01:53:24 lucas Exp $
d137 1
a137 1
                               isPublic, dlURL);
@


1.21
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@a54 2
import java.util.List;
import java.util.ArrayList;
d78 1
a78 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.20 2001/02/21 01:08:23 dlr Exp $
@


1.21.6.1
log
@Corrected call to disapprove().  Called delete() instead (deleting
from the file system), as per IZ #3757.
@
text
@d80 1
a80 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.21 2001/03/07 01:53:24 lucas Exp $
d154 1
a154 3
                    {
                        dl.delete(acl, true, dlURL);
                    }
@


1.21.6.2
log
@Refactored to not delete database entries, to make use of new ProjectFileArtifactAdd class, and to sync w/ changed APIs.
@
text
@d55 2
d80 1
a80 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.24 2001/04/24 16:03:28 dlr Exp $
d139 1
a139 1
                               isPublic, dlURL, null);
@


1.20
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d71 1
a71 2
import org.tigris.helm.om.peer.ProjectDownloadPeer;
import org.tigris.helm.om.*;
d80 1
a80 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.18.2.4 2001/02/20 23:34:28 elicia Exp $
@


1.19
log
@cleanup
@
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
d60 2
a61 1
import org.webmacro.util.Log;
d71 2
a73 1
import org.tigris.helm.database.ProjectDownloadManager;
d81 1
a81 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.18 2001/01/26 18:29:04 edk Exp $
d85 1
a85 3
    private static Log log = new Log("projDLEd", "ProjectDownloadEdit");

    private static final boolean debug = true;
a94 2
        if (debug) log.info("started!");

d98 1
a98 5
        if (debug) log.info("action=" + action);

        ProjectDownloadManager dlMgr = (ProjectDownloadManager)
            getDataManager (context).getManager
            ("org.tigris.helm.database.ProjectDownloadManager");
d104 1
a104 1
            AccessControlList acl = getACL(context, conn, loginUserID);
d131 2
a132 1
                    Download dl = new Download(conn, dMgr, downloadID);
d139 2
a140 2
                        dl.edit(acl, description,
                                getLoginUser(context).getID(), isPublic, dlURL);
d151 3
a153 1
                    Download dl = new Download(conn, dMgr, downloadID);
d155 1
a155 1
                        dl.delete(acl, context);
d159 1
a159 1
                StringBuffer url = new StringBuffer("ProjectDownload");
d164 1
a164 1
            List downloads = project.getDownloads();
d176 4
a179 4
            log.exception(e);
            String errMsg = e.getMessage();
            if (debug) log.warning(errMsg);
            appendToMessage(context, errMsg);
a181 1
        if (debug) log.debug("done");
@


1.18
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.15 2001/01/08 23:25:03 dlr Exp $
d158 1
a158 1
                        dl.delete(acl, dlURL);
@


1.18.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.18 2001/01/26 18:29:04 edk Exp $
@


1.18.2.2
log
@Ported to peer port branch from HEAD.
@
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
d60 1
a60 2
import org.apache.turbine.util.Log;

a69 2
import org.tigris.helm.om.peer.ProjectDownloadPeer;
import org.tigris.helm.om.*;
d71 1
d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.19 2001/02/08 02:38:38 elicia Exp $
d83 3
a85 1
    private static final boolean DEBUG = true;
d95 2
d100 5
a104 1
        if (DEBUG) Log.debug("action=" + action);
d110 1
a110 1
            AccessControlList acl = getACL(context, loginUserID);
d137 1
a137 2
                    ProjectDownload dl =
                        ProjectDownloadPeer.getInstance(downloadID);
d144 2
a145 2
                        dl.edit(acl, description, getLoginUser(context),
                                isPublic, dlURL);
d156 1
a156 2
                    ProjectDownload dl =
                        ProjectDownloadPeer.getInstance(downloadID);
d158 1
a158 1
                        dl.delete(acl, true, context);
d167 1
a167 1
            List downloads = project.getProjectDownloads();
d179 4
a182 4
            String errMsg = "Error editing download: " + e.getMessage();
            Log.error(errMsg, e);
            appendToError(context, errMsg);
            throw new HandlerException(errMsg);
d185 1
@


1.18.2.3
log
@changed name of list servlet to redirect to
@
text
@d81 1
a81 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.18.2.2 2001/02/20 02:19:56 dlr Exp $
d140 1
a140 1
                               isPublic, dlURL);
d158 1
a158 1
                StringBuffer url = new StringBuffer("ProjectDownloadList");
@


1.18.2.4
log
@calling disapprove method
@
text
@d81 1
a81 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.18.2.3 2001/02/20 22:51:50 elicia Exp $
a152 1
                      Log.debug("delete action");
d154 1
a154 1
                        dl.disapprove(acl, "", dlURL);
@


1.17
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
@d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.16 2001/01/26 02:02:08 elicia Exp $
d137 1
a137 1
                    Download dl = new Download(dMgr, downloadID);
d156 1
a156 1
                    Download dl = new Download(dMgr, downloadID);
@


1.16
log
@no longer passing connections
@
text
@d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.15 2001/01/08 23:25:03 dlr Exp $
@


1.15
log
@Corrected a bunch of regressions to previous User instantion method.  Deprecated User's getUserID() method in favor of getID() for better conformance with BusinessObject interface and orthoginality with other business objects.  Added a guest user and interface.  Added some JavaDoc to User.
@
text
@d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.14 2000/12/29 03:37:33 dlr Exp $
d137 1
a137 1
                    Download dl = new Download(conn, dMgr, downloadID);
d156 1
a156 1
                    Download dl = new Download(conn, dMgr, downloadID);
@


1.15.2.1
log
@moved changed from HEAD for ProjectDocuments and ProjectDownloads
@
text
@d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.18 2001/01/26 18:29:04 edk Exp $
@


1.14
log
@Made use of new DBFlag class.
@
text
@d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.13 2000/12/13 02:02:27 dlr Exp $
d108 1
a108 1
            String loginUserID = getLoginUser(context).getUserID();
@


1.13
log
@Regenerate .htaccess file on download deletion.
@
text
@d68 1
d72 1
a72 1
import org.joist.security.RedirectException;
d79 1
a79 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.12 2000/12/13 01:32:42 dlr Exp $
d138 3
a140 3
                    String isPublic = (haveValue(request.getParameter
                                                 ("public " + downloadID)) ? 
                                       "Y" : "N");
@


1.12
log
@Merged duplicate download addition code into a Download ctor.  Made Download.edit() regenerate the .htaccess file.
@
text
@d78 1
a78 1
 * @@version $Id: ProjectDownloadEdit.java,v 1.11 2000/12/13 00:05:43 dlr Exp $
d126 3
d144 1
a144 3
                                getLoginUser(context).getID(), isPublic,
                                URL.schemeAndServer(context) +
                                "/servlets/ProjectDownload");
d157 1
a157 1
                        dl.delete(acl);
@


1.11
log
@Added support for isPublic.  Switched from use of Vector to ArrayList,
as unnecessary synchronization is avoided this way.  Added a tidbit of
doc.  Reduced the scope of some variables, and their accompanying
memory allocation.
@
text
@d78 1
a78 1
 * @@version $Id: $
d141 3
a143 1
                                getLoginUser(context).getID(), isPublic);
@


1.10
log
@Say goodbye, tabbies!
@
text
@d55 2
a56 1
import java.util.Vector;
d73 7
d82 2
a83 2
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.9 2000/11/18 10:33:35 dlr Exp $";
    private static Log log = new Log("ProjectDownloadEdit", "Tigris StartPage");
d89 1
a89 1
     *  Display and process the login screen.
d91 1
a91 2
    protected String
        processRequest (Connection conn, WebContext context)
a97 4
        Enumeration paramNames = request.getParameterNames ();
        String paramName;
        Vector editSet = new Vector (50);
        Vector deleteSet = new Vector (50);
d99 1
a99 1
        if (debug) log.info("action=" + action );
d113 4
d120 4
a123 4
                    if (paramName.startsWith ("edit"))
                        editSet.addElement (paramName);
                    else if (paramName.startsWith ("delete"))
                        deleteSet.addElement (paramName);
d126 2
a127 4
                // Do the edits
                // TODO: Handle isPrivate in UI.
                String isPrivate = null;
                for (int i = 0; i < editSet.size (); i++)
d129 1
a129 1
                    String element = (String) editSet.elementAt (i);
d132 1
a132 1
                    String downloadID = tok.nextToken ();
d134 3
d141 1
a141 1
                                getLoginUser(context).getID(), isPrivate);
d145 2
a146 2
                // Do deletes
                for (int i = 0; i < deleteSet.size (); i++)
d148 2
a149 2
                    String element = (String) deleteSet.elementAt (i);
                    StringTokenizer tok = new StringTokenizer (element);
@


1.9
log
@- Fixed your run of the mill RedirectException caught when shouldn't be
  bug that would never be a problem if Joist had a decent mechanism
  for handling this (i.e. one that didn't use gotos--er, I mean
  Exceptions...right, that's it).
- Removed the need for the code that wraps a DataSet of downloads as a
  list of Download objects.
- This servlet is still swiss cheese--it apparently needs some serious
  refactoring to reduce a bug infestation.
@
text
@d74 1
a74 1
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.8 2000/11/18 10:14:58 dlr Exp $";
d84 2
a85 2
	processRequest (Connection conn, WebContext context)
	throws HandlerException, RedirectException
d87 1
a87 1
	if (debug) log.info("started!");
d89 1
a89 1
	String templateName = super.processRequest(conn, context);
d93 1
a93 1
	Vector editSet = new Vector (50);
d95 2
a96 2
	String action = getAction(context);
	if (debug) log.info("action=" + action );
d99 2
a100 2
           getDataManager (context).getManager
          ("org.tigris.helm.database.ProjectDownloadManager");
d102 1
a102 1
	try
d104 3
a106 3
	    String loginUserID = getLoginUser(context).getUserID();
	    Project project = getCurrentProject(context);
	    AccessControlList acl = getACL(context, conn, loginUserID);
d160 2
a161 2
	}
	catch (RedirectException e)
d165 1
a165 1
	catch (Exception e)
d167 2
a168 2
	    log.exception(e);
	    String errMsg = e.getMessage();
d170 4
a173 4
	    appendToMessage(context, errMsg);
	}	
	
	if (debug) log.debug("done");
@


1.8
log
@Removed unused context variable.
@
text
@d51 1
d74 1
a74 1
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.7 2000/11/18 09:57:01 dlr Exp $";
d87 1
a87 1
	if (debug) log.info("ProjectDownloadEdit: started!");
d96 1
a96 6

	if (debug)
	     log.info("ProjectDownloadEdit: action=" + action );
	     
        DataSet downloadSet = null;
        ArrayList downloadList = new ArrayList();
d102 2
a103 1
	try {
d105 1
a105 1
	    Project currentProject = getCurrentProject(context);
d108 52
a159 62
           // Get all downloads for this project
           downloadSet = dlMgr.getDownloadsForProject 
	                 (conn, currentProject.getID());

           for (int i = 0; i < downloadSet.size(); i++)
           {
               Record r = downloadSet.getRecord(i);
	       downloadList.add(new Download(conn, dMgr, r));
           }

	   if (action.equals(EDIT_DOWNLOADS))
	   {
	      while (paramNames.hasMoreElements ())
	      {
	        paramName = (String) paramNames.nextElement ();
	        if (paramName.startsWith ("edit"))  
	           editSet.addElement (paramName);
		if (paramName.startsWith ("delete"))
	           deleteSet.addElement (paramName);
	       }
	    

	      // Do the edits
              // TODO: Handle isPrivate in UI.
              String isPrivate = null;
	      for (int i = 0; i < editSet.size (); i++)
	      {
	         String element = (String) editSet.elementAt (i);
	         StringTokenizer tok = new StringTokenizer (element);
		 String whichAction = tok.nextToken();
	         String downloadID = tok.nextToken ();
	         Download dl = new Download(conn, dMgr, downloadID);
		 if (whichAction.equals("edit"))
		 {
		     String description = context.getForm(element);
		     dl.edit(acl, description, getLoginUser(context).getID(), 
                             isPrivate);
		 }
	      }

	      // Do deletes
	      for (int i = 0; i < deleteSet.size (); i++)
	      {
	         String element = (String) deleteSet.elementAt (i);
	         StringTokenizer tok = new StringTokenizer (element);
		 String whichAction = tok.nextToken();
	         String downloadID = tok.nextToken ();
	         Download dl = new Download(conn, dMgr, downloadID);
		 if (whichAction.equals("delete"))
		     dl.delete(acl);
	      }

	      // Redirect back to ProjectDownload
	      StringBuffer url = new StringBuffer("ProjectDownload");
              url.append("?projectID=").append(currentProject.getID());
              redirectToURL(context, url.toString());
	   }

           if (downloadSet.size() > 0)
           {
              context.put ("downloads", downloadList);
           }
d161 6
a166 2

	catch (Exception e) {
d168 3
a170 3
	    String message = "ProjectDownloadEdit" + e.getMessage();
	    if (debug) log.debug(message);
	    context.put("message", message);
d173 1
a173 2
	if (debug) log.debug("ProjectDownloadEdit:  done");

a175 1
  
@


1.7
log
@Lights, camera, ACTION!
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.6 2000/11/18 09:25:19 dlr Exp $";
d170 1
d172 1
a172 1
	   context.put("projectID", currentProject.getID());
@


1.6
log
@Sync'd w/ modified editDownload() interface--also renamed to edit().
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.5 2000/11/17 23:20:06 dlr Exp $";
d75 3
a77 1
    private static boolean debug = true;
d94 1
a94 1
	String action = (String)context.get("action");
d121 1
a121 1
	   if (action.equals("Do Selected Actions"))
@


1.5
log
@Sync'd w/ interface changes.
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.4 2000/11/15 23:12:39 elicia Exp $";
d144 2
a145 2
		     dl.editDownload(acl, dl, description,
                                     getLoginUser(context).getID(), isPrivate);
@


1.4
log
@using delete method in business object instead of tablemanager
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.3 2000/11/15 21:07:59 elicia Exp $";
d132 2
d144 2
a145 2
		     dl.editDownload(conn, acl, dl, description,
                                     getLoginUser(context).getID());
@


1.3
log
@modernized: added edit method to Business Object.

TODO: add delete method to Business Object.
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.2 2000/11/15 00:27:10 dlr Exp $";
d130 1
d138 1
a138 1
		 Download dl = new Download(conn, dMgr, downloadID);
d154 1
d156 1
a156 2
                     // TODO: Use a business object w/ ACL checking.
		     dlMgr.deleteDownload(conn, downloadID);
@


1.2
log
@- Corrected broken build.
- TODO: Use business objects in this servlet.
@
text
@d67 1
a67 1
import org.tigris.helm.security.HelmServlet;
d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.1.1.1 2000/11/12 21:16:05 dlr Exp $";
d81 1
a81 1
	processRequest (Connection connection, WebContext context)
d86 1
a86 1
	String templateName = super.processRequest(connection, context);
a97 1
        String projectID = context.getForm ("projectID");
d105 4
d110 2
a111 1
           downloadSet = dlMgr.getDownloadsForProject (connection, projectID);
d116 1
a116 1
	       downloadList.add(new Download(connection, dMgr, r));
d137 1
d141 2
a142 3
                     // TODO: Use a business object w/ ACL checking.
		     dlMgr.editDownload(connection, downloadID, description, 
                                        getLoginUser(context).getID());
d155 1
a155 1
		     dlMgr.deleteDownload(connection, downloadID);
d160 1
a160 1
              url.append("?projectID=").append(projectID);
d163 4
a175 3
        if (downloadSet.size() > 0)
            context.put ("downloads", downloadList);
	context.put("projectID", projectID);
@


1.1
log
@Initial revision
@
text
@a50 3
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
d55 2
d58 1
a58 1
import org.webmacro.util.*;
a59 3
import org.webmacro.engine.*;
import org.webmacro.broker.*;
import org.webmacro.resource.*;
d62 1
a69 1
//import org.joist.database.DataManager;
d71 3
a73 2
public class ProjectDownloadEdit extends org.tigris.helm.security.HelmServlet {
    public static final  String versionID = "$Id: ProjectDownloadEdit.java,v 1.1 2000/11/09 22:02:24 elicia Exp $";
d132 1
a132 1
	         String download_id = tok.nextToken ();
d136 3
a138 1
		     dlMgr.editDownload(connection, download_id, description);
d148 1
a148 1
	         String download_id = tok.nextToken ();
d150 2
a151 1
		     dlMgr.deleteDownload(connection, download_id);
d176 1
a176 1
} /* end class ProjectDownloadEdit */
@


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
d51 3
a53 1
import java.util.List;
d57 1
a57 6
import java.util.List;
import java.util.ArrayList;
import java.sql.*;
import javax.servlet.http.*;

import org.apache.turbine.util.Log;
d59 1
d61 3
a65 1

d69 3
d73 1
d75 4
a78 17
import org.tigris.helm.om.peer.ProjectDownloadPeer;
import org.tigris.helm.om.*;
import org.tigris.helm.security.*;
import org.tigris.helm.tool.DBFlag;

/**
 * Allows edits of multiple file downloads.
 *
 * @@author <a href="mailto:elicia@@collab.net">Elicia David</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: ProjectDownloadEdit.java,v 1.18.2.4 2001/02/20 23:34:28 elicia Exp $
 */
public class ProjectDownloadEdit extends HelmServlet
{
    private static final boolean DEBUG = true;

    private static final String EDIT_DOWNLOADS = "Edit Downloads";
d81 1
a81 1
     * Handles UI and form processing.
d83 3
a85 2
    protected String processRequest (Connection conn, WebContext context)
        throws HandlerException, RedirectException
d87 3
a89 1
        String templateName = super.processRequest(conn, context);
d91 81
a171 2
        String action = getAction(context);
        if (DEBUG) Log.debug("action=" + action);
a172 82
        try
        {
            String loginUserID = getLoginUser(context).getID();
            Project project = getCurrentProject(context);
            AccessControlList acl = getACL(context, loginUserID);

            if (action.equals(EDIT_DOWNLOADS))
            {
                Enumeration paramNames = request.getParameterNames();
                List editSet = new ArrayList();
                List deleteSet = new ArrayList();
                String paramName;
                while (paramNames.hasMoreElements ())
                {
                    paramName = (String) paramNames.nextElement ();
                    if (paramName.startsWith("edit"))
                        editSet.add(paramName);
                    else if (paramName.startsWith("delete"))
                        deleteSet.add(paramName);
                }

                String dlURL = 
                    URL.schemeAndServer(context) + "/servlets/ProjectDownload";

                // Do edits.
                for (int i = 0; i < editSet.size(); i++)
                {
                    String element = (String) editSet.get(i);
                    StringTokenizer tok = new StringTokenizer (element);
                    String whichAction = tok.nextToken();
                    String downloadID = tok.nextToken();
                    ProjectDownload dl =
                        ProjectDownloadPeer.getInstance(downloadID);
                    String isPublic =
                        DBFlag.flagValueOf(request.getParameter
                                           ("public " + downloadID));
                    if (whichAction.equals("edit"))
                    {
                        String description = context.getForm(element);
                        dl.edit(acl, description, getLoginUser(context),
                               isPublic, dlURL);
                    }
                }

                // Do deletes.
                for (int i = 0; i < deleteSet.size(); i++)
                {
                    String element = (String) deleteSet.get(i);
                    StringTokenizer tok = new StringTokenizer(element);
                    String whichAction = tok.nextToken();
                    String downloadID = tok.nextToken ();
                    ProjectDownload dl =
                        ProjectDownloadPeer.getInstance(downloadID);
                      Log.debug("delete action");
                    if (whichAction.equals("delete"))
                        dl.disapprove(acl, "", dlURL);
                }

                // Redirect back to ProjectDownload
                StringBuffer url = new StringBuffer("ProjectDownloadList");
                url.append("?projectID=").append(project.getID());
                redirectToURL(context, url.toString());
            }

            List downloads = project.getProjectDownloads();
            if (downloads.size() > 0)
            {
                context.put ("downloads", downloads);
            }
        }
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            String errMsg = "Error editing download: " + e.getMessage();
            Log.error(errMsg, e);
            appendToError(context, errMsg);
            throw new HandlerException(errMsg);
        }    
    
d175 2
a176 1
}
@

