head	1.13;
access;
symbols
	TIGRIS_1_1_0RC2:1.3
	TIGRIS_1_1_0RC1:1.3
	TIGRIS_1_1:1.3.0.4
	TIGRIS_1_0_8:1.3
	TIGRIS_1_0_8RC3:1.3
	TIGRIS_1_0_8RC2:1.3
	TIGRIS_1_0_8RC1:1.3
	TIGRIS_1_0_7:1.3
	TIGRIS_1_0_7RC3:1.3
	TIGRIS_1_0_7RC2:1.3
	TIGRIS_1_0_7RC1:1.3
	TIGRIS_1_0_6:1.3
	TIGRIS_1_0_6RC5:1.3
	TIGRIS_1_0_6RC4:1.3
	TIGRIS_1_0_6RC3:1.3
	TIGRIS_1_0_6RC2:1.3
	TIGRIS_1_0_6RC1:1.3
	TIGRIS_1_0_5:1.3
	TIGRIS_1_0_5RC6:1.3
	TIGRIS_1_0_5RC5:1.3
	TIGRIS_1_0_5RC4:1.3
	TIGRIS_1_0_5RC3:1.3
	TIGRIS_1_0_5RC2:1.3
	TIGRIS_1_0_5RC1:1.3
	TIGRIS_1_0_4:1.3
	TIGRIS_1_0_3:1.3
	TIGRIS_1_0_2:1.3
	TIGRIS_1_0_1:1.3
	TIGRIS_1_0:1.3.0.6
	TIGRIS_1_0_0:1.3
	TIGRIS_1_0_0_RC1:1.3.0.2
	dlr:1.1.1
	HELM_PEER_PORT_BRANCH:1.1.1.1;
locks; strict;
comment	@# @;


1.13
date	2001.08.28.17.45.17;	author leonardr;	state Exp;
branches;
next	1.12;

1.12
date	2001.08.11.09.08.07;	author dlr;	state Exp;
branches;
next	1.11;

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

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

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

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

1.7
date	2001.06.02.01.17.00;	author elicia;	state Exp;
branches;
next	1.6;

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

1.5
date	2001.05.23.01.22.12;	author ms;	state Exp;
branches;
next	1.4;

1.4
date	2001.05.23.00.43.49;	author ms;	state Exp;
branches;
next	1.3;

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

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

1.1
date	2001.02.06.20.00.53;	author elicia;	state Exp;
branches
	1.1.1.1
	1.1.2.1;
next	;

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

1.1.2.1
date	2001.02.17.00.19.02;	author elicia;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2001.02.20.19.59.57;	author elicia;	state Exp;
branches;
next	;


desc
@@


1.13
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 CollabNet (http://www.Collab.Net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */


package org.tigris.helm.project;

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

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

import org.apache.velocity.context.Context;

import org.tigris.helm.tool.Emailer;

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

public class ProjectNewsEditAdvanced extends HelmServlet
{
    private static final boolean debug = true;

    private static String SUBMIT_CHANGES_ACTION="Submit Changes";

    private static String INVALID_PUBLISH_DATE_ERROR =
        "Publish date is not valid.";

    private static String REMOVE_DATE_BEFORE_CURRENT_DATE_ERROR = 
        "The remove date should be later than the current date.";

    private static String REMOVE_DATE_TOO_CLOSE_TO_PUBLISH_DATE_ERROR =
        "The remove date should be at least one day after the publish date.";

    private static String INVALID_REMOVE_DATE_ERROR =
        "Remove date is not valid.";

    protected String processRequest(Context context)
        throws NestableException, RedirectException
    {
        String templateName = super.processRequest(context);
        String action = getAction(context);

        int month, year;

        try
        {
            Project currentProject = getCurrentProject(context);
            User loginUser = getLoginUser(context);
            AccessControlList acl = loginUser.getACL();
      
            // Get current newsItem to edit
            String newsID = ContextAPI.getParameter(context, "newsID");
            NewsItem newsItem = (NewsItem)NewsItemPeer.getInstance(newsID);
            context.put("newsItem", newsItem);

            // Put current date into context as a default
            // Default remove month is current month plus one
            GregorianCalendar current = new GregorianCalendar();
      
            month = current.get(Calendar.MONTH) + 1;
            String currentMonth = Integer.toString(month);
            year = current.get(Calendar.YEAR);
            String currentYear = Integer.toString(year);
            String publishYear;
            if (month == 12)
            {
                context.put("isDecember", "");
                publishYear = ContextAPI.processField(context, "publish_year");
            }
            else
            {
                publishYear= currentYear;
            }
      
            String currentDay = 
                Integer.toString(current.get(Calendar.DAY_OF_MONTH));

            context.put("current_month", currentMonth);
            context.put("current_day", currentDay);
            context.put("current_year", currentYear);
            context.put("next_year", Integer.toString(++year));
            context.put("default_remove_month", 
                    Integer.toString(current.get(Calendar.MONTH) +2));

            if ("none".equals(action))
            {
                // Get date values from database
                String publishDateString = newsItem.getPublishDate().toString();
                String removeDateString = newsItem.getRemoveDate().toString();
                String publish_month = publishDateString.substring(5,7);
                String publish_day = publishDateString.substring(8,10);
                String publish_year = publishDateString.substring(0,4);
                String remove_month = removeDateString.substring(5,7);
                String remove_day = removeDateString.substring(8,10);
                String remove_year = removeDateString.substring(0,4);
          
                // Put date values in context for display
                context.put("publish_month", publish_month);
                context.put("publish_day", publish_day);
                context.put("publish_year", publish_year);
                context.put("remove_month", remove_month);
                context.put("remove_day", remove_day);
                context.put("remove_year", remove_year);

                // If publish date has already passed, 
                // Default to publish = "immediately"
                if (newsItem.getPublishDate().compareTo(new Date()) <= 0)
                {
                    context.put("publish", "immediately");
                } else {
                    context.put("publish", "date");
                }
	      
                // If remove date is the far future date,
                // Default to remove = "never"
                if (remove_year.equals("3999"))
                {
                    context.put("remove", "never");
                } else {
                    context.put("remove", "date");
                }
            }

            else if (SUBMIT_CHANGES_ACTION.equals(action))
            {
 
                // Get user-entered values
                String publish = ContextAPI.processField(context, "publish");
                String publishMonth = ContextAPI.processField
                    (context, "publish_month");
                String publishDay = ContextAPI.processField
                    (context, "publish_day");
                String remove = ContextAPI.processField
                    (context, "remove");
                String removeMonth = ContextAPI.processField
                    (context, "remove_month");
                String removeDay = ContextAPI.processField
                    (context, "remove_day");
                String removeYear = ContextAPI.processField
                    (context, "remove_year");

                // Do update - publish and remove fields
                Date publishDate = null;
                Date removeDate = null;
                Calendar cal = new GregorianCalendar();
                cal.setLenient(false);

                // Format publish date
                // If user selected "immediately", set to today's date
                if (publish.equals("immediately"))
                {
                    publishDate = current.getTime(); 
                }
                else 
                {
                    cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(publishDay));
                    cal.set(Calendar.MONTH, Integer.parseInt(publishMonth)-1);
                    cal.set(Calendar.YEAR, Integer.parseInt(publishYear));    
                    try
                    {
                        publishDate = cal.getTime();
                    }
                    catch (IllegalArgumentException e)
                    {
                        ContextAPI.addValidationError
                            (context, INVALID_PUBLISH_DATE_ERROR);
                    }
                } 
	  
                // Format remove date
                // If they set removeDate to "never", set to future date 3999-01-01 
                if (remove.equals("never"))
                {
                    DateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd");
                    removeDate = myFormat.parse("3999-01-01");
                }
                else 
                {
                    cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(removeDay));
                    cal.set(Calendar.MONTH, Integer.parseInt(removeMonth)-1);
                    cal.set(Calendar.YEAR, Integer.parseInt(removeYear));    
                    try
                    {
                        removeDate = cal.getTime();
                        // If remove date is before publish date, show error message
                        if (removeDate.compareTo(publishDate) <= 0)
                        {
                            ContextAPI.addValidationError
                                (context, 
                                 REMOVE_DATE_TOO_CLOSE_TO_PUBLISH_DATE_ERROR);
                        } 
                        else if (removeDate.compareTo(new Date()) <= 0) 
                        {
                            ContextAPI.addValidationError
                                (context, 
                                 REMOVE_DATE_BEFORE_CURRENT_DATE_ERROR);
                        }
                    }
                    catch (IllegalArgumentException e)
                    {
                        ContextAPI.addValidationError
                            (context, INVALID_REMOVE_DATE_ERROR);
                    }
                    catch (Exception e)
                    {
                        Log.error(e);
                        String message = "NewsItemView: " + e.getMessage ();
                        if (debug) Log.debug (message);
                    }

               
                } 
 
                // Check for errors
                if (ContextAPI.isValidUserInput(context))
                {
                    // If no errors, do update
                    // TODO: Remove hardcoded priority.
                    newsItem.edit(acl, null, null, null, 
                                  publishDate, removeDate, 
                                  null, null, null);
                    redirectToURL(context, "ProjectNewsList");

                } 
                else 
                {
                    context.put("errors", "yes");
                }
            }
        }
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            Log.error (e);
            String message = "ProjectNewsAddAdd: " + e.getMessage ();
            if (debug) Log.info (message);
            context.put ("message", message);
        }
    
        if (debug) Log.debug ("ProjectNewsAddAdd:  done");
    
        return templateName;
    }     
}				/* end class ProjectNewsAddAdvanced */
@


1.12
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d98 1
a98 1
            String newsID = getParameter(context, "newsID");
@


1.11
log
@Removed Joist references.
@
text
@d55 1
a55 1
import org.apache.turbine.util.TurbineException;
d84 1
a84 1
        throws TurbineException, RedirectException
@


1.10
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d59 1
a59 1
import org.joist.mail.Emailer;
@


1.9
log
@Cleanup for port to new error handling system.
@
text
@a50 1
import java.util.Date;
a51 1
import java.sql.*;
a55 1
import org.apache.turbine.util.TurbineException;
a58 1
import org.joist.security.*;
d67 1
a67 1
    private static boolean debug = true;
@


1.8
log
@Ported servlets to new error-handling mechanism.
@
text
@d118 1
a118 1
                publishYear = processField(context, "publish_year");
d178 13
a190 7
                String publish = processField(context, "publish");
                String publishMonth = processField(context, "publish_month");
                String publishDay = processField(context, "publish_day");
                String remove = processField(context, "remove");
                String removeMonth = processField(context, "remove_month");
                String removeDay = processField(context, "remove_day");
                String removeYear = processField(context, "remove_year");
@


1.7
log
@added imageURL and original article URL fields
@
text
@d17 1
a17 1
 * software developed by Collab.Net (http://www.Collab.Net/)."
d27 1
a27 1
 * permission of Collab.Net.
d32 1
a32 1
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d67 1
a67 1
import org.tigris.helm.om.*;
d71 3
a73 1
  private static boolean debug = true;
d75 2
a76 1
  private static String SUBMIT_CHANGES_ACTION="Submit Changes";
d78 2
a79 5
  protected String processRequest(Context ctx)
    throws TurbineException, RedirectException
  {
    if (debug)
      Log.debug ("ProjectNewsAddAdvanced: started!");
d81 2
a82 2
    String templateName = super.processRequest(ctx);
    String action = (String) ctx.get ("action");
d84 2
a85 2
    if (debug)
        Log.debug ("ProjectNewsAddAdvanced: action=" + action);
d87 5
a91 2
    ArrayList validationErrors = new ArrayList ();
    ArrayList missingFields = new ArrayList ();
d93 1
a93 1
    int month, year;
d95 5
a99 5
    try
    {
      Project currentProject = getCurrentProject(ctx);
      User loginUser = getLoginUser(ctx);
      AccessControlList acl = loginUser.getACL();
d101 8
a108 8
      // Get current newsItem to edit
      String newsID = getParameter(ctx, "newsID");
      NewsItem newsItem = (NewsItem)NewsItemPeer.getInstance(newsID);
      ctx.put("newsItem", newsItem);

      // Put current date into ctx as a default
      // Default remove month is current month plus one
      GregorianCalendar current = new GregorianCalendar();
d110 14
a123 14
      month = current.get(Calendar.MONTH) + 1;
      String currentMonth = Integer.toString(month);
      year = current.get(Calendar.YEAR);
      String currentYear = Integer.toString(year);
      String publishYear;
      if (month == 12)
      {
          ctx.put("isDecember", "");
          publishYear = processField(ctx, "publish_year");
      }
      else
      {
          publishYear= currentYear;
      }
d125 2
a126 2
      String currentDay = 
	    Integer.toString(current.get(Calendar.DAY_OF_MONTH));
d128 18
a145 18
      ctx.put("current_month", currentMonth);
      ctx.put("current_day", currentDay);
      ctx.put("current_year", currentYear);
      ctx.put("next_year", Integer.toString(++year));
      ctx.put("default_remove_month", 
		  Integer.toString(current.get(Calendar.MONTH) +2));

      if (action.equals("none"))
      {
          // Get date values from database
          String publishDateString = newsItem.getPublishDate().toString();
          String removeDateString = newsItem.getRemoveDate().toString();
          String publish_month = publishDateString.substring(5,7);
          String publish_day = publishDateString.substring(8,10);
          String publish_year = publishDateString.substring(0,4);
          String remove_month = removeDateString.substring(5,7);
          String remove_day = removeDateString.substring(8,10);
          String remove_year = removeDateString.substring(0,4);
d147 16
a162 16
          // Put date values in ctx for display
          ctx.put("publish_month", publish_month);
          ctx.put("publish_day", publish_day);
          ctx.put("publish_year", publish_year);
          ctx.put("remove_month", remove_month);
          ctx.put("remove_day", remove_day);
          ctx.put("remove_year", remove_year);

	      // If publish date has already passed, 
	      // Default to publish = "immediately"
	      if (newsItem.getPublishDate().compareTo(new Date()) <= 0)
          {
	          ctx.put("publish", "immediately");
          } else {
	          ctx.put("publish", "date");
          }
d164 9
a172 9
	      // If remove date is the far future date,
	      // Default to remove = "never"
	      if (remove_year.equals("3999"))
          {
	          ctx.put("remove", "never");
          } else {
	          ctx.put("remove", "date");
          }
      }
d174 2
a175 2
      else if (action.equals(SUBMIT_CHANGES_ACTION))
      {
d177 36
a212 33
          // Get user-entered values
          String publish = processField(ctx, "publish");
          String publishMonth = processField(ctx, "publish_month");
          String publishDay = processField(ctx, "publish_day");
          String remove = processField(ctx, "remove");
          String removeMonth = processField(ctx, "remove_month");
          String removeDay = processField(ctx, "remove_day");
          String removeYear = processField(ctx, "remove_year");

          // Do update - publish and remove fields
          Date publishDate = null;
          Date removeDate = null;
          Calendar cal = new GregorianCalendar();
          cal.setLenient(false);

          // Format publish date
	      // If user selected "immediately", set to today's date
	      if (publish.equals("immediately"))
	      {
              publishDate = current.getTime(); 
          } else {
              cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(publishDay));
              cal.set(Calendar.MONTH, Integer.parseInt(publishMonth)-1);
              cal.set(Calendar.YEAR, Integer.parseInt(publishYear));    
              try
	          {
                  publishDate = cal.getTime();
              }
              catch (IllegalArgumentException e)
              {
		          validationErrors.add("Publish date is not valid.");
              }
	      } 
d214 40
a253 31
	      // Format remove date
          // If they set removeDate to "never", set to future date 3999-01-01 
	      if (remove.equals("never"))
	      {
 	          DateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd");
	          removeDate = myFormat.parse("3999-01-01");
          } else {
              cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(removeDay));
              cal.set(Calendar.MONTH, Integer.parseInt(removeMonth)-1);
              cal.set(Calendar.YEAR, Integer.parseInt(removeYear));    
              try
              {
                  removeDate = cal.getTime();
                  // If remove date is before publish date, show error message
                  if (removeDate.compareTo(publishDate) <= 0)
                  {
                      validationErrors.add("The remove date should be at least one day after the publish date.");
                  } else if (removeDate.compareTo(new Date()) <= 0) {
                      validationErrors.add("The remove date should be later than the current date.");
                  }
              }
              catch (IllegalArgumentException e)
              {
		          validationErrors.add("Remove date is not valid.");
              }
              catch (Exception e)
              {
                  Log.error(e);
                  String message = "NewsItemView: " + e.getMessage ();
                  if (debug) Log.debug (message);
              }
d256 1
a256 1
	      } 
d258 28
a285 27
	      // Check for errors
          if (isValidUserInput(missingFields, validationErrors))
	      {
             // If no errors, do update
	         // TODO: Remove hardcoded priority.
	         newsItem.edit(acl, null, null, null, 
                           publishDate, removeDate, 
                           null, null, null);
             redirectToURL(ctx, "ProjectNewsList");

          } else {
              reportInvalidUserInput(ctx, missingFields, validationErrors);
	          ctx.put("errors", "yes");
          }
      }
    }
    catch (RedirectException e)
    {
       throw e;
    }
    catch (Exception e)
    {
      Log.error (e);
      String message = "ProjectNewsAddAdd: " + e.getMessage ();
      if (debug) Log.info (message);
      ctx.put ("message", message);
    }
d287 1
a287 1
    if (debug) Log.debug ("ProjectNewsAddAdd:  done");
d289 2
a290 5
    return templateName;

  }
      

@


1.6
log
@Ported Helm from WebMacro to Velocity.
@
text
@d249 2
a250 1
                           publishDate, removeDate, null);
@


1.5
log
@fixed npe in year
@
text
@d57 2
d60 1
a60 1
import org.webmacro.servlet.*;
d75 2
a76 2
  protected String processRequest (Connection conn, WebContext ctx)
    throws HandlerException, RedirectException
d81 1
a81 1
    String templateName = super.processRequest (conn, ctx);
d99 1
a99 1
      String newsID = ctx.getForm("newsID");
@


1.4
log
@only let next year be specified in december of previous year
@
text
@d107 3
d113 5
d119 1
a119 1

a121 2
      year = current.get(Calendar.YEAR);
      String currentYear = Integer.toString(year);
a175 1
          String publishYear = processField(ctx, "publish_year");
@


1.3
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d88 2
d104 8
a111 2
      String currentMonth = 
	    Integer.toString(current.get(Calendar.MONTH) +1);
d114 3
a116 2
      String currentYear = 
	    Integer.toString(current.get(Calendar.YEAR));
d120 1
@


1.2
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d65 1
a65 3
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;

@


1.1
log
@added these servlets as advanced options to provide publish and removal dates for news items
@
text
@d50 1
a51 1
import java.util.*;
d56 2
a57 1
import org.webmacro.util.*;
d61 1
d64 3
a66 1
import org.tigris.helm.domain.*;
d69 1
a69 1
public class ProjectNewsEditAdvanced extends org.tigris.helm.security.HelmServlet
a70 3
  public static final String versionID =
    "$Id: ProjectNewsAdd.java,v 1.22 2001/02/02 01:10:22 elicia Exp $";
  private static Log log = new Log ("ProjectNewsAddAdvanced", "PrjNwsAddAdv");
a74 4

    /**
     *  Display and process the login screen.
     */
d79 1
a79 1
      log.debug ("ProjectNewsAddAdvanced: started!");
d85 1
a85 1
        log.debug ("ProjectNewsAddAdvanced: action=" + action);
d93 2
a94 1
      AccessControlList acl = getACL(ctx, conn);
d98 1
a98 1
      NewsItem newsItem = new NewsItem(conn, dMgr, newsID);
d119 8
a126 8
          String publishOnString = newsItem.getPublishOn();
          String removeOnString = newsItem.getRemoveOn();
          String publish_month = publishOnString.substring(0,2);
          String publish_day = publishOnString.substring(3,5);
          String publish_year = publishOnString.substring(6,10);
          String remove_month = removeOnString.substring(0,2);
          String remove_day = removeOnString.substring(3,5);
          String remove_year = removeOnString.substring(6,10);
d138 1
a138 1
	      if (newsItem.getPublishOnAsDate().compareTo(new Date()) <= 0)
d206 7
d218 7
a224 7
              // If remove date is before publish date, show error message
	          if (removeDate.compareTo(publishDate) <= 0)
	          {
	              validationErrors.add("The remove date should be at least one day after the publish date.");
	          } else if (removeDate.compareTo(new Date()) <= 0) {
	              validationErrors.add("The remove date should be later than the current date.");
	          }
d235 1
a235 1
             redirectToURL(ctx, "ProjectNews");
d249 1
a249 1
      log.exception (e);
d251 1
a251 1
      if (debug) log.info (message);
d255 1
a255 1
    if (debug) log.debug ("ProjectNewsAddAdd:  done");
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d50 1
a51 1
import java.util.Date;
d56 1
a56 2
import org.apache.turbine.util.Log;

a59 1
import org.joist.mail.Emailer;
d62 1
a62 3
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
d65 1
a65 1
public class ProjectNewsEditAdvanced extends HelmServlet
d67 3
d74 4
d82 1
a82 1
      Log.debug ("ProjectNewsAddAdvanced: started!");
d88 1
a88 1
        Log.debug ("ProjectNewsAddAdvanced: action=" + action);
d96 1
a96 2
      User loginUser = getLoginUser(ctx);
      AccessControlList acl = loginUser.getACL();
d100 1
a100 1
      NewsItem newsItem = (NewsItem)NewsItemPeer.getInstance(newsID);
d121 8
a128 8
          String publishDateString = newsItem.getPublishDate().toString();
          String removeDateString = newsItem.getRemoveDate().toString();
          String publish_month = publishDateString.substring(5,7);
          String publish_day = publishDateString.substring(8,10);
          String publish_year = publishDateString.substring(0,4);
          String remove_month = removeDateString.substring(5,7);
          String remove_day = removeDateString.substring(8,10);
          String remove_year = removeDateString.substring(0,4);
d140 1
a140 1
	      if (newsItem.getPublishDate().compareTo(new Date()) <= 0)
a207 7
                  // If remove date is before publish date, show error message
                  if (removeDate.compareTo(publishDate) <= 0)
                  {
                      validationErrors.add("The remove date should be at least one day after the publish date.");
                  } else if (removeDate.compareTo(new Date()) <= 0) {
                      validationErrors.add("The remove date should be later than the current date.");
                  }
d213 7
a219 7
              catch (Exception e)
              {
                  Log.error(e);
                  String message = "NewsItemView: " + e.getMessage ();
                  if (debug) Log.debug (message);
              }

d230 1
a230 1
             redirectToURL(ctx, "ProjectNewsList");
d244 1
a244 1
      Log.error (e);
d246 1
a246 1
      if (debug) Log.info (message);
d250 1
a250 1
    if (debug) Log.debug ("ProjectNewsAddAdd:  done");
@


1.1.2.1
log
@split add and edit methods into two steps-- advanced options are optional
@
text
@d50 1
a51 1
import java.util.Date;
d56 1
a56 2
import org.apache.turbine.util.Log;

a59 1
import org.joist.mail.Emailer;
d62 1
a62 3
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
d65 1
a65 1
public class ProjectNewsEditAdvanced extends HelmServlet
d67 3
d74 4
d82 1
a82 1
      Log.debug ("ProjectNewsAddAdvanced: started!");
d88 1
a88 1
        Log.debug ("ProjectNewsAddAdvanced: action=" + action);
d96 1
a96 2
      User loginUser = getLoginUser(ctx);
      AccessControlList acl = loginUser.getACL();
d100 1
a100 1
      NewsItem newsItem = (NewsItem)NewsItemPeer.getInstance(newsID);
d121 8
a128 8
          String publishDateString = newsItem.getPublishDate().toString();
          String removeDateString = newsItem.getRemoveDate().toString();
          String publish_month = publishDateString.substring(5,7);
          String publish_day = publishDateString.substring(8,10);
          String publish_year = publishDateString.substring(0,4);
          String remove_month = removeDateString.substring(5,7);
          String remove_day = removeDateString.substring(8,10);
          String remove_year = removeDateString.substring(0,4);
d140 1
a140 1
	      if (newsItem.getPublishDate().compareTo(new Date()) <= 0)
a207 7
                  // If remove date is before publish date, show error message
                  if (removeDate.compareTo(publishDate) <= 0)
                  {
                      validationErrors.add("The remove date should be at least one day after the publish date.");
                  } else if (removeDate.compareTo(new Date()) <= 0) {
                      validationErrors.add("The remove date should be later than the current date.");
                  }
d213 7
d230 1
a230 1
             redirectToURL(ctx, "ProjectNewsList");
d244 1
a244 1
      Log.error (e);
d246 1
a246 1
      if (debug) Log.info (message);
d250 1
a250 1
    if (debug) Log.debug ("ProjectNewsAddAdd:  done");
@


1.1.2.2
log
@added exception handling
@
text
@a217 7
              catch (Exception e)
              {
                  Log.error(e);
                  String message = "NewsItemView: " + e.getMessage ();
                  if (debug) Log.debug (message);
              }

@


