head	1.58;
access;
symbols
	TIGRIS_0_9_2_4:1.52.2.1
	TIGRIS_0_9_2_3:1.52
	HELM_PEER_PORT_BRANCH:1.56.0.2
	TURBINE_PEER:1.56
	TIGRIS_0_9_2_1:1.56
	TIGRIS_0_9_2:1.52.0.2
	TIGRIS_0_9_0:1.49.0.2
	TIGRIS_0_8_4:1.33.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.58
date	2001.02.21.03.40.12;	author edk;	state dead;
branches;
next	1.57;

1.57
date	2001.02.08.02.38.38;	author elicia;	state Exp;
branches;
next	1.56;

1.56
date	2001.01.26.18.29.04;	author edk;	state Exp;
branches
	1.56.2.1;
next	1.55;

1.55
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.54;

1.54
date	2001.01.23.02.26.55;	author elicia;	state Exp;
branches;
next	1.53;

1.53
date	2001.01.19.02.28.09;	author dlr;	state Exp;
branches;
next	1.52;

1.52
date	2001.01.18.06.38.19;	author dlr;	state Exp;
branches
	1.52.2.1;
next	1.51;

1.51
date	2001.01.17.23.17.57;	author dlr;	state Exp;
branches;
next	1.50;

1.50
date	2000.12.29.03.37.33;	author dlr;	state Exp;
branches;
next	1.49;

1.49
date	2000.12.13.02.02.27;	author dlr;	state Exp;
branches;
next	1.48;

1.48
date	2000.12.12.23.21.37;	author dlr;	state Exp;
branches;
next	1.47;

1.47
date	2000.12.12.22.39.53;	author dlr;	state Exp;
branches;
next	1.46;

1.46
date	2000.12.12.20.38.14;	author dlr;	state Exp;
branches;
next	1.45;

1.45
date	2000.12.12.20.04.34;	author dlr;	state Exp;
branches;
next	1.44;

1.44
date	2000.12.10.00.43.20;	author dlr;	state Exp;
branches;
next	1.43;

1.43
date	2000.12.09.08.25.52;	author dlr;	state Exp;
branches;
next	1.42;

1.42
date	2000.12.09.08.23.11;	author dlr;	state Exp;
branches;
next	1.41;

1.41
date	2000.12.08.09.23.24;	author dlr;	state Exp;
branches;
next	1.40;

1.40
date	2000.12.06.09.31.08;	author lucas;	state Exp;
branches;
next	1.39;

1.39
date	2000.12.06.06.45.13;	author npm;	state Exp;
branches;
next	1.38;

1.38
date	2000.12.06.06.43.37;	author npm;	state Exp;
branches;
next	1.37;

1.37
date	2000.12.06.06.06.04;	author dlr;	state Exp;
branches;
next	1.36;

1.36
date	2000.12.06.06.02.47;	author dlr;	state Exp;
branches;
next	1.35;

1.35
date	2000.12.06.05.39.59;	author npm;	state Exp;
branches;
next	1.34;

1.34
date	2000.12.05.02.19.16;	author leonardr;	state Exp;
branches;
next	1.33;

1.33
date	2000.12.04.05.00.22;	author edk;	state Exp;
branches
	1.33.2.1;
next	1.32;

1.32
date	2000.11.29.02.26.17;	author dlr;	state Exp;
branches;
next	1.31;

1.31
date	2000.11.29.02.23.35;	author dlr;	state Exp;
branches;
next	1.30;

1.30
date	2000.11.29.01.47.45;	author dlr;	state Exp;
branches;
next	1.29;

1.29
date	2000.11.22.09.42.33;	author dlr;	state Exp;
branches;
next	1.28;

1.28
date	2000.11.22.09.37.15;	author dlr;	state Exp;
branches;
next	1.27;

1.27
date	2000.11.22.03.50.18;	author dlr;	state Exp;
branches;
next	1.26;

1.26
date	2000.11.22.03.42.19;	author dlr;	state Exp;
branches;
next	1.25;

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

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

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

1.22
date	2000.11.20.10.02.56;	author dlr;	state Exp;
branches;
next	1.21;

1.21
date	2000.11.19.07.13.09;	author dlr;	state Exp;
branches;
next	1.20;

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

1.19
date	2000.11.18.00.31.51;	author leonardr;	state Exp;
branches;
next	1.18;

1.18
date	2000.11.17.23.27.10;	author dlr;	state Exp;
branches;
next	1.17;

1.17
date	2000.11.17.22.22.08;	author dlr;	state Exp;
branches;
next	1.16;

1.16
date	2000.11.17.20.29.16;	author dlr;	state Exp;
branches;
next	1.15;

1.15
date	2000.11.17.20.11.23;	author dlr;	state Exp;
branches;
next	1.14;

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

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

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

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

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

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

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

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

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

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

1.4
date	2000.11.14.05.07.26;	author dlr;	state Exp;
branches;
next	1.3;

1.3
date	2000.11.14.04.31.44;	author dlr;	state Exp;
branches;
next	1.2;

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

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

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

1.33.2.1
date	2000.12.05.06.34.17;	author jrobbins;	state Exp;
branches;
next	1.33.2.2;

1.33.2.2
date	2000.12.06.05.29.59;	author npm;	state Exp;
branches;
next	1.33.2.3;

1.33.2.3
date	2000.12.06.05.40.52;	author npm;	state Exp;
branches;
next	1.33.2.4;

1.33.2.4
date	2000.12.06.06.07.08;	author npm;	state Exp;
branches;
next	1.33.2.5;

1.33.2.5
date	2000.12.06.06.32.32;	author dlr;	state Exp;
branches;
next	1.33.2.6;

1.33.2.6
date	2000.12.06.06.47.35;	author npm;	state Exp;
branches;
next	1.33.2.7;

1.33.2.7
date	2000.12.06.07.54.22;	author lucas;	state Exp;
branches;
next	;

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

1.56.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	;


desc
@@


1.58
log
@renamed to ProjectDownloadList
@
text
@/* ================================================================
 * Copyright (c) 2000 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 COLLAB.NET 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.net.InetAddress;
import java.net.URLEncoder;
import java.sql.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.webmacro.util.Log;
import org.webmacro.servlet.*;

import com.oreilly.servlet.MultipartRequest;

import com.workingdogs.village.*;

import org.joist.*;
import org.joist.util.*;
import org.joist.session.*;
import org.joist.security.RedirectException;
import org.joist.security.RedirectURLException;
import org.joist.database.DataManager;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.*;
import org.tigris.helm.database.ProjectDownloadManager;
import org.tigris.helm.domain.User;
import org.tigris.helm.tool.MDACookie;
import org.tigris.helm.tool.DBFlag;

/**
 * Handles project uploads and downloads.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@author <a href="mailto:elicia@@collab.net">Elicia David</a>
 * @@version $Id: ProjectDownload.java,v 1.57 2001/02/08 02:38:38 elicia Exp $
 */
public class ProjectDownload extends HelmServlet
{
    /**
     * The action key for adding a new download.
     */
    private static final String ADD_DOWNLOAD = "Upload File";

    /**
     * The action key for download an existing file.
     */
    private static final String DO_DOWNLOAD = "download";

    /**
     * The query string parameter name of a download's database key.
     */
    private static final String DOWNLOAD_ID = "dlID";

    /**
     * Key for whether the download is private.
     */
    private static final String IS_PUBLIC = "isPublic";

    /**
     * The log file.
     */
    private static Log log = new Log("prjDnld", "ProjectDownload");

    /**
     * Whether to log debugging info.
     */
    private static final boolean debug = true;

    /**
     * Display and process project downloads screen.
     */
    protected String processRequest (Connection conn, WebContext ctx)
	throws HandlerException, RedirectException
    {
	if (debug) log.info("started");
	String templateName = super.processRequest(conn, ctx);

        String action = getAction(ctx);
        if (debug) log.info("action=" + action);
        HttpServletRequest req = ctx.getRequest();
        String msg = req.getParameter(Project.MESSAGE);
        if (haveValue(msg)) appendToMessage(ctx, msg);

        try
        {
            String descrip = null;
            String isPublic = null;
            Project project = getCurrentProject(ctx);
            User user = getLoginUser(ctx);

            if (action != null && action.equals(ADD_DOWNLOAD))
            {
                // Do not allow overwrites of existing downloads.
                if (FileUpload.isValidContentType(ctx))
                {
                    File saveDir = new File
                        (project.getUploadDirectory(getBaseSaveDir(), user));
                    if (!saveDir.exists()) saveDir.mkdirs();
                    int maxPostSize = Integer.parseInt
                        (myProperties.getProperty("maxPostSize"));
                    String fsPerms = 
                        myProperties.getProperty("filesystemPermissions");
                    FileUpload upload = 
                        new FileUpload(conn, ctx, maxPostSize, 
                                       saveDir.getAbsolutePath(), fsPerms);
                    List files = upload.getFiles();
                    MultipartRequest mreq = upload.getMultipartRequest();
                    descrip = mreq.getParameter("description");

                    isPublic = mreq.getParameter(IS_PUBLIC);
                    if (debug) log.info("isPublic=" + isPublic);

                    // HELP: The user actually may have uploaded many files, 
                    // but the current UI doesn't support this.  Punting, 
                    // handling only the first upload for now.
                    switch (files.size())
                    {
                    case 1:
                        processUpload(conn, ctx, project, (File)files.get(0), 
                                      descrip, isPublic);

                        // No need to redisplay the user input.
                        descrip = "";
                        isPublic = null;
                        break;
                    case 0:
                        appendToMessage(ctx, "No file uploaded");
                        break;
                    default:
                        appendToError
                            (ctx, "Please upload only one file at a time");
                    }
                }
                else
                {
                    log.warning("Incorrect content type for file upload");
                }
            }
            else if (action != null && action.equals(DO_DOWNLOAD))
            {
                // Authorize the download and redirect to the file server.
                String dlID = req.getParameter(DOWNLOAD_ID);
                if (debug) log.info("dlID=" + dlID);
                Download dl = new Download(conn, dMgr, dlID);
                authDownload(project, user, dl.isPublic(), req, ctx.getResponse());
                StringBuffer dlURL = new StringBuffer(req.getScheme());
                dlURL.append("://")
                    .append(myProperties.getProperty("fileServer"));
                if (req.getServerPort() != URL.HTTP_PORT &&
                    req.getServerPort() != URL.HTTPS_PORT)
                {
                    dlURL.append(':').append(req.getServerPort());
                }
                dlURL.append("/files/").append(project.getID())
                    .append('/').append(dl.getUploadedBy().getID()).append('/')
		    .append(URLEncoder.encode(dl.getName()));
                redirectToURL(ctx, dlURL.toString());
            }

            ctx.put("description", descrip != null ? descrip : "");
            if (isPublic != null) ctx.put(IS_PUBLIC, DBFlag.ON);

            // If we already have a list, it needs to be refreshed.
            List downloads = project.getDownloads();
            if (downloads.size() > 0)
            {
                ctx.put("downloads", downloads);
            }
        }
        catch (ACLException e)
        {
            throw e;
        }
        catch (RedirectURLException e)
        {
            throw e;
        }
        catch (HandlerException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        }

	if (debug) log.info("done");
        return templateName;
    }

    /**
     * Processes a single uploaded file.
     */
    private void processUpload (Connection conn, WebContext ctx,
                                Project project, File fileToAdd,
                                String descrip, String isPublic)
        throws ACLException, Exception
    {
        AccessControlList acl = getACL(ctx, conn);
        String url = URL.schemeAndServer(ctx) + "/servlets/ProjectDownload";

        // Check for overwritten files.
        String fileName = fileToAdd.getName();
        String filePath = Download.extractLocation(fileToAdd);
        if (debug) log.info("fileName=" + fileName);
        List downloads = project.getDownloads();
        int nbrDownloads = downloads.size();
        for (int i = 0; i < nbrDownloads; i++)
        {
            Download dl = (Download)downloads.get(i);
            if (debug) log.info("dl.getName()=" + dl.getName());
            if (filePath.equals(dl.getLocation()) &&
                fileName.equals(dl.getName()))
            {
                // The file has already been overwritten--no need to delete it
                // from disk.                
                dl.delete(acl, true, ctx);
                appendToMessage(ctx, fileName + 
                                " was overwritten by your upload");
                break;
            }
        }

        // Add the download to the project.
        project.addDownload(acl, fileToAdd, descrip, isPublic, url);
    }

    /**
     * Macro to return the upload directory.
     */
    private final String getBaseSaveDir ()
    {
        return myProperties.getProperty("baseSaveDir");
    }

    /**
     * Cookies the user with a ticket that authorizes download of a specific
     * file.  The authorization must happen regardless of whether the file is 
     * public--otherwise, mod_auth_mda will reject access as a result of no
     * MDACookie existing for the client.
     */
    private void authDownload (Project project, User user, Boolean isPublic,
                               HttpServletRequest req, HttpServletResponse res)
        throws HandlerException
    {
        try
        {
            MDACookie.write(myProperties.getProperty("fileServer"), project, 
                            user, isPublic, req, res);
        }
        catch (Exception e)
        {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        }
    }
}
@


1.57
log
@cleanup
@
text
@d84 1
a84 1
 * @@version $Id: ProjectDownload.java,v 1.56 2001/01/26 18:29:04 edk Exp $
@


1.56
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d84 1
a84 1
 * @@version $Id: ProjectDownload.java,v 1.54 2001/01/23 02:26:55 elicia Exp $
d267 1
a267 1
                dl.delete(acl, url, false);
@


1.56.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d84 1
a84 1
 * @@version $Id: ProjectDownload.java,v 1.56 2001/01/26 18:29:04 edk Exp $
@


1.55
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.54
log
@made changed argument to MDACookie
@
text
@d84 1
a84 1
 * @@version $Id: ProjectDownload.java,v 1.53 2001/01/19 02:28:09 dlr Exp $
@


1.53
log
@Out damn tabs!
@
text
@d84 1
a84 1
 * @@version $Id: ProjectDownload.java,v 1.52 2001/01/18 06:38:19 dlr Exp $
d194 1
a194 1
                authDownload(project, user, dl, req, ctx.getResponse());
d292 1
a292 1
    private void authDownload (Project project, User user, Download dl,
d299 1
a299 1
                            user, dl, req, res);
@


1.52
log
@Handles downloads with spaces in the file name.
@
text
@d84 1
a84 1
 * @@version $Id: ProjectDownload.java,v 1.51 2001/01/17 23:17:57 dlr Exp $
d198 1
a198 1
		if (req.getServerPort() != URL.HTTP_PORT &&
@


1.52.2.1
log
@moved changed from HEAD for ProjectDocuments and ProjectDownloads
@
text
@d84 1
a84 1
 * @@version $Id: ProjectDownload.java,v 1.56 2001/01/26 18:29:04 edk Exp $
d194 1
a194 1
                authDownload(project, user, dl.isPublic(), req, ctx.getResponse());
d198 1
a198 1
                if (req.getServerPort() != URL.HTTP_PORT &&
d292 1
a292 1
    private void authDownload (Project project, User user, Boolean isPublic,
d299 1
a299 1
                            user, isPublic, req, res);
@


1.51
log
@Enhanced authDownload() documentation.
@
text
@d53 1
d84 1
a84 1
 * @@version $Id: ProjectDownload.java,v 1.50 2000/12/29 03:37:33 dlr Exp $
d195 12
a206 14
                String dlURL =
		    req.getScheme()
		    + "://"
		    + myProperties.getProperty("fileServer")
		    + ((req.getServerPort() == 80 || req.getServerPort() == 443)
		       ? ""
		       : ":" + req.getServerPort())
		    + "/files/"
		    + project.getID()
		    + '/'
		    + dl.getUploadedBy().getID()
		    + '/'
		    + dl.getName();
                redirectToURL(ctx, dlURL);
@


1.50
log
@Made use of new DBFlag class.
@
text
@d83 1
a83 1
 * @@version $Id: ProjectDownload.java,v 1.49 2000/12/13 02:02:27 dlr Exp $
d289 3
a291 1
     * file.
@


1.49
log
@Regenerate .htaccess file on download deletion.
@
text
@d76 1
d83 1
a83 1
 * @@version $Id: ProjectDownload.java,v 1.48 2000/12/12 23:21:37 dlr Exp $
d211 1
a211 1
            if (isPublic != null) ctx.put(IS_PUBLIC, "Y");
@


1.48
log
@- Correctly handle display of isPublic state.
- Check download path when checking for overwrites.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.47 2000/12/12 22:39:53 dlr Exp $
d250 1
d267 1
a267 1
                dl.delete(acl, false);
d275 1
a275 3
        project.addDownload(acl, fileToAdd, descrip, isPublic,
                            URL.schemeAndServer(ctx) + 
                            "/servlets/ProjectDownload");
@


1.47
log
@Correctly retrieve value for isPublic checkbox.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.46 2000/12/12 20:38:14 dlr Exp $
d134 1
d157 1
a157 2
                    String isPublic = mreq.getParameter(IS_PUBLIC);
                    if (haveValue(isPublic)) ctx.put(IS_PUBLIC, "Y");
d169 1
a169 1
                        // No need to redisplay the description.
d171 1
d210 1
d253 1
d261 2
a262 2
            // TODO: Compare path information.
            if (fileName.equals(dl.getName()))
@


1.46
log
@Added trace.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.45 2000/12/12 20:04:34 dlr Exp $
d155 5
a159 1
                    
d167 1
a167 1
                                      descrip, req);
d244 1
a244 1
                                String descrip, HttpServletRequest req)
a268 4

        String isPublic = (String)req.getParameter(IS_PUBLIC);
        if (haveValue(isPublic)) ctx.put(IS_PUBLIC, "Y");
        if (debug) log.info("isPublic=" + isPublic);
@


1.45
log
@Changed IS_PRIVATE to IS_PUBLIC--propogating all the way through to the UI.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.44 2000/12/10 00:43:20 dlr Exp $
d268 1
d270 1
a270 1
        // Add the downloads to the project.
@


1.44
log
@Minor misc. refinements.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.43 2000/12/09 08:25:52 dlr Exp $
d104 1
a104 1
    private static final String IS_PRIVATE = "isPrivate";
d266 2
a267 2
        String isPrivate = (String)req.getParameter(IS_PRIVATE);
        if (haveValue(isPrivate)) ctx.put(IS_PRIVATE, "Y");
d270 1
a270 1
        project.addDownload(acl, fileToAdd, descrip, isPrivate,
@


1.43
log
@unsightly
@
text
@d78 1
a78 1
 * Handles project downloads.
d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.42 2000/12/09 08:23:11 dlr Exp $
a100 1

d169 1
a169 1
                        appendToError(ctx, "No file uploaded");
d192 1
a192 1
		    + (((req.getServerPort() == 80) || (req.getServerPort() == 443))
d194 1
a194 1
		       : (":" + req.getServerPort()))
d197 1
a197 1
		    + "/"
d199 1
a199 1
		    + "/"
@


1.42
log
@Differentiate between errors and messages.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.41 2000/12/08 09:23:24 dlr Exp $
a85 2
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.41 2000/12/08 09:23:24 dlr Exp $";

@


1.41
log
@Removed low value trace.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.40 2000/12/06 09:31:08 lucas Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.40 2000/12/06 09:31:08 lucas Exp $";
d172 1
a172 1
                        appendToMessage(ctx, "No file uploaded");
d175 1
a175 1
                        appendToMessage
@


1.40
log
@Fixed compile error

Added support for file upload/download

PR:
Obtained from:
Submitted by:
Reviewed by:
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.39 2000/12/06 06:45:13 npm Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.39 2000/12/06 06:45:13 npm Exp $";
a272 1
        log.info("DASD!");
@


1.39
log
@change to make it match branch
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.38 2000/12/06 06:43:37 npm Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.38 2000/12/06 06:43:37 npm Exp $";
d197 1
a197 1
		       : (':' + req.getServerPort().toString()))
d200 1
a200 1
		    + '/'
d202 1
a202 1
		    + '/'
@


1.38
log
@file dl url now supports sandbox webservers at ports other than 80/443
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.37 2000/12/06 06:06:04 dlr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.37 2000/12/06 06:06:04 dlr Exp $";
a190 2
                // For mod_auth_mda's httpd.conf fragment
                // 'Alias /files/ "__SANDBOX__/data/helm/fileserv/"'
@


1.37
log
@Corrected quoting.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.36 2000/12/06 06:02:47 dlr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.36 2000/12/06 06:02:47 dlr Exp $";
d197 3
@


1.36
log
@Corrected broken mailtos.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.35 2000/12/06 05:39:59 npm Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.35 2000/12/06 05:39:59 npm Exp $";
d191 2
d197 1
a197 1
		    + '/files/'	// NPM -- for mod_auth_mda's httpd.conf fragment 'Alias /files/ "__SANDBOX__/data/helm/fileserv/"'
@


1.35
log
@lucas' inclusion of mod_auth_mda.rpm into standard tigris install allows
standalone use of ProjectDownload. In "standalone" tigris+mod_auth_mda
configuration, we stick all files under alias "/files/" via mod_auth_mda's
httpd.conf fragment:
	Alias /files/ "__SANDBOX__/data/helm/fileserv/"
	<Directory __SANDBOX__/data/helm/fileserv> ...
For standalone fileserver setup we do
	Alias /files/ "/home/httpd/html/"
	<Directory "/home/httpd/html"> ...

Therefore, I modified code where URL path is constucted, adding "/files"
which corresponds to the aliases setup for both standalone tigris w/ file
DL as well as separate file DL server.
@
text
@d80 3
a82 3
 * @@author <a href="mailto:dlr@@collab.net>Daniel Rall</a>
 * @@author <a href="mailto:elicia@@collab.net>Elicia David</a>
 * @@version $Id: ProjectDownload.java,v 1.34 2000/12/05 02:19:16 leonardr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.34 2000/12/05 02:19:16 leonardr Exp $";
@


1.34
log
@Added and used method to show the user's sourcecast address, as opposed to the address they signed up with.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.33 2000/12/04 05:00:22 edk Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.33 2000/12/04 05:00:22 edk Exp $";
d191 10
a200 4
                String dlURL = req.getScheme() + "://" + 
                    myProperties.getProperty("fileServer") + '/' + 
                    project.getID() + '/' + dl.getUploadedBy().getID() + '/' +
                    dl.getName();
@


1.33
log
@fix bug in the generated URL ... this logic should be moved into
Download.java, where it'll be more efficient anyway.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.32 2000/11/29 02:26:17 dlr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.32 2000/11/29 02:26:17 dlr Exp $";
d158 1
a158 1

d252 1
a252 1
                // from disk.
d264 1
@


1.33.2.1
log
@merged in changes from HEAD
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.34 2000/12/05 02:19:16 leonardr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.34 2000/12/05 02:19:16 leonardr Exp $";
d158 1
a158 1
                    
d252 1
a252 1
                // from disk.                
a263 1
        log.info("DASD!");
@


1.33.2.2
log
@lucas' inclusion of mod_auth_mda.rpm into standard tigris install allows
standalone use of ProjectDownload. In "standalone" tigris+mod_auth_mda
configuration, we stick all files under alias "/files/" via mod_auth_mda's
httpd.conf fragment:
	Alias /files/ "__SANDBOX__/data/helm/fileserv/"
	<Directory __SANDBOX__/data/helm/fileserv> ...
For standalone fileserver setup we do
	Alias /files/ "/home/httpd/html/"
	<Directory "/home/httpd/html"> ...

Therefore, I modified code where URL path is constucted, adding "/files"
which corresponds to the aliases setup for both standalone tigris w/ file
DL as well as separate file DL server.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.33.2.1 2000/12/05 06:34:17 jrobbins Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.33.2.1 2000/12/05 06:34:17 jrobbins Exp $";
d191 4
a194 9
                String dlURL = req.getScheme()
		    + "://"
		    + myProperties.getProperty("fileServer")
		    + '/files/'	// NPM -- for mod_auth_mda's httpd.conf fragment 'Alias /files/ "__SANDBOX__/data/helm/fileserv/"'
		    + project.getID()
		    + '/'
		    + dl.getUploadedBy().getID()
		    + '/'
		    + dl.getName();
@


1.33.2.3
log
@reformatted just like same change i made to HEAD
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.33.2.2 2000/12/06 05:29:59 npm Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.33.2.2 2000/12/06 05:29:59 npm Exp $";
d191 1
a191 2
                String dlURL =
		    req.getScheme()
@


1.33.2.4
log
@fixed stupidism
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.33.2.3 2000/12/06 05:40:52 npm Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.33.2.3 2000/12/06 05:40:52 npm Exp $";
d195 1
a195 1
		    + "/files/"	// NPM -- for mod_auth_mda's httpd.conf fragment 'Alias /files/ "__SANDBOX__/data/helm/fileserv/"'
@


1.33.2.5
log
@Brought up to sync with HEAD.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.33.2.4 2000/12/06 06:07:08 npm Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.33.2.4 2000/12/06 06:07:08 npm Exp $";
a190 2
                // For mod_auth_mda's httpd.conf fragment
                // 'Alias /files/ "__SANDBOX__/data/helm/fileserv/"'
d195 1
a195 1
		    + "/files/"
@


1.33.2.6
log
@file dl url now supports sandbox webservers at ports other than 80/443
@
text
@d80 2
a81 2
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@author <a href="mailto:elicia@@collab.net">Elicia David</a>
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.33.2.5 2000/12/06 06:32:32 dlr Exp $";
a196 3
		    + (((req.getServerPort() == 80) || (req.getServerPort() == 443))
		       ? ""
		       : (':' + req.getServerPort().toString()))
@


1.33.2.7
log
@Fixed compile error and took out properties which are now in zone.properties.

PR:
Obtained from:
Submitted by:
Reviewed by:
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.33.2.6 2000/12/06 06:47:35 npm Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.33.2.6 2000/12/06 06:47:35 npm Exp $";
d199 1
a199 1
		       : (":" + req.getServerPort()))
d202 1
a202 1
		    + "/"
d204 1
a204 1
		    + "/"
@


1.32
log
@Assume that the file server uses the same protocol--i.e. http or
https--as this servlet does.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.31 2000/11/29 02:23:35 dlr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.31 2000/11/29 02:23:35 dlr Exp $";
d193 2
a194 1
                    project.getID() + '/' + user.getID() + '/' + dl.getName();
@


1.31
log
@Added support for isPrivate.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.30 2000/11/29 01:47:45 dlr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.30 2000/11/29 01:47:45 dlr Exp $";
d191 1
a191 1
                String dlURL = "http://" + 
@


1.30
log
@Use the same scheme that the request did when calling Project's
addDownload() method.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.29 2000/11/22 09:42:33 dlr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.29 2000/11/22 09:42:33 dlr Exp $";
d103 6
d166 1
a166 1
                                      descrip);
d233 1
a233 1
                                String descrip)
d259 2
a260 2
        // TODO: Add UI for isPrivate.
        String isPrivate = null;
@


1.29
log
@Corrrecte compile errors.
@
text
@d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.28 2000/11/22 09:37:15 dlr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.28 2000/11/22 09:37:15 dlr Exp $";
d232 1
a232 1
        // Expensive check for overwritten files.
d241 1
d258 1
a258 1
                            getHttpAndServer(ctx) + 
@


1.28
log
@- Made use of local var in processRequest().
- Sync'd w/ interface changes in MDACookie.write().
@
text
@d54 1
d82 1
a82 1
 * @@version $Id: ProjectDownload.java,v 1.27 2000/11/22 03:50:18 dlr Exp $
d86 1
a86 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.27 2000/11/22 03:50:18 dlr Exp $";
d280 1
a280 1
                            user, dl, res);
@


1.27
log
@Moved CGI key into Project...couldn't figure out a good way to handle
proper encapsulation in this situation.
@
text
@d81 1
a81 1
 * @@version $Id: ProjectDownload.java,v 1.26 2000/11/22 03:42:19 dlr Exp $
d85 1
a85 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.26 2000/11/22 03:42:19 dlr Exp $";
d123 2
a124 1
        String msg = ctx.getRequest().getParameter(Project.MESSAGE);
d180 1
a180 1
                String dlID = ctx.getRequest().getParameter(DOWNLOAD_ID);
d183 1
a183 1
                authDownload(project, user, dl, ctx.getResponse());
d273 1
a273 1
                               HttpServletResponse res)
@


1.26
log
@Display a "message in red" if mod_auth_mda times out and redirect to
this page.
@
text
@d81 1
a81 1
 * @@version $Id: ProjectDownload.java,v 1.25 2000/11/21 02:44:18 dlr Exp $
d85 1
a85 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.25 2000/11/21 02:44:18 dlr Exp $";
a102 5
     * The query string parameter name of the display message.
     */
    private static final String MESSAGE = "msg";

    /**
d122 2
a123 1
        String msg = ctx.getRequest().getParameter(MESSAGE);
a124 1
        if (debug) log.info("action=" + action);
@


1.25
log
@Use the request's host name.
@
text
@d81 1
a81 1
 * @@version $Id: ProjectDownload.java,v 1.24 2000/11/21 00:35:12 dlr Exp $
d85 1
a85 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.24 2000/11/21 00:35:12 dlr Exp $";
d103 5
d127 2
@


1.24
log
@Simplified code after speaking to Jason Hunter regarding how
MultipartRequest works.
@
text
@d81 1
a81 1
 * @@version $Id: ProjectDownload.java,v 1.23 2000/11/20 23:52:35 dlr Exp $
d85 1
a85 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.23 2000/11/20 23:52:35 dlr Exp $";
d253 1
a253 2
                            "http://" +
                            InetAddress.getLocalHost().getHostName() + 
a274 1
            // TODO: Set the cookie at the "domain" level.
@


1.23
log
@Restructed to send MDA auth via cookies instead of query string.
@
text
@d81 1
a81 1
 * @@version $Id: ProjectDownload.java,v 1.22 2000/11/20 10:02:56 dlr Exp $
d85 1
a85 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.22 2000/11/20 10:02:56 dlr Exp $";
d155 5
a159 12
                        File f = (File)files.get(0);
                        if (f != null)
                        {
                            processUpload(conn, ctx, project, f, descrip);

                            // No need to redisplay the description.
                            descrip = "";
                        }
                        else
                        {
                            noFilesUploadedMsg(ctx);
                        }
d162 1
a162 1
                        noFilesUploadedMsg(ctx);
a263 8
    }

    /**
     * Macro to add a message to the context.
     */
    private final void noFilesUploadedMsg (WebContext ctx)
    {
        appendToMessage(ctx, "No file uploaded");
@


1.22
log
@Handle invalid servlet inputs more gracefully.  This includes a
workaround for a possible bug in the MultipartRequest class where the
list of file names returned may include an empty and possibly nameless
file.  Will seek input from JH with regard to this.
@
text
@d54 1
d67 1
d74 1
d81 1
a81 1
 * @@version $Id: ProjectDownload.java,v 1.21 2000/11/19 07:13:09 dlr Exp $
d85 1
a85 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.21 2000/11/19 07:13:09 dlr Exp $";
d93 10
d181 12
a199 1
                ctx.put("dlSvr", myProperties.getProperty("fileServer"));
d207 8
d279 21
@


1.21
log
@Include the host name of the JVM's machine in the callback URL.
@
text
@d78 1
a78 1
 * @@version $Id: ProjectDownload.java,v 1.20 2000/11/18 09:36:55 dlr Exp $
d82 1
a82 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.20 2000/11/18 09:36:55 dlr Exp $";
d109 1
a109 1
        if (debug) log.info("action=" + action );
a112 1
            List downloads = null;
d120 1
a120 29
                List validationErrors = new ArrayList();
                File saveDir = new File
                    (project.getUploadDirectory(getBaseSaveDir(), user));
                if (!saveDir.exists()) saveDir.mkdirs();
                int maxPostSize = Integer.parseInt
                    (myProperties.getProperty("maxPostSize"));
                String fsPerms = 
                    myProperties.getProperty("filesystemPermissions");
                FileUpload upload = new FileUpload(conn, ctx, maxPostSize, 
                                                   saveDir.getAbsolutePath(),
                                                   fsPerms);
                MultipartRequest mreq = upload.getMultipartRequest();
                descrip = mreq.getParameter("description");
                if (debug) log.info("descrip=" + descrip);

                List files = upload.getFiles();
                AccessControlList acl = getACL(ctx, conn);

                // HELP: The user actually may have uploaded many files, but
                // the current UI doesn't support this.  Punting, handling
                // only the first upload for now.
                File fileToAdd = (File)files.get(0);

                // Super-expensive check for overwritten files.
                String fileName = fileToAdd.getName();
                if (debug) log.info("fileName=" + fileName);
                downloads = project.getDownloads();
                int nbrDownloads = downloads.size();
                for (int j = 0; j < nbrDownloads; j++)
d122 18
a139 3
                    Download dl = (Download)downloads.get(j);
                    if (debug) log.info("dl.getName()=" + dl.getName());
                    if (fileName.equals(dl.getName()))
d141 13
a153 3
                        dl.delete(acl);
                        appendToMessage(ctx, fileName + 
                                        " was overwritten by your upload");
d155 6
d163 4
a166 8

                String isPrivate = null; // TODO
                // Add the downloads to the project.
                project.addDownload(acl, fileToAdd, descrip, isPrivate,
                                    "http://" +
                                    InetAddress.getLocalHost().getHostName() + 
                                    "/servlets/ProjectDownload");
                descrip = "";
d172 1
a172 1
            downloads = project.getDownloads();
d194 40
d239 8
@


1.20
log
@Shifted some functionality to the Project business object.
@
text
@d52 1
d78 1
a78 1
 * @@version $Id: ProjectDownload.java,v 1.18 2000/11/17 23:27:10 dlr Exp $
d82 1
a82 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.19 dlr Exp $";
d165 2
@


1.19
log
@Now uses getAction.
@
text
@d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.18 2000/11/17 23:27:10 dlr Exp $";
d115 1
d121 2
a122 2
                User user = getLoginUser(ctx);
                File saveDir = new File(getUploadSaveDir(project, user));
d164 1
a164 1
                                    getMDAAuthURL(project));
d174 1
a174 2
                // TODO: Use frogdot URL munging...pass in realm & user email.
                ctx.put("fileServer", myProperties.getProperty("fileServer"));
d176 5
a180 1
            }   
d193 1
a193 27
     * Gets the directory to save uploads to.
     *
     * @@return The directory to save uploads to.
     */
    private String getUploadSaveDir (Project project, User user)
        throws DataSetException
    {
        // Save to /pub-fileserver/projectID/userID/fileNameAsUploaded.
        StringBuffer dir = 
            new StringBuffer(myProperties.getProperty("baseSaveDir"));
        dir.append(File.separatorChar).append(project.getID())
            .append(File.separatorChar).append(user.getID());
        return dir.toString();
    }

    /**
     * The shared secret with the mod_auth_mda Apache module running on the
     * file server.
     */
    private String MD5_CRYPT_KEY = 
        "w b@@5b15#664038f.f9d8U19b7e25 664eY9ad2%4393e,a2ef";

    /**
     * Returns a digitally signed URL to be interpretted by the Apache module
     * mod_auth_mda.
     *
     * @@param project The project for which to generate the signed URL.
d195 1
a195 1
    private String getMDAAuthURL (Project project)
d197 1
a197 3
        String url = null;
        // TODO
        return url;
@


1.18
log
@Sync'd with Project's addDownload() interface.
@
text
@d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.17 2000/11/17 22:22:08 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.17 2000/11/17 22:22:08 dlr Exp $";
d107 1
a107 1
        String action = ctx.getForm("action");
@


1.17
log
@Sync'd w/ changed interfaces.
@
text
@d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.16 2000/11/17 20:29:16 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.16 2000/11/17 20:29:16 dlr Exp $";
d162 2
a163 1
                project.addDownload(acl, fileToAdd, descrip, isPrivate);
d202 20
@


1.16
log
@Removed legacy HELP.
@
text
@d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.15 2000/11/17 20:11:23 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.15 2000/11/17 20:11:23 dlr Exp $";
a122 1
                String path = saveDir.getAbsolutePath();
d128 2
a129 1
                                                   path, fsPerms);
a133 2
                List descriptions = new ArrayList(1);
                descriptions.add(descrip);
d137 5
d143 2
d146 2
a147 1
                for (int i = 0; i < files.size(); i++)
d149 3
a151 4
                    String fileName = ((File)files.get(i)).getName();
                    if (debug) log.info("fileName=" + fileName);
                    int nbrDownloads = downloads.size();
                    for (int j = 0; j < nbrDownloads; j++)
d153 4
a156 8
                        Download dl = (Download)downloads.get(j);
                        if (debug) log.info("dl.getName()=" + dl.getName());
                        if (fileName.equals(dl.getName()))
                        {
                            dl.delete(acl);
                            appendToMessage(ctx, fileName + 
                                            " was overwritten by your upload");
                        }
d160 1
d162 1
a162 1
                project.addDownloads(acl, files, descriptions, path);
d172 1
@


1.15
log
@Sync'd w/ interfaces changes in the Project BusinessObject.
@
text
@d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.14 2000/11/16 02:41:43 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.14 2000/11/16 02:41:43 dlr Exp $";
a120 2
                // HELP: This check is not working because the HTML form data
                // does not use the regular encoding.
@


1.14
log
@Removed unnecessary cast.
@
text
@d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.13 2000/11/16 02:39:31 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.13 2000/11/16 02:39:31 dlr Exp $";
d125 1
d131 1
a131 2
                                                   saveDir.getAbsolutePath(),
                                                   fsPerms);
d162 1
a162 1
                project.addDownloads(acl, files, descriptions);
@


1.13
log
@Added necessary space in message to user.
@
text
@d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.12 2000/11/16 02:38:08 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.12 2000/11/16 02:38:08 dlr Exp $";
d152 1
a152 1
                        if (fileName.equals((String)dl.getName()))
@


1.12
log
@Switched from overwrite-proofed method to overwrite-allowed (w/ a
message indicating that an overwrite happened).
@
text
@d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.11 2000/11/16 01:30:54 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.11 2000/11/16 01:30:54 dlr Exp $";
d156 1
a156 1
                                            "was overwritten by your upload");
@


1.11
log
@Finally getting some data in the description field.
@
text
@d68 1
a68 1
import org.tigris.helm.security.HelmServlet;
d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.10 2000/11/15 23:24:23 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.10 2000/11/15 23:24:23 dlr Exp $";
d112 1
d123 21
a143 1
                try
d145 14
a158 3
                    new Download(conn, dMgr, project.getID(), user.getID(), 
                                 ctx.getForm("file"));
                    validationErrors.add("File already exists");
d160 4
a163 21
                catch (DoesNotExist proceedWithUpload)
                {
                    File saveDir = new File(getUploadSaveDir(project, user));
                    if (!saveDir.exists()) saveDir.mkdirs();
                    int maxPostSize = Integer.parseInt
                        (myProperties.getProperty("maxPostSize"));
                    String fsPerms = 
                        myProperties.getProperty("filesystemPermissions");
                    FileUpload upload = 
                        new FileUpload(conn, ctx, maxPostSize, 
                                       saveDir.getAbsolutePath(), fsPerms);
                    MultipartRequest mreq = upload.getMultipartRequest();
                    descrip = mreq.getParameter("description");
                    if (debug) log.info("descrip=" + descrip);

                    List descriptions = new ArrayList(1);
                    descriptions.add(descrip);
                    project.addDownloads(getACL(ctx, conn), upload.getFiles(), 
                                         descriptions);
                }
                reportInvalidUserInput(ctx, null, validationErrors);
d167 3
a169 1
            List downloads = project.getDownloads();
d172 1
@


1.10
log
@Added non-functional check for duplicate project.
@
text
@d57 2
d77 1
a77 1
 * @@version $Id: ProjectDownload.java,v 1.9 2000/11/15 21:07:13 elicia Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.9 2000/11/15 21:07:13 elicia Exp $";
a106 2
        String descrip = processField(ctx, "description");
        if (debug) log.info("descrip=" + descrip);
d112 1
d132 2
d137 6
a142 3
                        new FileUpload(conn, ctx, saveDir.getAbsolutePath(),
                                       fsPerms);
                    List files = upload.getFiles();
d145 1
a145 1
                    project.addDownloads(getACL(ctx, conn), files,
d151 1
@


1.9
log
@changed it so it is getting downloads for the current project
@
text
@d65 1
d75 1
a75 1
 * @@version $Id: ProjectDownload.java,v 1.8 2000/11/15 20:55:53 dlr Exp $
d79 1
a79 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.8 2000/11/15 20:55:53 dlr Exp $";
d106 1
d112 1
a112 2
            Project project = getCurrentDomain(ctx).getSpecialProject();
	    Project currentProject = getCurrentProject(ctx);
d116 2
d119 24
a142 12
                File saveDir = new File(getUploadSaveDir(project, user));
                if (!saveDir.exists()) saveDir.mkdirs();
                String fsPerms = 
                    myProperties.getProperty("filesystemPermissions");
                FileUpload upload = new FileUpload(conn, ctx, 
                                                   saveDir.getAbsolutePath(),
                                                   fsPerms);
                List files = upload.getFiles();
                List descriptions = new ArrayList(1);
                descriptions.add(descrip);
                if (debug) log.info("descrip=" + descrip);
                project.addDownloads(getACL(ctx, conn), files, descriptions);
d145 1
a145 1
            List downloads = currentProject.getDownloads();
@


1.8
log
@Added debug info.
@
text
@d74 1
a74 1
 * @@version $Id: ProjectDownload.java,v 1.7 2000/11/15 03:41:58 dlr Exp $
d78 1
a78 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.7 2000/11/15 03:41:58 dlr Exp $";
d111 1
d130 1
a130 1
            List downloads = project.getDownloads();
d142 1
a142 1
	if (debug) log.debug("done");
@


1.7
log
@Stuck decl together with assignment.
@
text
@d74 1
a74 1
 * @@version $Id: ProjectDownload.java,v 1.6 2000/11/15 00:14:40 dlr Exp $
d78 1
a78 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.6 2000/11/15 00:14:40 dlr Exp $";
d125 1
@


1.6
log
@Upload code now beginning to be functional.
@
text
@d74 1
a74 1
 * @@version $Id: ProjectDownload.java,v 1.5 2000/11/14 20:20:10 dlr Exp $
d78 1
a78 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.5 2000/11/14 20:20:10 dlr Exp $";
d128 1
a128 3
            List downloads = null;
            downloads = project.getDownloads();

@


1.5
log
@Can't get the action in the usual manner (a submit input named
"Button" and a call to context.get("action")).
@
text
@d74 1
a74 1
 * @@version $Id: ProjectDownload.java,v 1.4 2000/11/14 05:07:26 dlr Exp $
d78 1
a78 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.4 2000/11/14 05:07:26 dlr Exp $";
d104 1
d106 2
a107 3
	if (debug) log.info("action=" + action );
        Project project = getCurrentProject(ctx);
	     
d110 2
d114 3
a116 3
                FileUpload upload = null;
                User user = getCurrentUser(ctx);
                String saveDir = getUploadSaveDir(project, user);
d119 3
a121 1
                upload = new FileUpload(conn, ctx, saveDir, fsPerms);
d123 3
a125 1
                project.addDownloads(files);
@


1.4
log
@corrected log id
@
text
@d74 1
a74 1
 * @@version $Id: ProjectDownload.java,v 1.3 2000/11/14 04:31:44 dlr Exp $
d78 1
a78 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.3 2000/11/14 04:31:44 dlr Exp $";
d104 1
a104 1
	String action = (String)ctx.get("action");
@


1.3
log
@Called stub and changed ADD_DOWNLOAD key.
@
text
@d74 1
a74 1
 * @@version $Id: ProjectDownload.java,v 1.2 2000/11/14 01:35:23 dlr Exp $
d78 1
a78 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.2 2000/11/14 01:35:23 dlr Exp $";
d88 1
a88 1
    private static Log log = new Log("ProjectDownload", "Tigris StartPage");
@


1.2
log
@Support for project downloads addition.
@
text
@d74 1
a74 1
 * @@version $Id: $
d78 1
a78 1
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.1.1.1 2000/11/12 21:16:02 dlr Exp $";
d83 1
a83 1
    private static final String ADD_DOWNLOAD = "upload";
d119 1
a119 1
                // TODO: Inform the db of the uploaded files.
@


1.1
log
@Initial revision
@
text
@a52 3
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.ArrayList;
d54 1
a54 1
import org.webmacro.util.*;
a55 3
import org.webmacro.engine.*;
import org.webmacro.broker.*;
import org.webmacro.resource.*;
d58 1
d62 2
d67 17
a83 2
import org.joist.security.RedirectException;
import org.joist.database.DataManager;
d85 3
a87 2
public class ProjectDownload extends org.tigris.helm.security.HelmServlet {
    public static final  String versionID = "$Id: ProjectDownload.java,v 1.6 2000/11/10 01:50:37 dlr Exp $";
a88 1
    private static boolean debug = true;
d91 1
a91 1
     *  Display and process the login screen.
d93 6
a98 1
    protected String processRequest (Connection connection, WebContext context)
d101 2
a102 1
	if (debug) log.info("ProjectDownload: started!");
d104 3
a106 4
	String templateName = super.processRequest(connection, context);
	String action = (String)context.get("action");
	if (debug)
	     log.info("ProjectDownload: action=" + action );
d108 27
a134 29
        DataSet downloadSet = null;
        String projectID = context.getForm ("projectID");
        ArrayList downloadList = new ArrayList();

        ProjectDownloadManager dlMgr = (ProjectDownloadManager)
           getDataManager (context).getManager
          ("org.tigris.helm.database.ProjectDownloadManager");

	try {
           // Get all downloads for this project
           downloadSet = dlMgr.getDownloadsForProject (connection, projectID);

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

	catch (Exception e) {
	    log.exception(e);
	    String message = "ProjectDownload" + e.getMessage();
	    if (debug) log.debug(message);
	    context.put("message", message);
	}	
	
        if (downloadSet.size() > 0)
            context.put ("downloads", downloadList);
	if (debug) log.debug("ProjectDownload:  done");
d136 1
d139 17
a155 2
  
} /* end class ProjectDownload */
@


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
@@
