You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@archiva.apache.org by Brett Porter <br...@apache.org> on 2006/09/12 14:40:48 UTC
Re: svn commit: r442513 - in /maven/archiva/trunk/archiva-webapp/src/main: java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java webapp/WEB-INF/jsp/admin/configure.jsp
Hi Deng,
- shouldn't the validation be in a validate method, overriding the
one in the base class instead of in the execute action?
- the HTML shouldn't have had to be changed: the ww: tags introduce
table elements already. Can this please be put back?
Thanks,
Brett
On 12/09/2006, at 6:12 PM, oching@apache.org wrote:
> Author: oching
> Date: Tue Sep 12 01:12:25 2006
> New Revision: 442513
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=442513
> Log:
> Updated cron expression editor (configure.jsp). Added validation
> for cron expression.
>
> Modified:
> maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/
> maven/archiva/web/action/admin/ConfigureAction.java
> maven/archiva/trunk/archiva-webapp/src/main/webapp/WEB-INF/jsp/
> admin/configure.jsp
>
> Modified: maven/archiva/trunk/archiva-webapp/src/main/java/org/
> apache/maven/archiva/web/action/admin/ConfigureAction.java
> URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-
> webapp/src/main/java/org/apache/maven/archiva/web/action/admin/
> ConfigureAction.java?view=diff&rev=442513&r1=442512&r2=442513
> ======================================================================
> ========
> --- maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/
> maven/archiva/web/action/admin/ConfigureAction.java (original)
> +++ maven/archiva/trunk/archiva-webapp/src/main/java/org/apache/
> maven/archiva/web/action/admin/ConfigureAction.java Tue Sep 12
> 01:12:25 2006
> @@ -26,6 +26,7 @@
> import org.apache.maven.archiva.indexer.RepositoryIndexException;
> import
> org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
> import org.codehaus.plexus.xwork.action.PlexusActionSupport;
> +import org.codehaus.plexus.scheduler.CronExpressionValidator;
>
> import java.io.File;
> import java.io.IOException;
> @@ -49,6 +50,23 @@
> */
> private Configuration configuration;
>
> + private CronExpressionValidator cronValidator;
> +
> + private String second = "0";
> +
> + private String minute = "0";
> +
> + private String hour = "*";
> +
> + private String dayOfMonth = "*";
> +
> + private String month = "*";
> +
> + private String dayOfWeek = "?";
> +
> + private String year;
> +
> +
> public String execute()
> throws IOException, RepositoryIndexException,
> RepositoryIndexSearchException, ConfigurationStoreException,
> InvalidConfigurationException, ConfigurationChangeException
> @@ -56,6 +74,19 @@
> // TODO: if this didn't come from the form, go to
> configure.action instead of going through with re-saving what was
> just loaded
> // TODO: if this is changed, do we move the index or
> recreate it?
>
> + String cronEx = ( second + " " + minute + " " + hour + " "
> + dayOfMonth + " " + month +
> + " " + dayOfWeek + " " + year ).trim();
> +
> + //validate cron expression
> + cronValidator = new CronExpressionValidator();
> + if( !cronValidator.validate( cronEx ) )
> + {
> + addActionError( "Invalid Cron Expression" );
> + return ERROR;
> + }
> +
> + configuration.setIndexerCronExpression( cronEx );
> +
> // Normalize the path
> File file = new File( configuration.getIndexPath() );
> configuration.setIndexPath( file.getCanonicalPath() );
> @@ -79,6 +110,24 @@
>
> public String input()
> {
> + String[] cronEx = configuration.getIndexerCronExpression
> ().split( " " );
> + int i = 0;
> +
> + while ( i < cronEx.length )
> + {
> + switch( i )
> + {
> + case 0 : second = cronEx[i]; break;
> + case 1 : minute = cronEx[i]; break;
> + case 2 : hour = cronEx[i]; break;
> + case 3 : dayOfMonth = cronEx[i]; break;
> + case 4 : month = cronEx[i]; break;
> + case 5 : dayOfWeek = cronEx[i]; break;
> + case 6 : year = cronEx[i]; break;
> + }
> + i++;
> + }
> +
> return INPUT;
> }
>
> @@ -92,4 +141,74 @@
> {
> configuration =
> configurationStore.getConfigurationFromStore();
> }
> -}
> \ No newline at end of file
> +
> + public String getSecond()
> + {
> + return second;
> + }
> +
> + public void setSecond( String second )
> + {
> + this.second = second;
> + }
> +
> + public String getMinute()
> + {
> + return minute;
> + }
> +
> + public void setMinute( String minute )
> + {
> + this.minute = minute;
> + }
> +
> + public String getHour()
> + {
> + return hour;
> + }
> +
> + public void setHour( String hour )
> + {
> + this.hour = hour;
> + }
> +
> + public String getDayOfMonth()
> + {
> + return dayOfMonth;
> + }
> +
> + public void setDayOfMonth( String dayOfMonth )
> + {
> + this.dayOfMonth = dayOfMonth;
> + }
> +
> + public String getYear()
> + {
> + return year;
> + }
> +
> + public void setYear( String year )
> + {
> + this.year = year;
> + }
> +
> + public String getMonth()
> + {
> + return month;
> + }
> +
> + public void setMonth( String month )
> + {
> + this.month = month;
> + }
> +
> + public String getDayOfWeek()
> + {
> + return dayOfWeek;
> + }
> +
> + public void setDayOfWeek( String dayOfWeek )
> + {
> + this.dayOfWeek = dayOfWeek;
> + }
> +}
>
> Modified: maven/archiva/trunk/archiva-webapp/src/main/webapp/WEB-
> INF/jsp/admin/configure.jsp
> URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-
> webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp?
> view=diff&rev=442513&r1=442512&r2=442513
> ======================================================================
> ========
> --- maven/archiva/trunk/archiva-webapp/src/main/webapp/WEB-INF/jsp/
> admin/configure.jsp (original)
> +++ maven/archiva/trunk/archiva-webapp/src/main/webapp/WEB-INF/jsp/
> admin/configure.jsp Tue Sep 12 01:12:25 2006
> @@ -29,13 +29,90 @@
> <div id="contentArea">
> <ww:actionmessage/>
> <ww:form method="post" action="saveConfiguration" namespace="/
> admin" validate="true">
> - <ww:textfield name="indexPath" label="Index Directory"
> size="100" required="true"/>
> - <ww:textfield name="indexerCronExpression" label="Indexing
> Schedule"/>
> - <ww:hidden name="proxy.protocol" value="http"/>
> - <ww:textfield name="proxy.host" label="HTTP Proxy Host"/>
> - <ww:textfield name="proxy.port" label="HTTP Proxy Port"/>
> - <ww:textfield name="proxy.username" label="HTTP Proxy Username"/>
> - <ww:password name="proxy.password" label="HTTP Proxy Password"/>
> +
> + <div>
> + <table>
> + <tbody>
> + <tr>
> + <th><font size="2"><ww:label theme="simple"
> value="Indexing Directory*:"/></font></th>
> + <td><ww:textfield name="indexPath" theme="simple"
> size="140" required="true"/></td>
> + </tr>
> + <tr>
> + <th><font size="2"><ww:label theme="simple"
> value="Indexing Schedule:"/></font></th>
> + <td>
> + <table>
> + <tr>
> + <th><ww:label theme="simple" value="Second:"/></th>
> + <td><ww:textfield name="second" theme="simple"
> size="2"/></td>
> +
> + <th><ww:label theme="simple" value="Minute:"/></th>
> + <td><ww:textfield name="minute" theme="simple"
> size="2"/></td>
> +
> + <th><ww:label theme="simple" value="Hour:"/></th>
> + <td><ww:textfield name="hour" theme="simple"
> size="2"/></td>
> +
> + <th><ww:label theme="simple" value="Day of
> Month:"/></th>
> + <td><ww:textfield name="dayOfMonth"
> theme="simple" size="2"/></td>
> +
> + <th><ww:label theme="simple" value="Month:"/></th>
> + <td><ww:textfield name="month" theme="simple"
> size="2"/></td>
> +
> + <th><ww:label theme="simple" value="Day of
> Week:"/></th>
> + <td><ww:textfield name="dayOfWeek"
> theme="simple" size="2"/></td>
> +
> + <th><ww:label theme="simple" value="Year
> [optional]:"/></th>
> + <td><ww:textfield name="year" theme="simple"
> size="4"/></td>
> + </tr>
> + </table>
> + </td>
> + </tr>
> + <ww:hidden name="proxy.protocol" value="http"/>
> + <tr>
> + <th><font size="2"><ww:label theme="simple"
> value="HTTP Proxy Host:"/></font></th>
> + <td><ww:textfield name="proxy.host" theme="simple"/></td>
> + </tr>
> + <tr>
> + <th><font size="2"><ww:label theme="simple"
> value="HTTP Proxy Port:"/></font></th>
> + <td><ww:textfield name="proxy.port" theme="simple"/></td>
> + </tr>
> + <tr>
> + <th><font size="2"><ww:label theme="simple"
> value="HTTP Proxy Username:"/></font></th>
> + <td><ww:textfield name="proxy.username" theme="simple"/
> ></td>
> + </tr>
> + <tr>
> + <th><font size="2"><ww:label theme="simple"
> value="HTTP Proxy Password:"/></font></th>
> + <td><ww:textfield name="proxy.password" theme="simple"/
> ></td>
> + </tr>
> + </tbody>
> + </table>
> + </div>
> +
> + <div>
> + <p><i>For valid cron expression values for the Indexing
> Schedule, see <ww:a href="http://www.opensymphony.com/quartz/api/
> org/quartz/CronExpression.html">here</ww:a></i></p>
> + </div>
> + <div>
> + <table>
> + <tr>
> + <b>Indexing Schedule Keys:</b>
> + </tr>
> + <tr>
> + <th>*</th>
> + <td>every</td>
> + </tr>
> + <tr>
> + <th>?</th>
> + <td>any</td>
> + </tr>
> + <tr>
> + <th>-</th>
> + <td>ranges</td>
> + </tr>
> + <tr>
> + <th>/</th>
> + <td>increments</td>
> + </tr>
> + </table>
> + </div>
> <ww:submit value="Save Configuration"/>
> </ww:form>
>
>