head	1.9;
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;
locks; strict;
comment	@# @;


1.9
date	2001.08.28.17.45.17;	author leonardr;	state Exp;
branches;
next	1.8;

1.8
date	2001.08.28.17.13.33;	author leonardr;	state Exp;
branches;
next	1.7;

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

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

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

1.4
date	2001.03.07.01.53.25;	author lucas;	state Exp;
branches;
next	1.3;

1.3
date	2001.02.22.22.20.48;	author elicia;	state Exp;
branches;
next	1.2;

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

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


desc
@@


1.9
log
@More methods migrated to ContextAPI.
@
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.commons.util.exception.NestableException;

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

import org.tigris.helm.security.RedirectException;

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

public class ProjectNewsApprovalReason extends HelmServlet 
{
    private static boolean debug = true;
    private static String ACTION="Disapprove";

    /**
     * Process requests for project news approval.
     */
    protected String processRequest(Context ctx)
	    throws NestableException, 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("PjctNewsAppvlRsn:: action=" + action );
	    
	    boolean validAction = false;
	    if (action.equals("none"))
	    	validAction = true;

        if (action.equals(ACTION))
        {
            validAction = true;
            Enumeration paramNames =
                ContextAPI.getRequest(ctx).getParameterNames();
            String paramName;
            while (paramNames.hasMoreElements())
            {
                paramName = (String) paramNames.nextElement();
                if (paramName.startsWith("rationale_"))
                {
                    String rationale = ContextAPI.getParameter(ctx, paramName);
                    String newsID = paramName.substring(10);
                    
                    User loginUser = getLoginUser(ctx);
                    AccessControlList acl = loginUser.getACL();
                    NewsItem newsItem = (NewsItem)NewsItemPeer
                        .getInstance(newsID);
                    
                    newsItem.disapprove(acl, rationale);
                }
            }
            String url = 
                currentProject.getProjectPageURL("ProjectNewsList").toString();
            redirectToURL(ctx, url);
        }
        
        if (!validAction) redirectToUnauthorized();
	} 
    catch (RedirectException e)
    {
       throw e;
    }
    catch (Exception e)
    {
        Log.error(e);
        String message = "ProjectNewsApproval: " + e.getMessage();
        if (debug) Log.debug(message);
        ctx.put("message", message);
    }

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

    return templateName;
    }
}
@


1.8
log
@Completed migration of more methods to ContextAPI.
@
text
@d103 1
a103 1
                    String rationale = getParameter(ctx, paramName);
@


1.7
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d56 1
d63 1
a63 1
import org.apache.turbine.util.Log;
d93 13
a105 13
	    {
		    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 newsID = paramName.substring(10);

d109 11
a119 11
                                        .getInstance(newsID);

		            newsItem.disapprove(acl, rationale);
		        }
		    }
		    String url = 
		        currentProject.getProjectPageURL("ProjectNewsList").toString();
		        redirectToURL(ctx, url);
	    }
          
	    if (!validAction) redirectToUnauthorized();
@


1.6
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d53 2
a54 1
import org.apache.turbine.util.*;
d59 2
d62 2
a63 3
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.om.*;
import org.tigris.helm.om.*;
d73 1
a73 1
	    throws TurbineException, RedirectException
@


1.5
log
@Ported Helm from WebMacro to Velocity.
@
text
@d56 1
a56 1
import org.joist.security.RedirectException;
@


1.4
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);
d133 1
a134 2
  
} /* end class ProjectNewsApprovalReason */
@


1.3
log
@cleanup
@
text
@d61 1
a61 2
import org.tigris.helm.om.peer.*;

@


1.2
log
@Corrected compile time errors.  Mostly functional.  Need rationale for
news item disapproval.
@
text
@a48 1
import java.io.*;
a50 1
import javax.servlet.*;
d53 1
a53 2
import org.apache.turbine.util.Log;

a55 3
import org.joist.*;
import org.joist.util.*;
import org.joist.session.*;
a56 1
import org.joist.database.JoistDatabaseException;
a57 2
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.*;
d60 2
a61 1
import org.tigris.helm.tool.*;
d63 1
a63 1
public class ProjectNewsApprovalReason extends HelmServlet
d65 2
a66 3
    private static final boolean DEBUG = true;

    private static String ACTION = "Disapprove";
d74 2
a75 2
	String templateName = super.processRequest(conn, ctx);
	Project currentProject = getCurrentProject(ctx);
d77 1
a77 1
        try
d79 2
a80 2
            HttpSession session = getSessionManager(ctx).getSession();
            List disapproveList = (List)session.getValue("disapproveList");
d84 1
a84 1
	    if (DEBUG) Log.debug("PjctNewsAppvlRsn:: action=" + action );
d88 1
a88 3
	    {
		validAction = true;
	    }
d90 1
a90 1
            if (action.equals(ACTION))
d92 5
a96 8
		validAction = true;
		Enumeration paramNames =
		    ctx.getRequest().getParameterNames();
		String paramName;
		while (paramNames.hasMoreElements())
		{
		    paramName = (String) paramNames.nextElement();
		    if (paramName.startsWith("reason_"))
d98 10
a107 26
			String reason = ctx.getForm(paramName);
			if (DEBUG) Log.debug("PjctNewsAppvlRsn: reason= " + reason);
			String newsID = paramName.substring(7);
                        if (DEBUG) Log.debug("newsID=" + newsID);

                        AccessControlList acl = getACL(ctx);
                        NewsItem newsItem = NewsItemPeer.getInstance(newsID);

			//Send email to the owners.
			User disapprovingUser =
                            UserPeer.getInstance(acl.getUserID());
			String subject = "NewsItem for Project "
			                 + currentProject.getName()
					 + " disapproved.";
			StringBuffer body = new StringBuffer();
			body.append("Sorry, your submission of the news item '")
			    .append(newsItem.getHeadline()).append("' for project ");
			body.append(currentProject.getName()).append(" has been disapproved for the following reason: \n\n");
			body.append(reason).append("\n\n");
			body.append("For more information, please contact ")
			    .append(disapprovingUser.getRealName())
                            .append(" (").append(disapprovingUser.getEmail())
                            .append(")");
			HelmEmailer emailer = new HelmEmailer();
			emailer.sendEmail(newsItem.getProposedByUser().
			                  getEmail(), subject, body.toString());
d109 2
a110 2
                        // TODO: Add rationale for disapproval.
		        newsItem.disapprove(acl, "");
d112 3
a114 4
		}
		String url = 
		    currentProject.getProjectPageURL("ProjectNews").toString();
		redirectToURL(ctx, url);
d119 13
a131 11
        catch (RedirectException e)
        {
           throw e;
        }
        catch (Exception e)
        {
	       String msg = "ProjectNewsApprovalReason error: " +
                   e.getMessage();
	       Log.error(msg, e);
	       throw new HandlerException(msg);
        }
d133 1
a133 2
        return templateName;
   }
d135 2
@


1.1
log
@initial revision
@
text
@d55 2
a56 1
import org.webmacro.util.*;
a58 2
import com.workingdogs.village.*;

d65 2
a68 1
import org.tigris.helm.domain.*;
d71 5
a75 5
public class ProjectNewsApprovalReason extends HelmServlet {
    public static final  String versionID = "$Id: ProjectNewsApproval.java,v 1.5 2001/01/26 18:29:05 edk Exp $";
    private static Log log = new Log("ProjectNewsApprovalReason", "ProjectNewsApprovalReason");
    private static boolean debug = true;
    private static String ACTION="Disapprove";
d93 1
a93 1
	    if (debug) log.info("PjctNewsAppvlRsn:: action=" + action );
d113 1
a113 1
			if (debug) log.info("PjctNewsAppvlRsn: reason= " + reason);
d115 1
a115 1
                        if (debug) log.info("newsID=" + newsID);
d117 2
a118 3
                        AccessControlList acl = getACL(ctx, conn);
                        NewsItem newsItem = 
                            new NewsItem(conn, dMgr, newsID);
d121 2
a122 1
			User disapprovingUser = User.getInstance(conn, dMgr, acl.getUserID());
d132 4
a135 3
			    .append(disapprovingUser.getName()).append(" (")
			    .append(disapprovingUser.getEmail()).append(")");
			HelmEmailer emailer = new HelmEmailer(conn, dMgr);
d139 2
a140 1
		        newsItem.disapprove(acl);
d156 4
a159 4
	       log.exception(e);
	       String message = "ProjectNewsApproval: " + e.getMessage();
	       if (debug) log.debug(message);
	       ctx.put("message", message);
a161 2
        if (debug) log.info("ProjectNewsApprovalReason:  done");

d164 1
a164 2
  
} /* end class ProjectNewsApprovalReason */
@

