continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r488252 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/validator/ resources/ resources/org/apache/maven/continuum/web/action/
Date Mon, 18 Dec 2006 12:44:02 GMT
Author: evenisse
Date: Mon Dec 18 04:44:01 2006
New Revision: 488252

URL: http://svn.apache.org/viewvc?view=rev&rev=488252
Log:
[CONTINUUM-1064] Add validation on scheduler fields
Submitted by: Maria Odea Ching

Added:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/CronExpressionValidator.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ScheduleAction-saveSchedule-validation.xml
    maven/continuum/trunk/continuum-webapp/src/main/resources/validators.xml

Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/CronExpressionValidator.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/CronExpressionValidator.java?view=auto&rev=488252
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/CronExpressionValidator.java
(added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/CronExpressionValidator.java
Mon Dec 18 04:44:01 2006
@@ -0,0 +1,60 @@
+package org.apache.maven.continuum.web.validator;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.opensymphony.xwork.validator.validators.ValidatorSupport;
+import com.opensymphony.xwork.validator.ValidationException;
+import com.opensymphony.xwork.validator.ValidatorContext;
+import org.quartz.CronTrigger;
+
+import java.text.ParseException;
+
+/**
+ *
+ * Validator class for the cron expression in the continuum schedules.
+ */
+public class CronExpressionValidator
+    extends ValidatorSupport
+{
+
+    public void validate( Object object )
+        throws ValidationException
+    {
+        String second = ( String ) getFieldValue( "second", object);
+        String minute = ( String ) getFieldValue( "minute", object );
+        String hour = ( String ) getFieldValue( "hour", object );
+        String dayOfMonth = ( String ) getFieldValue( "dayOfMonth", object );
+        String month = ( String ) getFieldValue( "month", object );
+        String dayOfWeek = ( String ) getFieldValue( "dayOfWeek", object );
+        String year = ( String ) getFieldValue( "year", object );
+
+        String cronExpression = ( second + " " + minute + " " + hour + " " + dayOfMonth +
" " +
+            month + " " + dayOfWeek + " " + year ).trim();
+
+        org.codehaus.plexus.scheduler.CronExpressionValidator validator =
+            new org.codehaus.plexus.scheduler.CronExpressionValidator();
+
+        ValidatorContext ctxt = getValidatorContext();
+
+        if ( !validator.validate( cronExpression ) )
+        {
+            ctxt.addActionError( "Invalid cron expression value(s)" );
+            return;
+        }
+    }
+
+}

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/CronExpressionValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/validator/CronExpressionValidator.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ScheduleAction-saveSchedule-validation.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ScheduleAction-saveSchedule-validation.xml?view=diff&rev=488252&r1=488251&r2=488252
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ScheduleAction-saveSchedule-validation.xml
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ScheduleAction-saveSchedule-validation.xml
Mon Dec 18 04:44:01 2006
@@ -28,4 +28,7 @@
       <message key="schedule.delay.invalid"/>  
     </field-validator>
   </field>
+  <validator type="cronexpression">
+    <message/>
+  </validator>
 </validators>

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/validators.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/validators.xml?view=diff&rev=488252&r1=488251&r2=488252
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/validators.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/validators.xml Mon Dec 18 04:44:01
2006
@@ -12,5 +12,6 @@
   <validator name="conversion" class="com.opensymphony.xwork.validator.validators.ConversionErrorFieldValidator"/>
   <validator name="stringlength" class="com.opensymphony.xwork.validator.validators.StringLengthFieldValidator"/>
   <validator name="regex" class="com.opensymphony.xwork.validator.validators.RegexFieldValidator"/>
+  <validator name="cronexpression" class="org.apache.maven.continuum.web.validator.CronExpressionValidator"/>
 </validators>
 



Mime
View raw message