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


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

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

1.9
date	2001.07.18.10.15.15;	author dlr;	state Exp;
branches;
next	1.8;

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

1.7
date	2001.07.17.16.00.43;	author leonardr;	state Exp;
branches;
next	1.6;

1.6
date	2001.07.02.18.56.42;	author leonardr;	state Exp;
branches;
next	1.5;

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

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

1.3
date	2001.01.26.18.29.08;	author edk;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	2001.01.26.05.24.07;	author edk;	state dead;
branches;
next	1.1;

1.1
date	2000.12.07.18.26.08;	author leonardr;	state Exp;
branches
	1.1.1.1;
next	;

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

1.3.2.1
date	2001.01.28.01.02.19;	author dlr;	state dead;
branches;
next	1.3.2.2;

1.3.2.2
date	2001.02.06.01.52.15;	author leonardr;	state Exp;
branches;
next	1.3.2.3;

1.3.2.3
date	2001.02.15.20.50.43;	author leonardr;	state Exp;
branches;
next	;


desc
@@


1.11
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@/* ================================================================
 * Copyright (c) 2000-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.security;

import java.util.*;
import javax.servlet.http.*;

import org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;

import org.apache.velocity.context.Context;

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

/**
 * Create a new resource.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: ResourceAdd.java,v 1.10 2001/07/19 19:54:05 dlr Exp $
 */
public class ResourceAdd extends org.tigris.helm.security.HelmServlet 
{
    /**
     * Action which triggers resource creation.
     */
    private static String CREATE_RESOURCE_ACTION="Create Resource";

    /**
     * Field containing the ID of the project with which the new
     * resource is to be associated. 
     */
    private static String ASSOCIATED_PROJECT_FIELD="associatedProject";

    /**
     * Field containing the description of the new resource.
     */
    private static String DESCRIPTION_FIELD="description";

    /**
     * Field containing the pattern of the new resource.
     */
    private static String PATTERN_FIELD="pattern";

    /**
     *  Validate data and create a new resource.
     */
    protected String processRequest(Context context)
        throws NestableException, RedirectException
    {
        String templateName = super.processRequest(context);
        try 
        {
            String action = getAction(context);

            Project currentProject = getCurrentProject(context);

            String associatedProjectID = ContextAPI.processField
                (context,  ASSOCIATED_PROJECT_FIELD, currentProject.getID());
            Project associatedProject = ProjectPeer.getInstance
                (associatedProjectID);
            String pattern = ContextAPI.processRequiredField
                (context, PATTERN_FIELD, "Resource pattern");
            String description = ContextAPI.processRequiredField
                (context, DESCRIPTION_FIELD, "Description");
            
            if (CREATE_RESOURCE_ACTION.equals(action))
            {
                AccessControlList acl = getLoginUser(context).getACL();
                
                if (ContextAPI.isValidUserInput(context))
                {
                    Resource g = Resource.add
                        (acl, associatedProject, pattern, description);
                    redirectToURL
                        (context, currentProject.getProjectPageURL
                         ("ResourceList"));
                } 
            }
        } 
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e) 
        {
            Log.error("Exception in ResourceAdd: ", e);
            throw new NestableException(e);
        }

        return templateName;  
    }
}
@


1.10
log
@Removed Joist references.
@
text
@d54 1
a54 1
import org.apache.turbine.util.TurbineException;
d67 1
a67 1
 * @@version $Id: ResourceAdd.java,v 1.9 2001/07/18 10:15:15 dlr Exp $
d96 1
a96 1
        throws TurbineException, RedirectException
d135 1
a135 1
            throw new TurbineException(e);
@


1.9
log
@clean up
@
text
@a57 3
import org.joist.*;
import org.joist.util.*;

d67 1
a67 1
 * @@version $Id: ResourceAdd.java,v 1.8 2001/07/18 10:05:15 dlr Exp $
@


1.8
log
@Ported Joist Redirect*Exception to Helm.
@
text
@a50 2
import java.sql.*;
import javax.servlet.*;
d55 1
a60 4
import com.workingdogs.village.*;

import org.tigris.helm.security.RedirectException;

d70 1
a70 1
 * @@version $Id: ResourceAdd.java,v 1.7 2001/07/17 16:00:43 leonardr Exp $
a73 2
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.7 2001/07/17 16:00:43 leonardr Exp $";

d99 1
a99 1
	throws TurbineException, RedirectException
d101 1
a101 1
	String templateName = super.processRequest(context);
a142 1

a143 2


@


1.7
log
@Ported servlets over to the new error handling system.
@
text
@d64 1
a64 1
import org.joist.security.RedirectException;
d75 1
a75 1
 * @@version $Id: ResourceAdd.java,v 1.6 2001/07/02 18:56:42 leonardr Exp $
d79 1
a79 1
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.6 2001/07/02 18:56:42 leonardr Exp $";
@


1.6
log
@Implemented project-scoped roles.
@
text
@d69 1
d75 1
a75 1
 * @@version $Id: ResourceAdd.java,v 1.5 2001/05/23 01:50:20 dlr Exp $
d79 1
a79 1
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.5 2001/05/23 01:50:20 dlr Exp $";
a111 9
            String errorMessage = (String)context.get("Error");
            if (errorMessage != null)
            {
                action = null;
                appendToMessage(context, errorMessage);
            }

            ArrayList missingFields = new ArrayList();
            ArrayList validationErrors = new ArrayList();
d115 1
a115 1
            String associatedProjectID = processField
d119 4
a122 4
            String pattern = processField(context, PATTERN_FIELD,
                                          "Resource pattern", missingFields);
            String description = processField(context, DESCRIPTION_FIELD,
                                              "Description", missingFields);
d127 2
a128 2

                if (isValidUserInput(missingFields, validationErrors))
a135 6
                else 
                {
                    // Report missing fields and validation errors.
                    reportInvalidUserInput(context, missingFields, 
                                           validationErrors);
                }
@


1.5
log
@Ported Helm from WebMacro to Velocity.
@
text
@a56 1
import org.apache.turbine.util.TurbineException;
a60 1
import org.tigris.helm.tool.SessionManager;
a64 1
import org.joist.database.*;
d74 1
a74 1
 * @@version $Id: ResourceAdd.java,v 1.4 2001/02/21 01:08:25 dlr Exp $
d78 1
a78 1
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.4 2001/02/21 01:08:25 dlr Exp $";
d80 3
d84 10
d95 4
d100 1
a100 1
    
a110 3
            // If we are returning to this page as a result of an
            // error, we just want to refresh the display, without
            // doing any further action.
a117 1
            // Gather any user input, adding it to the context as well.
d120 7
d132 1
a132 1
            if (action != null && action.equals(CREATE_RESOURCE_ACTION))
a133 1
                Domain currentDomain = getCurrentDomain(context);
d139 1
a139 1
                        (acl, currentDomain, pattern, description);
d141 1
a141 1
                        (context, currentDomain.getDomainHomeServletURL
d143 3
a145 1
                } else {
d151 7
a157 1
        } catch (Exception e) {
d165 1
a165 1
} /* end class ProjectGroupAdd */
@


1.4
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d56 3
a58 1
import org.webmacro.servlet.*;
d62 1
a62 1
import org.joist.session.*;
d77 1
a77 1
 * @@version $Id: ResourceAdd.java,v 1.3.2.3 2001/02/15 20:50:43 leonardr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.3.2.3 2001/02/15 20:50:43 leonardr Exp $";
d90 2
a91 2
    protected String processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
d93 1
a93 1
	String templateName = super.processRequest(connection, context);
d135 1
a135 1
            throw new HandlerException(e.getMessage());
@


1.3
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d2 1
a2 1
 * Copyright (c) 2000 CollabNet.  All rights reserved.
d55 1
a55 1
import org.webmacro.util.*;
d68 1
a68 2
import org.tigris.helm.domain.Domain;
import org.tigris.helm.domain.Resource;
d75 1
a75 1
 * @@version $Id: ResourceAdd.java,v 1.1 2000/12/07 18:26:08 leonardr Exp $
d79 1
a79 4
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.1 2000/12/07 18:26:08 leonardr Exp $";

    private static Log log = new Log("ResAdd", "Resource Add Servlet");
    private static boolean debug = true;
a104 1
            log.info("Action: " + action);
a114 1
                log.info("I'm going to create!");
d120 2
a121 3
                    Resource g = new Resource
                        (connection, dMgr, acl, currentDomain,
                         pattern, description);
a125 1
                    log.info("Some bad data.");
d131 2
a132 8
        } catch (DataSetException e) {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        } catch (SQLException e) {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        } catch (JoistDatabaseException e) {
            log.exception(e);
@


1.3.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d76 1
a76 1
 * @@version $Id: ResourceAdd.java,v 1.3 2001/01/26 18:29:08 edk Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.3 2001/01/26 18:29:08 edk Exp $";
@


1.3.2.2
log
@Ported over resource manipulation servlets.
@
text
@d55 1
a55 1
import org.apache.turbine.util.Log;
d68 2
a69 1
import org.tigris.helm.om.*;
d82 3
d109 1
d120 1
d126 3
a128 2
                    Resource g = Resource.add
                        (acl, currentDomain, pattern, description);
d133 1
d139 8
a146 2
        } catch (Exception e) {
            Log.error("Exception in ResourceAdd: ", e);
@


1.3.2.3
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d75 1
a75 1
 * @@version $Id: ResourceAdd.java,v 1.3.2.2 2001/02/06 01:52:15 leonardr Exp $
d79 1
a79 1
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.3.2.2 2001/02/06 01:52:15 leonardr Exp $";
@


1.2
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.1
log
@New servlet - Resource Add
@
text
@d76 1
a76 1
 * @@version $Id: ResourceAdd.java,v 1.1 2000/11/29 20:58:59 leonardr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.1 2000/11/29 20:58:59 leonardr Exp $";
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d55 1
a55 1
import org.apache.turbine.util.Log;
d68 2
a69 1
import org.tigris.helm.om.*;
d76 1
a76 1
 * @@version $Id: ResourceAdd.java,v 1.3.2.3 2001/02/15 20:50:43 leonardr Exp $
d80 4
a83 1
    public static final  String versionID = "$Id: ResourceAdd.java,v 1.3.2.3 2001/02/15 20:50:43 leonardr Exp $";
d109 1
d120 1
d126 3
a128 2
                    Resource g = Resource.add
                        (acl, currentDomain, pattern, description);
d133 1
d139 8
a146 2
        } catch (Exception e) {
            Log.error("Exception in ResourceAdd: ", e);
@


