You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/10/05 00:29:50 UTC
svn commit: r582020 [2/3] - in /maven/archiva/trunk:
archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/
archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/
archiva-base...
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java?rev=582020&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java (added)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java Thu Oct 4 15:29:43 2007
@@ -0,0 +1,106 @@
+package org.apache.maven.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+
+/**
+ * DeleteProxyConnectorAction
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteProxyConnectorAction"
+ */
+public class DeleteProxyConnectorAction
+ extends AbstractProxyConnectorAction
+{
+ private String sourceId;
+
+ private String targetId;
+
+ private ProxyConnectorConfiguration proxyConfig;
+
+ public String confirmDelete()
+ {
+ this.proxyConfig = findProxyConnector( sourceId, targetId );
+
+ // Not set? Then there is nothing to delete.
+ if ( this.proxyConfig == null )
+ {
+ addActionError( "Unable to delete proxy configuration, configuration with source [" + sourceId
+ + "], and target [" + targetId + "] does not exist." );
+ return ERROR;
+ }
+
+ return INPUT;
+ }
+
+ public String delete()
+ {
+ this.proxyConfig = findProxyConnector( sourceId, targetId );
+
+ // Not set? Then there is nothing to delete.
+ if ( this.proxyConfig == null )
+ {
+ addActionError( "Unable to delete proxy configuration, configuration with source [" + sourceId
+ + "], and target [" + targetId + "] does not exist." );
+ return ERROR;
+ }
+
+ if ( hasActionErrors() )
+ {
+ return ERROR;
+ }
+
+ removeProxyConnector( proxyConfig );
+ addActionMessage( "Successfully removed proxy connector [" + sourceId + " , " + targetId + " ]" );
+
+ setSourceId( null );
+ setTargetId( null );
+
+ return saveConfiguration();
+ }
+
+ public String getSourceId()
+ {
+ return sourceId;
+ }
+
+ public void setSourceId( String sourceId )
+ {
+ this.sourceId = sourceId;
+ }
+
+ public String getTargetId()
+ {
+ return targetId;
+ }
+
+ public void setTargetId( String targetId )
+ {
+ this.targetId = targetId;
+ }
+
+ public ProxyConnectorConfiguration getProxyConfig()
+ {
+ return proxyConfig;
+ }
+}
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java?rev=582020&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java (added)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java Thu Oct 4 15:29:43 2007
@@ -0,0 +1,114 @@
+package org.apache.maven.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+
+
+/**
+ * EditProxyConnectorAction
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="editProxyConnectorAction"
+ */
+public class EditProxyConnectorAction
+ extends AbstractProxyConnectorFormAction
+{
+ /**
+ * The proxy connector source id to edit. (used with {@link #target})
+ */
+ private String source;
+
+ /**
+ * The proxy connector target id to edit. (used with {@link #source})
+ */
+ private String target;
+
+ @Override
+ public void prepare()
+ {
+ super.prepare();
+
+ connector = findProxyConnector( source, target );
+ }
+
+ public String input()
+ {
+ if ( connector == null )
+ {
+ addActionError( "Unable to edit non existant proxy connector with source [" + source + "] and target ["
+ + target + "]" );
+ return ERROR;
+ }
+
+ return INPUT;
+ }
+
+ public String commit()
+ {
+ validateConnector();
+
+ if ( hasActionErrors() )
+ {
+ return INPUT;
+ }
+
+ String sourceId = connector.getSourceRepoId();
+ String targetId = connector.getTargetRepoId();
+
+ ProxyConnectorConfiguration otherConnector = findProxyConnector( sourceId, targetId );
+ if ( otherConnector != null )
+ {
+ // Remove the previous connector.
+ removeProxyConnector( otherConnector );
+ }
+
+ if ( hasActionErrors() )
+ {
+ return INPUT;
+ }
+
+ addProxyConnector( connector );
+ return saveConfiguration();
+ }
+
+ public String getSource()
+ {
+ return source;
+ }
+
+ public void setSource( String source )
+ {
+ this.source = source;
+ }
+
+ public String getTarget()
+ {
+ return target;
+ }
+
+ public void setTarget( String target )
+ {
+ this.target = target;
+ }
+
+}
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java?rev=582020&r1=582019&r2=582020&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java Thu Oct 4 15:29:43 2007
@@ -20,19 +20,11 @@
*/
import com.opensymphony.xwork.Preparable;
-import org.apache.commons.collections.Closure;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+
+import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
-import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
-import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
-import org.codehaus.plexus.xwork.action.PlexusActionSupport;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -42,75 +34,37 @@
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
+ *
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="proxyConnectorsAction"
*/
public class ProxyConnectorsAction
- extends PlexusActionSupport
- implements SecureAction, Preparable
+ extends AbstractProxyConnectorAction
+ implements Preparable
{
- /**
- * @plexus.requirement
- */
- private ArchivaConfiguration archivaConfiguration;
-
- private Map repoMap;
+ private Map<String, AbstractRepositoryConfiguration> repoMap;
/**
* Map of Proxy Connectors.
*/
- private Map proxyConnectorMap;
+ private Map<String, List<ProxyConnectorConfiguration>> proxyConnectorMap;
public void prepare()
{
Configuration config = archivaConfiguration.getConfiguration();
- repoMap = new HashMap();
+ repoMap = new HashMap<String, AbstractRepositoryConfiguration>();
repoMap.putAll( config.getRemoteRepositoriesAsMap() );
repoMap.putAll( config.getManagedRepositoriesAsMap() );
- proxyConnectorMap = new HashMap();
-
- Closure addToProxyConnectorMap = new Closure()
- {
- public void execute( Object input )
- {
- if ( input instanceof ProxyConnectorConfiguration )
- {
- ProxyConnectorConfiguration proxyConfig = (ProxyConnectorConfiguration) input;
- String key = proxyConfig.getSourceRepoId();
-
- List connectors = (List) proxyConnectorMap.get( key );
- if ( connectors == null )
- {
- connectors = new ArrayList();
- proxyConnectorMap.put( key, connectors );
- }
-
- connectors.add( proxyConfig );
- }
- }
- };
-
- CollectionUtils.forAllDo( config.getProxyConnectors(), addToProxyConnectorMap );
- }
-
- public SecureActionBundle getSecureActionBundle()
- throws SecureActionException
- {
- SecureActionBundle bundle = new SecureActionBundle();
-
- bundle.setRequiresAuthentication( true );
- bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
-
- return bundle;
+ proxyConnectorMap = createProxyConnectorMap();
}
- public Map getRepoMap()
+ public Map<String, AbstractRepositoryConfiguration> getRepoMap()
{
return repoMap;
}
- public Map getProxyConnectorMap()
+ public Map<String, List<ProxyConnectorConfiguration>> getProxyConnectorMap()
{
return proxyConnectorMap;
}
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java?rev=582020&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java (added)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java Thu Oct 4 15:29:43 2007
@@ -0,0 +1,136 @@
+package org.apache.maven.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * 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.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+
+import java.util.List;
+
+/**
+ * SortProxyConnectorsAction -
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="sortProxyConnectorsAction"
+ */
+public class SortProxyConnectorsAction
+ extends AbstractProxyConnectorAction
+{
+ private String source;
+
+ private String target;
+
+ public String getSource()
+ {
+ return source;
+ }
+
+ public String getTarget()
+ {
+ return target;
+ }
+
+ public void setSource( String id )
+ {
+ this.source = id;
+ }
+
+ public void setTarget( String id )
+ {
+ this.target = id;
+ }
+
+ public String sortDown()
+ {
+ List<ProxyConnectorConfiguration> connectors = createProxyConnectorMap().get( source );
+
+ int idx = findTargetConnector( connectors, target );
+
+ if ( idx >= 0 )
+ {
+ incrementConnectorOrder( connectors, idx );
+ decrementConnectorOrder( connectors, idx + 1 );
+ }
+
+ return saveConfiguration();
+ }
+
+ public String sortUp()
+ {
+ List<ProxyConnectorConfiguration> connectors = createProxyConnectorMap().get( source );
+
+ int idx = findTargetConnector( connectors, target );
+
+ if ( idx >= 0 )
+ {
+ decrementConnectorOrder( connectors, idx );
+ incrementConnectorOrder( connectors, idx - 1 );
+ }
+
+ return saveConfiguration();
+ }
+
+ private void decrementConnectorOrder( List<ProxyConnectorConfiguration> connectors, int idx )
+ {
+ if ( !validIndex( connectors, idx ) )
+ {
+ // Do nothing.
+ return;
+ }
+
+ int order = connectors.get( idx ).getOrder();
+ connectors.get( idx ).setOrder( Math.max( 1, order - 1 ) );
+ }
+
+ private int findTargetConnector( List<ProxyConnectorConfiguration> connectors, String targetRepoId )
+ {
+ int idx = ( -1 );
+
+ for ( int i = 0; i < connectors.size(); i++ )
+ {
+ if ( StringUtils.equals( targetRepoId, connectors.get( i ).getTargetRepoId() ) )
+ {
+ idx = i;
+ break;
+ }
+ }
+
+ return idx;
+ }
+
+ private void incrementConnectorOrder( List<ProxyConnectorConfiguration> connectors, int idx )
+ {
+ if ( !validIndex( connectors, idx ) )
+ {
+ // Do nothing.
+ return;
+ }
+
+ int order = connectors.get( idx ).getOrder();
+ connectors.get( idx ).setOrder( order + 1 );
+ }
+
+ private boolean validIndex( List<ProxyConnectorConfiguration> connectors, int idx )
+ {
+ return ( idx >= 0 ) && ( idx < connectors.size() );
+ }
+}
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml?rev=582020&r1=582019&r2=582020&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/resources/xwork.xml Thu Oct 4 15:29:43 2007
@@ -286,31 +286,31 @@
<result name="input">/WEB-INF/jsp/admin/proxyConnectors.jsp</result>
</action>
- <action name="addProxyConnector" class="configureProxyConnectorAction" method="add">
- <result name="input">/WEB-INF/jsp/admin/editProxyConnector.jsp</result>
+ <action name="addProxyConnector" class="addProxyConnectorAction" method="input">
+ <result name="input">/WEB-INF/jsp/admin/addProxyConnector.jsp</result>
<result name="success" type="redirect-action">proxyConnectors</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
- <action name="configureProxyConnector" class="configureProxyConnectorAction" method="input">
+ <action name="editProxyConnector" class="editProxyConnectorAction" method="input">
<result name="input">/WEB-INF/jsp/admin/editProxyConnector.jsp</result>
<result name="success" type="redirect-action">proxyConnectors</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
- <action name="editProxyConnector" class="configureProxyConnectorAction" method="edit">
+ <action name="sortUpProxyConnector" class="sortProxyConnectorsAction" method="sortUp">
<result name="input">/WEB-INF/jsp/admin/editProxyConnector.jsp</result>
<result name="success" type="redirect-action">proxyConnectors</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
- <action name="saveProxyConnector" class="configureProxyConnectorAction" method="save">
+
+ <action name="sortDownProxyConnector" class="sortProxyConnectorsAction" method="sortDown">
<result name="input">/WEB-INF/jsp/admin/editProxyConnector.jsp</result>
<result name="success" type="redirect-action">proxyConnectors</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
-
- <action name="deleteProxyConnector" class="configureProxyConnectorAction" method="confirm">
+
+ <action name="deleteProxyConnector" class="deleteProxyConnectorAction" method="confirm">
<result name="input">/WEB-INF/jsp/admin/deleteProxyConnector.jsp</result>
<result name="success" type="redirect-action">proxyConnectors</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp?rev=582020&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp (added)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp Thu Oct 4 15:29:43 2007
@@ -0,0 +1,45 @@
+<%--
+ ~ 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 Proxy Connector</title>
+ <ww:head/>
+</head>
+
+<body>
+
+<h1>Admin: Add Proxy Connector</h1>
+
+<div id="contentArea">
+
+ <ww:actionerror/>
+ <ww:actionmessage/>
+
+ <ww:form name="saveProxyConnector" method="post" action="addProxyConnector!commit" namespace="/admin" validate="true">
+ <%@ include file="/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf" %>
+ <ww:submit value="Add Proxy Connector"/>
+ </ww:form>
+
+</div>
+
+</body>
+</html>
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp?rev=582020&r1=582019&r2=582020&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp Thu Oct 4 15:29:43 2007
@@ -20,266 +20,26 @@
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<c:url var="iconDeleteUrl" value="/images/icons/delete.gif"/>
-<c:url var="iconCreateUrl" value="/images/icons/create.png"/>
-
-<c:choose>
- <c:when test="${mode == 'edit'}">
- <c:set var="addedit" value="Edit"/>
- </c:when>
- <c:otherwise>
- <c:set var="addedit" value="Add"/>
- </c:otherwise>
-</c:choose>
-
<html>
<head>
- <title>Admin : ${addedit} Proxy Connector</title>
+ <title>Admin : Edit Proxy Connector</title>
<ww:head/>
</head>
<body>
-<h1>Admin : ${addedit} Proxy Connector</h1>
+<h1>Admin : Edit Proxy Connector</h1>
<div id="contentArea">
-<ww:actionerror/>
-<ww:actionmessage/>
-
-<ww:form name="saveProxyConnector" method="post" action="saveProxyConnector" namespace="/admin">
-<ww:hidden name="mode"/>
-
-<input type="hidden" name="pattern"/>
-<ww:select name="connector.proxyId" list="proxyIdOptions" label="Network Proxy" required="true"/>
-<ww:select name="connector.sourceRepoId" list="managedRepoIdList"
- label="Managed Repository" required="true"/>
-<ww:select name="connector.targetRepoId" list="remoteRepoIdList"
- label="Remote Repository" required="true"/>
-
-<tr>
- <td valign="top"><label>Policies:</label>
- </td>
- <td>
- <table>
- <c:forEach items="${policyMap}" var="policy" varStatus="i">
- <tr>
- <td>
- <ww:label for="policy_${policy.key}" required="true"
- theme="simple">${policy.key}:
- </ww:label>
- </td>
- <td>
- <ww:select name="connector.policies['${policy.key}']"
- list="policyMap['${policy.key}'].options"
- value="connector.policies['${policy.key}']"
- id="policy_${policy.key}"
- theme="simple"
- cssStyle="width: 10em"/>
- </td>
- </tr>
- </c:forEach>
- </table>
- </td>
-</tr>
-
-<tr class="seperator">
- <td valign="top">
- <label for="propertiesEntry">Properties:</label>
- </td>
- <td>
- <ww:textfield name="propertyKey" size="15" id="propertiesEntry" theme="simple"
- onkeypress="submitenter(event, 'editProxyConnector!addProperty.action')"/>
- :
- <ww:textfield name="propertyValue" size="15" id="propertiesValue" theme="simple"
- onkeypress="submitenter(event, 'editProxyConnector!addProperty.action')"/>
- <ww:submit name="action:editProxyConnector!addProperty" value="Add Property" theme="simple"/>
- </td>
-</tr>
-
-<tr>
- <td>
- </td>
- <td>
- <c:choose>
- <c:when test="${empty(connector.properties)}">
- <i>No properties have been set.</i>
- </c:when>
- <c:otherwise>
- <ww:url id="removePropertyUrl"
- action="editProxyConnector"
- method="removeProperty"/>
- <table>
- <c:forEach items="${connector.properties}" var="property" varStatus="i">
- <tr>
- <td>
- <ww:label for="property_${property.key}"
- theme="simple">${property.key}</ww:label>
- </td>
- <td>
- <ww:textfield name="connector.properties['${property.key}']"
- size="15"
- id="property_${property.key}"
- theme="simple"/>
- </td>
- <td>
- <ww:a href="#" title="Remove [${property.key}] Property"
- onclick="setAndSubmit('propertyKey', '${property.key}', '%{removePropertyUrl}')"
- theme="simple">
- <img src="${iconDeleteUrl}"/></ww:a>
-
- </td>
- </tr>
- </c:forEach>
- </table>
- </c:otherwise>
- </c:choose>
- </td>
-</tr>
-
-<tr class="seperator">
- <td valign="top">
- <label for="blackListEntry">Black List:</label>
- </td>
- <td>
- <ww:textfield name="blackListPattern" size="30" id="blackListEntry" theme="simple"
- onkeypress="submitenter(event, 'editProxyConnector!addBlackListPattern.action')"/>
- <ww:submit name="action:editProxyConnector!addBlackListPattern" value="Add Pattern" theme="simple"/>
- </td>
-</tr>
-
-<tr>
- <td>
- </td>
- <td>
- <ww:url id="removeBlackListPatternUrl"
- action="editProxyConnector"
- method="removeBlackListPattern"/>
- <c:choose>
- <c:when test="${empty(connector.blackListPatterns)}">
- <i>No black list patterns have been set.</i>
- </c:when>
- <c:otherwise>
- <table>
- <c:forEach items="${connector.blackListPatterns}" var="pattern" varStatus="i">
- <tr>
- <td>
- <ww:hidden name="connector.blackListPatterns" value="${pattern}"/>
- <code>"${pattern}"</code>
- </td>
- <td>
- <ww:a href="#" title="Remove [${pattern}] Pattern"
- onclick="setAndSubmit('pattern', '${pattern}', '%{removeBlackListPatternUrl}')"
- theme="simple">
- <img src="${iconDeleteUrl}"/></ww:a>
- </td>
- </tr>
- </c:forEach>
- </table>
- </c:otherwise>
- </c:choose>
- </td>
-</tr>
-
-<tr class="seperator">
- <td valign="top">
- <label for="whiteListEntry">White List:</label>
- </td>
- <td>
- <ww:textfield name="whiteListPattern" size="30" id="whiteListEntry" theme="simple"
- onkeypress="submitenter(event, 'editProxyConnector!addWhiteListPattern.action')"/>
- <ww:submit name="action:editProxyConnector!addWhiteListPattern" value="Add Pattern" theme="simple"/>
- </td>
-</tr>
-<tr>
- <td>
- </td>
- <td>
- <ww:url id="removeWhiteListPatternUrl"
- action="editProxyConnector"
- method="removeWhiteListPattern"/>
- <c:choose>
- <c:when test="${empty(connector.whiteListPatterns)}">
- <i>No white list patterns have been set.</i>
- </c:when>
- <c:otherwise>
- <table>
- <c:forEach items="${connector.whiteListPatterns}" var="pattern" varStatus="i">
- <tr>
- <td>
- <ww:hidden name="connector.whiteListPatterns" value="${pattern}"/>
- <code>"${pattern}"</code>
- </td>
- <td>
- <ww:a href="#" title="Remove [${pattern}] Pattern"
- onclick="setAndSubmit('pattern', '${pattern}', '%{removeWhiteListPatternUrl}')"
- theme="simple">
- <img src="${iconDeleteUrl}"/></ww:a>
- </td>
- </tr>
- </c:forEach>
- </table>
- </c:otherwise>
- </c:choose>
- </td>
-</tr>
-
-
-<ww:submit value="Save Proxy Connector"/>
-</ww:form>
-
-<script type="text/javascript">
- <!--
- document.getElementById("saveProxyConnector_proxyId").focus();
-
- function setAndSubmit( id, value, action )
- {
- var f = document.forms['saveProxyConnector'];
-
- f.action = action;
- f.elements[id].value = value;
- f.submit();
- }
-
- function submitForm( action )
- {
- var f = document.forms['saveProxyConnector'];
-
- f.action = action;
- f.submit();
- }
-
- function submitenter( e, action )
- {
- var keycode;
-
- if ( window.event )
- {
- keycode = window.event.keyCode;
- }
- else if ( e )
- {
- keycode = e.which;
- }
- else
- {
- return true;
- }
-
- if ( keycode == 13 )
- {
- submitForm(action);
- return false;
- }
- else
- {
- return true;
- }
- }
-
- //-->
-</script>
+ <ww:actionerror/>
+ <ww:actionmessage/>
+ <ww:form name="saveProxyConnector" method="post" action="editProxyConnector!commit" namespace="/admin" validate="true">
+ <%@ include file="/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf" %>
+ <ww:submit value="Save Proxy Connector"/>
+ </ww:form>
+
</div>
</body>
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf?rev=582020&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf (added)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf Thu Oct 4 15:29:43 2007
@@ -0,0 +1,256 @@
+<%--
+ ~ 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" %>
+
+<c:url var="iconDeleteUrl" value="/images/icons/delete.gif"/>
+<c:url var="iconCreateUrl" value="/images/icons/create.png"/>
+
+<%-- This hidden 'pattern' field is used by remove (white|black)list scripts --%>
+<ww:hidden name="pattern" />
+
+<ww:hidden name="connector.order" />
+
+<ww:select name="connector.proxyId" list="proxyIdOptions" label="Network Proxy" required="true"/>
+<ww:select name="connector.sourceRepoId" list="managedRepoIdList"
+ label="Managed Repository" required="true"/>
+<ww:select name="connector.targetRepoId" list="remoteRepoIdList"
+ label="Remote Repository" required="true"/>
+
+<tr>
+ <td valign="top"><label>Policies:</label>
+ </td>
+ <td>
+ <table>
+ <c:forEach items="${policyMap}" var="policy" varStatus="i">
+ <tr>
+ <td>
+ <ww:label for="policy_${policy.key}" required="true"
+ theme="simple">${policy.key}:
+ </ww:label>
+ </td>
+ <td>
+ <ww:select name="connector.policies['${policy.key}']"
+ list="policyMap['${policy.key}'].options"
+ value="connector.policies['${policy.key}']"
+ id="policy_${policy.key}"
+ theme="simple"
+ cssStyle="width: 10em"/>
+ </td>
+ </tr>
+ </c:forEach>
+ </table>
+ </td>
+</tr>
+
+<tr class="seperator">
+ <td valign="top">
+ <label for="propertiesEntry">Properties:</label>
+ </td>
+ <td>
+ <ww:textfield name="propertyKey" size="15" id="propertiesEntry" theme="simple"
+ onkeypress="submitenter(event, 'addProperty')"/>
+ :
+ <ww:textfield name="propertyValue" size="15" id="propertiesValue" theme="simple"
+ onkeypress="submitenter(event, 'addProperty')"/>
+ <input type="button" onclick="submitForm('addProperty')" value="Add Property" />
+ </td>
+</tr>
+
+<tr>
+ <td>
+ </td>
+ <td>
+ <c:choose>
+ <c:when test="${empty(connector.properties)}">
+ <i>No properties have been set.</i>
+ </c:when>
+ <c:otherwise>
+ <table>
+ <c:forEach items="${connector.properties}" var="property" varStatus="i">
+ <tr>
+ <td>
+ <ww:label for="property_${property.key}"
+ theme="simple">${property.key}</ww:label>
+ </td>
+ <td>
+ <ww:textfield name="connector.properties['${property.key}']"
+ size="15"
+ id="property_${property.key}"
+ theme="simple"/>
+ </td>
+ <td>
+ <ww:a href="#" title="Remove [${property.key}] Property"
+ onclick="setAndSubmit('propertyKey', '${property.key}', 'removeProperty')"
+ theme="simple">
+ <img src="${iconDeleteUrl}"/></ww:a>
+ </td>
+ </tr>
+ </c:forEach>
+ </table>
+ </c:otherwise>
+ </c:choose>
+ </td>
+</tr>
+
+<tr class="seperator">
+ <td valign="top">
+ <label for="blackListEntry">Black List:</label>
+ </td>
+ <td>
+ <ww:textfield name="blackListPattern" size="30" id="blackListEntry" theme="simple"
+ onkeypress="submitenter(event, 'addBlackListPattern')"/>
+ <input type="button" onclick="submitForm('addBlackListPattern')" value="Add Pattern" />
+ </td>
+</tr>
+
+<tr>
+ <td>
+ </td>
+ <td>
+ <c:choose>
+ <c:when test="${empty(connector.blackListPatterns)}">
+ <i>No black list patterns have been set.</i>
+ </c:when>
+ <c:otherwise>
+ <table>
+ <c:forEach items="${connector.blackListPatterns}" var="pattern" varStatus="i">
+ <tr>
+ <td>
+ <ww:hidden name="connector.blackListPatterns" value="${pattern}"/>
+ <code>"${pattern}"</code>
+ </td>
+ <td>
+ <a href="#" title="Remove [${pattern}] Pattern"
+ onclick="setAndSubmit('pattern', '${pattern}', 'removeBlackListPattern')">
+ <img src="${iconDeleteUrl}"/></a>
+ </td>
+ </tr>
+ </c:forEach>
+ </table>
+ </c:otherwise>
+ </c:choose>
+ </td>
+</tr>
+
+<tr class="seperator">
+ <td valign="top">
+ <label for="whiteListEntry">White List:</label>
+ </td>
+ <td>
+ <ww:textfield name="whiteListPattern" size="30" id="whiteListEntry" theme="simple"
+ onkeypress="submitenter(event, 'addWhiteListPattern')"/>
+ <input type="button" onclick="submitForm('addWhiteListPattern')" value="Add Pattern" />
+ </td>
+</tr>
+<tr>
+ <td>
+ </td>
+ <td>
+ <c:choose>
+ <c:when test="${empty(connector.whiteListPatterns)}">
+ <i>No white list patterns have been set.</i>
+ </c:when>
+ <c:otherwise>
+ <table>
+ <c:forEach items="${connector.whiteListPatterns}" var="pattern" varStatus="i">
+ <tr>
+ <td>
+ <ww:hidden name="connector.whiteListPatterns" value="${pattern}"/>
+ <code>"${pattern}"</code>
+ </td>
+ <td>
+ <ww:a href="#" title="Remove [${pattern}] Pattern"
+ onclick="setAndSubmit('pattern', '${pattern}', 'removeWhiteListPattern')"
+ theme="simple">
+ <img src="${iconDeleteUrl}"/></ww:a>
+ </td>
+ </tr>
+ </c:forEach>
+ </table>
+ </c:otherwise>
+ </c:choose>
+ </td>
+</tr>
+
+<script type="text/javascript">
+ <!--
+ function adjustActionMethod( action, method )
+ {
+ var idx = action.indexOf( "!" );
+ if( idx == (-1) )
+ {
+ // no "name!method.action" defined, split by ".action" instead.
+ idx = action.indexOf( ".action" );
+ }
+
+ return action.substring( 0, idx ) + "!" + method + ".action";
+ }
+
+ function setAndSubmit( id, value, method )
+ {
+ var f = document.forms['saveProxyConnector'];
+
+ f.action = adjustActionMethod( f.action, method );
+ f.elements[id].value = value;
+ f.submit();
+ }
+
+ function submitForm( method )
+ {
+ var f = document.forms['saveProxyConnector'];
+
+ var before = f.action;
+ f.action = adjustActionMethod( f.action, method );
+ f.submit();
+ }
+
+ function submitenter( e, method )
+ {
+ var keycode;
+
+
+ if ( window.event )
+ {
+ keycode = window.event.keyCode;
+ }
+ else if ( e )
+ {
+ keycode = e.which;
+ }
+ else
+ {
+ return true;
+ }
+
+ if ( keycode == 13 )
+ {
+ submitForm( method );
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ document.forms["saveProxyConnector"]["connector.proxyId"].focus();
+ //-->
+</script>
+
Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp?rev=582020&r1=582019&r2=582020&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp Thu Oct 4 15:29:43 2007
@@ -36,6 +36,8 @@
<c:url var="iconDeleteUrl" value="/images/icons/delete.gif"/>
<c:url var="iconEditUrl" value="/images/icons/edit.png"/>
<c:url var="iconCreateUrl" value="/images/icons/create.png"/>
+<c:url var="iconUpUrl" value="/images/icons/up.gif"/>
+<c:url var="iconDownUrl" value="/images/icons/down.gif"/>
<div id="contentArea">
@@ -59,26 +61,40 @@
<strong>No Repository Proxy Connectors Defined.</strong>
</c:when>
<c:otherwise>
-<table width="100%">
-<c:forEach items="${proxyConnectorMap}" var="repository" varStatus="i">
-<c:forEach items="${repository.value}" var="connector" varStatus="pc">
-<tr class="proxyConnector">
-<c:if test="${pc.first}">
- <td class="managedRepo" rowspan="${fn:length(repository.value)}">
- <div>
- <img src="<c:url value="/images/archiva-splat-32.gif"/>"/>
+<div class="admin">
- <p class="id">${repository.key}</p>
+<c:forEach items="${proxyConnectorMap}" var="repository" varStatus="i">
- <p class="name">${repoMap[repository.key].name}</p>
- </div>
- </td>
-</c:if>
-<td class="connector">
- <div class="wrap">
+<div class="proxyConfig">
+ <div class="managedRepo">
+ <img src="<c:url value="/images/archiva-splat-32.gif"/>"/>
+ <p class="id">${repository.key}</p>
+ <p class="name">${repoMap[repository.key].name}</p>
+ </div>
+
+ <c:forEach items="${repository.value}" var="connector" varStatus="pc">
+
+ <c:choose>
+ <c:when test='${(pc.index)%2 eq 0}'>
+ <c:set var="rowColor" value="dark" scope="page"/>
+ </c:when>
+ <c:otherwise>
+ <c:set var="rowColor" value="lite" scope="page"/>
+ </c:otherwise>
+ </c:choose>
+
+ <div class="connector ${rowColor}">
<div class="controls">
<redback:ifAnyAuthorized permissions="archiva-manage-configuration">
+ <ww:url id="sortDownProxyConnectorUrl" action="sortDownProxyConnector">
+ <ww:param name="target" value="%{'${connector.targetRepoId}'}"/>
+ <ww:param name="source" value="%{'${connector.sourceRepoId}'}"/>
+ </ww:url>
+ <ww:url id="sortUpProxyConnectorUrl" action="sortUpProxyConnector">
+ <ww:param name="target" value="%{'${connector.targetRepoId}'}"/>
+ <ww:param name="source" value="%{'${connector.sourceRepoId}'}"/>
+ </ww:url>
<ww:url id="editProxyConnectorUrl" action="editProxyConnector">
<ww:param name="target" value="%{'${connector.targetRepoId}'}"/>
<ww:param name="source" value="%{'${connector.sourceRepoId}'}"/>
@@ -87,6 +103,13 @@
<ww:param name="source" value="%{'${connector.sourceRepoId}'}"/>
<ww:param name="target" value="%{'${connector.targetRepoId}'}"/>
</ww:url>
+ <em>${connector.order}</em>
+ <ww:a href="%{sortUpProxyConnectorUrl}" cssClass="up" title="Move Proxy Connector Up">
+ <img src="${iconUpUrl}"/>
+ </ww:a>
+ <ww:a href="%{sortDownProxyConnectorUrl}" cssClass="down" title="Move Proxy Connector Down">
+ <img src="${iconDownUrl}"/>
+ </ww:a>
<ww:a href="%{editProxyConnectorUrl}" cssClass="edit" title="Edit Proxy Connector">
<img src="${iconEditUrl}"/>
</ww:a>
@@ -97,13 +120,22 @@
</div>
<h4>Proxy Connector</h4>
- <table>
+
+ <div class="remoteRepo">
+ <img src="<c:url value="/images/archiva-world.png"/>"/>
+ <p class="id">${connector.targetRepoId}</p>
+ <p class="name">${repoMap[connector.targetRepoId].name}</p>
+ <p class="url"><a href="${repoMap[connector.targetRepoId].url}">${repoMap[connector.targetRepoId].url}</a></p>
+ </div>
+
+ <a class="expand" href="#" onclick="Effect.toggle('proxySettings_${connector.sourceRepoId}_${connector.targetRepoId}','slide'); return false;">Expand</a>
+ <table class="settings" style="display: none;" id="proxySettings_${connector.sourceRepoId}_${connector.targetRepoId}">
<tr>
<th nowrap="nowrap">Network Proxy:</th>
<td>
<c:choose>
<c:when test="${empty(connector.proxyId)}">
- <i>(Direct Connection)</i>
+ <span class="directConnection">(Direct Connection)</span>
</c:when>
<c:otherwise>
<ww:url id="editProxyIdUrl" action="editNetworkProxy">
@@ -120,9 +152,14 @@
<tr>
<th>Policies:</th>
<td nowrap="nowrap">
- <c:forEach items="${connector.policies}" var="policies">
- <p><em>${policies.key}</em>: ${policies.value}</p>
- </c:forEach>
+ <table class="policies">
+ <c:forEach items="${connector.policies}" var="policies">
+ <tr>
+ <th>${policies.key}</th>
+ <td>${policies.value}</td>
+ </tr>
+ </c:forEach>
+ </table>
</td>
</tr>
@@ -152,30 +189,24 @@
<tr>
<th>Properties:</th>
<td>
- <c:forEach items="${connector.properties}" var="prop">
- <p><em>${prop.key}</em>: ${prop.value}</p>
- </c:forEach>
+ <table class="props">
+ <c:forEach items="${connector.properties}" var="prop">
+ <tr>
+ <th>${prop.key}</th>
+ <td>${prop.value}</td>
+ </tr>
+ </c:forEach>
+ </table>
</td>
</tr>
</c:if>
</table>
- </div>
-</td>
-<td class="remoteRepo">
- <div>
- <img src="<c:url value="/images/archiva-world.png"/>"/>
-
- <p class="id">${connector.targetRepoId}</p>
+ </div> <%-- connector --%>
- <p class="name">${repoMap[connector.targetRepoId].name}</p>
-
- <p class="url">${repoMap[connector.targetRepoId].url}</p>
- </div>
-</td>
-</tr>
</c:forEach>
+</div> <%-- proxyConfig --%>
</c:forEach>
-</table>
+</div> <%-- admin --%>
</c:otherwise>
</c:choose>
Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/css/site.css
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/css/site.css?rev=582020&r1=582019&r2=582020&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/css/site.css (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/css/site.css Thu Oct 4 15:29:43 2007
@@ -245,72 +245,82 @@
border-bottom: 1px solid #DFDEDE;
}
-tr.proxyConnector {
- border-bottom: 1px solid #DFDEDE;
+div.proxyConfig {
+ border: 1px dashed #DFDEDE;
+ margin-bottom: 15px;
+ padding: 5px;
}
-tr.proxyConnector td.managedRepo div,
-tr.proxyConnector td.remoteRepo div {
+div.proxyConfig div.managedRepo,
+div.proxyConfig div.remoteRepo {
border: 1px dotted gray;
padding: 5px;
background-color: white;
}
-tr.proxyConnector td.managedRepo img,
-tr.proxyConnector td.remoteRepo img {
+div.proxyConfig div.remoteRepo {
+ margin: 5px;
+}
+
+div.proxyConfig div.managedRepo img,
+div.proxyConfig div.remoteRepo img {
float: left;
border: 0px;
}
-tr.proxyConnector td.managedRepo div p,
-tr.proxyConnector td.remoteRepo div p {
+div.proxyConfig div.managedRepo p,
+div.proxyConfig div.remoteRepo p {
margin: 0px;
margin-left: 40px;
padding: 0px;
}
-tr.proxyConnector td.managedRepo div p.id,
-tr.proxyConnector td.remoteRepo div p.id {
+div.proxyConfig div.managedRepo p.id,
+div.proxyConfig div.remoteRepo p.id {
font-family: monospace;
}
-tr.proxyConnector td.connector {
- padding-left: 10px;
- padding-right: 10px;
+div.proxyConfig div.connector {
+ border: 1px solid #aaaaff;
+ margin-top: 10px;
+ margin-left: 40px !important;
}
-tr.proxyConnector td.connector div.wrap {
- margin-left: 10px;
- margin-right: 10px;
- padding: 5px;
- border: 1px solid gray;
- background-color: #eeeeee;
+div.proxyConfig a.expand {
+ font-size: 7pt;
+ color: gray;
}
-tr.proxyConnector td.connector div.controls {
+div.proxyConfig div.controls {
float: right;
}
-tr.proxyConnector td.connector div h4 {
- font-size: 1.0em;
+div.proxyConfig div.connector h4 {
+ padding: 3px;
+ font-size: 8pt;
margin: 0px;
}
-tr.proxyConnector td.connector table {
+div.proxyConfig div.connector table.settings {
border: 0px;
background-color: transparent;
- font-size: 0.8em;
+ font-size: 8pt;
+ margin-left: 10px;
}
-tr.proxyConnector td.connector table p {
- margin: 0px;
- padding: 0px;
+div.proxyConfig div.connector table.settings th,
+div.proxyConfig div.connector table.settings td {
+ font-size: 8pt;
}
-tr.seperator td {
- border-top: 1px dashed #dddddd !important;
+div.proxyConfig div.connector table.settings table.policies {
+ border: 1px dotted gray;
}
+div.proxyConfig div.connector table p {
+ margin: 0px;
+ padding: 0px;
+}
div.admin div.dark,
div.admin div.lite {
border: 1px solid #aaaaaa;
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/images/icons/down.gif
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/images/icons/down.gif?rev=582020&view=auto
==============================================================================
Binary file - no diff available.
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/images/icons/down.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/images/icons/up.gif
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/images/icons/up.gif?rev=582020&view=auto
==============================================================================
Binary file - no diff available.
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/images/icons/up.gif
------------------------------------------------------------------------------
svn:mime-type = image/gif
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java?rev=582020&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java (added)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java Thu Oct 4 15:29:43 2007
@@ -0,0 +1,128 @@
+package org.apache.maven.archiva.web.action;
+
+/*
+ * 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.
+ */
+
+import com.opensymphony.xwork.ActionSupport;
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * AbstractWebworkTestCase
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractWebworkTestCase
+ extends PlexusTestCase
+{
+ /**
+ * This is a conveinence method for mimicking how the webwork interceptors
+ * operate on an action, before the request is processed.
+ *
+ * Call this before each major request to the action to be sure you mimic the webwork process correctly.
+ */
+ protected void preRequest( ActionSupport action )
+ {
+ action.clearErrorsAndMessages();
+ }
+
+ /**
+ * Tests the action to ensure that it has errors.
+ *
+ * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
+ */
+ protected void assertHasErrors( ActionSupport action )
+ {
+ assertNotNull( action.getActionErrors() );
+ assertTrue( "Expected an error to occur.", action.getActionErrors().size() > 0 );
+ }
+
+ /**
+ * Tests the action to ensure that it has messages.
+ *
+ * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
+ */
+ protected void assertHasMessages( ActionSupport action )
+ {
+ assertNotNull( action.getActionMessages() );
+ assertTrue( "Expected an message to be set.", action.getActionMessages().size() > 0 );
+ }
+
+ /**
+ * Tests the action to ensure that it has NO errors.
+ *
+ * NOTE: Don't forget to run {@link #preRequest(ActionSupport)} before each request to your action!
+ */
+ protected void assertNoErrors( ActionSupport action )
+ {
+ List<String> errors = (List<String>) action.getActionErrors();
+
+ assertNotNull( errors );
+ if ( errors.size() > 0 )
+ {
+ StringBuffer msg = new StringBuffer();
+ msg.append( "Should have had no errors. but found the following errors." );
+
+ for ( String error : errors )
+ {
+ msg.append( "\n " ).append( error );
+ }
+ fail( msg.toString() );
+ }
+ }
+
+ protected void assertRequestStatus( ActionSupport action, String expectedStatus, String methodName )
+ throws Exception
+ {
+ action.clearErrorsAndMessages();
+
+ Method method = action.getClass().getDeclaredMethod( methodName, (Class[]) null );
+ Object actualStatus = method.invoke( action, (Object[]) null );
+ assertTrue( "return should be of type String", actualStatus instanceof String );
+
+ if ( !StringUtils.equals( expectedStatus, (String) actualStatus ) )
+ {
+ StringBuffer msg = new StringBuffer();
+ msg.append( "Unexpected status returned from method <" );
+ msg.append( methodName ).append( "> on action <" );
+ String clazzname = action.getClass().getName();
+ msg.append( clazzname.substring( clazzname.lastIndexOf( '.' ) ) );
+ msg.append( ">: expected:<" ).append( expectedStatus ).append( "> but was:<" );
+ msg.append( (String) actualStatus ).append( ">. (see attached action messages and errors below)" );
+
+ for ( String message : (Collection<String>) action.getActionMessages() )
+ {
+ msg.append( "\n [MESSAGE]: " ).append( message );
+ }
+
+ for ( String error : (Collection<String>) action.getActionErrors() )
+ {
+ msg.append( "\n [ERROR]: " ).append( error );
+ }
+
+ fail( msg.toString() );
+ }
+ }
+}
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractWebworkTestCase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java?rev=582020&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java (added)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java Thu Oct 4 15:29:43 2007
@@ -0,0 +1,408 @@
+package org.apache.maven.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * 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.
+ */
+
+import com.opensymphony.xwork.Action;
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.maven.archiva.policies.CachedFailuresPolicy;
+import org.apache.maven.archiva.policies.ChecksumPolicy;
+import org.apache.maven.archiva.policies.ReleasesPolicy;
+import org.apache.maven.archiva.policies.SnapshotsPolicy;
+import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
+import org.codehaus.plexus.registry.RegistryException;
+import org.easymock.MockControl;
+
+import java.util.List;
+
+/**
+ * AddProxyConnectorActionTest
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class AddProxyConnectorActionTest
+ extends AbstractWebworkTestCase
+{
+ private AddProxyConnectorAction action;
+
+ private MockControl archivaConfigurationControl;
+
+ private ArchivaConfiguration archivaConfiguration;
+
+ public void testAddBlackListPattern()
+ throws Exception
+ {
+ expectConfigurationRequests( 7 );
+ archivaConfigurationControl.replay();
+
+ // Prepare Test.
+ action.prepare();
+ ProxyConnectorConfiguration connector = action.getConnector();
+ populateProxyConnector( connector );
+
+ // Perform Test w/no values.
+ preRequest( action );
+ String status = action.addBlackListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no blacklist pattern added.
+ assertHasErrors( action );
+ assertEquals( 0, connector.getBlackListPatterns().size() );
+
+ // Try again, but now with a pattern to add.
+ action.setBlackListPattern( "**/*-javadoc.jar" );
+ preRequest( action );
+ status = action.addBlackListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have no error, and 1 blacklist pattern added.
+ assertNoErrors( action );
+ assertEquals( 1, connector.getBlackListPatterns().size() );
+ }
+
+ public void testAddProperty()
+ throws Exception
+ {
+ expectConfigurationRequests( 7 );
+ archivaConfigurationControl.replay();
+
+ // Prepare Test.
+ action.prepare();
+ ProxyConnectorConfiguration connector = action.getConnector();
+ populateProxyConnector( connector );
+
+ // Perform Test w/no values.
+ preRequest( action );
+ String status = action.addProperty();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no property pattern added.
+ assertHasErrors( action );
+ assertEquals( 0, connector.getProperties().size() );
+
+ // Try again, but now with a property key/value to add.
+ action.setPropertyKey( "eat-a" );
+ action.setPropertyValue( "gramov-a-bits" );
+ preRequest( action );
+ status = action.addProperty();
+ assertEquals( Action.INPUT, status );
+
+ // Should have no error, and 1 property added.
+ assertNoErrors( action );
+ assertEquals( 1, connector.getProperties().size() );
+ }
+
+ public void testAddProxyConnectorCommit()
+ throws Exception
+ {
+ expectConfigurationRequests( 7 );
+ archivaConfigurationControl.replay();
+
+ // Prepare Test.
+ action.prepare();
+ ProxyConnectorConfiguration connector = action.getConnector();
+ populateProxyConnector( connector );
+
+ // Create the input screen.
+ assertRequestStatus( action, Action.SUCCESS, "commit" );
+ assertNoErrors( action );
+
+ // Test configuration.
+ List<ProxyConnectorConfiguration> proxyConfigs = archivaConfiguration.getConfiguration().getProxyConnectors();
+ assertNotNull( proxyConfigs );
+ assertEquals( 1, proxyConfigs.size() );
+
+ ProxyConnectorConfiguration actualConnector = proxyConfigs.get( 0 );
+
+ assertNotNull( actualConnector );
+ // The use of "(direct connection)" should result in a proxyId which is <null>.
+ assertNull( actualConnector.getProxyId() );
+ assertEquals( "corporate", actualConnector.getSourceRepoId() );
+ assertEquals( "central", actualConnector.getTargetRepoId() );
+ }
+
+ public void testAddProxyConnectorInitialPage()
+ throws Exception
+ {
+ expectConfigurationRequests( 3 );
+ archivaConfigurationControl.replay();
+
+ action.prepare();
+ ProxyConnectorConfiguration configuration = action.getConnector();
+ assertNotNull( configuration );
+ assertNull( configuration.getProxyId() );
+ assertNull( configuration.getSourceRepoId() );
+ assertNull( configuration.getTargetRepoId() );
+ assertTrue( configuration.getPolicies().isEmpty() );
+ assertTrue( configuration.getProperties().isEmpty() );
+ assertTrue( configuration.getBlackListPatterns().isEmpty() );
+ assertTrue( configuration.getWhiteListPatterns().isEmpty() );
+
+ String status = action.input();
+ assertEquals( Action.INPUT, status );
+ }
+
+ public void testAddWhiteListPattern()
+ throws Exception
+ {
+ expectConfigurationRequests( 7 );
+ archivaConfigurationControl.replay();
+
+ // Prepare Test.
+ action.prepare();
+ ProxyConnectorConfiguration connector = action.getConnector();
+ populateProxyConnector( connector );
+
+ // Perform Test w/no values.
+ preRequest( action );
+ String status = action.addWhiteListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no whitelist pattern added.
+ assertHasErrors( action );
+ assertEquals( 0, connector.getWhiteListPatterns().size() );
+
+ // Try again, but now with a pattern to add.
+ action.setWhiteListPattern( "**/*.jar" );
+ preRequest( action );
+ status = action.addWhiteListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have no error, and 1 whitelist pattern added.
+ assertNoErrors( action );
+ assertEquals( 1, connector.getWhiteListPatterns().size() );
+ }
+
+ public void testRemoveBlackListPattern()
+ throws Exception
+ {
+ expectConfigurationRequests( 7 );
+ archivaConfigurationControl.replay();
+
+ // Prepare Test.
+ action.prepare();
+ ProxyConnectorConfiguration connector = action.getConnector();
+ populateProxyConnector( connector );
+
+ // Add some arbitrary blacklist patterns.
+ connector.addBlackListPattern( "**/*-javadoc.jar" );
+ connector.addBlackListPattern( "**/*.war" );
+
+ // Perform Test w/no pattern value.
+ preRequest( action );
+ String status = action.removeBlackListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no blacklist pattern removed.
+ assertHasErrors( action );
+ assertEquals( 2, connector.getBlackListPatterns().size() );
+
+ // Perform test w/invalid (non-existant) pattern value to remove.
+ preRequest( action );
+ action.setPattern( "**/*oops*" );
+ status = action.removeBlackListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no blacklist pattern removed.
+ assertHasErrors( action );
+ assertEquals( 2, connector.getBlackListPatterns().size() );
+
+ // Try again, but now with a valid pattern to remove.
+ action.setPattern( "**/*-javadoc.jar" );
+ preRequest( action );
+ status = action.removeBlackListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have no error, and 1 blacklist pattern left.
+ assertNoErrors( action );
+ assertEquals( 1, connector.getBlackListPatterns().size() );
+ assertEquals( "Should have left 1 blacklist pattern", "**/*.war", connector.getBlackListPatterns().get( 0 ) );
+ }
+
+ public void testRemoveProperty()
+ throws Exception
+ {
+ expectConfigurationRequests( 7 );
+ archivaConfigurationControl.replay();
+
+ // Prepare Test.
+ action.prepare();
+ ProxyConnectorConfiguration connector = action.getConnector();
+ populateProxyConnector( connector );
+
+ // Add some arbitrary properties.
+ connector.addProperty( "username", "general-tso" );
+ connector.addProperty( "password", "chicken" );
+
+ // Perform Test w/no property key.
+ preRequest( action );
+ String status = action.removeProperty();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no properties removed.
+ assertHasErrors( action );
+ assertEquals( 2, connector.getProperties().size() );
+
+ // Perform test w/invalid (non-existant) property key to remove.
+ preRequest( action );
+ action.setPropertyKey( "slurm" );
+ status = action.removeProperty();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no properties removed.
+ assertHasErrors( action );
+ assertEquals( 2, connector.getProperties().size() );
+
+ // Try again, but now with a valid property to remove.
+ preRequest( action );
+ action.setPropertyKey( "password" );
+ status = action.removeProperty();
+ assertEquals( Action.INPUT, status );
+
+ // Should have no error, and 1 property left.
+ assertNoErrors( action );
+ assertEquals( 1, connector.getProperties().size() );
+ assertEquals( "Should have left 1 property", "general-tso", connector.getProperties().get( "username" ) );
+ }
+
+ public void testRemoveWhiteListPattern()
+ throws Exception
+ {
+ expectConfigurationRequests( 7 );
+ archivaConfigurationControl.replay();
+
+ // Prepare Test.
+ action.prepare();
+ ProxyConnectorConfiguration connector = action.getConnector();
+ populateProxyConnector( connector );
+
+ // Add some arbitrary whitelist patterns.
+ connector.addWhiteListPattern( "javax/**/*" );
+ connector.addWhiteListPattern( "com/sun/**/*" );
+
+ // Perform Test w/no pattern value.
+ preRequest( action );
+ String status = action.removeWhiteListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no whitelist pattern removed.
+ assertHasErrors( action );
+ assertEquals( 2, connector.getWhiteListPatterns().size() );
+
+ // Perform test w/invalid (non-existant) pattern value to remove.
+ preRequest( action );
+ action.setPattern( "**/*oops*" );
+ status = action.removeWhiteListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have returned an error, with no whitelist pattern removed.
+ assertHasErrors( action );
+ assertEquals( 2, connector.getWhiteListPatterns().size() );
+
+ // Try again, but now with a valid pattern to remove.
+ action.setPattern( "com/sun/**/*" );
+ preRequest( action );
+ status = action.removeWhiteListPattern();
+ assertEquals( Action.INPUT, status );
+
+ // Should have no error, and 1 whitelist pattern left.
+ assertNoErrors( action );
+ assertEquals( 1, connector.getWhiteListPatterns().size() );
+ assertEquals( "Should have left 1 whitelist pattern", "javax/**/*", connector.getWhiteListPatterns().get( 0 ) );
+ }
+
+ public void testSecureActionBundle()
+ throws Exception
+ {
+ expectConfigurationRequests( 3 );
+ archivaConfigurationControl.replay();
+
+ action.prepare();
+ SecureActionBundle bundle = action.getSecureActionBundle();
+ assertTrue( bundle.requiresAuthentication() );
+ assertEquals( 1, bundle.getAuthorizationTuples().size() );
+ }
+
+ private Configuration createInitialConfiguration()
+ {
+ Configuration config = new Configuration();
+
+ ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+ managedRepo.setId( "corporate" );
+ managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+ managedRepo.setReleases( true );
+
+ config.addManagedRepository( managedRepo );
+
+ RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+ remoteRepo.setId( "central" );
+ remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+
+ config.addRemoteRepository( remoteRepo );
+
+ return config;
+ }
+
+ private void expectConfigurationRequests( int requestConfigCount )
+ throws RegistryException, IndeterminateConfigurationException
+ {
+ Configuration config = createInitialConfiguration();
+
+ for ( int i = 0; i < requestConfigCount; i++ )
+ {
+ archivaConfiguration.getConfiguration();
+ archivaConfigurationControl.setReturnValue( config );
+ }
+
+ archivaConfiguration.save( config );
+ }
+
+ private void populateProxyConnector( ProxyConnectorConfiguration connector )
+ {
+ connector.setProxyId( AbstractProxyConnectorFormAction.DIRECT_CONNECTION );
+ connector.setSourceRepoId( "corporate" );
+ connector.setTargetRepoId( "central" );
+
+ connector.getPolicies().put( "releases", ReleasesPolicy.IGNORED );
+ connector.getPolicies().put( "snapshots", SnapshotsPolicy.DISABLED );
+ connector.getPolicies().put( "checksum", ChecksumPolicy.FIX );
+ connector.getPolicies().put( "cache-failures", CachedFailuresPolicy.IGNORED );
+ }
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ action = (AddProxyConnectorAction) lookup( Action.class.getName(), "addProxyConnectorAction" );
+
+ archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+ archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+ action.setArchivaConfiguration( archivaConfiguration );
+ }
+}
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java?rev=582020&view=auto
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java (added)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java Thu Oct 4 15:29:43 2007
@@ -0,0 +1,225 @@
+package org.apache.maven.archiva.web.action.admin.connectors.proxy;
+
+/*
+ * 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.
+ */
+
+import com.opensymphony.xwork.Action;
+
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
+import org.codehaus.plexus.registry.RegistryException;
+import org.easymock.MockControl;
+
+/**
+ * DeleteProxyConnectorActionTest
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class DeleteProxyConnectorActionTest
+ extends AbstractWebworkTestCase
+{
+ private static final String TEST_TARGET_ID = "central";
+
+ private static final String TEST_SOURCE_ID = "corporate";
+
+ private DeleteProxyConnectorAction action;
+
+ private MockControl archivaConfigurationControl;
+
+ private ArchivaConfiguration archivaConfiguration;
+
+ public void testConfirmDelete()
+ throws Exception
+ {
+ expectConfigurationRequests( 1 );
+ archivaConfigurationControl.replay();
+
+ // Show the confirm the delete of proxy connector screen.
+ preRequest( action );
+ action.setSourceId( TEST_SOURCE_ID );
+ action.setTargetId( TEST_TARGET_ID );
+ String status = action.confirmDelete();
+ assertEquals( Action.INPUT, status );
+ assertNoErrors( action );
+ }
+
+ public void testConfirmDeleteBadSourceOrTarget()
+ throws Exception
+ {
+ expectConfigurationRequests( 4 );
+ archivaConfigurationControl.replay();
+
+ // Attempt to show the confirm delete screen, but provide
+ // a bad source id or target id to actually delete
+
+ preRequest( action );
+ action.setSourceId( "bad-source" ); // id doesn't exist.
+ action.setTargetId( "bad-target" ); // id doesn't exist.
+ String status = action.confirmDelete();
+ // Should have resulted in an error.
+ assertEquals( Action.ERROR, status );
+ assertHasErrors( action );
+
+ preRequest( action );
+ action.setSourceId( "bad" ); // Bad doesn't exist.
+ action.setTargetId( TEST_TARGET_ID );
+ status = action.confirmDelete();
+ // Should have resulted in an error.
+ assertEquals( Action.ERROR, status );
+ assertHasErrors( action );
+
+ preRequest( action );
+ action.setSourceId( TEST_SOURCE_ID );
+ action.setTargetId( "bad" ); // Bad doesn't exist.
+ status = action.confirmDelete();
+ // Should have resulted in an error.
+ assertEquals( Action.ERROR, status );
+ assertHasErrors( action );
+ }
+
+ public void testConfirmDeleteNoSourceOrTarget()
+ throws Exception
+ {
+ expectConfigurationRequests( 1 );
+ archivaConfigurationControl.replay();
+
+ // Attempt to show the confirm delete screen, but don't provide
+ // the source id or target id to actually delete
+
+ preRequest( action );
+ action.setSourceId( null ); // No source Id.
+ action.setTargetId( null ); // No target Id.
+ String status = action.confirmDelete();
+ // Should have resulted in an error.
+ assertEquals( Action.ERROR, status );
+ assertHasErrors( action );
+
+ preRequest( action );
+ action.setSourceId( TEST_SOURCE_ID );
+ action.setTargetId( null ); // No target Id.
+ status = action.confirmDelete();
+ // Should have resulted in an error.
+ assertEquals( Action.ERROR, status );
+ assertHasErrors( action );
+
+ preRequest( action );
+ action.setSourceId( null ); // No source Id.
+ action.setTargetId( TEST_TARGET_ID );
+ status = action.confirmDelete();
+ // Should have resulted in an error.
+ assertEquals( Action.ERROR, status );
+ assertHasErrors( action );
+ }
+
+ public void testDelete()
+ throws Exception
+ {
+ expectConfigurationRequests( 5 );
+ archivaConfigurationControl.replay();
+
+ // Show the confirm the delete of proxy connector screen.
+ preRequest( action );
+ action.setSourceId( TEST_SOURCE_ID );
+ action.setTargetId( TEST_TARGET_ID );
+ String status = action.confirmDelete();
+ assertEquals( Action.INPUT, status );
+ assertNoErrors( action );
+
+ // Perform the delete.
+ preRequest( action );
+ status = action.delete();
+ assertEquals( Action.SUCCESS, status );
+ assertNoErrors( action );
+ assertHasMessages( action );
+
+ // Test the configuration.
+ assertEquals( 0, archivaConfiguration.getConfiguration().getProxyConnectors().size() );
+ }
+
+ public void testSecureActionBundle()
+ throws Exception
+ {
+ expectConfigurationRequests( 1 );
+ archivaConfigurationControl.replay();
+
+ SecureActionBundle bundle = action.getSecureActionBundle();
+ assertTrue( bundle.requiresAuthentication() );
+ assertEquals( 1, bundle.getAuthorizationTuples().size() );
+ }
+
+ private Configuration createInitialConfiguration()
+ {
+ Configuration config = new Configuration();
+
+ ManagedRepositoryConfiguration managedRepo = new ManagedRepositoryConfiguration();
+ managedRepo.setId( TEST_SOURCE_ID );
+ managedRepo.setLayout( "${java.io.tmpdir}/archiva-test/managed-repo" );
+ managedRepo.setReleases( true );
+
+ config.addManagedRepository( managedRepo );
+
+ RemoteRepositoryConfiguration remoteRepo = new RemoteRepositoryConfiguration();
+ remoteRepo.setId( TEST_TARGET_ID );
+ remoteRepo.setUrl( "http://repo1.maven.org/maven2/" );
+
+ config.addRemoteRepository( remoteRepo );
+
+ ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
+ connector.setSourceRepoId( TEST_SOURCE_ID );
+ connector.setTargetRepoId( TEST_TARGET_ID );
+
+ config.addProxyConnector( connector );
+
+ return config;
+ }
+
+ private void expectConfigurationRequests( int requestConfigCount )
+ throws RegistryException, IndeterminateConfigurationException
+ {
+ Configuration config = createInitialConfiguration();
+
+ for ( int i = 0; i < requestConfigCount; i++ )
+ {
+ archivaConfiguration.getConfiguration();
+ archivaConfigurationControl.setReturnValue( config );
+ }
+
+ archivaConfiguration.save( config );
+ }
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ action = (DeleteProxyConnectorAction) lookup( Action.class.getName(), "deleteProxyConnectorAction" );
+
+ archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+ archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+ action.setArchivaConfiguration( archivaConfiguration );
+ }
+}
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/trunk/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain