head	1.5;
access;
symbols
	TIGRIS_1_1_0RC2:1.2
	TIGRIS_1_1_0RC1:1.2
	TIGRIS_1_1:1.2.0.4
	TIGRIS_1_0_8:1.2
	TIGRIS_1_0_8RC3:1.2
	TIGRIS_1_0_8RC2:1.2
	TIGRIS_1_0_8RC1:1.2
	TIGRIS_1_0_7:1.2
	TIGRIS_1_0_7RC3:1.2
	TIGRIS_1_0_7RC2:1.2
	TIGRIS_1_0_7RC1:1.2
	TIGRIS_1_0_6:1.2
	TIGRIS_1_0_6RC5:1.2
	TIGRIS_1_0_6RC4:1.2
	TIGRIS_1_0_6RC3:1.2
	TIGRIS_1_0_6RC2:1.2
	TIGRIS_1_0_6RC1:1.2
	TIGRIS_1_0_5:1.2
	TIGRIS_1_0_5RC6:1.2
	TIGRIS_1_0_5RC5:1.2
	TIGRIS_1_0_5RC4:1.2
	TIGRIS_1_0_5RC3:1.2
	TIGRIS_1_0_5RC2:1.2
	TIGRIS_1_0_5RC1:1.2
	TIGRIS_1_0_4:1.2
	TIGRIS_1_0_3:1.2
	TIGRIS_1_0_2:1.2
	TIGRIS_1_0_1:1.2
	TIGRIS_1_0:1.2.0.6
	TIGRIS_1_0_0:1.2
	TIGRIS_1_0_0_RC1:1.2.0.2;
locks; strict;
comment	@# @;


1.5
date	2001.07.16.02.23.42;	author jrobbins;	state dead;
branches;
next	1.4;

1.4
date	2001.07.13.19.47.34;	author leonardr;	state Exp;
branches;
next	1.3;

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

1.2
date	2001.03.07.01.53.25;	author lucas;	state Exp;
branches;
next	1.1;

1.1
date	2001.02.27.02.20.28;	author elicia;	state Exp;
branches;
next	;


desc
@@


1.5
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.sql.*;
import java.util.*;
import javax.servlet.http.*;

import org.apache.turbine.util.*;
import org.apache.velocity.context.Context;

import org.joist.security.RedirectException;

import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.om.*;
import org.tigris.helm.om.*;
public class ProjectSectionApprovalReason extends HelmServlet 
{
    private static boolean debug = true;
    private static String ACTION="Disapprove";

    /**
     * Process requests for project section approval.
     */
    protected String processRequest(Context ctx)
	    throws TurbineException, RedirectException
    {
        String templateName = super.processRequest(ctx);
        Project currentProject = getCurrentProject(ctx);

        try
	{
            HttpSession session = getSessionManager(ctx).getSession();
            List disapproveList = (List)session.getValue("disapproveList");
	    ctx.put("disapproveList", disapproveList);

	    String action = (String)ctx.get("action");
	    if (debug) Log.debug("PjctSctAppvlRsn:: action=" + action );
	    
	    boolean validAction = false;
	    if (action.equals("none"))
	    	validAction = true;

            if (action.equals(ACTION))
            {
                validAction = true;
                Enumeration paramNames =
                    getRequest(ctx).getParameterNames();
                String paramName;
                while (paramNames.hasMoreElements())
                {
                    paramName = (String) paramNames.nextElement();
                    if (paramName.startsWith("rationale_"))
                    {
                        String rationale = getParameter(ctx, paramName);
                        String sectionID = paramName.substring(10);

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

                        section.disapprove(acl, rationale);
                    }
                }
                String url = 
                    currentProject.getProjectPageURL("ProjectDocumentList");
                redirectToURL(ctx, url);
	    }
          
	    if (!validAction) redirectToUnauthorized();
	} 
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            Log.error(e);
            String message = "ProjectSctApprovalReason: " + e.getMessage();
            if (debug) Log.debug(message);
            ctx.put("message", message);
        }

        if (debug) Log.debug("ProjectSctApprovalReason:  done");

        return templateName;
    }
  
} /* end class ProjectSectionApprovalReason */
@


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


1.3
log
@Ported Helm from WebMacro to Velocity.
@
text
@d73 2
a74 2
	    String templateName = super.processRequest(ctx);
	    Project currentProject = getCurrentProject(ctx);
d76 1
a76 1
    try
d78 2
a79 2
        HttpSession session = getSessionManager(ctx).getSession();
        List disapproveList = (List)session.getValue("disapproveList");
d89 25
a113 25
        if (action.equals(ACTION))
	    {
		    validAction = true;
		    Enumeration paramNames =
		        getRequest(ctx).getParameterNames();
		    String paramName;
		    while (paramNames.hasMoreElements())
		    {
		        paramName = (String) paramNames.nextElement();
		        if (paramName.startsWith("rationale_"))
		        {
			        String rationale = getParameter(ctx, paramName);
			        String sectionID = paramName.substring(10);

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

		            section.disapprove(acl, rationale);
		        }
		    }
		    String url = 
		        currentProject.getProjectPageURL("ProjectDocumentList").toString();
		        redirectToURL(ctx, url);
d118 11
a128 11
    catch (RedirectException e)
    {
       throw e;
    }
    catch (Exception e)
    {
        Log.error(e);
        String message = "ProjectSctApprovalReason: " + e.getMessage();
        if (debug) Log.debug(message);
        ctx.put("message", message);
    }
d130 1
a130 1
    if (debug) Log.debug("ProjectSctApprovalReason:  done");
d132 2
a133 2
    return templateName;
}
@


1.2
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d54 1
a54 1
import org.webmacro.servlet.*;
d70 2
a71 2
    protected String processRequest (Connection conn, WebContext ctx)
	    throws HandlerException, RedirectException
d73 1
a73 1
	    String templateName = super.processRequest(conn, ctx);
d93 1
a93 1
		        ctx.getRequest().getParameterNames();
d100 1
a100 1
			        String rationale = ctx.getForm(paramName);
@


1.1
log
@added extra step to allow disapproving admin to provide reason for disapproval
@
text
@d61 1
a61 2
import org.tigris.helm.om.peer.*;

@

