From e245b5c063566d82c88ab4a5764ea3c897fbb1f3 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 11 May 2007 18:04:39 +0000 Subject: [PATCH] [MRM-332]: Adding a Proxy Connector displays a blank page git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@537251 13f79535-47bb-0310-9956-ffa450edef68 --- .../proxy/ConfigureProxyConnectorAction.java | 60 +++--- ...onnector-saveProxyConnector-validation.xml | 37 ++++ .../src/main/resources/xwork.xml | 2 +- .../WEB-INF/jsp/admin/editNetworkProxy.jsp | 2 +- .../WEB-INF/jsp/admin/editProxyConnector.jsp | 200 +++++++++++++++++- .../jsp/admin/include/proxyConnectorForm.jspf | 196 ----------------- .../jsp/admin/include/repositoryForm.jspf | 4 +- .../WEB-INF/jsp/admin/proxyConnectors.jsp | 16 +- 8 files changed, 277 insertions(+), 240 deletions(-) create mode 100644 archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml delete mode 100644 archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java index 9375b0859..7432b9bb9 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java @@ -20,7 +20,6 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy; */ import com.opensymphony.xwork.Preparable; -import com.opensymphony.xwork.Validateable; import org.apache.commons.collections.Closure; import org.apache.commons.collections.CollectionUtils; @@ -29,7 +28,6 @@ import org.apache.commons.collections.functors.NotPredicate; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.InvalidConfigurationException; import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate; @@ -46,7 +44,6 @@ import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; import org.codehaus.plexus.registry.RegistryException; import org.codehaus.plexus.xwork.action.PlexusActionSupport; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -64,7 +61,7 @@ import java.util.Map.Entry; */ public class ConfigureProxyConnectorAction extends PlexusActionSupport - implements SecureAction, Preparable, Validateable, Initializable + implements SecureAction, Preparable, Initializable { private static final String DIRECT_CONNECTION = "(direct connection)"; @@ -408,35 +405,32 @@ public class ConfigureProxyConnectorAction String sourceId = getConnector().getSourceRepoId(); String targetId = getConnector().getTargetRepoId(); + if ( !validateConnector( getConnector() ) ) + { + return INPUT; + } + if ( StringUtils.equalsIgnoreCase( "edit", mode ) ) { removeConnector( sourceId, targetId ); } - - try + else { - if ( StringUtils.equals( DIRECT_CONNECTION, getConnector().getProxyId() ) ) + if ( findProxyConnector( sourceId, targetId ) != null ) { - getConnector().setProxyId( null ); + addActionError( "Unable to add new proxy connector with source [" + sourceId + "] and target [" + + targetId + "] as previously declared proxy connector, go edit that one instead." ); + return INPUT; } - - addProxyConnector( getConnector() ); - saveConfiguration(); - } - catch ( IOException e ) - { - addActionError( "I/O Exception: " + e.getMessage() ); } - catch ( InvalidConfigurationException e ) - { - addActionError( "Invalid Configuration Exception: " + e.getMessage() ); - } - catch ( RegistryException e ) + + if ( StringUtils.equals( DIRECT_CONNECTION, getConnector().getProxyId() ) ) { - addActionError( "Configuration Registry Exception: " + e.getMessage() ); + getConnector().setProxyId( null ); } - return SUCCESS; + addProxyConnector( getConnector() ); + return saveConfiguration(); } public void setBlackListPattern( String blackListPattern ) @@ -490,7 +484,6 @@ public class ConfigureProxyConnectorAction } private void addProxyConnector( ProxyConnectorConfiguration proxyConnector ) - throws IOException { archivaConfiguration.getConfiguration().addProxyConnector( proxyConnector ); } @@ -502,11 +495,9 @@ public class ConfigureProxyConnectorAction ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate( sourceId, targetId ); return (ProxyConnectorConfiguration) CollectionUtils.find( config.getProxyConnectors(), selectedProxy ); } - - public void validate() + + public boolean validateConnector( ProxyConnectorConfiguration proxyConnector ) { - ProxyConnectorConfiguration proxyConnector = getConnector(); - if ( proxyConnector.getPolicies() == null ) { addActionError( "Policies must be set." ); @@ -544,6 +535,8 @@ public class ConfigureProxyConnectorAction continue; } } + + return !hasActionErrors(); } private void removeConnector( String sourceId, String targetId ) @@ -554,11 +547,16 @@ public class ConfigureProxyConnectorAction } private String saveConfiguration() - throws IOException, InvalidConfigurationException, RegistryException { - archivaConfiguration.save( archivaConfiguration.getConfiguration() ); - - addActionMessage( "Successfully saved configuration" ); + try + { + archivaConfiguration.save( archivaConfiguration.getConfiguration() ); + addActionMessage( "Successfully saved configuration" ); + } + catch ( RegistryException e ) + { + addActionError( "Unable to save configuration: " + e.getMessage() ); + } return SUCCESS; } diff --git a/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml b/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml new file mode 100644 index 000000000..5c6e25ce3 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnector-saveProxyConnector-validation.xml @@ -0,0 +1,37 @@ + + + + + + + + + true + You must select a source repository Id. + + + + + true + You must select a target repository Id. + + + \ No newline at end of file diff --git a/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-web/archiva-webapp/src/main/resources/xwork.xml index c791e7206..94d9d7b62 100644 --- a/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -271,7 +271,7 @@ - /WEB-INF/jsp/admin/addProxyConnector.jsp + /WEB-INF/jsp/admin/editProxyConnector.jsp proxyConnectors diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editNetworkProxy.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editNetworkProxy.jsp index 97cf89cd7..d371fb121 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editNetworkProxy.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editNetworkProxy.jsp @@ -49,7 +49,7 @@ - + diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp index 879347e36..5c9f87fb8 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp @@ -18,27 +18,215 @@ --%> <%@ taglib prefix="ww" uri="/webwork" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + + + + - Admin : Edit Proxy Connector + Admin : ${addedit} Proxy Connector + -

Admin : Edit Proxy Connector

+

Admin : ${addedit} Proxy Connector

-

Edit Proxy Connector

- - + - <%@ include file="/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf" %> + + + + + + + + + + + + + + + + + +
+ ${policy.key}: + + +
+ + + + + + + + : + + + + + + + + + + + + No properties have been set. + + + + + + + + + + + +
+ ${property.key} + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + No black list patterns have been set. + + + + + + + + + +
+ + "${pattern}" + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + No white list patterns have been set. + + + + + + + + + +
+ + "${pattern}" + + + +
+
+
+ + + +
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf deleted file mode 100644 index a6a1b2a02..000000000 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf +++ /dev/null @@ -1,196 +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" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - - - - - - - - - - - - - - - - - -
- ${policy.key}: - - -
- - - - - - - - : - - - - - - - - - - - No properties have been set. - - - - - - - - - - - -
- ${property.key} - - - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - No black list patterns have been set. - - - - - - - - - -
- - "${pattern}" - - - -
-
-
- - - - - - - - - - - - - - - - - - - - No white list patterns have been set. - - - - - - - - - -
- - "${pattern}" - - - -
-
-
- - diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf index 683bb9dac..4f5c77fb2 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf @@ -20,10 +20,10 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - + - + diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp index 1e98a81e4..eb5146b4f 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp @@ -33,6 +33,10 @@

Administration - Proxy Connectors

+ + + +
@@ -82,10 +86,10 @@ - " /> + - " /> +
@@ -100,7 +104,13 @@ (Direct Connection) - ${connector.proxyId} + + + + + ${connector.proxyId} + + -- 2.39.5