commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prick...@apache.org
Subject cvs commit: jakarta-commons-sandbox/periodicity/src/velocity/test Event_detail.vm
Date Thu, 28 Mar 2002 08:49:14 GMT
prickett    02/03/28 00:49:14

  Modified:    periodicity build.xml
               periodicity/conf/build build.jars.properties deps.list
               periodicity/src/velocity/test Event_detail.vm
  Added:       periodicity/src/java/org/apache/commons/periodicity/turbine/actions
                        EvtDoJrlFBTestAction.java EvtDoJrlTestAction.java
                        EvtDoTestAction.java NoAlarmTestAction.java
                        SaveEventTestAction.java
               periodicity/src/java/org/apache/commons/periodicity/util
                        ICalSessionKeys.java RunDataUtils.java
  Log:
  Added code to save the event to a database via a web browser witha a set of
  Turbine actions.
  
  Added a dependency on the servlet jar file.
  
  Revision  Changes    Path
  1.21      +1 -0      jakarta-commons-sandbox/periodicity/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/build.xml,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- build.xml	26 Mar 2002 10:15:13 -0000	1.20
  +++ build.xml	28 Mar 2002 08:49:13 -0000	1.21
  @@ -31,6 +31,7 @@
       <pathelement location="${commons-collections.jar}"/>
       <pathelement location="${commons-lang.jar}"/>
       <pathelement location="${junit.jar}"/>
  +    <pathelement location="${servlet.jar}"/>
       <pathelement location="${stratum.jar}"/>
       <pathelement location="${tdk.jar}"/>
       <pathelement location="${torque.jar}"/>
  
  
  
  1.2       +1 -0      jakarta-commons-sandbox/periodicity/conf/build/build.jars.properties
  
  Index: build.jars.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/conf/build/build.jars.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.jars.properties	25 Mar 2002 09:24:17 -0000	1.1
  +++ build.jars.properties	28 Mar 2002 08:49:13 -0000	1.2
  @@ -8,6 +8,7 @@
   commons-lang.jar = ${lib.repo}/commons-lang-0.1-dev.jar
   jdbc.jar = ${lib.repo}/jdbc2_0-stdext.jar
   junit.jar = ${lib.repo}/junit-3.7.jar
  +servlet.jar= ${lib.repo}/servlet-2.2.jar
   stratum.jar = ${lib.repo}/stratum-0.1-dev.jar
   torque.jar=${lib.repo}/torque-3.0-dev.jar
   tdk.jar= ${lib.repo}/tdk.jar
  
  
  
  1.2       +1 -0      jakarta-commons-sandbox/periodicity/conf/build/deps.list
  
  Index: deps.list
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/conf/build/deps.list,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- deps.list	25 Mar 2002 09:24:17 -0000	1.1
  +++ deps.list	28 Mar 2002 08:49:13 -0000	1.2
  @@ -4,6 +4,7 @@
   jdbc2_0-stdext.jar
   junit-3.7.jar
   log4j-1.1.3.jar
  +servlet-2.2.jar
   stratum-0.1-dev.jar
   torque-3.0-dev.jar
   turbine-2.2-b2-dev.jar
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/java/org/apache/commons/periodicity/turbine/actions/EvtDoJrlFBTestAction.java
  
  Index: EvtDoJrlFBTestAction.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.commons.periodicity.turbine.actions;
  
  import javax.servlet.http.HttpServletRequest;
  import org.apache.turbine.util.RunData;
  import org.apache.velocity.context.Context;
  import org.apache.turbine.util.Log;
  import org.apache.commons.periodicity.util.TestTemplateParams;
  import org.apache.commons.periodicity.util.RunDataUtils;
  import org.apache.commons.periodicity.util.ICalendarException;
  import org.apache.commons.periodicity.ical.vobjects.VEvent;
  import org.apache.commons.periodicity.ical.properties.Organizer;
  import org.apache.commons.periodicity.ical.properties.UID;
  import org.apache.commons.periodicity.ical.properties.URLProp;
  
  public class EvtDoJrlFBTestAction extends NoAlarmTestAction 
  {
      public void doPerform(RunData data, Context context) throws Exception
      {
          if(data != null && context != null)
          {
              Log.debug(
                     "context and data are not null so we will save the event");
              VEvent event = RunDataUtils.getCurrentEvent(data);
              if(event == null)
              {
                  event = new VEvent();
              }
              setValuesFromWeb(data, event);
          }
          else if(data == null)
          {
              Log.debug("data == null");
          }
          else if(context == null)
          {
              Log.debug("context == null");
          }
          else
          {
              Log.debug("Some other error has occured cannot save event");
          }    
      }
  
      protected void setValuesFromWeb(RunData data, VEvent event) 
             throws ICalendarException
      {
          super.setValuesFromWeb(data, event);
          if(data != null && event != null)
          {
              HttpServletRequest request = data.getRequest();
              if(request != null)
              {
                  String rawOrganizer = request.getParameter(
                         TestTemplateParams.ORGANIZER_PARAM);
                  if(rawOrganizer != null)
                  {
                      Organizer organizer = new Organizer(rawOrganizer);
                      String rawOrganizerName = request.getParameter(
                             TestTemplateParams.ORGANIZER_NAME_PARAM);
                      if(rawOrganizerName != null)
                      {
                          organizer.setCommonName(rawOrganizerName);
                      }
                      String rawOrganizerDirectory = request.getParameter(
                             TestTemplateParams.ORGANIZER_DIRECTORY_PARAM);
                      if(rawOrganizerDirectory != null)
                      {
                          organizer.setDirectoryParameter(rawOrganizerDirectory);
                      }
                      String rawOrganizerSentby = request.getParameter(
                             TestTemplateParams.ORGANIZER_SENTBY_PARAM);
                      if(rawOrganizerSentby != null)
                      {
                          organizer.setSentByParameter(rawOrganizerSentby);
                      }
                      String rawOrganizerLang = request.getParameter(
                             TestTemplateParams.ORGANIZER_LANG_PARAM);
                      if(rawOrganizerLang != null)
                      {
                          organizer.setLanguageParameter(rawOrganizerLang);
                      }
                      event.setOrganizerProp(organizer);
                  }
                  else
                  {
                      event.setOrganizerProp(null);
                  }
                  String rawUid = request.getParameter(
                         TestTemplateParams.UID_PARAM);
                  if(rawUid != null)
                  {
                      UID uid = new UID(rawUid);
                      event.setUIDProp(uid);
                  }
                  else
                  {
                      event.setUIDProp(null);
                  }
                  String rawUrl = request.getParameter(
                         TestTemplateParams.URL_PARAM);
                  if(rawUrl != null)
                  {
                      URLProp url = new URLProp(rawUrl);
                      event.setURLProp(url);
                  }
                  else
                  {
                      event.setURLProp(null);
                  }    
              }
          }    
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/java/org/apache/commons/periodicity/turbine/actions/EvtDoJrlTestAction.java
  
  Index: EvtDoJrlTestAction.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.commons.periodicity.turbine.actions;
  
  import java.util.GregorianCalendar;
  import javax.servlet.http.HttpServletRequest;
  import org.apache.turbine.util.RunData;
  import org.apache.velocity.context.Context;
  import org.apache.turbine.util.Log;
  import org.apache.commons.periodicity.util.TestTemplateParams;
  import org.apache.commons.periodicity.util.RunDataUtils;
  import org.apache.commons.periodicity.util.ICalendarException;
  import org.apache.commons.periodicity.ical.vobjects.VEvent;
  import org.apache.commons.periodicity.ical.properties.ClassProp;
  import org.apache.commons.periodicity.ical.properties.Description;
  import org.apache.commons.periodicity.ical.properties.RecurID;
  import org.apache.commons.periodicity.ical.properties.Sequence;
  import org.apache.commons.periodicity.ical.properties.Status;
  import org.apache.commons.periodicity.ical.properties.Summary;
  
  public class EvtDoJrlTestAction extends EvtDoJrlFBTestAction 
  {
      public void doPerform(RunData data, Context context) throws Exception
      {
          if(data != null && context != null)
          {
              Log.debug(
                     "context and data are not null so we will save the event");
              VEvent event = RunDataUtils.getCurrentEvent(data);
              if(event == null)
              {
                  event = new VEvent();
              }
              setValuesFromWeb(data, event);
          }
          else if(data == null)
          {
              Log.debug("data == null");
          }
          else if(context == null)
          {
              Log.debug("context == null");
          }
          else
          {
              Log.debug("Some other error has occured cannot save event");
          }    
      }
  
      protected void setValuesFromWeb(RunData data, VEvent event)
             throws ICalendarException
      {
          super.setValuesFromWeb(data, event);
          if(data != null && event != null)
          {
              HttpServletRequest request = data.getRequest();
              if(request != null)
              {
                  String rawClassify = request.getParameter(
                         TestTemplateParams.CLASSIFICATION_PARAM);
                  if(rawClassify != null)
                  {
                      ClassProp classify = new ClassProp(rawClassify);
                      event.setClassification(classify);
                  }
                  else
                  {
                      event.setClassification(null);
                  }
                  String rawDesc = request.getParameter(
                         TestTemplateParams.DESCRIPTION_PARAM);
                  if(rawDesc != null)
                  {
                      Description descProp = new Description(rawDesc);
                      String rawDescAltrep = request.getParameter(
                             TestTemplateParams.DESC_ALTREP_PARAM);
                      if(rawDescAltrep != null)
                      {
                          descProp.setAltRep(rawDescAltrep);
                      }
                      String rawDescLang = request.getParameter(
                             TestTemplateParams.DESC_LANG_PARAM);
                      if(rawDescLang != null)
                      {
                          descProp.setLanguageParameter(rawDescLang);
                      }
                      event.setDescProp(descProp);
                  }    
                  else
                  {
                      event.setDescProp(null);
                  }
                  String rawMonth = request.getParameter(
                         TestTemplateParams.RECURID_MONTH_PARAM);
                  String rawDate = request.getParameter(
                         TestTemplateParams.RECURID_DATE_PARAM);
                  String rawYear = request.getParameter(
                         TestTemplateParams.RECURID_YEAR_PARAM);
                  String rawHour = request.getParameter(
                         TestTemplateParams.RECURID_HOUR_PARAM);
                  String rawMinute = request.getParameter(
                         TestTemplateParams.RECURID_MINUTE_PARAM);
                  if(rawMonth != null && rawDate != null && rawYear != null &&
                         rawHour != null && rawMinute != null)
                  {
                      Integer month = Integer.valueOf(rawMonth);
                      Integer date = Integer.valueOf(rawDate);
                      Integer year = Integer.valueOf(rawYear);
                      Integer hour = Integer.valueOf(rawHour);
                      Integer minute = Integer.valueOf(rawMinute);
                      if(month != null && date != null && year != null && 
                             hour != null && minute != null)
                      {
                          GregorianCalendar recuriddt = new GregorianCalendar();
                          recuriddt.set(GregorianCalendar.MONTH, 
                                 month.intValue() - 1);
                          recuriddt.set(GregorianCalendar.DATE, date.intValue());
                          recuriddt.set(GregorianCalendar.YEAR, year.intValue());
                          recuriddt.set(GregorianCalendar.HOUR_OF_DAY,
                                 hour.intValue());
                          recuriddt.set(GregorianCalendar.MINUTE, 
                                 minute.intValue());
                          RecurID recurid = new RecurID();
                          recurid.setDateTime(recuriddt);
                          String rawRange = request.getParameter(
                                 TestTemplateParams.RECURID_RANGE_PARAM);
                          if(rawRange != null)
                          {
                              recurid.setRangeParameter(rawRange);
                          }
                          String rawTzid = request.getParameter(
                                 TestTemplateParams.RECURID_TZID_PARAM);
                          if(rawTzid != null)
                          {
                              recurid.setTimeZoneID(rawTzid);
                          }
                          event.setRecurID(recurid);
                      }
                      else
                      {
                          event.setRecurID(null);
                      }
                  }
                  else
                  {
                      event.setRecurID(null);
                  }    
                  String rawSeq = request.getParameter(
                         TestTemplateParams.SEQUENCE_PARAM);
                  if(rawSeq != null)
                  {
                      Integer sequence = Integer.valueOf(rawSeq);
                      if(sequence != null)
                      {
                          Sequence seqProp = new Sequence(sequence.intValue());
                          event.setSequenceProp(seqProp);
                      }
                      else
                      {
                          event.setSequenceProp(null);
                      }
                  }
                  else
                  {
                      event.setSequenceProp(null);
                  }
                  String rawStatus = request.getParameter(
                         TestTemplateParams.STATUS_PARAM);
                  if(rawStatus != null)
                  {
                      Status status = new Status(rawStatus);
                      event.setStatusProp(status);
                  }
                  else
                  {
                      event.setStatusProp(null);
                  }
                  String rawSummary = request.getParameter(
                         TestTemplateParams.SUMMARY_PARAM);
                  if(rawSummary != null)
                  {
                      Summary summary = new Summary(rawSummary);
                      String rawSummaryAltrep = request.getParameter(
                             TestTemplateParams.SUMMARY_ALTREP_PARAM);
                      if(rawSummaryAltrep != null)
                      {
                          summary.setAltRep(rawSummaryAltrep);
                      }
                      String rawSummaryLang = request.getParameter(
                             TestTemplateParams.SUMMARY_LANG_PARAM);
                      if(rawSummaryLang != null)
                      {
                          summary.setLanguageParameter(rawSummaryLang);
                      }
                      event.setSummaryProp(summary);
                  }
                  else
                  {
                      event.setSummaryProp(null);
                  }    
              }
          }    
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/java/org/apache/commons/periodicity/turbine/actions/EvtDoTestAction.java
  
  Index: EvtDoTestAction.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.commons.periodicity.turbine.actions;
  
  import java.util.GregorianCalendar;
  import javax.servlet.http.HttpServletRequest;
  import org.apache.turbine.util.RunData;
  import org.apache.velocity.context.Context;
  import org.apache.turbine.util.Log;
  import org.apache.commons.periodicity.util.TestTemplateParams;
  import org.apache.commons.periodicity.util.RunDataUtils;
  import org.apache.commons.periodicity.util.ICalendarException;
  import org.apache.commons.periodicity.ical.vobjects.VEvent;
  import org.apache.commons.periodicity.ical.properties.GeoProp;
  import org.apache.commons.periodicity.ical.properties.Location;
  import org.apache.commons.periodicity.ical.properties.Priority;
  
  public class EvtDoTestAction extends EvtDoJrlTestAction 
  {
      public void doPerform(RunData data, Context context) throws Exception
      {
          if(data != null && context != null)
          {
              Log.debug(
                     "context and data are not null so we will save the event");
              VEvent event = RunDataUtils.getCurrentEvent(data);
              if(event == null)
              {
                  event = new VEvent();
              }
              setValuesFromWeb(data, event);
          }
          else if(data == null)
          {
              Log.debug("data == null");
          }
          else if(context == null)
          {
              Log.debug("context == null");
          }
          else
          {
              Log.debug("Some other error has occured cannot save event");
          }    
      }
  
      protected void setValuesFromWeb(RunData data, VEvent event)
             throws ICalendarException
      {
          super.setValuesFromWeb(data, event);
          if(data != null && event != null)
          {
              HttpServletRequest request = data.getRequest();
              if(request != null)
              {
                  String rawLatitude = request.getParameter(
                         TestTemplateParams.LATITUDE_PARAM);
                  String rawLongitude = request.getParameter(
                         TestTemplateParams.LONGITUDE_PARAM);
                  if(rawLatitude != null && rawLongitude != null)
                  {
                      Float latitude = Float.valueOf(rawLatitude);
                      Float longitude = Float.valueOf(rawLongitude);
                      if(latitude != null && longitude != null)
                      {
                          GeoProp geo = new GeoProp(latitude.floatValue(),
                                 longitude.floatValue());
                          event.setGeoProp(geo);
                      }
                      else
                      {
                          event.setGeoProp(null);
                      }
                  }
                  else
                  {
                      event.setGeoProp(null);
                  }
                  String rawLocation = request.getParameter(
                         TestTemplateParams.LOCATION_PARAM);
                  if(rawLocation != null)
                  {
                      Location location = new Location(rawLocation);
                      String rawLocationAltrep = request.getParameter(
                             TestTemplateParams.LOCATION_ALTREP_PARAM);
                      if(rawLocationAltrep != null)
                      {
                          location.setAltRep(rawLocationAltrep);
                      }
                      String rawLocationLang = request.getParameter(
                             TestTemplateParams.LOCATION_LANG_PARAM);
                      if(rawLocationLang != null)
                      {
                          location.setLanguageParameter(rawLocationLang);
                      }
                      event.setLocationProp(location);
                  }
                  else
                  {
                      event.setLocationProp(null);
                  }    
                  String rawPriority = request.getParameter(
                         TestTemplateParams.PRIORITY_PARAM);
                  if(rawPriority != null)
                  {
                      Integer priority = Integer.valueOf(rawPriority);
                      if(priority != null)
                      {
                          Priority priorityProp = new Priority(
                                 priority.intValue());
                          event.setPriorityProp(priorityProp);
                      }
                      else
                      {
                          event.setPriorityProp(null);
                      }
                  }
                  else
                  {
                      event.setPriorityProp(null);
                  }    
              }
          }    
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/java/org/apache/commons/periodicity/turbine/actions/NoAlarmTestAction.java
  
  Index: NoAlarmTestAction.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.commons.periodicity.turbine.actions;
  
  import java.util.GregorianCalendar;
  import javax.servlet.http.HttpServletRequest;
  import org.apache.turbine.util.RunData;
  import org.apache.velocity.context.Context;
  import org.apache.turbine.modules.actions.VelocityAction;
  import org.apache.turbine.util.Log;
  import org.apache.commons.periodicity.util.TestTemplateParams;
  import org.apache.commons.periodicity.util.RunDataUtils;
  import org.apache.commons.periodicity.util.ICalendarException;
  import org.apache.commons.periodicity.ical.vobjects.VEvent;
  import org.apache.commons.periodicity.ical.properties.Dtstart;
  
  public class NoAlarmTestAction extends VelocityAction 
  {
      public void doPerform(RunData data, Context context) throws Exception
      {
          if(data != null && context != null)
          {
              Log.debug(
                     "context and data are not null so we will save the event");
              VEvent event = RunDataUtils.getCurrentEvent(data);
              if(event == null)
              {
                  event = new VEvent();
              }
              setValuesFromWeb(data, event);
          }
          else if(data == null)
          {
              Log.debug("data == null");
          }
          else if(context == null)
          {
              Log.debug("context == null");
          }
          else
          {
              Log.debug("Some other error has occured cannot save event");
          }    
      }
  
      protected void setValuesFromWeb(RunData data, VEvent event)
             throws ICalendarException
      {
          if(data != null && event != null)
          {
              HttpServletRequest request = data.getRequest();
              if(request != null)
              {
                  String rawMonth = request.getParameter(
                         TestTemplateParams.DTSTART_MONTH_PARAM);
                  String rawDate = request.getParameter(
                         TestTemplateParams.DTSTART_DATE_PARAM);
                  String rawYear = request.getParameter(
                         TestTemplateParams.DTSTART_YEAR_PARAM);
                  String rawHour = request.getParameter(
                         TestTemplateParams.DTSTART_HOUR_PARAM);
                  String rawMinute = request.getParameter(
                         TestTemplateParams.DTSTART_MINUTE_PARAM);
                  if(rawMonth != null && rawDate != null && rawYear != null &&
                         rawHour != null && rawMinute != null)
                  {
                      Integer month = Integer.valueOf(rawMonth);
                      Integer date = Integer.valueOf(rawDate);
                      Integer year = Integer.valueOf(rawYear);
                      Integer hour = Integer.valueOf(rawHour);
                      Integer minute = Integer.valueOf(rawMinute);
                      if(month != null && date != null && year != null &&
                             hour != null && minute != null)
                      {
                          GregorianCalendar startTime = new GregorianCalendar();
                          startTime.set(GregorianCalendar.MONTH,
                                 month.intValue() - 1);
                          startTime.set(GregorianCalendar.DATE, date.intValue());
                          startTime.set(GregorianCalendar.YEAR, year.intValue());
                          startTime.set(GregorianCalendar.HOUR_OF_DAY,
                                 hour.intValue());
                          startTime.set(GregorianCalendar.MINUTE, 
                                 minute.intValue());
                          Dtstart start = new Dtstart();
                          start.setDateTime(startTime);
                          String rawTzid = request.getParameter(
                                 TestTemplateParams.DTSTART_TZID_PARAM);
                          if(rawTzid != null)
                          {
                              start.setTimeZoneID(rawTzid);
                          }
                          event.setStartProp(start);
                      }    
                      else
                      {
                          event.setStartProp(null);
                      }
                  }
                  else
                  {
                      event.setStartProp(null);
                  }    
              }
          }    
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/java/org/apache/commons/periodicity/turbine/actions/SaveEventTestAction.java
  
  Index: SaveEventTestAction.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.commons.periodicity.turbine.actions;
  
  import java.util.GregorianCalendar;
  import javax.servlet.http.HttpServletRequest;
  import org.apache.turbine.util.RunData;
  import org.apache.velocity.context.Context;
  import org.apache.turbine.util.Log;
  import org.apache.commons.periodicity.util.TestTemplateParams;
  import org.apache.commons.periodicity.util.RunDataUtils;
  import org.apache.commons.periodicity.util.ICalendarException;
  import org.apache.commons.periodicity.ical.vobjects.VEvent;
  import org.apache.commons.periodicity.ical.properties.Transparency;
  import org.apache.commons.periodicity.ical.properties.Dtend;
  
  public class SaveEventTestAction extends EvtDoTestAction 
  {
      public void doPerform(RunData data, Context context) throws Exception
      {
          if(data != null && context != null)
          {
              Log.debug(
                     "context and data are not null so we will save the event");
              VEvent event = RunDataUtils.getCurrentEvent(data);
              if(event == null)
              {
                  event = new VEvent();
              }
              setValuesFromWeb(data, event);
          }
          else if(data == null)
          {
              Log.debug("data == null");
          }
          else if(context == null)
          {
              Log.debug("context == null");
          }
          else
          {
              Log.debug("Some other error has occured cannot save event");
          }    
      }
  
      protected void setValuesFromWeb(RunData data, VEvent event)
             throws ICalendarException
      {
          super.setValuesFromWeb(data, event);
          if(data != null && event != null)
          {
              HttpServletRequest request = data.getRequest();
              if(request != null)
              {
                  String rawDate = request.getParameter(
                         TestTemplateParams.END_DATE_PARAM);
                  String rawMonth = request.getParameter(
                         TestTemplateParams.END_MONTH_PARAM);
                  String rawYear = request.getParameter(
                         TestTemplateParams.END_YEAR_PARAM);
                  String rawHour = request.getParameter(
                         TestTemplateParams.END_HOUR_PARAM);
                  String rawMinute = request.getParameter(
                         TestTemplateParams.END_MINUTE_PARAM);
                  if(rawDate != null && rawMonth != null && rawYear != null &&
                         rawHour != null && rawMinute != null)
                  {
                      Integer date = Integer.valueOf(rawDate);
                      Integer month = Integer.valueOf(rawMonth);
                      Integer year = Integer.valueOf(rawYear);
                      Integer hour = Integer.valueOf(rawHour);
                      Integer minute = Integer.valueOf(rawMinute);
                      if(date != null && month != null && year != null &&
                             hour != null && minute != null)
                      {
                          Dtend endTimeProp = new Dtend();
                          GregorianCalendar endDate = new GregorianCalendar();
                          endDate.set(GregorianCalendar.DATE, date.intValue());
                          endDate.set(GregorianCalendar.MONTH,
                                 month.intValue() - 1);
                          endDate.set(GregorianCalendar.YEAR, year.intValue());
                          endDate.set(GregorianCalendar.HOUR, hour.intValue());
                          endDate.set(GregorianCalendar.MINUTE, 
                                 minute.intValue());
                          endTimeProp.setDateTime(endDate);
                          event.setEndTimeProp(endTimeProp);
                      }
                      else
                      {
                          event.setEndTimeProp(null);
                      }    
                  }
                  else
                  {
                      event.setEndTimeProp(null);
                  }    
                  String rawTransparency = request.getParameter(
                         TestTemplateParams.TRANSPARENCY_PARAM);
                  if(rawTransparency != null)
                  {
                      Transparency transparent = new Transparency();
                      transparent.setValue(rawTransparency);
                      event.setTransProp(transparent);
                  }
                  else
                  {
                      event.setTransProp(null);
                  }
              }
          }    
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/java/org/apache/commons/periodicity/util/ICalSessionKeys.java
  
  Index: ICalSessionKeys.java
  ===================================================================
  package org.apache.commons.periodicity.util;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  public class ICalSessionKeys 
  {
  
      /** The session key for the event that the user is currently viewing or
        * editing */
      public static final String CURRENT_EVENT = "current_event";  
  
  }    
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/java/org/apache/commons/periodicity/util/RunDataUtils.java
  
  Index: RunDataUtils.java
  ===================================================================
  package org.apache.commons.periodicity.util;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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 THE APACHE SOFTWARE FOUNDATION 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 the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import javax.servlet.http.HttpSession;
  import org.apache.turbine.util.RunData;
  import org.apache.commons.periodicity.ical.vobjects.VEvent;
  
  public class RunDataUtils 
  {
      public static VEvent getCurrentEvent(RunData data) throws ICalendarException
      {
          if(data != null)
          {
              HttpSession session = data.getSession();
              if(session != null)
              {
                  return (VEvent) session.getAttribute(
                         ICalSessionKeys.CURRENT_EVENT);
              }
              else
              {
                  throw new ICalendarException("session == null");
              }
          }
          else
          {
              throw new ICalendarException("data == null");
          }
      }    
  }    
  
  
  
  1.3       +1 -1      jakarta-commons-sandbox/periodicity/src/velocity/test/Event_detail.vm
  
  Index: Event_detail.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/velocity/test/Event_detail.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Event_detail.vm	27 Mar 2002 06:08:06 -0000	1.2
  +++ Event_detail.vm	28 Mar 2002 08:49:14 -0000	1.3
  @@ -1,4 +1,4 @@
  -   <form action="${link.setPage("Event_detail.vm")}"
  +   <form action="/periodicity/turbine/template/Event_detail.vm/action/SaveEventTestAction")}"
            method="post" enctype="text/html">
         <table>
            <tr>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message