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.24.00.02.28;	author leonardr;	state Exp;
branches;
next	1.9;

1.9
date	2001.07.18.10.15.47;	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.11.19.46.30;	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 org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;

import org.apache.velocity.context.Context;

import org.tigris.helm.security.RedirectException;

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

/**
 * Change a resource.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: ResourceEdit.java,v 1.10 2001/07/24 00:02:28 leonardr Exp $
 */
public class ResourceEdit extends org.tigris.helm.security.HelmServlet 
{
    /**
     * Action which triggers resource edit.
     */
    private static String SUBMIT_CHANGES_ACTION="Submit Changes";

    /**
     * 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";
    
    /**
     *  Change a resource's pattern or descrpition.
     */
    protected String processRequest(Context context)
        throws NestableException, RedirectException
    {
        String templateName = super.processRequest(context);
        try 
        {
            String action = getAction(context);

            // Gather any user input.
            String pattern = ContextAPI.processField
                (context, PATTERN_FIELD, "Resource pattern");
            String description = ContextAPI.processField
                (context, DESCRIPTION_FIELD, "Description");
            
            if (SUBMIT_CHANGES_ACTION.equals(action))
            {
                Domain currentDomain = getCurrentDomain(context);
                AccessControlList acl = getLoginUser(context).getACL();
                
                if (ContextAPI.isValidUserInput(context))
                {
                    Resource currentResource = getCurrentResource(context);
                    currentResource.update(acl, pattern, description);
                    redirectToURL
                        (context, currentDomain.getDomainHomeServletURL
                         ("ResourceList"));
                } 
            }
        } 
        catch (RedirectException e) 
        {
            throw e;
        }
        catch (Exception e) 
        {
            Log.error("Exception in ResourceEdit: ", e);
            throw new NestableException(e);
        }

        return templateName;  
    }
}
@


1.10
log
@The final pieces of the error handling revolution.
@
text
@d53 1
a53 1
import org.apache.turbine.util.TurbineException;
d67 1
a67 1
 * @@version $Id: ResourceEdit.java,v 1.9 2001/07/18 10:15:47 dlr Exp $
d96 1
a96 1
        throws TurbineException, RedirectException
d131 1
a131 1
            throw new TurbineException(e);
@


1.9
log
@clean up
@
text
@d67 1
a67 1
 * @@version $Id: ResourceEdit.java,v 1.8 2001/07/18 10:05:15 dlr Exp $
a101 9
            // 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.
            String errorMessage = (String)context.get("Error");
            if (errorMessage != null)
            {
                action = null;
                appendToMessage(context, errorMessage);
            }
@


1.8
log
@Ported Joist Redirect*Exception to Helm.
@
text
@a50 1
import java.sql.*;
d54 1
d67 1
a67 1
 * @@version $Id: ResourceEdit.java,v 1.7 2001/07/17 16:00:43 leonardr Exp $
a70 2
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.7 2001/07/17 16:00:43 leonardr Exp $";

d96 1
a96 1
	throws TurbineException, RedirectException
d98 1
a98 1
	String templateName = super.processRequest(context);
a145 2


@


1.7
log
@Ported servlets over to the new error handling system.
@
text
@d57 1
a57 1
import org.joist.security.RedirectException;
d67 1
a67 1
 * @@version $Id: ResourceEdit.java,v 1.6 2001/07/02 18:56:42 leonardr Exp $
d71 1
a71 1
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.6 2001/07/02 18:56:42 leonardr Exp $";
@


1.6
log
@Implemented project-scoped roles.
@
text
@d61 1
d67 1
a67 1
 * @@version $Id: ResourceEdit.java,v 1.5 2001/05/23 01:50:20 dlr Exp $
d71 1
a71 1
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.5 2001/05/23 01:50:20 dlr Exp $";
d115 4
a118 6
            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();
            String pattern = processField(context, PATTERN_FIELD,
                                          "Resource pattern", missingFields);
            String description = processField(context, DESCRIPTION_FIELD,
                                              "Description", missingFields);
d120 1
a120 1
            if (action != null && action.equals(SUBMIT_CHANGES_ACTION))
d125 1
a125 1
                if (isValidUserInput(missingFields, validationErrors))
a132 6
                else 
                {
                    // Report missing fields and validation errors.
                    reportInvalidUserInput(context, missingFields, 
                                           validationErrors);
                }
@


1.5
log
@Ported Helm from WebMacro to Velocity.
@
text
@a54 1
import org.apache.turbine.util.TurbineException;
d63 1
a63 1
 * Create a new resource.
d66 1
a66 1
 * @@version $Id: ResourceEdit.java,v 1.4 2001/02/21 01:08:25 dlr Exp $
d70 1
a70 1
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.4 2001/02/21 01:08:25 dlr Exp $";
d72 3
d76 10
d87 4
d125 1
a125 1

d129 1
a129 2
                    currentResource.update(acl, currentDomain, 
                                           pattern, description);
d133 3
a135 1
                } else {
d141 7
a147 1
        } catch (Exception e) {
d154 1
a154 2

} /* end class ResourceEdit */
@


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
@d54 3
a56 1
import org.webmacro.servlet.*;
d67 1
a67 1
 * @@version $Id: ResourceEdit.java,v 1.3.2.3 2001/02/15 20:50:43 leonardr Exp $
d71 1
a71 1
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.3.2.3 2001/02/15 20:50:43 leonardr Exp $";
d80 2
a81 2
    protected String processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
d83 1
a83 1
	String templateName = super.processRequest(connection, context);
d126 1
a126 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.
a51 2
import javax.servlet.*;
import javax.servlet.http.*;
d53 1
a53 1
import org.webmacro.util.*;
a55 6
import org.joist.*;
import org.joist.util.*;
import org.joist.session.*;

import com.workingdogs.village.*;

a56 1
import org.joist.database.*;
d58 1
a58 3
import org.tigris.helm.*;
import org.tigris.helm.domain.Domain;
import org.tigris.helm.domain.Resource;
d65 1
a65 1
 * @@version $Id: ResourceEdit.java,v 1.1 2000/12/11 19:46:30 leonardr Exp $
d69 1
a69 4
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.1 2000/12/11 19:46:30 leonardr Exp $";

    private static Log log = new Log("ResEdit", "Resource Edit Servlet");
    private static boolean debug = true;
d96 2
a97 2
            ArrayList missingFields = new ArrayList();
            ArrayList validationErrors = new ArrayList();
d122 2
a123 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: ResourceEdit.java,v 1.3 2001/01/26 18:29:08 edk Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.3 2001/01/26 18:29:08 edk Exp $";
@


1.3.2.2
log
@Ported over resource manipulation servlets.
@
text
@d52 2
d55 1
a55 1
import org.apache.turbine.util.Log;
d58 6
d65 1
d67 3
a69 1
import org.tigris.helm.om.*;
d82 3
d110 2
a111 2
            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();
d136 8
a143 2
        } catch (Exception e) {
            Log.error("Exception in ResourceEdit: ", e);
@


1.3.2.3
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d65 1
a65 1
 * @@version $Id: ResourceEdit.java,v 1.3.2.2 2001/02/06 01:52:15 leonardr Exp $
d69 1
a69 1
    public static final  String versionID = "$Id: ResourceEdit.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: ResourceEdit
@
text
@d76 1
a76 1
 * @@version $Id: ResourceEdit.java,v 1.1 2000/12/07 18:26:08 leonardr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.1 2000/12/07 18:26:08 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.
d52 2
d55 1
a55 1
import org.apache.turbine.util.Log;
d58 6
d65 1
d67 3
a69 1
import org.tigris.helm.om.*;
d76 1
a76 1
 * @@version $Id: ResourceEdit.java,v 1.3.2.3 2001/02/15 20:50:43 leonardr Exp $
d80 4
a83 1
    public static final  String versionID = "$Id: ResourceEdit.java,v 1.3.2.3 2001/02/15 20:50:43 leonardr Exp $";
d110 2
a111 2
            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();
d136 8
a143 2
        } catch (Exception e) {
            Log.error("Exception in ResourceEdit: ", e);
@


