[MRM-327]: Adding/Editing network proxies doesn't have validation

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@537036 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2007-05-10 23:13:26 +00:00
parent 73d6f00c8e
commit 688bd8114e
5 changed files with 90 additions and 59 deletions

View File

@ -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();

View File

@ -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>

View File

@ -307,7 +307,7 @@
</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>

View File

@ -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>

View File

@ -18,25 +18,42 @@
--%>
<%@ 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>