]> source.dussan.org Git - archiva.git/commitdiff
[MRM-327]: Adding/Editing network proxies doesn't have validation
authorJoakim Erdfelt <joakime@apache.org>
Thu, 10 May 2007 23:13:26 +0000 (23:13 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Thu, 10 May 2007 23:13:26 +0000 (23:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@537036 13f79535-47bb-0310-9956-ffa450edef68

archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java
archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml [new file with mode: 0644]
archiva-web/archiva-webapp/src/main/resources/xwork.xml
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addNetworkProxy.jsp [deleted file]
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editNetworkProxy.jsp

index 79d35b593af7972dfef61722054c7b5908e51d37..aea9b4f946b8464858f9948e7d58da6f7851600e 100644 (file)
@@ -89,7 +89,7 @@ public class ConfigureNetworkProxyAction
             addActionError( "Unable to remove network proxy, proxy with id [" + id + "] not found." );
             return SUCCESS;
         }
-        
+
         archivaConfiguration.getConfiguration().removeNetworkProxy( proxyConfig );
         addActionMessage( "Successfully removed network proxy [" + id + "]" );
         return saveConfiguration();
@@ -158,6 +158,14 @@ public class ConfigureNetworkProxyAction
         {
             removeNetworkProxy( id );
         }
+        else
+        {
+            if ( findNetworkProxy( id ) != null )
+            {
+                addActionError( "Unable to add new repository with id [" + id + "], that id already exists." );
+                return INPUT;
+            }
+        }
 
         addNetworkProxy( getProxy() );
         return saveConfiguration();
diff --git a/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml b/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction-saveNetworkProxy-validation.xml
new file mode 100644 (file)
index 0000000..401708c
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+
+<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+
+
+<validators>
+  <field name="proxy.id">
+    <field-validator type="stringlength">
+      <param name="minLength">4</param>
+      <param name="maxLength">45</param>
+      <param name="trim">true</param>
+      <message>You must enter an identifier of 4 or more than 4 characters.</message>
+    </field-validator>
+  </field>
+  <field name="proxy.protocol">
+    <field-validator type="requiredstring">
+      <param name="trim">true</param>
+      <message>You must enter a protocol.</message>
+    </field-validator>
+  </field>
+  <field name="proxy.host">
+    <field-validator type="requiredstring">
+      <param name="trim">true</param>
+      <message>You must enter a host.</message>
+    </field-validator>
+  </field>
+  <field name="proxy.port">
+    <field-validator type="required">
+      <message>You must enter an port.</message>
+    </field-validator>
+    <field-validator type="int">
+      <param name="min">1</param>
+      <param name="max">65535</param>
+      <message>Port needs to be between ${min} and ${max}</message>
+    </field-validator>
+  </field>
+</validators>
\ No newline at end of file
index aa45634ec08e9eb80ccf93f96d0f903df385e184..c791e7206b7ee13e857b9b5faa034e44914fdbfe 100644 (file)
     </action>
     
     <action name="addNetworkProxy" class="configureNetworkProxyAction" method="add">
-      <result name="input">/WEB-INF/jsp/admin/addNetworkProxy.jsp</result>
+      <result name="input">/WEB-INF/jsp/admin/editNetworkProxy.jsp</result>
       <result name="success" type="redirect-action">networkProxies</result>
       <interceptor-ref name="configuredPrepareParamsStack"/>
     </action>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addNetworkProxy.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addNetworkProxy.jsp
deleted file mode 100644 (file)
index 7561af3..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<%--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you 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.
-  --%>
-
-<%@ taglib prefix="ww" uri="/webwork" %>
-
-<html>
-<head>
-  <title>Admin: Add Network Proxy</title>
-  <ww:head/>
-</head>
-
-<body>
-
-<h1>Admin: Add Network Proxy</h1>
-
-<div id="contentArea">
-
-  <h2>Add Network Proxy</h2>
-
-  <ww:actionmessage/>
-  <ww:form method="post" action="saveNetworkProxy" namespace="/admin" validate="true">
-    <ww:hidden name="mode" value="add"/>
-    <ww:textfield name="proxy.id" label="Identifier" size="10" required="true"/>
-    <%@ include file="/WEB-INF/jsp/admin/include/networkProxyForm.jspf" %>
-    <ww:submit value="Add Network Proxy"/>
-  </ww:form>
-
-  <script type="text/javascript">
-    document.getElementById("saveNetworkProxy_id").focus();
-  </script>
-
-</div>
-
-</body>
-</html>
index 73da77a8fa32c114c97eff0549e82a4ff0a0d261..97cf89cd7a187ee93e3f7217c8489bba927680be 100644 (file)
   --%>
 
 <%@ taglib prefix="ww" uri="/webwork" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+<c:choose>
+  <c:when test="${mode == 'edit'}">
+    <c:set var="addedit" value="Edit" />
+    <c:set var="disableId" value="true" />
+  </c:when>
+  <c:otherwise>
+    <c:set var="addedit" value="Add" />
+    <c:set var="disableId" value="false" />
+  </c:otherwise>
+</c:choose>
 
 <html>
 <head>
-  <title>Admin: Edit Network Proxy</title>
+  <title>Admin: ${addedit} Network Proxy</title>
   <ww:head/>
 </head>
 
 <body>
 
-<h1>Admin: Network Proxy</h1>
+<h1>Admin: ${addedit} Network Proxy</h1>
 
 <div id="contentArea">
 
-  <h2>Edit Network Proxy</h2>
+  <h2>${addedit} Network Proxy</h2>
 
+  <ww:actionerror/> 
   <ww:actionmessage/>
-  <ww:form method="post" action="saveNetworkProxy" namespace="/admin" validate="false">
-    <ww:hidden name="mode" value="edit"/>  
-    <ww:hidden name="proxy.id"/>
+  
+  <ww:form method="post" action="saveNetworkProxy" namespace="/admin">
+    <ww:hidden name="mode"/>  
+    
+    <ww:textfield name="proxy.id" label="Identifier" size="10" required="true"
+      disabled="${disableId}"/>
+    
     <%@ include file="/WEB-INF/jsp/admin/include/networkProxyForm.jspf" %>
     <ww:submit value="Save Network Proxy"/>
   </ww:form>