--- /dev/null
+package org.apache.maven.archiva.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;
+
+/**
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ */
+public class IntervalValidator
+ extends ValidatorSupport
+{
+
+ public void validate( Object obj )
+ throws ValidationException
+ {
+ String snapshotsPolicy = ( String ) getFieldValue( "snapshotsPolicy", obj );
+ String releasesPolicy = ( String ) getFieldValue( "releasesPolicy", obj );
+ Integer snapshotsInterval = ( Integer ) getFieldValue( "snapshotsInterval", obj );
+ Integer releasesInterval = ( Integer ) getFieldValue( "releasesInterval", obj );
+
+ ValidatorContext ctxt = getValidatorContext();
+
+ if( !snapshotsPolicy.equals( "interval" ) )
+ {
+ if( snapshotsInterval.intValue() != 0 )
+ {
+ ctxt.addActionError( "Snapshots Interval must be set to zero." );
+ }
+ }
+
+ if( !releasesPolicy.equals( "interval" ) )
+ {
+ if( releasesInterval.intValue() != 0 )
+ {
+ ctxt.addActionError( "Releases Interval must be set to zero." );
+ }
+ }
+
+ if( ctxt.hasActionErrors() )
+ {
+ return;
+ }
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.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;
+
+/**
+ * Validator for synced repository form. The values to be validated depends on the
+ * selected sync method to be used.
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ */
+public class SyncedRepositoryValidator
+ extends ValidatorSupport
+{
+
+ public void validate( Object obj )
+ throws ValidationException
+ {
+
+ String method = ( String ) getFieldValue( "method", obj );
+ ValidatorContext ctxt = getValidatorContext();
+
+ if( method.equals( "rsync" ) )
+ {
+ String rsyncHost = ( String ) getFieldValue( "rsyncHost", obj );
+ if( rsyncHost == null || rsyncHost.equals("") )
+ {
+ ctxt.addActionError( "Rsync host is required." );
+ }
+
+ String rsyncDirectory = ( String ) getFieldValue( "rsyncDirectory", obj );
+ if( rsyncDirectory == null || rsyncDirectory.equals("") )
+ {
+ ctxt.addActionError( "Rsync directory is required." );
+ }
+
+ String rsyncMethod = ( String ) getFieldValue( "rsyncMethod", obj );
+ if( rsyncMethod == null || rsyncMethod.equals("") )
+ {
+ ctxt.addActionError( "Rsync method is required." );
+ }
+ else
+ {
+ if( !rsyncMethod.equals( "anonymous" ) && !rsyncMethod.equals( "ssh" ) )
+ {
+ ctxt.addActionError( "Invalid rsync method" );
+ }
+ }
+
+ String username = ( String ) getFieldValue( "username", obj );
+ if( username == null || username.equals("") )
+ {
+ ctxt.addActionError( "Username is required." );
+ }
+
+ }
+ else if ( method.equals( "svn" ) )
+ {
+ String svnUrl = ( String ) getFieldValue( "svnUrl", obj );
+ if( svnUrl == null || svnUrl.equals("") )
+ {
+ ctxt.addActionError( "SVN url is required." );
+ }
+
+ String username = ( String ) getFieldValue( "username", obj );
+ if( username == null || username.equals("") )
+ {
+ ctxt.addActionError( "Username is required." );
+ }
+ }
+ else if ( method.equals( "cvs" ) )
+ {
+ String cvsRoot = ( String ) getFieldValue( "cvsRoot", obj );
+ if( cvsRoot == null || cvsRoot.equals("") )
+ {
+ ctxt.addActionError( "CVS root is required." );
+ }
+ }
+ else if ( method.equals( "file" ) )
+ {
+ String directory = ( String ) getFieldValue( "directory", obj );
+ if( directory == null || directory.equals("") )
+ {
+ ctxt.addActionError( "Directory is required." );
+ }
+ }
+
+ if( ctxt.hasActionErrors() )
+ {
+ return;
+ }
+ }
+
+}
<field-validator type="requiredstring">
<message>You must enter the repository identifier.</message>
</field-validator>
+ <!--field-validator type="regex">
+ <param name="expression"><![CDATA[([A-Z][a-z][0-9])]]></param>
+ <message>Id must not have special characters.</message>
+ </field-validator-->
</field>
<field name="name">
<field-validator type="requiredstring">
<message>You must enter the repository name.</message>
</field-validator>
</field>
+
+ <!-- deng todo: check if the entered repo url exists -->
<field name="url">
<field-validator type="requiredstring">
<message>You must enter the repository URL.</message>
</field-validator>
</field>
+ <field name="snapshotsInterval">
+ <field-validator type="regex">
+ <param name="expression"><![CDATA[([0-9])]]></param>
+ <message>The value must be numeric</message>
+ </field-validator>
+ </field>
+ <field name="releasesInterval">
+ <field-validator type="regex">
+ <param name="expression"><![CDATA[([0-9])]]></param>
+ <message>The value must be numeric</message>
+ </field-validator>
+ </field>
+
+ <!-- deng todo: check if the interval validator is still valid -->
+ <validator type="interval">
+ <message/>
+ </validator>
+
+ <field name="layout">
+ <field-validator type="required">
+ <message>Repository type is required.</message>
+ </field-validator>
+ <field-validator type="fieldexpression">
+ <param name="expression">layout in {"legacy", "default"} </param>
+ <message>Invalid repository type.</message>
+ </field-validator>
+ </field>
+ <field name="snapshotsPolicy">
+ <field-validator type="fieldexpression">
+ <param name="expression">snapshotsPolicy in { "disabled", "daily", "hourly", "never", "interval" }</param>
+ <message>Invalid snapshot policy.</message>
+ </field-validator>
+ </field>
+ <field name="releasesPolicy">
+ <field-validator type="fieldexpression">
+ <param name="expression">releasesPolicy in { "disabled", "daily", "hourly", "never", "interval" }</param>
+ <message>Invalid releases policy.</message>
+ </field-validator>
+ </field>
+
+ <field name="managedRepository">
+ <field-validator type="requiredstring">
+ <message>A managed repository must be selected.</message>
+ </field-validator>
+ </field>
+
<!-- TODO: validate managed repository -->
<!-- TODO: validate layout -->
<!-- TODO: validate policies -->
<message>You must enter the repository name.</message>
</field-validator>
</field>
+ <!-- deng todo: validate if the specified directory exists -->
<field name="directory">
<field-validator type="requiredstring">
<message>You must enter the repository directory.</message>
</field-validator>
</field>
- <!-- TODO: validate layout -->
+ <field name="layout">
+ <field-validator type="fieldexpression">
+ <param name="expression">layout in {"legacy", "default"} </param>
+ <message>Invalid repository type.</message>
+ </field-validator>
+ </field>
</validators>
\ No newline at end of file
<message>You must enter the repository name.</message>
</field-validator>
</field>
+ <field name="layout">
+ <field-validator type="requiredstring">
+ <message>Select repository type.</message>
+ </field-validator>
+ <field-validator type="fieldexpression">
+ <param name="expression">layout in {"legacy", "default"} </param>
+ <message>Invalid repository type.</message>
+ </field-validator>
+ </field>
+ <field name="managedRepository">
+ <field-validator type="requiredstring">
+ <message>A managed repository must be selected.</message>
+ </field-validator>
+ </field>
+
+ <validator type="syncedrepo">
+ <message/>
+ </validator>
+
<!-- TODO: validate managed repository -->
<!-- TODO: validate layout -->
<!-- TODO: validate sync settings, depending on what method -->
<field-validator type="requiredstring">
<message>You must enter the synchronization method.</message>
</field-validator>
+ <field-validator type="fieldexpression">
+ <param name="expression">method in { "rsync", "cvs", "svn", "file" }</param>
+ <message>Invalid method.</message>
+ </field-validator>
</field>
</validators>
\ No newline at end of file
--- /dev/null
+<validators>
+ <validator name="required" class="com.opensymphony.xwork.validator.validators.RequiredFieldValidator"/>
+ <validator name="requiredstring" class="com.opensymphony.xwork.validator.validators.RequiredStringValidator"/>
+ <validator name="int" class="com.opensymphony.xwork.validator.validators.IntRangeFieldValidator"/>
+ <validator name="double" class="com.opensymphony.xwork.validator.validators.DoubleRangeFieldValidator"/>
+ <validator name="date" class="com.opensymphony.xwork.validator.validators.DateRangeFieldValidator"/>
+ <validator name="expression" class="com.opensymphony.xwork.validator.validators.ExpressionValidator"/>
+ <validator name="fieldexpression" class="com.opensymphony.xwork.validator.validators.FieldExpressionValidator"/>
+ <validator name="email" class="com.opensymphony.xwork.validator.validators.EmailValidator"/>
+ <validator name="url" class="com.opensymphony.xwork.validator.validators.URLValidator"/>
+ <validator name="visitor" class="com.opensymphony.xwork.validator.validators.VisitorFieldValidator"/>
+ <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="interval" class="org.apache.maven.archiva.web.validator.IntervalValidator"/>
+ <validator name="syncedrepo" class="org.apache.maven.archiva.web.validator.SyncedRepositoryValidator"/>
+</validators>
+
<h2>Add Proxied Repository</h2>
+ <%@ include file="errorMessages.jsp" %>
+
<ww:actionmessage/>
<ww:form method="post" action="addProxiedRepository" namespace="/admin" validate="true">
<ww:textfield name="id" label="Identifier" size="10"/>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
<ww:actionmessage/>
<ww:form method="post" action="addRepository" namespace="/admin" validate="true">
- <ww:textfield name="id" label="Identifier" size="10"/>
+ <ww:textfield name="id" label="Identifier" size="10" required="true"/>
<%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %>
<ww:checkbox name="indexed" fieldValue="true" value="true" label="Indexed"/>
<ww:submit value="Add Repository"/>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
<h2>Add Synced Repository</h2>
+ <%@ include file="errorMessages.jsp" %>
+
<ww:actionmessage/>
<ww:form method="post" action="addSelectedSyncedRepository" namespace="/admin" validate="true">
- <ww:textfield name="id" label="Identifier" size="10"/>
+ <ww:textfield name="id" label="Identifier" size="10" required="true"/>
<%@ include file="/WEB-INF/jsp/admin/include/syncedRepositoryForm.jspf" %>
<ww:submit value="Add Repository"/>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
<div id="contentArea">
<ww:actionmessage/>
<ww:form method="post" action="saveConfiguration" namespace="/admin" validate="true">
- <ww:textfield name="indexPath" label="Index Directory" size="100"/>
+ <ww:textfield name="indexPath" label="Index Directory" size="100" required="true"/>
<ww:textfield name="indexerCronExpression" label="Indexing Schedule"/>
<ww:textfield name="reporterCronExpression" label="Reporting Schedule"/>
<ww:hidden name="proxy.protocol" value="http"/>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
<h2>Edit Proxied Repository</h2>
+ <%@ include file="errorMessages.jsp" %>
+
<ww:actionmessage/>
<ww:form method="post" action="editProxiedRepository" namespace="/admin" validate="true">
<ww:hidden name="id"/>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
<h2>Edit Synced Repository</h2>
+ <%@ include file="errorMessages.jsp" %>
+
<ww:actionmessage/>
<ww:form method="post" action="editSyncedRepository" namespace="/admin" validate="true">
<ww:hidden name="id"/>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
--- /dev/null
+<p>
+<ww:if test="hasActionErrors()">
+ <b style="color: red;" >Errors:</b>
+ <ww:iterator value="actionErrors">
+ <li style="color: red;"><ww:property/></li>
+ </ww:iterator>
+</ww:if>
+</p>
\ No newline at end of file
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<ww:textfield name="name" label="Name" size="50" />
-<ww:textfield name="directory" label="Directory" size="100" />
+<ww:textfield name="name" label="Name" size="50" required="true" />
+<ww:textfield name="directory" label="Directory" size="100" required="true"/>
<ww:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
name="layout" label="Type" />
<ww:checkbox name="includeSnapshots" fieldValue="true" label="Snapshots Included" />
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
-<ww:textfield name="name" label="Name" size="50" />
-<ww:textfield name="url" label="URL" size="50" />
+<ww:textfield name="name" label="Name" size="50" required="true"/>
+<ww:textfield name="url" label="URL" size="50" required="true"/>
<ww:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
name="layout" label="Type" />
<ww:select name="snapshotsPolicy" label="Snapshots" list="#@java.util.LinkedHashMap@{