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


1.12
date	2001.07.16.02.23.42;	author jrobbins;	state dead;
branches;
next	1.11;

1.11
date	2001.07.13.19.47.34;	author leonardr;	state Exp;
branches;
next	1.10;

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

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

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

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

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

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

1.4
date	2001.01.26.18.29.05;	author edk;	state Exp;
branches
	1.4.2.1;
next	1.3;

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

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

1.1
date	2001.01.17.00.02.55;	author elicia;	state Exp;
branches
	1.1.1.1
	1.1.2.1;
next	;

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

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

1.4.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	1.4.2.2;

1.4.2.2
date	2001.02.16.23.07.29;	author elicia;	state Exp;
branches;
next	;


desc
@@


1.12
log
@factoring project documents out to project nidaba.tigris.org
@
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.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.velocity.context.Context;

import com.workingdogs.village.*;

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

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

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

public class ProjectSectionApproval extends HelmServlet
{
    private static final boolean DEBUG = true;
    private static String DISAPPROVE_LIST="disapproveList";

    /**
     * Process requests for section approval.
     */
    protected String processRequest(Context ctx)
        throws TurbineException, RedirectException
    {
        if (DEBUG) Log.info("ProjectSectionApproval: started!");

        String templateName = super.processRequest(ctx);
    
        String action = (String)ctx.get("action");
        if (DEBUG) Log.info("ProjectSectionApproval: action=" + action );

        try
        {
            boolean validAction = false;
            ArrayList disapproveList = new ArrayList();

            if (action.equals("none"))
            {
                validAction = true;
            }

            if (action.equals("Perform Actions"))
            {
                validAction = true;
                User loginUser = getLoginUser(ctx);
                Enumeration paramNames =
                    getRequest(ctx).getParameterNames();
                String paramName;
                while (paramNames.hasMoreElements())
                {
                    paramName = (String) paramNames.nextElement();
                    if (DEBUG) Log.debug("SctnApproval: param name=" +
                                         paramName);
                    if (paramName.startsWith("action_"))
                    {
                        String desiredAction = getParameter(ctx, paramName);
                        if (DEBUG) 
                            Log.info("SctnApproval: desired action=" +
                                     desiredAction);
                        String sectionID = paramName.substring(7);
                        if (DEBUG) Log.info("sectionID=" + sectionID);

                        AccessControlList acl = loginUser.getACL();
                        ProjectSection section = 
                            (ProjectSection)ProjectSectionPeer
                            .getInstance(sectionID);

                        if (desiredAction.equals("Approve"))
                        {
                            section.approve(acl);
                        }
                        if (desiredAction.equals("Disapprove"))
                        {
                            disapproveList.add((ProjectSection)
                                               ProjectSectionPeer
                                               .getInstance(sectionID));
                        }
                    }
                }
                String url;
                Project currentProject = getCurrentProject(ctx);
                if (disapproveList.isEmpty())
                {
                    url = currentProject.getProjectPageURL
                        ("ProjectDocumentList").toString();
                }
                else {
                    HttpSession session = getSessionManager(ctx).getSession();
                    session.putValue(DISAPPROVE_LIST, disapproveList); 
                    url = currentProject.getProjectPageURL
                        ("ProjectSectionApprovalReason").toString();
                }
                redirectToURL(ctx, url);
            } 

            if (!validAction) redirectToUnauthorized();
        } 
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            Log.error(e);
            String message = "ProjectSectionApproval: " + e.getMessage();
            if (DEBUG) Log.debug(message);
            ctx.put("message", message);
        }

        return templateName;
    }
}
@


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


1.10
log
@Ported Helm from WebMacro to Velocity.
@
text
@a69 1
import org.tigris.helm.om.*;
a71 2
//import org.tigris.helm.project.Section;
//import org.tigris.helm.domain.User;
@


1.9
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d55 1
a55 1
import org.webmacro.servlet.*;
d60 2
d65 1
a65 1
import org.joist.session.*;
d84 2
a85 2
    protected String processRequest (Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
d89 1
a89 1
        String templateName = super.processRequest(conn, ctx);
d109 1
a109 1
                    ctx.getRequest().getParameterNames();
d118 1
a118 1
                        String desiredAction = ctx.getForm(paramName);
@


1.8
log
@Upper cased debugging flag.
@
text
@d67 2
a68 2
import org.tigris.helm.om.*; 
import org.tigris.helm.om.peer.*;
@


1.7
log
@Corrected excessive bs formatting.  PLEASE take more care with the
formatting.
@
text
@d76 1
a76 1
    private static boolean debug = true;
@


1.6
log
@added extra step to allow disapproving admin to provide reason for disapproval
@
text
@d74 2
a75 2
public class ProjectSectionApproval extends HelmServlet {
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.5 2001/02/21 01:08:23 dlr Exp $";
d83 1
a83 1
	    throws HandlerException, RedirectException
d85 1
a85 1
	    if (debug) Log.info("ProjectSectionApproval: started!");
d87 4
a90 4
	    String templateName = super.processRequest(conn, ctx);
	
	    String action = (String)ctx.get("action");
	    if (debug) Log.info("ProjectSectionApproval: action=" + action );
d92 2
a93 2
	    try
	    {
d103 2
a104 2
	        {
	        	validAction = true;
d106 1
a106 1
		        Enumeration paramNames =
d108 14
a121 12
		        String paramName;
		        while (paramNames.hasMoreElements())
		        {
		            paramName = (String) paramNames.nextElement();
		            if (debug) Log.info("SctnApproval: param name=" + paramName);
		            if (paramName.startsWith("action_"))
		            {
			            String desiredAction = ctx.getForm(paramName);
			            if (debug) 
                           Log.info("SctnApproval: desired action=" + desiredAction);
			            String sectionID = paramName.substring(7);
                        if (debug) Log.info("sectionID=" + sectionID);
d128 6
a133 6
			            if (desiredAction.equals("Approve"))
			            {
			               section.approve(acl);
			            }
			            if (desiredAction.equals("Disapprove"))
			            {
d136 4
a139 4
                                              .getInstance(sectionID));
			            }
		            }
		        }
d144 4
a147 2
                    url = currentProject.getProjectPageURL("ProjectDocumentList").toString();
                } else {
d150 2
a151 1
                    url = currentProject.getProjectPageURL("ProjectSectionApprovalReason").toString();
d153 2
a154 2
		        redirectToURL(ctx, url);
	        } 
d157 1
a157 1
	    } 
d160 1
a160 1
           throw e;
d164 4
a167 4
	       Log.error(e);
	       String message = "ProjectSectionApproval: " + e.getMessage();
	       if (debug) Log.debug(message);
	       ctx.put("message", message);
a169 2
        if (debug) Log.info("ProjectSectionApproval:  done");

d171 2
a172 3
   }
  
} /* end class ProjectSectionApproval */
@


1.5
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d75 1
a75 1
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.4.2.2 2001/02/16 23:07:29 elicia Exp $";
d77 1
d95 1
d123 2
a124 2
                            //new Section(conn, dMgr, sectionID);
                            (ProjectSection)ProjectSectionPeer.getInstance(sectionID);
d132 3
a134 1
                           section.disapprove(acl);
d138 1
d140 8
a147 1
                String url = currentProject.getProjectPageURL("ProjectDocumentList").toString();
@


1.4
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@a54 1
import org.webmacro.util.*;
d59 2
d67 2
d71 2
a72 2
import org.tigris.helm.project.Section;
import org.tigris.helm.domain.User;
d75 1
a75 2
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.1 2001/01/17 00:02:55 elicia Exp $";
    private static Log log = new Log("ProjectSectionApproval", "SctnApprvl");
d84 1
a84 1
	    if (debug) log.info("ProjectSectionApproval: started!");
d89 1
a89 1
	    if (debug) log.info("ProjectSectionApproval: action=" + action );
d110 1
a110 1
		            if (debug) log.info("SctnApproval: param name=" + paramName);
d115 1
a115 1
                           log.info("SctnApproval: desired action=" + desiredAction);
d117 1
a117 1
                        if (debug) log.info("sectionID=" + sectionID);
d119 4
a122 3
                        AccessControlList acl = getACL(ctx, conn);
                        Section section = 
                            new Section(conn, dMgr, sectionID);
d135 1
a135 1
                String url = currentProject.getProjectPageURL("ProjectDocuments").toString();
d147 1
a147 1
	       log.exception(e);
d149 1
a149 1
	       if (debug) log.debug(message);
d153 1
a153 1
        if (debug) log.info("ProjectSectionApproval:  done");
@


1.4.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d72 1
a72 1
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.4 2001/01/26 18:29:05 edk Exp $";
@


1.4.2.2
log
@ported to turbine
@
text
@d55 1
a59 2
import org.apache.turbine.util.Log;

a65 2
import org.tigris.helm.om.*; 
import org.tigris.helm.om.peer.*;
d68 2
a69 2
//import org.tigris.helm.project.Section;
//import org.tigris.helm.domain.User;
d73 1
d82 1
a82 1
	    if (debug) Log.info("ProjectSectionApproval: started!");
d87 1
a87 1
	    if (debug) Log.info("ProjectSectionApproval: action=" + action );
d108 1
a108 1
		            if (debug) Log.info("SctnApproval: param name=" + paramName);
d113 1
a113 1
                           Log.info("SctnApproval: desired action=" + desiredAction);
d115 1
a115 1
                        if (debug) Log.info("sectionID=" + sectionID);
d117 3
a119 4
                        AccessControlList acl = loginUser.getACL();
                        ProjectSection section = 
                            //new Section(conn, dMgr, sectionID);
                            (ProjectSection)ProjectSectionPeer.getInstance(sectionID);
d132 1
a132 1
                String url = currentProject.getProjectPageURL("ProjectDocumentList").toString();
d144 1
a144 1
	       Log.error(e);
d146 1
a146 1
	       if (debug) Log.debug(message);
d150 1
a150 1
        if (debug) Log.info("ProjectSectionApproval:  done");
@


1.3
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
@d72 1
a72 1
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.2 2001/01/26 02:01:31 elicia Exp $";
d119 1
a119 1
                            new Section(dMgr, sectionID);
@


1.2
log
@no longer passing connection
@
text
@d72 1
a72 1
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.1 2001/01/17 00:02:55 elicia Exp $";
@


1.1
log
@initial revision
@
text
@d72 1
a72 1
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.2 2001/01/16 23:06:37 elicia Exp $";
d119 1
a119 1
                            new Section(conn, dMgr, sectionID);
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d55 1
a59 2
import org.apache.turbine.util.Log;

a65 2
import org.tigris.helm.om.*; 
import org.tigris.helm.om.peer.*;
d68 2
a69 2
//import org.tigris.helm.project.Section;
//import org.tigris.helm.domain.User;
d72 2
a73 1
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.4.2.2 2001/02/16 23:07:29 elicia Exp $";
d82 1
a82 1
	    if (debug) Log.info("ProjectSectionApproval: started!");
d87 1
a87 1
	    if (debug) Log.info("ProjectSectionApproval: action=" + action );
d108 1
a108 1
		            if (debug) Log.info("SctnApproval: param name=" + paramName);
d113 1
a113 1
                           Log.info("SctnApproval: desired action=" + desiredAction);
d115 1
a115 1
                        if (debug) Log.info("sectionID=" + sectionID);
d117 3
a119 4
                        AccessControlList acl = loginUser.getACL();
                        ProjectSection section = 
                            //new Section(conn, dMgr, sectionID);
                            (ProjectSection)ProjectSectionPeer.getInstance(sectionID);
d132 1
a132 1
                String url = currentProject.getProjectPageURL("ProjectDocumentList").toString();
d144 1
a144 1
	       Log.error(e);
d146 1
a146 1
	       if (debug) Log.debug(message);
d150 1
a150 1
        if (debug) Log.info("ProjectSectionApproval:  done");
@


1.1.2.1
log
@moved changed from HEAD for ProjectDocuments and ProjectDownloads
@
text
@d72 1
a72 1
    public static final  String versionID = "$Id: ProjectSectionApproval.java,v 1.4 2001/01/26 18:29:05 edk Exp $";
@


