head	1.35;
access;
symbols
	TIGRIS_1_1_0RC2:1.23
	TIGRIS_1_1_0RC1:1.23
	TIGRIS_1_1:1.23.0.4
	TIGRIS_1_0_8:1.23
	TIGRIS_1_0_8RC3:1.23
	TIGRIS_1_0_8RC2:1.23
	TIGRIS_1_0_8RC1:1.23
	TIGRIS_1_0_7:1.23
	TIGRIS_1_0_7RC3:1.23
	TIGRIS_1_0_7RC2:1.23
	TIGRIS_1_0_7RC1:1.23
	TIGRIS_1_0_6:1.23
	TIGRIS_1_0_6RC5:1.23
	TIGRIS_1_0_6RC4:1.23
	TIGRIS_1_0_6RC3:1.23
	TIGRIS_1_0_6RC2:1.23
	TIGRIS_1_0_6RC1:1.23
	TIGRIS_1_0_5:1.23
	TIGRIS_1_0_5RC6:1.23
	TIGRIS_1_0_5RC5:1.23
	TIGRIS_1_0_5RC4:1.23
	TIGRIS_1_0_5RC3:1.23
	TIGRIS_1_0_5RC2:1.23
	TIGRIS_1_0_5RC1:1.23
	TIGRIS_1_0_4:1.23
	TIGRIS_1_0_3:1.23
	TIGRIS_1_0_2:1.23
	TIGRIS_1_0_1:1.23
	TIGRIS_1_0:1.23.0.6
	TIGRIS_1_0_0:1.23
	TIGRIS_1_0_0_RC1:1.23.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.11
	TIGRIS_0_9_2_3:1.11
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.14
	TIGRIS_0_9_2_1:1.14
	TIGRIS_0_9_2:1.11.0.2
	TIGRIS_0_9_0:1.10.0.4
	TIGRIS_0_8_4:1.10.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.35
date	2001.08.28.17.45.17;	author leonardr;	state Exp;
branches;
next	1.34;

1.34
date	2001.08.11.09.08.07;	author dlr;	state Exp;
branches;
next	1.33;

1.33
date	2001.07.26.19.23.44;	author leonardr;	state Exp;
branches;
next	1.32;

1.32
date	2001.07.24.18.52.21;	author leonardr;	state Exp;
branches;
next	1.31;

1.31
date	2001.07.18.10.05.14;	author dlr;	state Exp;
branches;
next	1.30;

1.30
date	2001.07.17.22.32.06;	author dlr;	state Exp;
branches;
next	1.29;

1.29
date	2001.07.17.20.10.49;	author leonardr;	state Exp;
branches;
next	1.28;

1.28
date	2001.07.05.22.21.39;	author leonardr;	state Exp;
branches;
next	1.27;

1.27
date	2001.06.29.00.57.49;	author leonardr;	state Exp;
branches;
next	1.26;

1.26
date	2001.06.21.00.22.15;	author leonardr;	state Exp;
branches;
next	1.25;

1.25
date	2001.05.23.01.50.15;	author dlr;	state Exp;
branches;
next	1.24;

1.24
date	2001.04.26.16.16.44;	author leonardr;	state Exp;
branches;
next	1.23;

1.23
date	2001.03.14.20.56.50;	author elicia;	state Exp;
branches;
next	1.22;

1.22
date	2001.03.14.19.08.07;	author dlr;	state Exp;
branches;
next	1.21;

1.21
date	2001.03.08.03.24.02;	author leonardr;	state Exp;
branches;
next	1.20;

1.20
date	2001.03.07.18.09.10;	author leonardr;	state Exp;
branches;
next	1.19;

1.19
date	2001.03.07.01.53.24;	author lucas;	state Exp;
branches;
next	1.18;

1.18
date	2001.02.27.00.44.12;	author dlr;	state Exp;
branches;
next	1.17;

1.17
date	2001.02.27.00.31.23;	author dlr;	state Exp;
branches;
next	1.16;

1.16
date	2001.02.22.16.16.53;	author leonardr;	state Exp;
branches;
next	1.15;

1.15
date	2001.02.21.01.08.23;	author dlr;	state Exp;
branches;
next	1.14;

1.14
date	2001.01.26.18.29.04;	author edk;	state Exp;
branches
	1.14.2.1;
next	1.13;

1.13
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.12;

1.12
date	2001.01.25.02.54.52;	author ms;	state Exp;
branches;
next	1.11;

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

1.10
date	2000.12.04.02.57.09;	author jrobbins;	state Exp;
branches;
next	1.9;

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

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

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

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

1.5
date	2000.11.20.22.13.12;	author leonardr;	state Exp;
branches;
next	1.4;

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

1.3
date	2000.11.15.19.39.17;	author leonardr;	state Exp;
branches;
next	1.2;

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

1.1
date	2000.11.12.21.16.06;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.16.06;	author dlr;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2001.02.21.00.35.03;	author dlr;	state Exp;
branches;
next	;

1.14.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	1.14.2.2;

1.14.2.2
date	2001.02.17.00.19.47;	author elicia;	state Exp;
branches;
next	1.14.2.3;

1.14.2.3
date	2001.02.17.01.20.58;	author leonardr;	state Exp;
branches;
next	;


desc
@@


1.35
log
@More methods migrated to ContextAPI.
@
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 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 org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;
import org.apache.commons.util.exception.NestableException;
import org.apache.velocity.context.Context;

import org.tigris.helm.security.RedirectException;

import org.tigris.helm.security.*;

import org.tigris.helm.tool.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.*;

public class ProjectEdit extends HelmServlet
{
    /** 
     * The 'action' when the form is submitted
     */
    private final static String SUBMIT_CHANGES_ACTION = "Submit Changes";
    
    /** 
     * Property file field name for success page
     */
    private static final String SUCCESS_PAGE = "successPage";
    
    /**
     * Short description form field name
     */
    private final static String SHORT_DESCRIPTION_FIELD =
        "shortDescription";
    
    /**
     * Long description form field name
     */
    private final static String LONG_DESCRIPTION_FIELD =
        "longDescription";

    /**
     * Field name for project parent selection
     */
    private static String PARENT_FIELD="parent";

    /**
     * Field name for 'is public' checkbox.
     */
    private final static String IS_PUBLIC_FIELD = "isPublic";
    
    /**
     * Use index form field name.
     */
    private final static String USE_INDEX_FIELD = "useIndex";

    /**
     * Long description form field name
     */
    private final static String STATUS_FIELD = "status";

    /**
     * Licence field name
     */
    private final static String LICENSE_FIELD = "license";

    /**
     * Selected categories field name.
     */
    private final static String SELECTED_CATEGORIES_FIELD =
        "selectedCategories";

    /** 
     * Process user action.
     */
    protected String processRequest(Context context)
        throws NestableException, RedirectException
    {
        String templateName = super.processRequest(context);
                
        // Determine which button was pushed
        String action = getAction(context);
        try 
        {
            Project project = getCurrentProject(context);
            
            Project currentParent = project.getParentProject();

            String parentID = ContextAPI.processField
                (context, PARENT_FIELD, currentParent.getID());
            Project newParent = ProjectPeer.getInstance(parentID);

            //Redirect to the editing servlet for categories and
            //project groups.
            if (project.isGroup())
            {
                redirectTo("ProjectGroupEdit");
            } 
            else if (project.isCategory())
            {
                redirectTo("CategoryEdit");
            }            

            User loginUser = getLoginUser(context);
            AccessControlList acl = loginUser.getACL();
               
            context.put("changed", Boolean.FALSE);           
                        
            if (SUBMIT_CHANGES_ACTION.equals(action))
            {
                List missingFields = new ArrayList();
                List validationErrors = new ArrayList();

                // shortDescription, longDescription and status can be empty.
                // Assure that ProjectEditInfo works the same way.
                String shortDescription =
                    ContextAPI.processField(context, SHORT_DESCRIPTION_FIELD);
                String longDescription =
                    ContextAPI.processField(context, LONG_DESCRIPTION_FIELD);
                String isPublic = DBFlag.flagValueOf
                    (ContextAPI.processCheckbox(context, IS_PUBLIC_FIELD));
                String useIndex = DBFlag.flagValueOf
                    (ContextAPI.processCheckbox(context, USE_INDEX_FIELD));
                String status = ContextAPI.processField(context, STATUS_FIELD);
                String url = ContextAPI.processField(context, "url");

                String licenseID = ContextAPI.processRequiredField
                    (context, LICENSE_FIELD, "Project License");
                License license = LicensePeer.getInstance(licenseID);
                
                List projectCategories = null;
                String[] projectCategoryIDs = 
                    ContextAPI.getParameterValues
                    (context, SELECTED_CATEGORIES_FIELD);
                if (projectCategoryIDs != null)
                {
                    projectCategories 
                        = new ArrayList(projectCategoryIDs.length);
                    for (int i = 0; i < projectCategoryIDs.length; i++)
                    {
                        Category c = (Category)
                            ProjectPeer.getInstance(projectCategoryIDs[i]);
                        projectCategories.add(c);
                    }
                }
                
                if (ContextAPI.isValidUserInput(context))
                {
                    project.updateInfo(acl, license, isPublic,
                                       shortDescription, longDescription, 
                                       useIndex, status, url);
                    
                    if (projectCategories != null) 
                    {
                        project.changeCategories(projectCategories);
                    }
                    
                    if (!parentID.equals(currentParent.getID()))
                    {
                        project.changeParent(acl, newParent);
                    }

                    String projectHome = project.getProjectHome();
                    redirectToURL(context, projectHome);    
                }
            }
            else
            {
                //Initially populate the selected categories box with
                //the categories to which this project belongs.
                List categories = project.getCategories();
                String[] projectCategoryIDs = new String[categories.size()];
                for (int i = 0; i < projectCategoryIDs.length; i++)
                {
                    Category c = (Category)categories.get(i);
                    projectCategoryIDs[i] = c.getID();
                }            
                context.put(SELECTED_CATEGORIES_FIELD, projectCategoryIDs);
            }
        }
        catch (RedirectException e) 
        {
            throw e;
        }
        catch (Exception e) 
        {
            Log.error(e);
            throw new NestableException(e);
        }
        
        return templateName;
    }
}
@


1.34
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d181 2
a182 1
                    getParameterValues(context, SELECTED_CATEGORIES_FIELD);
@


1.33
log
@Correctly compare IDs.
@
text
@d54 2
a55 2
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
d125 1
a125 1
        throws TurbineException, RedirectException
d235 1
a235 1
            throw new TurbineException(e);
@


1.32
log
@Enabled nested projects for regular projects.
@
text
@d205 1
a205 1
                    if (parentID != currentParent.getID())
@


1.31
log
@Ported Joist Redirect*Exception to Helm.
@
text
@a67 5
    /**
     * Key to pull projectID from query string
     */
    private static final String PROJECTID_KEY = "projectID";
        
d91 5
d135 6
d146 2
a147 1
            } else if (project.isCategory())
a154 2
            if (project == null)
                redirectToError(context, "No project specified to edit");
d156 1
a156 7
            
            // Need to perpetuate projectID.  If i don't get it and
            // put it back into the context again, it gets lost.  
            //
            // Is this still neccesary? - leonardr
            context.put(PROJECTID_KEY, project.getID());            
            
d180 3
a182 2

                if (!project.isCategory())
d184 3
a186 3
                    String[] projectCategoryIDs = 
                        getParameterValues(context, SELECTED_CATEGORIES_FIELD);
                    if (projectCategoryIDs != null)
d188 3
a190 8
                        projectCategories 
                            = new ArrayList(projectCategoryIDs.length);
                        for (int i = 0; i < projectCategoryIDs.length; i++)
                        {
                            Category c = (Category)
                                ProjectPeer.getInstance(projectCategoryIDs[i]);
                            projectCategories.add(c);
                        }
d200 1
a200 1
                    if (!project.isCategory() && projectCategories != null) 
d205 5
@


1.30
log
@Cleanup.
@
text
@d58 1
a58 1
import org.joist.security.RedirectException;
@


1.29
log
@Ported servlets to new error-handling mechanism.
@
text
@d122 1
a122 7
     * Process ProjectEdit form.
     * @@param context  The WebContext, partially populated by WMServlet.
     * @@param conn The JDBC database connection to use.
     * @@return	   The name of the Template for formatting the Context data.
     *
     * @@exception HandlerException  Generic exception used for propogation.
     * @@exception RedirectException On any Joist redirect.
@


1.28
log
@Licenses are now contained in a database-managed table rather than in a custom Java class (yay!)
@
text
@d123 1
a123 1
     * @@param ctx  The WebContext, partially populated by WMServlet.
d130 1
a130 1
    protected String processRequest(Context ctx)
d133 1
a133 1
        String templateName = super.processRequest(ctx);
d136 1
a136 1
        String action = getAction(ctx);
d139 1
a139 1
            Project project = getCurrentProject(ctx);
d151 1
a151 1
            User loginUser = getLoginUser(ctx);
d155 2
a156 2
                redirectToError(ctx, "No project specified to edit");
            ctx.put("changed", Boolean.FALSE);           
d159 1
a159 1
            // put it back into the ctx again, it gets lost.  
d162 1
a162 1
            ctx.put(PROJECTID_KEY, project.getID());            
d172 1
a172 1
                    processField(ctx, SHORT_DESCRIPTION_FIELD);
d174 1
a174 1
                    processField(ctx, LONG_DESCRIPTION_FIELD);
d176 1
a176 1
                    (processCheckbox(ctx, IS_PUBLIC_FIELD));
d178 3
a180 3
                    (processCheckbox(ctx, USE_INDEX_FIELD));
                String status = processField(ctx, STATUS_FIELD);
                String url = processField(ctx, "url");
d182 2
a183 3
                String licenseID = processField
                    (ctx, LICENSE_FIELD, "Project License", missingFields);
                Log.debug("New license: " + licenseID);
d191 1
a191 1
                        getParameterValues(ctx, SELECTED_CATEGORIES_FIELD);
d205 1
a205 1
                if (isValidUserInput(missingFields, validationErrors))
d217 1
a217 1
                    redirectToURL(ctx, projectHome);    
a218 6
                else 
                {
                    // Report missing fields and validation errors.
                    reportInvalidUserInput(ctx, missingFields, 
                                           validationErrors);
                }    
d231 1
a231 1
                ctx.put(SELECTED_CATEGORIES_FIELD, projectCategoryIDs);
a233 7
        catch (DoesNotExist e) 
        {
            String msg = "Cannot edit project which does not exist: " +
                e.getMessage();
            Log.warn(msg, e);
            appendToError(ctx, msg);
        }
d241 1
@


1.27
log
@Implemented basic project group and category nesting.
@
text
@d72 1
a72 7
    
    /**
     * License list key.
     * Webmcro pulls list of licenses using this key.
     */
    private static final String LICENSELIST_KEY = "licenseList";
    
d86 1
a86 1
    private final static String SHORT_DESCRIPTION_FORM_FIELD =
d92 1
a92 1
    private final static String LONG_DESCRIPTION_FORM_FIELD =
d98 1
a98 1
    private final static String IS_PUBLIC_FORM_FIELD = "isPublic";
d103 1
a103 1
    private final static String USE_INDEX_FORM_FIELD = "useIndex";
d108 6
a113 1
    private final static String STATUS_FORM_FIELD = "status";
a153 4
            boolean allowProprietaryLicenses = true;
            Licenses.addToContext(ctx, LICENSELIST_KEY, 
                                  allowProprietaryLicenses);

a168 12
                /* NOTE: Don't allow changing of project name yet because of
                   the far-reaching repercussions of doing so.

                String projectName = processField(ctx, "projectName", 
                                                  "Project Name", 
                                                  missingFields);

                if (!Project.isValidName(projectName))
                {
                    validationErrors.add("Project name is invalid.");
                }*/

d172 1
a172 1
                    processField(ctx, SHORT_DESCRIPTION_FORM_FIELD);
d174 1
a174 1
                    processField(ctx, LONG_DESCRIPTION_FORM_FIELD);
d176 1
a176 1
                    (processCheckbox(ctx, IS_PUBLIC_FORM_FIELD));
d178 2
a179 2
                    (processCheckbox(ctx, USE_INDEX_FORM_FIELD));
                String status = processField(ctx, STATUS_FORM_FIELD);
d182 4
a185 4
                // According to db schema, this looks like text string
                String license = 
                    processField(ctx, "license", "Project License", 
                                 missingFields);
d193 1
a193 3
                    projectCategories 
                        = new ArrayList(projectCategoryIDs.length);
                    for (int i = 0; i < projectCategoryIDs.length; i++)
d195 8
a202 3
                        Category c = (Category)
                            ProjectPeer.getInstance(projectCategoryIDs[i]);
                        projectCategories.add(c);
a207 1
                    Log.debug("ispublic: " + isPublic);
d209 2
a210 5
                                       shortDescription,
                                       longDescription,
                                       useIndex,
                                       status, url
                                       );
d212 1
a212 1
                    if (!project.isCategory()) 
@


1.26
log
@Projects can now belong to more than one category.
@
text
@d141 11
@


1.25
log
@Ported Helm from WebMacro to Velocity.
@
text
@d116 6
d147 1
a147 1
            
d158 1
a158 1
            if (action != null && action.equals(SUBMIT_CHANGES_ACTION))
d193 1
a193 1
                Category projectCategory = null;
d197 10
a206 6
                    String projectCategoryID = 
                        processField(ctx, "projectCategory",  
                                     "Project Category", 
                                     missingFields);                  
                    projectCategory = (Category)ProjectPeer.getInstance
                        (projectCategoryID);
d208 1
a208 1

d221 1
a221 1
                        project.changeCategory(projectCategory);
d227 2
a228 1
                else {
d233 14
a246 1
            }  // End of switch action
d248 2
a249 1
        catch (DoesNotExist e) {
d255 2
a256 1
        catch (RedirectException e) {
d259 2
a260 1
        catch (Exception e) {
@


1.24
log
@Patches I forgot to commit before, for decoupling privateness from proprietariness.
@
text
@d54 3
a56 1
import org.webmacro.servlet.*;
d120 1
a120 1
     * @@return	   The name of the Template for formatting the WebContext data.
d125 2
a126 2
    protected String processRequest(Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
d128 1
a128 1
        String templateName = super.processRequest(conn, ctx);
@


1.23
log
@setting it so that the user can switch to a proprietary license from a private one (as per issue 1776)
@
text
@d63 1
a63 1
import org.tigris.helm.om.*;
d98 5
d173 4
a176 1
                String useIndex = processField(ctx, USE_INDEX_FORM_FIELD);
d199 2
a200 1
                    project.updateInfo(acl, license,
@


1.22
log
@No longer check the Use Index box behind the user's back.  If the user
desires no description, that's what they're gonna get.
@
text
@d131 1
a131 5
            boolean allowProprietaryLicenses = false;
            if (!project.isApproved() || project.isProprietary())
            {
                allowProprietaryLicenses = true;
            }
@


1.21
log
@Moved disabling/enabling ability from ProjectEdit to new servlet: ProjectEnabled.
@
text
@a169 1

a171 1

a172 5
                if (!haveValue(longDescription) && !haveValue(useIndex))
                {
                    useIndex = DBFlag.ON;
                }

a173 1

@


1.20
log
@Added the ability to disable projects.
@
text
@a108 5
    /**
     * Project enable field name
     */
    private final static String ENABLED_FIELD = "enabled";

a200 2
                boolean enabled = processCheckbox(ctx, ENABLED_FIELD);
                
a213 2
                    
                    project.setEnabledState(acl, enabled);
@


1.19
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d109 5
d160 1
a160 1
                   the far-reaching repurcussions of doing so.
d193 1
a193 1

d205 2
d217 2
a218 1
                    if (!project.isCategory()) {
d221 2
@


1.18
log
@Handling RedirectExceptions is a lot like fishing...catch and release.
@
text
@d63 1
a63 2
import org.tigris.helm.om.peer.*;

@


1.17
log
@* Cleaned up comments and error handling.
* Removed need for DEBUG constant.
@
text
@d231 3
@


1.16
log
@Corrected edit action.
@
text
@d65 2
a66 4
public class ProjectEdit extends HelmServlet {
    
    private static boolean debug = true;
    
d91 2
a92 1
    private final static String SHORT_DESCRIPTION_FORM_FIELD = "shortDescription";
d97 2
a98 1
    private final static String LONG_DESCRIPTION_FORM_FIELD = "longDescription";
a108 1
    
d112 3
a114 4
     * @@param ctx    The WebContext, partially populated by WMServlet.
     * @@param conn the JDBC database connection to use.
     * @@return	         The name of the Template for formatting the 
     *                   WebContext data.
a121 1
        if (debug) Log.debug("Started.");
d141 1
a141 1
                redirectToError(ctx, "ProjectEdit: No project specified");
d155 4
a158 2
                //Don't allow changing of project name yet.
                /*String projectName = processField(ctx, "projectName", 
a215 2
                    if(debug)
                        Log.debug("Done -- redirecting to "+ projectHome);
d217 2
a218 1
                } else {
d223 9
a231 2
            } // End of switch action
        } catch (DoesNotExist e) {
a232 8
            String message = e.getMessage();
            if (debug) Log.debug(message);
            appendToMessage(ctx, message);
        } catch (Exception e) {
            Log.error(e);
            String message = e.getMessage();
            if (debug) Log.debug(message);
            appendToMessage(ctx, message);
a233 3

        
        if (debug) Log.debug("ProjectEdit done");
@


1.15
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d2 1
a2 1
 * Copyright (c) 2000 CollabNet.  All rights reserved.
a52 3
import javax.servlet.*;
import javax.servlet.http.*;

a59 1
//import com.workingdogs.village.*;
d83 1
a83 1
    private final static String SUBMIT_CHANGES = "Edit Project";
d153 1
a153 1
            if (action != null && action.equals(SUBMIT_CHANGES))
@


1.14
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@a49 1

d56 1
a56 1
import org.webmacro.util.Log;
a59 1
import org.joist.database.JoistDatabaseException;
d61 1
a61 2
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.security.HelmServlet;
d63 1
a63 1
import com.workingdogs.village.*;
d66 2
a67 3
import org.tigris.helm.domain.Category;
import org.tigris.helm.database.ProjectProjectGroupManager;

a68 40
/**
 * Display the current settings for a project, and allow editing
 * of them.
 * <p>
 * Issues:
 * <ol>
 *  <li>Access Control for this page -- at least around the updateProject.  
 *      How to make it work?  Add as an issue
 * </li>
 * <li>shortDescription, longDescription and status can be null in ProjectEditInfo so
 * i made it same in here.  We can always change it.
 * </ol>
 * <p>
* Test Cases:
* <ol>
* <li>What happens when form is empty and it's submitted?
* 	<ol>
* 		<li>Complains about all missing fields. Redraws old values.  That's what we want.</li>
*       <li>If i empty all but the projectName, complains about missing shortDesc, longDesc, and status.  
*        These can be null in projectEditInfo.  So i've changed this handler to do same
*      same as ProjectEditInfo.  Means that we only get missingField errors if we make 
*       the projectName empty.
* </li>
* 	</ol>
* </li>
* <li>What happens when form is partially completed?  Does the missing fields messages display? YES. See above.</li>
* <li>On successful submission, does the content show up in the database?  YES. In HELM_PROJECT</li>
* <li>Do popup menus get correctly when we enter the form first time?  YES. </li>
* <li>On successful submission, are we taken to the next page, the project home 
* page? YES. To ProjectHome.</li>
* <li>Check the javadoc.  How does it come out?
* 		<ul>
*			<li>Looks good.  I used: 
*               <pre>/home/stack/software/jdk1.3/bin/javadoc -d javadoc -classpath /home/stack/cvsroot/sandbox/site/lib/joist.jar:${CLASSPATH}  -sourcepath . org.tigris.helm.project.ProjectEdit
*               </pre>
*          </li>
*		</ul>
* </li>
* </ol>
 */
a70 1
    private static Log log = new Log("projEdit", "ProjectEdit");
a72 1
    
a77 1
    
a83 1

a93 1
    
d117 2
a118 2
     * @@param context    The WebContext, partially populated by WMServlet.
     * @@param connection the JDBC database connection to use.
d125 1
a125 1
    protected String processRequest(Connection connection, WebContext context)
d128 2
a129 2
        if (debug) log.info("Started.");
        String templateName = super.processRequest(connection, context);
d132 1
a132 1
        String action = getAction(context);
d135 3
a137 1
            Project project = getCurrentProject(context);
d144 1
a144 1
            Licenses.addToContext(context, LICENSELIST_KEY, 
d148 2
a149 2
                redirectToError(context, "ProjectEdit: No project specified");
            context.put("changed", Boolean.FALSE);           
d152 1
a152 1
            // put it back into the context again, it gets lost.  
d155 1
a155 1
            context.put(PROJECTID_KEY, project.getID());            
d163 1
a163 1
                /*String projectName = processField(context, "projectName", 
d175 1
a175 1
                    processField(context, SHORT_DESCRIPTION_FORM_FIELD);
d178 1
a178 1
                    processField(context, LONG_DESCRIPTION_FORM_FIELD);
d180 1
a180 1
                String useIndex = processField(context, USE_INDEX_FORM_FIELD);
d186 1
a186 1
                String status = processField(context, STATUS_FORM_FIELD);
d188 1
a188 1
                String url = processField(context, "url");
d192 1
a192 1
                    processField(context, "license", "Project License", 
d200 1
a200 1
                        processField(context, "projectCategory",  
d203 2
a204 2
                    projectCategory = new Category(connection, dMgr, 
                                                   projectCategoryID);
d209 1
a209 2
                    project.updateInfo(getACL(context, connection),
                                       license,
d213 1
a213 2
                                       status,
                                       url
d222 2
a223 2
                        log.info("Done -- redirecting to "+ projectHome);
                    redirectToURL(context, projectHome);    
d226 1
a226 1
                    reportInvalidUserInput(context, missingFields, 
d230 2
a231 12
        } catch (UpdateException e) {
            log.exception(e);
            String message = e.getMessage();
            if (debug) log.info(message);
            appendToMessage(context, message);
        } catch (SQLException e) {
            log.exception(e);
            String message = e.getMessage();
            if (debug) log.info(message);
            appendToMessage(context, message);
        } catch (DataSetException e) {
            log.exception(e);
d233 4
a236 9
            if (debug) log.info(message);
            appendToMessage(context, message);
        } catch (JoistDatabaseException e) {
            log.exception(e);
            String message = e.getMessage();
            if (debug) log.info(message);
            appendToMessage(context, message);
        } catch (DoesNotExist e) {
            log.exception(e);
d238 2
a239 2
            if (debug) log.info(message);
            appendToMessage(context, message);
d243 1
a243 1
        if (debug) log.info("ProjectEdit done");
@


1.14.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@@


1.14.2.2
log
@ported to turbine
@
text
@d50 1
d57 1
a57 1
import org.apache.turbine.util.Log;
d61 1
d63 2
a64 1
import org.tigris.helm.security.*;
d66 1
a66 1
//import com.workingdogs.village.*;
d69 3
a71 2
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d73 40
d115 1
d118 1
d124 1
d131 1
d142 1
d166 2
a167 2
     * @@param ctx    The WebContext, partially populated by WMServlet.
     * @@param conn the JDBC database connection to use.
d174 1
a174 1
    protected String processRequest(Connection conn, WebContext ctx)
d177 2
a178 2
        if (debug) Log.debug("Started.");
        String templateName = super.processRequest(conn, ctx);
d181 1
a181 1
        String action = getAction(ctx);
d184 1
a184 3
            Project project = getCurrentProject(ctx);
            User loginUser = getLoginUser(ctx);
            AccessControlList acl = loginUser.getACL();
d191 1
a191 1
            Licenses.addToContext(ctx, LICENSELIST_KEY, 
d195 2
a196 2
                redirectToError(ctx, "ProjectEdit: No project specified");
            ctx.put("changed", Boolean.FALSE);           
d199 1
a199 1
            // put it back into the ctx again, it gets lost.  
d202 1
a202 1
            ctx.put(PROJECTID_KEY, project.getID());            
d210 1
a210 1
                /*String projectName = processField(ctx, "projectName", 
d222 1
a222 1
                    processField(ctx, SHORT_DESCRIPTION_FORM_FIELD);
d225 1
a225 1
                    processField(ctx, LONG_DESCRIPTION_FORM_FIELD);
d227 1
a227 1
                String useIndex = processField(ctx, USE_INDEX_FORM_FIELD);
d233 1
a233 1
                String status = processField(ctx, STATUS_FORM_FIELD);
d235 1
a235 1
                String url = processField(ctx, "url");
d239 1
a239 1
                    processField(ctx, "license", "Project License", 
d247 1
a247 1
                        processField(ctx, "projectCategory",  
d250 2
a251 2
                    projectCategory = (Category)ProjectProjectgroupPeer
                                      .getInstance(projectCategoryID);
d256 2
a257 1
                    project.updateInfo(acl, license,
d261 2
a262 1
                                       status, url
d271 2
a272 2
                        Log.debug("Done -- redirecting to "+ projectHome);
                    redirectToURL(ctx, projectHome);    
d275 1
a275 1
                    reportInvalidUserInput(ctx, missingFields, 
d279 20
d300 1
a300 6
            Log.error(e);
            String message = e.getMessage();
            if (debug) Log.debug(message);
            appendToMessage(ctx, message);
        } catch (Exception e) {
            Log.error(e);
d302 2
a303 2
            if (debug) Log.debug(message);
            appendToMessage(ctx, message);
d307 1
a307 1
        if (debug) Log.debug("ProjectEdit done");
@


1.14.2.3
log
@Get a category object (fixes compile error)
@
text
@d203 2
a204 2
                    projectCategory = (Category)ProjectPeer.getInstance
                        (projectCategoryID);
@


1.13
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
@a59 1
import org.joist.util.TagValidator;
d223 1
a223 7
		if (TagValidator.containsHTML(shortDescription))
		{
		    log.info("summary has html");
		    validationErrors.add("Summary has HTML");
		    context.put(SHORT_DESCRIPTION_FORM_FIELD, 
				TagValidator.escapeHTML(shortDescription));
		}
a225 7
		if (!TagValidator.validate(longDescription))
		{
		    log.info("descr has html");
		    validationErrors.add("Description has bad HTML");
		    context.put(LONG_DESCRIPTION_FORM_FIELD, 
				TagValidator.escapeHTML(longDescription));
		}
d234 1
a234 6
		if (!TagValidator.validate(status))
		{
		    log.info("ownermsg has html");
		    validationErrors.add("Owner's message has bad HTML");
		    context.put(STATUS_FORM_FIELD, TagValidator.escapeHTML(status));
		}
@


1.12
log
@Integrated TagValidator with the form-input in the servlets so that when a
form says "no html here" it actually checks the input for html, and if it allows HTML then checks it for some releative sanity.
These changes require you to update joist also for changes in TagValidator.
@
text
@@


1.11
log
@Made use of new DBFlag class.
@
text
@d60 1
d224 7
a230 1

d233 7
d248 6
a253 1

@


1.10
log
@made it so categories do not go under each other
@
text
@a147 1
    
d153 5
a157 1
    
d220 1
a220 2
                // be sure to make ProjectEditInfo work the same way.
                //
d227 6
d244 2
a245 2
                if (!project.isCategory()) {
                    // This is an ID -- not category name
d260 1
@


1.9
log
@Deleted some low value lines.
@
text
@d234 11
a244 7
                // This is an ID -- not category name
                String projectCategoryID = 
                    processField(context, "projectCategory",  
                                 "Project Category", 
                                 missingFields);                  
                Category projectCategory = new Category(connection, dMgr, 
                                                        projectCategoryID);
d256 4
a259 1
                    project.changeCategory(projectCategory);
@


1.8
log
@Sync'd w/ method name change.
@
text
@a182 2
            // Need list of licenses.  Put them in context
            //
a229 1
                //
a234 1
                //
d295 1
a295 3
    
} /* end class ProjectEdit */

@


1.7
log
@Sync'd w/ moved interface.
@
text
@d213 1
a213 1
                if (!Project.isValidProjectName(projectName))
@


1.6
log
@Don't change button text without also changing the servlet that interprets the button text as an action.
@
text
@d115 2
a116 2
    static private Log log = new Log("projEdit", "ProjectEdit");
    static private boolean debug = true;
d213 1
a213 1
                if (!projMgr.isValidProjectName(projectName))
@


1.5
log
@Don't show box for editing project name.
@
text
@d135 1
a135 1
    private final static String SUBMIT_CHANGES = "Submit Changes";
a178 1
        
d211 1
a211 1
                                                  missingFields);*/
d216 1
a216 1
                }
d255 1
a255 1
                                         
@


1.4
log
@Can't proprietarize approved open source projects.
@
text
@d209 2
a210 1
                String projectName = processField(context, "projectName", 
d212 1
a212 1
                                                  missingFields);
@


1.3
log
@Modernized ProjectEdit; began to get rid of superfluous UpdateException handling.
@
text
@d179 1
a179 1

d186 7
a192 1
            Licenses.addToContext(context, LICENSELIST_KEY);
a216 1

@


1.2
log
@removed references to member policy
@
text
@d61 1
a65 1

d67 3
a69 2
import org.tigris.helm.tool.Licenses;
import org.tigris.helm.tool.Policies;
d119 4
a122 3
	/** Key to pull projectID from query string
	*/
	private static final String PROJECTID_KEY = "projectID";
d125 4
a128 3
    /** License list key.
    * Webmcro pulls list of licenses using this key.
    */
d132 2
a133 1
    /** The 'action' when the form is submitted
d137 2
a138 7
    
    /** Key to pull 'action' from context w/ getForm( )
     */
    private static final String ACTION_KEY = "action";
    
    
    /** Property file field name for success page
d143 2
a144 1
    /** Short description form field name
d149 2
a150 1
    /** Long description form field name
d155 2
a156 1
    /** Long description form field name
d161 2
a162 1
    /** Process ProjectEdit form.
d170 1
a170 1
    */
d174 1
a174 3
        if (debug) 
            log.debug("ProjectEdit: enter");
        
d178 1
a178 1
        String action = (String) context.get(ACTION_KEY);
d186 1
a186 1
            Licenses.addToContext(context, LICENSELIST_KEY );
d195 2
a196 2
            context.put( PROJECTID_KEY, project.getID( ) );
            
d204 2
a205 2
                                                    "Project Name", 
                                                    missingFields);
d216 7
a222 16
                String shortDescription 
                    = context.getForm( SHORT_DESCRIPTION_FORM_FIELD );
                //    processField(context, SHORT_DESCRIPTION_FORM_FIELD, 
                //                 "Short Description", 
                //                 missingFields);

                String longDescription 
                    = context.getForm( LONG_DESCRIPTION_FORM_FIELD );
                //    processField(context, LONG_DESCRIPTION_FORM_FIELD, 
                //                  "Long Description", 
                //                  missingFields);

                String status = context.getForm( STATUS_FORM_FIELD );
                //    processField(context, STATUS_FORM_FIELD, 
                //                 "Project Status", 
                //                 missingFields);
d230 1
a230 1
                        missingFields);
d234 7
a240 5
                String projectCategory = 
                    processField(context, "projectCategory",  "Project Category", 
                                 missingFields);  
            
            
d250 7
a256 22
                                              
                    // Now to update the category...
                    // Leonardr told me do it this way in IRC 10/25/2000. 
                    //
                    if( debug )
                        log.debug( "PROJECTCATEGORY: " + projectCategory );
                    ProjectProjectGroupManager prjGrpMgr = 
                        ( ProjectProjectGroupManager )dMgr.getManager( "org.tigris.helm.database.ProjectProjectGroupManager" );
                    prjGrpMgr.removeBaseFromComposites( connection, 
                        project.getID( ) );
                    prjGrpMgr.addBaseToComposite( connection, 
                                                    project.getID( ), 
                                                    projectCategory );
                                                    
                    String projectHome = project.getProjectHome( );                             
 					if( debug )
						log.debug( "ProjectEdit done -- redirecting to: " 
									+ projectHome );
					redirectToURL( context, projectHome  );    
                }               
                else
                {
d261 22
a282 4
            } // End of switch on action
        }
        catch (Exception e)
        {
d285 1
a285 1
            if (debug) log.debug(message);
d288 1
d290 1
a290 2
		if( debug ) 
			log.debug( "ProjectEdit done" );
d296 1
@


1.1
log
@Initial revision
@
text
@a68 1
import org.tigris.helm.tool.Policy;
a128 5
    /** Policy list key.
    * Webmcro pulls list of policies using this key.
    */
    private static final String POLICYLIST_KEY = "policyList";      
    
d183 1
a183 1
            // Need list of licenses and policies.  Put them in context
a186 7
            ArrayList policyList = new ArrayList();
            for( int i = 0; i < Policies.POLICIES.length; i++ )
            {
                policyList.add( new Policy( Policies.POLICIES[ i ], i + 1 ) );
            }
            context.put( POLICYLIST_KEY, policyList );
            
a212 1
                // If policy changes and we require that these be non-empty,
a239 7
                // According to db schema, this should be made into 
                // an ID for insertion in db.  I made it so.
                //
                String memberPolicy = 
                    processField(context, "memberPolicy", "Member Policy", 
                        missingFields);

d254 1
a254 2
                                       url,
                                       memberPolicy
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@


1.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d50 1
d57 1
a57 1
import org.apache.turbine.util.Log;
d62 2
a63 1
import org.tigris.helm.security.*;
a64 5
//import com.workingdogs.village.*;
import org.tigris.helm.tool.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d66 47
d115 13
a127 1
    private static boolean debug = true;
d129 7
a135 2
    /**
     * Key to pull projectID from query string
d137 2
a138 1
    private static final String PROJECTID_KEY = "projectID";
d140 1
a140 3
    /**
     * License list key.
     * Webmcro pulls list of licenses using this key.
d142 1
a142 1
    private static final String LICENSELIST_KEY = "licenseList";
a143 4
    /** 
     * The 'action' when the form is submitted
     */
    private final static String SUBMIT_CHANGES = "Edit Project";
d145 1
a145 2
    /** 
     * Property file field name for success page
d149 2
a150 2
    /**
     * Short description form field name
d154 2
a155 2
    /**
     * Long description form field name
d159 2
a160 7
    /**
     * Use index form field name.
     */
    private final static String USE_INDEX_FORM_FIELD = "useIndex";

    /**
     * Long description form field name
d165 3
a167 4
    /** 
     * Process ProjectEdit form.
     * @@param ctx    The WebContext, partially populated by WMServlet.
     * @@param conn the JDBC database connection to use.
d173 2
a174 2
     */
    protected String processRequest(Connection conn, WebContext ctx)
d177 4
a180 2
        if (debug) Log.debug("Started.");
        String templateName = super.processRequest(conn, ctx);
d183 2
a184 1
        String action = getAction(ctx);
d187 1
a187 3
            Project project = getCurrentProject(ctx);
            User loginUser = getLoginUser(ctx);
            AccessControlList acl = loginUser.getACL();
d189 6
a194 2
            boolean allowProprietaryLicenses = false;
            if (!project.isApproved() || project.isProprietary())
d196 1
a196 1
                allowProprietaryLicenses = true;
d198 1
a198 2
            Licenses.addToContext(ctx, LICENSELIST_KEY, 
                                  allowProprietaryLicenses);
d201 2
a202 2
                redirectToError(ctx, "ProjectEdit: No project specified");
            ctx.put("changed", Boolean.FALSE);           
d205 1
a205 1
            // put it back into the ctx again, it gets lost.  
d207 2
a208 2
            // Is this still neccesary? - leonardr
            ctx.put(PROJECTID_KEY, project.getID());            
d215 3
a217 4
                //Don't allow changing of project name yet.
                /*String projectName = processField(ctx, "projectName", 
                                                  "Project Name", 
                                                  missingFields);
d219 1
a219 1
                if (!Project.isValidName(projectName))
d222 2
a223 1
                }*/
d226 19
a244 14
                // Assure that ProjectEditInfo works the same way.
                String shortDescription =
                    processField(ctx, SHORT_DESCRIPTION_FORM_FIELD);

                String longDescription =
                    processField(ctx, LONG_DESCRIPTION_FORM_FIELD);

                String useIndex = processField(ctx, USE_INDEX_FORM_FIELD);
                if (!haveValue(longDescription) && !haveValue(useIndex))
                {
                    useIndex = DBFlag.ON;
                }

                String status = processField(ctx, STATUS_FORM_FIELD);
d246 1
a246 1
                String url = processField(ctx, "url");
d249 1
d251 2
a252 2
                    processField(ctx, "license", "Project License", 
                                 missingFields);
d254 14
a267 12
                Category projectCategory = null;

                if (!project.isCategory())
                {
                    String projectCategoryID = 
                        processField(ctx, "projectCategory",  
                                     "Project Category", 
                                     missingFields);                  
                    projectCategory = (Category)ProjectPeer.getInstance
                        (projectCategoryID);
                }
                
d270 2
a271 1
                    project.updateInfo(acl, license,
d274 3
a276 2
                                       useIndex,
                                       status, url
d278 22
a299 10
                    
                    if (!project.isCategory()) {
                        project.changeCategory(projectCategory);
                    }
                    
                    String projectHome = project.getProjectHome();
                    if(debug)
                        Log.debug("Done -- redirecting to "+ projectHome);
                    redirectToURL(ctx, projectHome);    
                } else {
d301 1
a301 1
                    reportInvalidUserInput(ctx, missingFields, 
d304 5
a308 8
            } // End of switch action
        } catch (DoesNotExist e) {
            Log.error(e);
            String message = e.getMessage();
            if (debug) Log.debug(message);
            appendToMessage(ctx, message);
        } catch (Exception e) {
            Log.error(e);
d310 2
a311 2
            if (debug) Log.debug(message);
            appendToMessage(ctx, message);
a312 1

d314 2
a315 1
        if (debug) Log.debug("ProjectEdit done");
d319 2
a320 1
}
@

