From e5be21e4bbafdc2842e52ed5b403d4bf4e8c1040 Mon Sep 17 00:00:00 2001 From: James William Dumay Date: Tue, 19 Aug 2008 08:45:45 +0000 Subject: [PATCH] MRM-541 - convenient way to take Archiva proxies "offline" * Implemented UI for enabling/disabling proxy connectors * changes to RepositoryProxyConnectors to skip offline connectors git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-541@686984 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/mdo/configuration.mdo | 9 ++ .../DefaultRepositoryProxyConnectors.java | 15 +++ .../maven/archiva/proxy/ProxyConnector.java | 13 +++ .../connector/RepositoryConnector.java | 4 + .../proxy/DisableProxyConnectorAction.java | 98 +++++++++++++++++++ .../proxy/EnableProxyConnectorAction.java | 98 +++++++++++++++++++ .../src/main/resources/xwork.xml | 13 +++ .../jsp/admin/disableProxyConnector.jsp | 50 ++++++++++ .../jsp/admin/enableProxyConnector.jsp | 50 ++++++++++ .../WEB-INF/jsp/admin/proxyConnectors.jsp | 18 ++++ 10 files changed, 368 insertions(+) create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/disableProxyConnector.jsp create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/enableProxyConnector.jsp diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index b7523ef13..1af52dd63 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -725,6 +725,15 @@ * + + disabled + 1.2+ + + If the the repository proxy connector is disabled or not + + boolean + false + diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java index 2c5da3ebf..9c81b53ed 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java @@ -151,6 +151,11 @@ public class DefaultRepositoryProxyConnectors Map previousExceptions = new LinkedHashMap(); for ( ProxyConnector connector : connectors ) { + if (connector.isDisabled()) + { + continue; + } + RemoteRepositoryContent targetRepository = connector.getTargetRepository(); requestProperties.setProperty( "remoteRepositoryId", targetRepository.getId() ); @@ -221,6 +226,11 @@ public class DefaultRepositoryProxyConnectors List connectors = getProxyConnectors( repository ); for ( ProxyConnector connector : connectors ) { + if (connector.isDisabled()) + { + continue; + } + RemoteRepositoryContent targetRepository = connector.getTargetRepository(); requestProperties.setProperty( "remoteRepositoryId", targetRepository.getId() ); @@ -280,6 +290,11 @@ public class DefaultRepositoryProxyConnectors List connectors = getProxyConnectors( repository ); for ( ProxyConnector connector : connectors ) { + if (connector.isDisabled()) + { + continue; + } + RemoteRepositoryContent targetRepository = connector.getTargetRepository(); File localRepoFile = toLocalRepoFile( repository, targetRepository, logicalPath ); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ProxyConnector.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ProxyConnector.java index 8d59d7d6b..8bf9d4548 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ProxyConnector.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ProxyConnector.java @@ -49,6 +49,18 @@ public class ProxyConnector private int order; private Map policies; + + private boolean disabled; + + public boolean isDisabled() + { + return disabled; + } + + public void setDisabled(boolean disabled) + { + this.disabled = disabled; + } public List getBlacklist() { @@ -110,6 +122,7 @@ public class ProxyConnector this.proxyId = proxyId; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java index 5aee6b2cc..92f944710 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java @@ -39,4 +39,8 @@ public interface RepositoryConnector public List getBlacklist(); public List getWhitelist(); + + public boolean isDisabled(); + + public void setDisabled(boolean disabled); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java new file mode 100644 index 000000000..5ae3a4ddf --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java @@ -0,0 +1,98 @@ +package org.apache.maven.archiva.web.action.admin.connectors.proxy; + +import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; + +/* + * 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. + */ + +/** + * DisableProxyConnectorAction + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="disableProxyConnectorAction" + */ +public class DisableProxyConnectorAction extends AbstractProxyConnectorAction +{ + private String source; + + private String target; + + private ProxyConnectorConfiguration proxyConfig; + + public String confirmDisable() + { + this.proxyConfig = findProxyConnector( source, target ); + + // Not set? Then there is nothing to delete. + if ( this.proxyConfig == null ) + { + addActionError( "Unable to disable proxy configuration, configuration with source [" + source + + "], and target [" + target + "] does not exist." ); + return ERROR; + } + + return INPUT; + } + + public String disable() + { + this.proxyConfig = findProxyConnector( source, target ); + + // Not set? Then there is nothing to delete. + if ( this.proxyConfig == null ) + { + addActionError( "Unable to disable proxy configuration, configuration with source [" + source + + "], and target [" + target + "] does not exist." ); + return ERROR; + } + + if ( hasActionErrors() ) + { + return ERROR; + } + + proxyConfig.setDisabled(true); + + addActionMessage( "Successfully disabled proxy connector [" + source + " , " + target + " ]" ); + + setSource( null ); + setTarget( null ); + + 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; + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java new file mode 100644 index 000000000..0b7bee4bb --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java @@ -0,0 +1,98 @@ +package org.apache.maven.archiva.web.action.admin.connectors.proxy; + +import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; + +/* + * 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. + */ + +/** + * EnableProxyConnectorAction + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="enableProxyConnectorAction" + */ +public class EnableProxyConnectorAction extends AbstractProxyConnectorAction +{ + private String source; + + private String target; + + private ProxyConnectorConfiguration proxyConfig; + + public String confirmEnable() + { + this.proxyConfig = findProxyConnector( source, target ); + + // Not set? Then there is nothing to delete. + if ( this.proxyConfig == null ) + { + addActionError( "Unable to enable proxy configuration, configuration with source [" + source + + "], and target [" + target + "] does not exist." ); + return ERROR; + } + + return INPUT; + } + + public String enable() + { + this.proxyConfig = findProxyConnector( source, target ); + + // Not set? Then there is nothing to delete. + if ( this.proxyConfig == null ) + { + addActionError( "Unable to enabled proxy configuration, configuration with source [" + source + + "], and target [" + target + "] does not exist." ); + return ERROR; + } + + if ( hasActionErrors() ) + { + return ERROR; + } + + proxyConfig.setDisabled(true); + + addActionMessage( "Successfully enabled proxy connector [" + source + " , " + target + " ]" ); + + setSource( null ); + setTarget( null ); + + 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; + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml index 21d0363f6..88297d58a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -377,6 +377,19 @@ proxyConnectors + + + /WEB-INF/jsp/admin/enableProxyConnector.jsp + proxyConnectors + + + + + /WEB-INF/jsp/admin/disableProxyConnector.jsp + proxyConnectors + + + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/disableProxyConnector.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/disableProxyConnector.jsp new file mode 100644 index 000000000..0906be58a --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/disableProxyConnector.jsp @@ -0,0 +1,50 @@ +<%-- + ~ 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" %> + + + + Admin: Disable Proxy Connector + + + + + +

Admin: Disable Proxy Connector

+ + + +
+ +

Disable Proxy Connector

+ +

+ Are you sure you want to disable proxy connector [ ${source} , ${target} ] ? +

+ + + + + + +
+ + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/enableProxyConnector.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/enableProxyConnector.jsp new file mode 100644 index 000000000..56750080f --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/enableProxyConnector.jsp @@ -0,0 +1,50 @@ +<%-- + ~ 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" %> + + + + Admin: Enable Proxy Connector + + + + + +

Admin: Enable Proxy Connector

+ + + +
+ +

Enable Proxy Connector

+ +

+ Are you sure you want to enable proxy connector [ ${source} , ${target} ] ? +

+ + + + + + +
+ + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp index 78963a1fa..cbd96026e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp @@ -105,6 +105,24 @@ + + + + + + + + + + + Enable + + + + + Disable + + -- 2.39.5