head	1.8;
access;
symbols
	TIGRIS_0_9_2_4:1.3.2.1
	TIGRIS_0_9_2_3:1.3
	HELM_PEER_PORT_BRANCH:1.7.0.2
	TURBINE_PEER:1.7
	TIGRIS_0_9_2_1:1.7
	TIGRIS_0_9_2:1.3.0.2
	TIGRIS_0_9_0:1.1.1.1.0.4
	TIGRIS_0_8_4:1.1.1.1.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.8
date	2001.02.21.03.47.14;	author edk;	state dead;
branches;
next	1.7;

1.7
date	2001.01.26.18.29.04;	author edk;	state Exp;
branches
	1.7.2.1;
next	1.6;

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

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

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

1.3
date	2001.01.17.18.35.07;	author elicia;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	2000.12.30.05.01.29;	author elicia;	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.3.2.1
date	2001.02.01.18.49.24;	author jrobbins;	state Exp;
branches;
next	;

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


desc
@@


1.8
log
@renamed to ProjectDocumentsList
@
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.sql.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

import org.joist.*;
import org.joist.util.*;
import org.joist.session.*;
import org.joist.security.RedirectURLException;

import org.tigris.helm.tool.MDACookie;
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.domain.User;
import org.tigris.helm.project.Document;
import org.joist.security.RedirectException;


public class ProjectDocuments extends org.tigris.helm.security.HelmServlet
{
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.7 2001/01/26 18:29:04 edk Exp $";
    private static Log log = new Log("ProjectDocuments", "Doc");
    private static boolean debug = true;

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

    /**
     * The database key of the document
     */
    private static final String DOCUMENT_ID = "dcID";


  protected String processRequest (Connection conn, WebContext ctx)
    throws HandlerException, RedirectException
  {
    String templateName = super.processRequest (conn, ctx);
    HttpServletRequest req = ctx.getRequest();
    String action = getAction(ctx);
    Project project = getCurrentProject(ctx);
    User user = getLoginUser(ctx);

    if (action.equals(DO_DOWNLOAD))
    {
       try
       {
           // Authorize the download and redirect to the file server.
           String dcID = req.getParameter(DOCUMENT_ID);
           if (debug) log.info("dcID=" + dcID);
           Document dc = new Document(conn, dMgr, dcID);
           authDownload(project, user, dc.isPublic(), req, ctx.getResponse());
           String dcURL =
		    req.getScheme()
		    + "://"
		    + myProperties.getProperty("fileServer")
		    + ((req.getServerPort() == 80 || req.getServerPort() == 443)
		       ? ""
		       : ":" + req.getServerPort())
		    + "/files/documents/"
		    + project.getID()
		    + '/'
		    + dc.getSuggestedBy().getID()
		    + '/'
		    + dc.getFilename();
           redirectToURL(ctx, dcURL);
        } 
        catch (RedirectURLException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        }
   }

    return templateName;
  }

  /**
   * Cookies the user with a ticket that authorizes download of a specific
   * file.
   */
  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());
        }
    }
} /* end class ProjectDocuments */
@


1.7
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.4 2001/01/23 02:24:35 elicia Exp $";
@


1.7.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.7 2001/01/26 18:29:04 edk Exp $";
@


1.6
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
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.5 2001/01/26 02:01:31 elicia Exp $";
d104 1
a104 1
           Document dc = new Document(dMgr, dcID);
@


1.5
log
@no longer passing connection
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.4 2001/01/23 02:24:35 elicia Exp $";
@


1.4
log
@added authorization for downloads
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.3 2001/01/17 18:35:07 elicia Exp $";
d104 1
a104 1
           Document dc = new Document(conn, dMgr, dcID);
@


1.3
log
@added download action
@
text
@d62 1
d64 1
d66 1
d73 1
a73 1
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.2 2000/12/30 05:01:29 elicia Exp $";
a93 1
     log.info("documents action= " + action);
d95 1
d98 9
a106 10
            {
             try
             {
                // Authorize the download and redirect to the file server.
                String dcID = req.getParameter(DOCUMENT_ID);
                if (debug) log.info("dcID=" + dcID);
                Document dc = new Document(conn, dMgr, dcID);
                //TODO: auth download
                //authDownload(project, user, dl, req, ctx.getResponse());
                String dcURL =
d113 1
a113 1
		    + "/files/"
d118 7
a124 4
		    + dc.getLocation();
                log.info("dcURL=" + dcURL);
                redirectToURL(ctx, dcURL);
            }
d130 2
a131 1
        }
d135 19
@


1.3.2.1
log
@moved changed from HEAD for ProjectDocuments and ProjectDownloads
@
text
@a61 1
import org.joist.security.RedirectURLException;
a62 1
import org.tigris.helm.tool.MDACookie;
a63 1
import org.tigris.helm.domain.User;
d70 1
a70 1
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.7 2001/01/26 18:29:04 edk Exp $";
d91 1
a92 1
    User user = getLoginUser(ctx);
d95 10
a104 9
    {
       try
       {
           // Authorize the download and redirect to the file server.
           String dcID = req.getParameter(DOCUMENT_ID);
           if (debug) log.info("dcID=" + dcID);
           Document dc = new Document(conn, dMgr, dcID);
           authDownload(project, user, dc.isPublic(), req, ctx.getResponse());
           String dcURL =
d111 1
a111 1
		    + "/files/documents/"
d116 4
a119 7
		    + dc.getFilename();
           redirectToURL(ctx, dcURL);
        } 
        catch (RedirectURLException e)
        {
            throw e;
        }
d125 1
a125 2
   }

a128 19
  /**
   * Cookies the user with a ticket that authorizes download of a specific
   * file.
   */
  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.2
log
@cleanup
@
text
@d53 2
d64 1
d70 2
a71 2
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.1.1.1 2000/11/12 21:16:02 dlr Exp $";
    private static Log log = new Log("ProjectDocuments", "Tigris StartPage");
d74 9
d84 2
a85 4
  /**
   * Display servlet only--no logic.
   */
  protected String processRequest (Connection connection, WebContext context)
d88 38
a125 1
    String templateName = super.processRequest (connection, context);
@


1.1
log
@Initial revision
@
text
@a52 2
import javax.servlet.*;
import javax.servlet.http.*;
d54 1
a54 1
import org.webmacro.util.*;
a55 3
import org.webmacro.engine.*;
import org.webmacro.broker.*;
import org.webmacro.resource.*;
a62 1
import org.joist.database.DataManager;
d65 5
d72 9
a80 4
public class ProjectDocuments extends org.tigris.helm.security.HelmServlet {
    public static final  String versionID = "$Id: ProjectDocuments.java,v 1.4 2000/11/06 06:15:31 edk Exp $";
    private static Log log = new Log("ProjectDocuments", "Tigris StartPage");
    private static boolean debug = true;
a81 47
    /**
     *  Display and process the login screen.
     */
    protected String
	processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
    {
	if (debug) log.debug("ProjectDocuments: started!");

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

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

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

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

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

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

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

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

        return templateName;
    }
  
@


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