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


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

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

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

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

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

1.1
date	2001.03.09.19.32.20;	author leonardr;	state Exp;
branches;
next	;


desc
@@


1.6
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@/* ================================================================
 * Copyright (c) 2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (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 CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */

package org.tigris.helm.project;

import javax.servlet.*;
import java.sql.Connection;

import org.apache.velocity.context.Context;
import org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;
import org.apache.commons.util.exception.NestableException;

import org.tigris.helm.security.RedirectException;
import org.tigris.helm.tool.FormCache;

import org.tigris.helm.om.*;
import org.tigris.helm.tool.audit.AuditLog;
import org.tigris.helm.security.*;
import org.tigris.helm.tool.ContextAPI;

/**
 * Lock or unlock a project
 */
public class ProjectLocked extends HelmServlet 
{

    private static final boolean DEBUG = true;
  
    private static final String LOCK_ACTION = "Lock Project";
    private static final String UNLOCK_ACTION = "Unlock Project";


    protected String processRequest(Context context)
      throws NestableException, ACLException, RedirectException 
    {
        
        String templateName = super.processRequest(context);
        
        User loginUser = getLoginUser(context);
        Domain currentDomain = getCurrentDomain(context);
        Project currentProject = getCurrentProject(context);
        
        if (currentProject == null) 
        {
            redirectToError(context, "ProjectLocked: No project specified");
        }
        
        // Determine which button was pushed
        String action = getAction(context);

        try 
        {
            if (action.equals(UNLOCK_ACTION)) 
            {                                  
                if (!currentProject.isLocked())
                {
                    ContextAPI.addError(context, "This project is already unlocked.");
                } 
                else
                {
                    currentProject.setLockedState(loginUser.getACL(), false);
                    ContextAPI.addMessage(context, "Project unlocked.");
                }
            } 
            else if (action.equals(LOCK_ACTION)) 
            {
                if (currentProject.isLocked())
                {
                    ContextAPI.addError(context, "This project is already locked.");
                } 
                else 
                {
                    currentProject.setLockedState(loginUser.getACL(), true);
                    ContextAPI.addMessage(context, "Project locked.");
                }
            }
        } 
        catch (Exception e) 
        {
            Log.error(e.getMessage());
            throw new NestableException(e);
        }
        return templateName;
    }   
} /* end class ProjectLocked */
@


1.5
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d54 2
a55 2
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
d78 1
a78 1
      throws TurbineException, ACLException, RedirectException 
d125 1
a125 1
            throw new TurbineException(e);
@


1.4
log
@Ported servlets to new error-handling mechanism.
@
text
@d57 1
a57 1
import org.joist.security.RedirectException;
@


1.3
log
@Import Helm FormCache (moved in from Joist).
@
text
@d63 1
d101 1
a101 1
                    appendToError(context, "This project is already unlocked.");
d106 1
a106 1
                    appendToMessage(context, "Project unlocked.");
d113 1
a113 1
                    appendToError(context, "This project is already locked.");
d118 1
a118 1
                    appendToMessage(context, "Project locked.");
@


1.2
log
@Ported Helm from WebMacro to Velocity.
@
text
@d58 1
a58 1
import org.joist.util.FormCache;
@


1.1
log
@Renamed ProjectEnabled to ProjectLocked.
@
text
@d52 1
a52 1
import org.webmacro.servlet.*;
d54 2
d76 2
a77 2
    protected String processRequest(Connection conn, WebContext context)
      throws HandlerException, ACLException, RedirectException 
d80 1
a80 1
        String templateName = super.processRequest(conn, context);
d124 1
a124 1
            throw new HandlerException(e.getMessage());
@

