From f8b9e076b351db6cb2aca0243fcb364e25ae7039 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Sat, 5 May 2007 00:05:23 +0000 Subject: [PATCH] * Updates to repositories and proxy connector configuration / admin screens. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@535418 13f79535-47bb-0310-9956-ffa450edef68 --- .../util/LocalRepositoryPredicate.java | 55 ++ .../ProxyConnectorSelectionPredicate.java | 59 ++ .../util/RemoteRepositoryPredicate.java | 54 ++ .../RepositoryConfigurationComparator.java | 63 ++ .../util/RepositoryIdListClosure.java | 56 ++ .../src/main/mdo/configuration.mdo | 15 +- .../policies/AbstractUpdatePolicy.java | 23 +- .../policies/CachedFailuresPolicy.java | 24 +- .../archiva/policies/ChecksumPolicy.java | 26 +- .../archiva/policies/DownloadPolicy.java | 21 +- .../archiva/policies/ReleasesPolicy.java | 7 +- .../archiva/policies/SnapshotsPolicy.java | 7 +- .../DefaultRepositoryProxyConnectors.java | 7 +- .../maven/archiva/proxy/ProxyConnector.java | 20 +- .../admin/AbstractDeleteRepositoryAction.java | 150 ----- .../admin/AbstractRepositoryAction.java | 208 ------ .../admin/ConfigureRepositoryAction.java | 291 --------- .../action/admin/DeleteRepositoryAction.java | 79 --- .../action/admin/EditRepositoryAction.java | 71 -- .../action/admin/SaveRepositoryAction.java | 93 --- .../proxy/ConfigureProxyConnectorAction.java | 606 ++++++++++++++++++ .../proxy/ProxyConnectorsAction.java | 151 +++++ .../proxy/SingleSelectTransformer.java | 56 ++ .../action/admin/database/DatabaseAction.java | 73 +++ .../web/action/admin/models/AdminModel.java | 110 ---- .../networkproxies/NetworkProxiesAction.java | 73 +++ .../AdminRepositoryConfiguration.java | 22 +- .../ConfigureRepositoryAction.java | 370 +++++++++++ .../RepositoriesAction.java | 99 +-- ...positoryConfigurationAdminTransformer.java | 75 +++ .../scanning/RepositoryScanningAction.java | 73 +++ .../src/main/resources/xwork.xml | 80 ++- .../WEB-INF/jsp/admin/addProxyConnector.jsp | 0 .../WEB-INF/jsp/admin/addRepository.jsp | 15 +- .../WEB-INF/jsp/admin/deleteRepository.jsp | 6 +- .../WEB-INF/jsp/admin/editProxyConnector.jsp | 52 ++ .../WEB-INF/jsp/admin/editRepository.jsp | 14 +- .../admin/include/proxiedRepositoryForm.jspf | 42 -- .../jsp/admin/include/proxyConnectorForm.jspf | 196 ++++++ ...epositoryForm.jspf => repositoryForm.jspf} | 14 +- .../admin/include/syncedRepositoryForm.jspf | 46 -- .../WEB-INF/jsp/admin/proxyConnectors.jsp | 170 +++++ .../webapp/WEB-INF/jsp/admin/repositories.jsp | 123 +++- .../webapp/WEB-INF/jsp/decorators/default.jsp | 30 +- .../src/main/webapp/css/maven-base.css | 1 - .../src/main/webapp/css/site.css | 74 +++ .../main/webapp/images/archiva-splat-32.gif | Bin 0 -> 1294 bytes .../src/main/webapp/images/archiva-world.png | Bin 0 -> 1936 bytes .../main/webapp/images/icons/arrow-down.png | Bin 0 -> 237 bytes .../main/webapp/images/icons/arrow-left.png | Bin 0 -> 231 bytes .../main/webapp/images/icons/arrow-right.png | Bin 0 -> 228 bytes .../src/main/webapp/images/icons/arrow-up.png | Bin 0 -> 230 bytes .../src/main/webapp/images/icons/box.png | Bin 0 -> 255 bytes .../src/main/webapp/images/icons/create.png | Bin 0 -> 236 bytes .../src/main/webapp/images/icons/delete.gif | Bin 0 -> 351 bytes .../src/main/webapp/images/icons/edit.png | Bin 0 -> 246 bytes .../main/webapp/images/icons/security-key.png | Bin 0 -> 300 bytes .../webapp/images/icons/security-lock.png | Bin 0 -> 281 bytes .../src/main/webapp/images/icons/user.png | Bin 0 -> 344 bytes 59 files changed, 2631 insertions(+), 1269 deletions(-) create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/LocalRepositoryPredicate.java create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/ProxyConnectorSelectionPredicate.java create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RemoteRepositoryPredicate.java create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RepositoryConfigurationComparator.java create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RepositoryIdListClosure.java delete mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractDeleteRepositoryAction.java delete mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractRepositoryAction.java delete mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureRepositoryAction.java delete mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteRepositoryAction.java delete mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/EditRepositoryAction.java delete mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SaveRepositoryAction.java create mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java create mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java create mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SingleSelectTransformer.java create mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java delete mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminModel.java create mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java rename archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/{models => repositories}/AdminRepositoryConfiguration.java (85%) create mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java rename archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/{ => repositories}/RepositoriesAction.java (56%) create mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryConfigurationAdminTransformer.java create mode 100644 archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java create mode 100644 archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp create mode 100644 archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp delete mode 100644 archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf create mode 100644 archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf rename archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/{managedRepositoryForm.jspf => repositoryForm.jspf} (65%) delete mode 100644 archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/syncedRepositoryForm.jspf create mode 100644 archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/archiva-splat-32.gif create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/archiva-world.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/arrow-down.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/arrow-left.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/arrow-right.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/arrow-up.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/box.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/create.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/delete.gif create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/edit.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/security-key.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/security-lock.png create mode 100644 archiva-web/archiva-webapp/src/main/webapp/images/icons/user.png diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/LocalRepositoryPredicate.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/LocalRepositoryPredicate.java new file mode 100644 index 000000000..8284d72da --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/LocalRepositoryPredicate.java @@ -0,0 +1,55 @@ +package org.apache.maven.archiva.configuration.util; + +/* + * 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.collections.Predicate; +import org.apache.maven.archiva.configuration.RepositoryConfiguration; + +/** + * Predicate for {@link RepositoryConfiguration} objects that are local (aka managed) + * {@link RepositoryConfiguration#isManaged()} + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class LocalRepositoryPredicate + implements Predicate +{ + public static final Predicate INSTANCE = new LocalRepositoryPredicate(); + + public static Predicate getInstance() + { + return INSTANCE; + } + + public boolean evaluate( Object object ) + { + boolean satisfies = false; + + if ( object instanceof RepositoryConfiguration ) + { + RepositoryConfiguration repoconfig = (RepositoryConfiguration) object; + return repoconfig.isManaged(); + } + + return satisfies; + } + +} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/ProxyConnectorSelectionPredicate.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/ProxyConnectorSelectionPredicate.java new file mode 100644 index 000000000..b1fc9fc3f --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/ProxyConnectorSelectionPredicate.java @@ -0,0 +1,59 @@ +package org.apache.maven.archiva.configuration.util; + +/* + * 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.collections.Predicate; +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; + +/** + * ProxyConnectorPredicate + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ProxyConnectorSelectionPredicate + implements Predicate +{ + private String sourceId; + + private String targetId; + + public ProxyConnectorSelectionPredicate( String sourceId, String targetId ) + { + this.sourceId = sourceId; + this.targetId = targetId; + } + + public boolean evaluate( Object object ) + { + boolean satisfies = false; + + if ( object instanceof ProxyConnectorConfiguration ) + { + ProxyConnectorConfiguration connector = (ProxyConnectorConfiguration) object; + return ( StringUtils.equals( sourceId, connector.getSourceRepoId() ) && StringUtils + .equals( targetId, connector.getTargetRepoId() ) ); + } + + return satisfies; + } + +} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RemoteRepositoryPredicate.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RemoteRepositoryPredicate.java new file mode 100644 index 000000000..bb8db282b --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RemoteRepositoryPredicate.java @@ -0,0 +1,54 @@ +package org.apache.maven.archiva.configuration.util; + +/* + * 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.collections.Predicate; +import org.apache.maven.archiva.configuration.RepositoryConfiguration; + +/** + * Predicate for {@link RepositoryConfiguration} objects that are remote + * {@link RepositoryConfiguration#isRemote()} + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RemoteRepositoryPredicate + implements Predicate +{ + public static final Predicate INSTANCE = new RemoteRepositoryPredicate(); + + public static Predicate getInstance() + { + return INSTANCE; + } + + public boolean evaluate( Object object ) + { + boolean satisfies = false; + + if ( object instanceof RepositoryConfiguration ) + { + RepositoryConfiguration repoconfig = (RepositoryConfiguration) object; + return repoconfig.isRemote(); + } + + return satisfies; + } +} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RepositoryConfigurationComparator.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RepositoryConfigurationComparator.java new file mode 100644 index 000000000..1077b0cc7 --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RepositoryConfigurationComparator.java @@ -0,0 +1,63 @@ +package org.apache.maven.archiva.configuration.util; + +/* + * 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.RepositoryConfiguration; + +import java.util.Comparator; + +/** + * RepositoryConfigurationComparator + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryConfigurationComparator + implements Comparator +{ + + public int compare( Object o1, Object o2 ) + { + if ( o1 == null && o2 == null ) + { + return 0; + } + + if ( o1 == null && o2 != null ) + { + return 1; + } + + if ( o1 != null && o2 == null ) + { + return -1; + } + + if ( ( o1 instanceof RepositoryConfiguration ) && ( o2 instanceof RepositoryConfiguration ) ) + { + String id1 = ( (RepositoryConfiguration) o1 ).getId(); + String id2 = ( (RepositoryConfiguration) o2 ).getId(); + return id1.compareToIgnoreCase( id2 ); + } + + return 0; + } + +} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RepositoryIdListClosure.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RepositoryIdListClosure.java new file mode 100644 index 000000000..97503d5b0 --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/util/RepositoryIdListClosure.java @@ -0,0 +1,56 @@ +package org.apache.maven.archiva.configuration.util; + +/* + * 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.collections.Closure; +import org.apache.maven.archiva.configuration.RepositoryConfiguration; + +import java.util.List; + +/** + * RepositoryIdListClosure + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryIdListClosure + implements Closure +{ + private List list; + + public RepositoryIdListClosure( List list ) + { + this.list = list; + } + + public void execute( Object input ) + { + if ( input instanceof RepositoryConfiguration ) + { + RepositoryConfiguration repoconfig = (RepositoryConfiguration) input; + list.add( repoconfig.getId() ); + } + } + + public List getList() + { + return list; + } +} diff --git a/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index 8ea11bd2b..66b39a368 100644 --- a/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -365,7 +365,7 @@ policies 1.0.0+ - Properties + Map Policy configuration for the connector. String @@ -375,7 +375,7 @@ properties 1.0.0+ - Properties + Map Configuration for the connector. String @@ -401,8 +401,15 @@ return null; } - return this.getPolicies().getProperty( policyId, defaultValue ); - } + Object value = this.getPolicies().get( policyId ); + + if ( value == null ) + { + return defaultValue; + } + + return (String) value; + } ]]> diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java index 44c224679..7ae434ae7 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/AbstractUpdatePolicy.java @@ -24,10 +24,10 @@ import org.apache.maven.archiva.common.utils.VersionUtil; import org.codehaus.plexus.logging.AbstractLogEnabled; import java.io.File; +import java.util.ArrayList; import java.util.Calendar; -import java.util.HashSet; +import java.util.List; import java.util.Properties; -import java.util.Set; /** * AbstractUpdatePolicy @@ -76,20 +76,25 @@ public abstract class AbstractUpdatePolicy */ public static final String ONCE = "once"; - private Set validPolicyCodes = new HashSet(); + private List options = new ArrayList(); public AbstractUpdatePolicy() { - validPolicyCodes.add( IGNORED ); - validPolicyCodes.add( DISABLED ); - validPolicyCodes.add( DAILY ); - validPolicyCodes.add( HOURLY ); - validPolicyCodes.add( ONCE ); + options.add( IGNORED ); + options.add( DISABLED ); + options.add( DAILY ); + options.add( HOURLY ); + options.add( ONCE ); } protected abstract boolean isSnapshotPolicy(); protected abstract String getUpdateMode(); + + public List getOptions() + { + return options; + } public boolean applyPolicy( String policySetting, Properties request, File localFile ) { @@ -101,7 +106,7 @@ public abstract class AbstractUpdatePolicy isSnapshotVersion = VersionUtil.isSnapshot( version ); } - if ( !validPolicyCodes.contains( policySetting ) ) + if ( !options.contains( policySetting ) ) { // No valid code? false it is then. getLogger().error( "Unknown artifact-update policyCode [" + policySetting + "]" ); diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java index ff4820456..66b13ff06 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/CachedFailuresPolicy.java @@ -24,9 +24,9 @@ import org.apache.maven.archiva.policies.urlcache.UrlFailureCache; import org.codehaus.plexus.logging.AbstractLogEnabled; import java.io.File; -import java.util.HashSet; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; -import java.util.Set; /** * {@link PreDownloadPolicy} to check if the requested url has failed before. @@ -53,17 +53,17 @@ public class CachedFailuresPolicy */ private UrlFailureCache urlFailureCache; - private Set validPolicyCodes = new HashSet(); + private List options = new ArrayList(); public CachedFailuresPolicy() { - validPolicyCodes.add( IGNORED ); - validPolicyCodes.add( CACHED ); + options.add( IGNORED ); + options.add( CACHED ); } public boolean applyPolicy( String policySetting, Properties request, File localFile ) { - if ( !validPolicyCodes.contains( policySetting ) ) + if ( !options.contains( policySetting ) ) { // No valid code? false it is then. getLogger().error( "Unknown checksum policyCode [" + policySetting + "]" ); @@ -93,8 +93,18 @@ public class CachedFailuresPolicy return true; } - public String getDefaultPolicySetting() + public String getDefaultOption() { return IGNORED; } + + public String getId() + { + return "cache-failures"; + } + + public List getOptions() + { + return options; + } } diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ChecksumPolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ChecksumPolicy.java index 864ba1358..4f19125a7 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ChecksumPolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ChecksumPolicy.java @@ -27,9 +27,9 @@ import org.codehaus.plexus.logging.AbstractLogEnabled; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.util.HashSet; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; -import java.util.Set; /** * ChecksumPolicy @@ -73,18 +73,18 @@ public class ChecksumPolicy */ private ChecksumFile checksumFile; - private Set validPolicyCodes = new HashSet(); + private List options = new ArrayList(); public ChecksumPolicy() { - validPolicyCodes.add( FAIL ); - validPolicyCodes.add( FIX ); - validPolicyCodes.add( IGNORED ); + options.add( FAIL ); + options.add( FIX ); + options.add( IGNORED ); } public boolean applyPolicy( String policySetting, Properties request, File localFile ) { - if ( !validPolicyCodes.contains( policySetting ) ) + if ( !options.contains( policySetting ) ) { // No valid code? false it is then. getLogger().error( "Unknown checksum policyCode [" + policySetting + "]" ); @@ -275,9 +275,19 @@ public class ChecksumPolicy } } - public String getDefaultPolicySetting() + public String getDefaultOption() { return FIX; } + public String getId() + { + return "checksum"; + } + + public List getOptions() + { + return options; + } + } diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/DownloadPolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/DownloadPolicy.java index e556c4b28..46b52514b 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/DownloadPolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/DownloadPolicy.java @@ -20,6 +20,7 @@ package org.apache.maven.archiva.policies; */ import java.io.File; +import java.util.List; import java.util.Properties; /** @@ -39,11 +40,25 @@ public interface DownloadPolicy public static final boolean FAIL = false; /** - * Get the default policy setting. + * Get the list of options for this policy. * - * @return the default policy setting. + * @return the list of options for this policy. */ - public String getDefaultPolicySetting(); + public List getOptions(); + + /** + * Get the default option for this policy. + * + * @return the default policy for this policy. + */ + public String getDefaultOption(); + + /** + * Get the id for this policy. + * + * @return the id for this policy. + */ + public String getId(); /** * Apply the download policy. diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java index 4e3fb2e53..728b30820 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/ReleasesPolicy.java @@ -33,7 +33,7 @@ public class ReleasesPolicy extends AbstractUpdatePolicy implements PreDownloadPolicy { - public String getDefaultPolicySetting() + public String getDefaultOption() { return AbstractUpdatePolicy.IGNORED; } @@ -47,4 +47,9 @@ public class ReleasesPolicy { return "releases"; } + + public String getId() + { + return "releases"; + } } diff --git a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java index 7298c2a06..e38177edf 100644 --- a/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java +++ b/archiva-base/archiva-policies/src/main/java/org/apache/maven/archiva/policies/SnapshotsPolicy.java @@ -33,7 +33,7 @@ public class SnapshotsPolicy extends AbstractUpdatePolicy implements PreDownloadPolicy { - public String getDefaultPolicySetting() + public String getDefaultOption() { return AbstractUpdatePolicy.IGNORED; } @@ -47,4 +47,9 @@ public class SnapshotsPolicy { return "snapshots"; } + + public String getId() + { + return "snapshots"; + } } diff --git a/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java index 1d1295df4..dae8e55da 100644 --- a/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java +++ b/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java @@ -20,6 +20,7 @@ package org.apache.maven.archiva.proxy; */ import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ConfigurationNames; import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; @@ -494,7 +495,7 @@ public class DefaultRepositoryProxyConnectors } } - private boolean applyPolicies( Properties policySettings, Map downloadPolicies, Properties request, File localFile ) + private boolean applyPolicies( Map policySettings, Map downloadPolicies, Properties request, File localFile ) { Iterator it = downloadPolicies.entrySet().iterator(); while ( it.hasNext() ) @@ -502,8 +503,8 @@ public class DefaultRepositoryProxyConnectors Map.Entry entry = (Entry) it.next(); String key = (String) entry.getKey(); DownloadPolicy policy = (DownloadPolicy) entry.getValue(); - String defaultSetting = policy.getDefaultPolicySetting(); - String setting = policySettings.getProperty( key, defaultSetting ); + String defaultSetting = policy.getDefaultOption(); + String setting = StringUtils.defaultString( (String) policySettings.get( key ), defaultSetting ); getLogger().debug( "Applying [" + key + "] policy with [" + setting + "]" ); if ( !policy.applyPolicy( setting, request, localFile ) ) diff --git a/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ProxyConnector.java b/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ProxyConnector.java index 978b6396c..a7b4d9b81 100644 --- a/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ProxyConnector.java +++ b/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/ProxyConnector.java @@ -22,9 +22,9 @@ package org.apache.maven.archiva.proxy; import org.apache.maven.archiva.model.ArchivaRepository; import org.apache.maven.archiva.repository.connector.RepositoryConnector; -import java.util.Enumeration; +import java.util.Iterator; import java.util.List; -import java.util.Properties; +import java.util.Map; /** * This represents a connector for a repository to repository proxy. @@ -45,7 +45,7 @@ public class ProxyConnector private String proxyId; - private Properties policies; + private Map policies; public List getBlacklist() { @@ -87,12 +87,12 @@ public class ProxyConnector this.whitelist = whitelist; } - public Properties getPolicies() + public Map getPolicies() { return policies; } - public void setPolicies( Properties policies ) + public void setPolicies( Map policies ) { this.policies = policies; } @@ -116,12 +116,12 @@ public class ProxyConnector sb.append( " target:" ).append( this.targetRepository ).append( "\n" ); sb.append( " proxyId:" ).append( this.proxyId ).append( "\n" ); - Enumeration keys = this.policies.propertyNames(); - while ( keys.hasMoreElements() ) + Iterator keys = this.policies.keySet().iterator(); + while ( keys.hasNext() ) { - String name = (String) keys.nextElement(); + String name = (String) keys.next(); sb.append( " policy[" ).append( name ).append( "]:" ); - sb.append( this.policies.getProperty( name ) ).append( "\n" ); + sb.append( this.policies.get( name ) ).append( "\n" ); } sb.append( "]" ); @@ -131,6 +131,6 @@ public class ProxyConnector public void setPolicy( String policyId, String policySetting ) { - // TODO Auto-generated method stub + this.policies.put( policyId, policySetting ); } } diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractDeleteRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractDeleteRepositoryAction.java deleted file mode 100644 index a904176bf..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractDeleteRepositoryAction.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.apache.maven.archiva.web.action.admin; - -/* - * 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.AbstractRepositoryConfiguration; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.InvalidConfigurationException; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.codehaus.plexus.rbac.profile.RoleProfileManager; -import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.plexus.security.rbac.Resource; -import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; -import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; -import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; -import org.codehaus.plexus.xwork.action.PlexusActionSupport; - -import java.io.IOException; - -/** - * Base action for repository removal actions. - * - * @author Brett Porter - */ -public abstract class AbstractDeleteRepositoryAction - extends PlexusActionSupport - implements SecureAction -{ - /** - * @plexus.requirement - */ - private ArchivaConfiguration archivaConfiguration; - - /** - * The repository ID to lookup when editing a repository. - */ - protected String repoId; - - /** - * Which operation to select. - */ - private String operation = "unmodified"; - - /** - * @plexus.requirement role-hint="archiva" - */ - protected RoleProfileManager roleProfileManager; - - public String execute() - throws IOException, InvalidConfigurationException, RegistryException - { - // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded - - if ( "delete-entry".equals( operation ) || "delete-contents".equals( operation ) ) - { - Configuration configuration = archivaConfiguration.getConfiguration(); - -// AbstractRepositoryConfiguration existingRepository = getRepository( configuration ); -// if ( existingRepository == null ) -// { -// addActionError( "A repository with that id does not exist" ); -// return ERROR; -// } -// -// // TODO: remove from index too! -// -// removeRepository( configuration, existingRepository ); -// -// archivaConfiguration.save( configuration ); -// -// if ( "delete-contents".equals( operation ) ) -// { -// removeContents( existingRepository ); -// } - } - - return SUCCESS; - } - -// protected abstract void removeContents( AbstractRepositoryConfiguration existingRepository ) -// throws IOException; -// -// protected abstract AbstractRepositoryConfiguration getRepository( Configuration configuration ); -// -// protected abstract void removeRepository( Configuration configuration, -// AbstractRepositoryConfiguration existingRepository ); - - public String input() - { - return INPUT; - } - - public String getRepoId() - { - return repoId; - } - - public void setRepoId( String repoId ) - { - this.repoId = repoId; - } - - public String getOperation() - { - return operation; - } - - public void setOperation( String operation ) - { - this.operation = operation; - } - - public SecureActionBundle getSecureActionBundle() - throws SecureActionException - { - SecureActionBundle bundle = new SecureActionBundle(); - - bundle.setRequiresAuthentication( true ); - - if ( getRepoId() != null ) - { - // TODO: not right. We only care about this permission on managed repositories. Otherwise, it's configuration - bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, getRepoId() ); - } - else - { - bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); - } - - return bundle; - } - -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractRepositoryAction.java deleted file mode 100644 index ac241e90b..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractRepositoryAction.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.apache.maven.archiva.web.action.admin; - -/* - * 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.ActionContext; -import com.opensymphony.xwork.ModelDriven; -import com.opensymphony.xwork.Preparable; - -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.InvalidConfigurationException; -import org.apache.maven.archiva.configuration.RepositoryConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.web.action.admin.models.AdminRepositoryConfiguration; -import org.codehaus.plexus.rbac.profile.RoleProfileException; -import org.codehaus.plexus.rbac.profile.RoleProfileManager; -import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.plexus.security.authorization.AuthorizationException; -import org.codehaus.plexus.security.authorization.AuthorizationResult; -import org.codehaus.plexus.security.rbac.RbacManagerException; -import org.codehaus.plexus.security.rbac.Resource; -import org.codehaus.plexus.security.system.SecuritySession; -import org.codehaus.plexus.security.system.SecuritySystem; -import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; -import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; -import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; -import org.codehaus.plexus.xwork.action.PlexusActionSupport; - -import java.io.File; -import java.io.IOException; - -/** - * AbstractRepositoryAction - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public abstract class AbstractRepositoryAction - extends PlexusActionSupport - implements ModelDriven, Preparable, SecureAction -{ - protected static final String SUCCESS = "success"; - - /** - * @plexus.requirement role-hint="archiva" - */ - private RoleProfileManager roleProfileManager; - - /** - * @plexus.requirement - */ - private SecuritySystem securitySystem; - - private String repoid; - - private String mode; - - /** - * @plexus.requirement - */ - protected ArchivaConfiguration archivaConfiguration; - - /** - * The model for this action. - */ - protected AdminRepositoryConfiguration repository; - - public String getMode() - { - return this.mode; - } - - public Object getModel() - { - return getRepository(); - } - - public String getRepoid() - { - return repoid; - } - - public SecureActionBundle getSecureActionBundle() - throws SecureActionException - { - SecureActionBundle bundle = new SecureActionBundle(); - - bundle.setRequiresAuthentication( true ); - bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); - - return bundle; - } - - public String input() - { - getLogger().info( "input()" ); - return INPUT; - } - - public abstract void prepare() - throws Exception; - - public void setMode( String mode ) - { - this.mode = mode; - } - - public void setRepoid( String repoid ) - { - this.repoid = repoid; - } - - protected void addRepository( AdminRepositoryConfiguration repository ) - throws IOException, RoleProfileException - { - getLogger().info( ".addRepository(" + repository + ")" ); - - if ( repository.isManaged() ) - { - // Normalize the path - File file = new File( repository.getDirectory() ); - repository.setDirectory( file.getCanonicalPath() ); - if ( !file.exists() ) - { - file.mkdirs(); - // TODO: error handling when this fails, or is not a directory! - } - } - - archivaConfiguration.getConfiguration().addRepository( repository ); - - // TODO: double check these are configured on start up - roleProfileManager.getDynamicRole( "archiva-repository-manager", repository.getId() ); - - roleProfileManager.getDynamicRole( "archiva-repository-observer", repository.getId() ); - } - - protected AdminRepositoryConfiguration getRepository() - { - if ( repository == null ) - { - repository = new AdminRepositoryConfiguration(); - } - - return repository; - } - - protected boolean operationAllowed( String permission, String repoid ) - { - ActionContext context = ActionContext.getContext(); - SecuritySession securitySession = (SecuritySession) context.get( SecuritySession.ROLE ); - - AuthorizationResult authzResult; - try - { - authzResult = securitySystem.authorize( securitySession, permission, repoid ); - - return authzResult.isAuthorized(); - } - catch ( AuthorizationException e ) - { - getLogger().info( - "Unable to authorize permission: " + permission + " against repo: " + repoid - + " due to: " + e.getMessage() ); - return false; - } - } - - protected void removeRepository( String repoId ) - { - getLogger().info( ".removeRepository()" ); - - RepositoryConfiguration toremove = archivaConfiguration.getConfiguration().findRepositoryById( repoId ); - if ( toremove != null ) - { - archivaConfiguration.getConfiguration().removeRepository( toremove ); - } - } - - protected String saveConfiguration() - throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, - RegistryException - { - getLogger().info( ".saveConfiguration()" ); - - archivaConfiguration.save( archivaConfiguration.getConfiguration() ); - - addActionMessage( "Successfully saved configuration" ); - - return SUCCESS; - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureRepositoryAction.java deleted file mode 100644 index de4b88c9a..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureRepositoryAction.java +++ /dev/null @@ -1,291 +0,0 @@ -package org.apache.maven.archiva.web.action.admin; - -/* - * 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.ModelDriven; -import com.opensymphony.xwork.Preparable; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.InvalidConfigurationException; -import org.apache.maven.archiva.configuration.RepositoryConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.web.action.admin.models.AdminRepositoryConfiguration; -import org.codehaus.plexus.rbac.profile.RoleProfileException; -import org.codehaus.plexus.rbac.profile.RoleProfileManager; -import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.plexus.security.rbac.RbacManagerException; -import org.codehaus.plexus.security.rbac.Resource; -import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; -import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; -import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; -import org.codehaus.plexus.xwork.action.PlexusActionSupport; - -import java.io.File; -import java.io.IOException; - -/** - * Configures the application repositories. - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureRepositoryAction" - */ -public class ConfigureRepositoryAction - extends PlexusActionSupport - implements ModelDriven, Preparable, SecureAction -{ - /** - * @plexus.requirement - */ - private ArchivaConfiguration archivaConfiguration; - - /** - * @plexus.requirement role-hint="archiva" - */ - private RoleProfileManager roleProfileManager; - - /** - * The repository. - */ - private AdminRepositoryConfiguration repository; - - /** - * The repository ID to lookup when editing a repository. - */ - private String repoId; - - /** - * The previously read configuration. - */ - private Configuration configuration; - - public String add() - throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, - RegistryException - { - // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded - getLogger().info( ".add()" ); - - AdminRepositoryConfiguration existingRepository = getRepository( repository.getId() ); - if ( existingRepository != null ) - { - addFieldError( "id", "A repository with that id already exists" ); - return INPUT; - } - - return saveConfiguration(); - } - - public String edit() - throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, - RegistryException - { - // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded - getLogger().info( ".edit()" ); - - if ( StringUtils.isBlank( repository.getId() ) ) - { - addFieldError( "id", "A repository with a blank id cannot be editted." ); - return INPUT; - } - - removeRepository( getRepository() ); - - addRepository(); - - return saveConfiguration(); - } - - public Configuration getConfiguration() - { - return configuration; - } - - public Object getModel() - { - getLogger().info( ".getModel()" ); - if( repository == null ) - { - repository = createRepository(); - } - - return repository; - } - - public String getRepoId() - { - return repoId; - } - - public SecureActionBundle getSecureActionBundle() - throws SecureActionException - { - SecureActionBundle bundle = new SecureActionBundle(); - - bundle.setRequiresAuthentication( true ); - - if ( getRepoId() != null ) - { - // TODO: this is not right. It needs to change based on method. But is this really the right way to restrict this area? - // TODO: not right. We only care about this permission on managed repositories. Otherwise, it's configuration - bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_EDIT_REPOSITORY, getRepoId() ); - } - else - { - bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); - } - - return bundle; - } - - public String input() - { - getLogger().info( ".input()" ); - return INPUT; - } - - public String doDefault() - throws Exception - { - getLogger().info( ".doDefault()" ); - return super.doDefault(); - } - - public String doInput() - throws Exception - { - getLogger().info( ".doInput()" ); - return super.doInput(); - } - - public void validate() - { - getLogger().info( ".validate()" ); - // super.validate(); - } - - public String execute() - throws Exception - { - getLogger().info( ".execute()" ); - return super.execute(); - } - - public void prepare() - { - getLogger().info( ".prepare()" ); - configuration = archivaConfiguration.getConfiguration(); - - if ( repository == null ) - { - repository = getRepository( repoId ); - } - if ( repository == null ) - { - repository = createRepository(); - } - } - - public void setRepoId( String repoId ) - { - this.repoId = repoId; - } - - private void addRepository() - throws IOException, RoleProfileException - { - getLogger().info( ".addRepository()" ); - AdminRepositoryConfiguration repository = (AdminRepositoryConfiguration) getRepository(); - - if ( repository.isManaged() ) - { - // Normalize the path - File file = new File( repository.getDirectory() ); - repository.setDirectory( file.getCanonicalPath() ); - if ( !file.exists() ) - { - file.mkdirs(); - // TODO: error handling when this fails, or is not a directory! - } - } - - configuration.addRepository( repository ); - - // TODO: double check these are configured on start up - roleProfileManager.getDynamicRole( "archiva-repository-manager", repository.getId() ); - - roleProfileManager.getDynamicRole( "archiva-repository-observer", repository.getId() ); - } - - private AdminRepositoryConfiguration createRepository() - { - getLogger().info( ".createRepository()" ); - AdminRepositoryConfiguration repository = new AdminRepositoryConfiguration(); - repository.setIndexed( false ); - return repository; - } - - private AdminRepositoryConfiguration getRepository() - { - return repository; - } - - private AdminRepositoryConfiguration getRepository( String id ) - { - getLogger().info( ".getRepository(" + id + ")" ); - - RepositoryConfiguration repoconfig = configuration.findRepositoryById( id ); - if ( repoconfig == null ) - { - return createRepository(); - } - return new AdminRepositoryConfiguration( repoconfig ); - } - - private boolean removeRepository( RepositoryConfiguration existingRepository ) - { - getLogger().info( ".removeRepository()" ); - - RepositoryConfiguration toremove = configuration.findRepositoryById( existingRepository.getId() ); - if ( toremove != null ) - { - configuration.removeRepository( toremove ); - return true; - } - - return false; - } - - private String saveConfiguration() - throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, - RegistryException - { - getLogger().info( ".saveConfiguration()" ); - addRepository(); - - archivaConfiguration.save( configuration ); - - // TODO: do we need to check if indexing is needed? - - addActionMessage( "Successfully saved configuration" ); - - return SUCCESS; - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteRepositoryAction.java deleted file mode 100644 index 9f38320be..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteRepositoryAction.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.maven.archiva.web.action.admin; - -/* - * 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.AbstractRepositoryConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.RepositoryConfiguration; -import org.codehaus.plexus.rbac.profile.RoleProfileException; -import org.codehaus.plexus.util.FileUtils; - -import java.io.IOException; - -/** - * Configures the application repositories. - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteRepositoryAction" - */ -public class DeleteRepositoryAction - extends AbstractDeleteRepositoryAction -{ -// protected AbstractRepositoryConfiguration getRepository( Configuration configuration ) -// { -// return configuration.getRepositoryById( repoId ); -// } -// -// protected void removeRepository( Configuration configuration, AbstractRepositoryConfiguration existingRepository ) -// { -// configuration.removeRepository( (RepositoryConfiguration) existingRepository ); -// -// try -// { -// removeRepositoryRoles( existingRepository ); -// } -// catch ( RoleProfileException e ) -// { -// getLogger().error( "Error removing user roles associated with repository " + existingRepository.getId() ); -// } -// } -// -// protected void removeContents( AbstractRepositoryConfiguration existingRepository ) -// throws IOException -// { -// RepositoryConfiguration repository = (RepositoryConfiguration) existingRepository; -// getLogger().info( "Removing " + repository.getDirectory() ); -// FileUtils.deleteDirectory( repository.getDirectory() ); -// } - - /** - * Remove user roles associated with the repository - * - * @param existingRepository - * @throws RoleProfileException - */ -// private void removeRepositoryRoles( AbstractRepositoryConfiguration existingRepository ) -// throws RoleProfileException -// { -// roleProfileManager.deleteDynamicRole( "archiva-repository-manager", existingRepository.getId() ); -// roleProfileManager.deleteDynamicRole( "archiva-repository-observer", existingRepository.getId() ); -// -// getLogger().info( "removed user roles associated with repository " + existingRepository.getId() ); -// } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/EditRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/EditRepositoryAction.java deleted file mode 100644 index ff6cce05e..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/EditRepositoryAction.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.apache.maven.archiva.web.action.admin; - -/* - * 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.RepositoryConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.web.action.admin.models.AdminRepositoryConfiguration; - -/** - * EditRepositoryAction - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="editRepositoryAction" - */ -public class EditRepositoryAction - extends AbstractRepositoryAction -{ - public String edit() - { - getLogger().info( ".edit()" ); - - if ( operationAllowed( ArchivaRoleConstants.OPERATION_EDIT_REPOSITORY, getRepoid() ) ) - { - addActionError( "You do not have the appropriate permissions to edit the " + getRepoid() + " repository." ); - return ERROR; - } - - return INPUT; - } - - public void prepare() - throws Exception - { - String id = getRepoid(); - if ( id == null ) - { - // TODO: Throw error? - return; - } - - RepositoryConfiguration repoconfig = archivaConfiguration.getConfiguration().findRepositoryById( id ); - if ( repoconfig != null ) - { - this.repository = new AdminRepositoryConfiguration( repoconfig ); - } - } - - public String getMode() - { - return "edit"; - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SaveRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SaveRepositoryAction.java deleted file mode 100644 index 8aa9bb427..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SaveRepositoryAction.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.apache.maven.archiva.web.action.admin; - -/* - * 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.InvalidConfigurationException; -import org.codehaus.plexus.rbac.profile.RoleProfileException; -import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.plexus.security.rbac.RbacManagerException; - -import java.io.IOException; - -/** - * SaveRepositoryAction - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="saveRepositoryAction" - */ -public class SaveRepositoryAction - extends AbstractRepositoryAction -{ - public void prepare() - throws Exception - { - /* nothing to do here */ - } - - public String save() - { - String mode = getMode(); - String repoId = getRepository().getId(); - - getLogger().info( "edit(" + mode + ":" + repoId + ")" ); - - if ( StringUtils.isBlank( repository.getId() ) ) - { - addFieldError( "id", "A repository with a blank id cannot be saved." ); - return SUCCESS; - } - - if( StringUtils.equalsIgnoreCase( "edit", mode ) ) - { - removeRepository( repoId ); - } - - try - { - addRepository( getRepository() ); - saveConfiguration(); - } - catch ( IOException e ) - { - addActionError( "I/O Exception: " + e.getMessage() ); - } - catch ( RoleProfileException e ) - { - addActionError( "Role Profile Exception: " + e.getMessage() ); - } - catch ( InvalidConfigurationException e ) - { - addActionError( "Invalid Configuration Exception: " + e.getMessage() ); - } - catch ( RbacManagerException e ) - { - addActionError( "RBAC Manager Exception: " + e.getMessage() ); - } - catch ( RegistryException e ) - { - addActionError( "Configuration Registry Exception: " + e.getMessage() ); - } - - return SUCCESS; - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java new file mode 100644 index 000000000..cca665ae5 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java @@ -0,0 +1,606 @@ +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.Preparable; + +import org.apache.commons.collections.Closure; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.functors.IfClosure; +import org.apache.commons.collections.functors.NotPredicate; +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.InvalidConfigurationException; +import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; +import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; +import org.apache.maven.archiva.configuration.util.ProxyConnectorSelectionPredicate; +import org.apache.maven.archiva.configuration.util.RemoteRepositoryPredicate; +import org.apache.maven.archiva.configuration.util.RepositoryIdListClosure; +import org.apache.maven.archiva.policies.DownloadPolicy; +import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; +import org.codehaus.plexus.registry.RegistryException; +import org.codehaus.plexus.security.rbac.Resource; +import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; +import org.codehaus.plexus.xwork.action.PlexusActionSupport; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * ConfigureProxyConnectorAction + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureProxyConnectorAction" + */ +public class ConfigureProxyConnectorAction + extends PlexusActionSupport + implements SecureAction, Preparable, Initializable +{ + private static final String DIRECT_CONNECTION = "(direct connection)"; + + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + /** + * @plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy" + */ + private Map preDownloadPolicyMap; + + /** + * @plexus.requirement role="org.apache.maven.archiva.policies.PostDownloadPolicy" + */ + private Map postDownloadPolicyMap; + + /** + * The model for this action. + */ + private ProxyConnectorConfiguration connector; + + private Map policyMap; + + private String source; + + private String target; + + private String mode; + + private String propertyKey; + + private String propertyValue; + + private String pattern; + + /** + * The list of possible proxy ids. + */ + private List proxyIdOptions = new ArrayList(); + + /** + * The list of local repository ids. + */ + private List localRepoIdList = new ArrayList(); + + /** + * The list of remote repository ids. + */ + private List remoteRepoIdList = new ArrayList(); + + /** + * The blacklist pattern to add. + */ + private String blackListPattern; + + /** + * The whitelist pattern to add. + */ + private String whiteListPattern; + + public String add() + { + getLogger().info( ".add()" ); + this.mode = "add"; + return INPUT; + } + + public String confirm() + { + getLogger().info( ".confirm()" ); + return INPUT; + } + + public String delete() + { + getLogger().info( ".delete()" ); + return INPUT; + } + + public String addProperty() + { + getLogger().info( ".addProperty()" ); + String key = getPropertyKey(); + String value = getPropertyValue(); + + if ( StringUtils.isBlank( key ) ) + { + addActionError( "Unable to add property with blank key." ); + } + + if ( StringUtils.isBlank( value ) ) + { + addActionError( "Unable to add property with blank value." ); + } + + if ( !hasActionErrors() ) + { + getConnector().getProperties().put( key, value ); + setPropertyKey( null ); + setPropertyValue( null ); + } + + return INPUT; + } + + public String removeProperty() + { + getLogger().info( ".removeProperty()" ); + String key = getPropertyKey(); + + if ( StringUtils.isBlank( key ) ) + { + addActionError( "Unable to remove property with blank key." ); + } + + if ( !hasActionErrors() ) + { + getConnector().getProperties().remove( key ); + setPropertyKey( null ); + setPropertyValue( null ); + } + + return INPUT; + } + + public String addWhiteListPattern() + { + getLogger().info( ".addWhiteListPattern()" ); + String pattern = getWhiteListPattern(); + + if ( StringUtils.isBlank( pattern ) ) + { + addActionError( "Cannot add an blank white list pattern." ); + } + + if ( !hasActionErrors() ) + { + getLogger().info( + "whitelist patterns: (" + getConnector().getWhiteListPatterns().size() + "): " + + getConnector().getWhiteListPatterns() ); + + getConnector().getWhiteListPatterns().add( pattern ); + setWhiteListPattern( null ); + } + + return INPUT; + } + + public String removeWhiteListPattern() + { + String pattern = getPattern(); + getLogger().info( ".removeWhiteListPattern(" + pattern + ")" ); + + if ( StringUtils.isBlank( pattern ) ) + { + addActionError( "Cannot remove an blank white list pattern." ); + } + + if ( !hasActionErrors() ) + { + getConnector().getWhiteListPatterns().remove( pattern ); + setWhiteListPattern( null ); + } + + return INPUT; + } + + public String addBlackListPattern() + { + getLogger().info( ".addBlackListPattern()" ); + String pattern = getBlackListPattern(); + + if ( StringUtils.isBlank( pattern ) ) + { + addActionError( "Cannot add an blank black list pattern." ); + } + + if ( !hasActionErrors() ) + { + getConnector().getBlackListPatterns().add( pattern ); + setBlackListPattern( null ); + } + + return INPUT; + } + + public String removeBlackListPattern() + { + getLogger().info( ".removeBlackListPattern()" ); + String pattern = getBlackListPattern(); + + if ( StringUtils.isBlank( pattern ) ) + { + addActionError( "Cannot remove an blank black list pattern." ); + } + + if ( !hasActionErrors() ) + { + getConnector().getBlackListPatterns().remove( pattern ); + setBlackListPattern( null ); + } + + return INPUT; + } + + public String edit() + { + getLogger().info( ".edit()" ); + this.mode = "edit"; + return INPUT; + } + + public String getBlackListPattern() + { + return blackListPattern; + } + + public ProxyConnectorConfiguration getConnector() + { + return connector; + } + + public List getLocalRepoIdList() + { + return localRepoIdList; + } + + public String getMode() + { + return this.mode; + } + + public Map getPolicyMap() + { + return policyMap; + } + + public String getPropertyKey() + { + return propertyKey; + } + + public String getPropertyValue() + { + return propertyValue; + } + + public List getProxyIdOptions() + { + return proxyIdOptions; + } + + public List getRemoteRepoIdList() + { + return remoteRepoIdList; + } + + public SecureActionBundle getSecureActionBundle() + throws SecureActionException + { + SecureActionBundle bundle = new SecureActionBundle(); + + bundle.setRequiresAuthentication( true ); + bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); + + return bundle; + } + + public String getSource() + { + return source; + } + + public String getTarget() + { + return target; + } + + public String getWhiteListPattern() + { + return whiteListPattern; + } + + public void initialize() + throws InitializationException + { + policyMap = new HashMap(); + policyMap.putAll( preDownloadPolicyMap ); + policyMap.putAll( postDownloadPolicyMap ); + } + + public String input() + { + getLogger().info( "input()" ); + return INPUT; + } + + public void prepare() + throws Exception + { + String sourceId = getSource(); + String targetId = getTarget(); + + getLogger().info( ".prepare() - sourceId [" + sourceId + "], targetId [" + targetId + "]" ); + + if ( StringUtils.isBlank( sourceId ) || StringUtils.isBlank( targetId ) ) + { + if ( this.connector == null ) + { + getLogger().info( "Creating new connector." ); + this.connector = new ProxyConnectorConfiguration(); + } + } + else + { + this.connector = findProxyConnector( sourceId, targetId ); + } + getLogger().info( "Connector: " + connector ); + + Configuration config = archivaConfiguration.getConfiguration(); + + // Gather Network Proxy Ids. + + this.proxyIdOptions = new ArrayList(); + this.proxyIdOptions.add( DIRECT_CONNECTION ); + + Closure addProxyIds = new Closure() + { + public void execute( Object input ) + { + if ( input instanceof NetworkProxyConfiguration ) + { + NetworkProxyConfiguration netproxy = (NetworkProxyConfiguration) input; + proxyIdOptions.add( netproxy.getId() ); + } + } + }; + + CollectionUtils.forAllDo( config.getNetworkProxies(), addProxyIds ); + + // Gather Local & Remote Repo Ids. + + RepositoryIdListClosure remoteRepoIdList = new RepositoryIdListClosure( new ArrayList() ); + RepositoryIdListClosure localRepoIdList = new RepositoryIdListClosure( new ArrayList() ); + Closure repoIfClosure = IfClosure.getInstance( RemoteRepositoryPredicate.getInstance(), remoteRepoIdList, + localRepoIdList ); + + CollectionUtils.forAllDo( config.getRepositories(), repoIfClosure ); + + this.remoteRepoIdList = remoteRepoIdList.getList(); + this.localRepoIdList = localRepoIdList.getList(); + } + + public String save() + { + String mode = getMode(); + + String sourceId = getConnector().getSourceRepoId(); + String targetId = getConnector().getTargetRepoId(); + + getLogger().info( ".save(" + mode + ":" + sourceId + "->" + targetId + ")" ); + + if ( !isValid( getConnector() ) ) + { + return INPUT; + } + + if ( StringUtils.equalsIgnoreCase( "edit", mode ) ) + { + removeConnector( sourceId, targetId ); + } + + try + { + if ( StringUtils.equals( DIRECT_CONNECTION, getConnector().getProxyId() ) ) + { + getConnector().setProxyId( null ); + } + + addProxyConnector( getConnector() ); + saveConfiguration(); + } + catch ( IOException e ) + { + addActionError( "I/O Exception: " + e.getMessage() ); + } + catch ( InvalidConfigurationException e ) + { + addActionError( "Invalid Configuration Exception: " + e.getMessage() ); + } + catch ( RegistryException e ) + { + addActionError( "Configuration Registry Exception: " + e.getMessage() ); + } + + return SUCCESS; + } + + public void setBlackListPattern( String blackListPattern ) + { + this.blackListPattern = blackListPattern; + } + + public void setConnector( ProxyConnectorConfiguration connector ) + { + this.connector = connector; + } + + public void setLocalRepoIdList( List localRepoIdList ) + { + this.localRepoIdList = localRepoIdList; + } + + public void setMode( String mode ) + { + this.mode = mode; + } + + public void setPropertyKey( String propertyKey ) + { + this.propertyKey = propertyKey; + } + + public void setPropertyValue( String propertyValue ) + { + this.propertyValue = propertyValue; + } + + public void setRemoteRepoIdList( List remoteRepoIdList ) + { + this.remoteRepoIdList = remoteRepoIdList; + } + + public void setSource( String source ) + { + this.source = source; + } + + public void setTarget( String target ) + { + this.target = target; + } + + public void setWhiteListPattern( String whiteListPattern ) + { + this.whiteListPattern = whiteListPattern; + } + + private void addProxyConnector( ProxyConnectorConfiguration proxyConnector ) + throws IOException + { + archivaConfiguration.getConfiguration().addProxyConnector( proxyConnector ); + } + + private ProxyConnectorConfiguration findProxyConnector( String sourceId, String targetId ) + { + Configuration config = archivaConfiguration.getConfiguration(); + + ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate( sourceId, targetId ); + return (ProxyConnectorConfiguration) CollectionUtils.find( config.getProxyConnectors(), selectedProxy ); + } + + private boolean isValid( ProxyConnectorConfiguration proxyConnector ) + { + if ( proxyConnector.getPolicies() == null ) + { + addActionError( "Policies must be set." ); + return false; + } + + Iterator it = policyMap.entrySet().iterator(); + while ( it.hasNext() ) + { + Map.Entry entry = (Entry) it.next(); + String policyId = (String) entry.getKey(); + DownloadPolicy policy = (DownloadPolicy) entry.getValue(); + List options = policy.getOptions(); + + if ( !proxyConnector.getPolicies().containsKey( policyId ) ) + { + addActionError( "Policy [" + policyId + "] must be set (missing id)." ); + continue; + } + + String arr[] = (String[]) proxyConnector.getPolicies().get( policyId ); + String value = arr[0]; + + proxyConnector.getPolicies().put( policyId, value ); + + if ( StringUtils.isBlank( value ) ) + { + addActionError( "Policy [" + policyId + "] must be set (missing value)." ); + continue; + } + + if ( !options.contains( value ) ) + { + addActionError( "Value of [" + value + "] is invalid for policy [" + policyId + "], valid values: " + + options ); + continue; + } + } + + if ( hasActionErrors() || hasActionMessages() ) + { + return false; + } + + return true; + } + + private void removeConnector( String sourceId, String targetId ) + { + ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate( sourceId, targetId ); + NotPredicate notSelectedProxy = new NotPredicate( selectedProxy ); + CollectionUtils.filter( archivaConfiguration.getConfiguration().getProxyConnectors(), notSelectedProxy ); + } + + private String saveConfiguration() + throws IOException, InvalidConfigurationException, RegistryException + { + archivaConfiguration.save( archivaConfiguration.getConfiguration() ); + + addActionMessage( "Successfully saved configuration" ); + + return SUCCESS; + } + + public String getPattern() + { + return pattern; + } + + public void setPattern( String pattern ) + { + this.pattern = pattern; + } +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java new file mode 100644 index 000000000..65c28c145 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java @@ -0,0 +1,151 @@ +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.Preparable; + +import org.apache.commons.collections.Closure; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.Transformer; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; +import org.apache.maven.archiva.configuration.RepositoryConfiguration; +import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.maven.archiva.web.action.admin.repositories.AdminRepositoryConfiguration; +import org.codehaus.plexus.security.rbac.Resource; +import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; +import org.codehaus.plexus.security.ui.web.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; + +/** + * ProxyConnectorsAction + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="proxyConnectorsAction" + */ +public class ProxyConnectorsAction + extends PlexusActionSupport + implements SecureAction, Preparable +{ + /** + * @plexus.requirement role-hint="adminrepoconfig" + */ + private Transformer repoConfigToAdmin; + + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + private Map /**/repoMap; + + /** + * Map of Proxy Connectors. + */ + private Map /**/proxyConnectorMap; + + public void prepare() + throws Exception + { + Configuration config = archivaConfiguration.getConfiguration(); + + repoMap = new HashMap(); + + Closure addToRepoMap = new Closure() + { + public void execute( Object input ) + { + if ( input instanceof RepositoryConfiguration ) + { + AdminRepositoryConfiguration arepo = (AdminRepositoryConfiguration) repoConfigToAdmin + .transform( input ); + repoMap.put( arepo.getId(), arepo ); + } + } + }; + + CollectionUtils.forAllDo( config.getRepositories(), addToRepoMap ); + + 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; + } + + public Map getRepoMap() + { + return repoMap; + } + + public void setRepoMap( Map repoMap ) + { + this.repoMap = repoMap; + } + + public Map getProxyConnectorMap() + { + return proxyConnectorMap; + } + + public void setProxyConnectorMap( Map proxyConnectorMap ) + { + this.proxyConnectorMap = proxyConnectorMap; + } +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SingleSelectTransformer.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SingleSelectTransformer.java new file mode 100644 index 000000000..dfabf03a2 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SingleSelectTransformer.java @@ -0,0 +1,56 @@ +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.collections.Transformer; + +/** + * Ensure that input strings are never arrays. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class SingleSelectTransformer + implements Transformer +{ + private static Transformer INSTANCE = new SingleSelectTransformer(); + + public Object transform( Object input ) + { + if ( input instanceof String ) + { + if ( input.getClass().isArray() ) + { + String arr[] = (String[]) input; + if ( arr.length > 0 ) + { + return arr[0]; + } + } + } + return null; + } + + public static Transformer getInstance() + { + return INSTANCE; + } + +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java new file mode 100644 index 000000000..87acd09f0 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java @@ -0,0 +1,73 @@ +package org.apache.maven.archiva.web.action.admin.database; + +/* + * 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.webwork.interceptor.ServletRequestAware; +import com.opensymphony.xwork.ModelDriven; +import com.opensymphony.xwork.Preparable; +import com.opensymphony.xwork.Validateable; + +import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; +import org.codehaus.plexus.xwork.action.PlexusActionSupport; + +import javax.servlet.http.HttpServletRequest; + +/** + * DatabaseAction + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="databaseAction" + */ +public class DatabaseAction +extends PlexusActionSupport +implements ModelDriven, Preparable, Validateable, SecureAction, ServletRequestAware +{ + + public Object getModel() + { + // TODO Auto-generated method stub + return null; + } + + public void prepare() + throws Exception + { + // TODO Auto-generated method stub + + } + + public SecureActionBundle getSecureActionBundle() + throws SecureActionException + { + // TODO Auto-generated method stub + return null; + } + + public void setServletRequest( HttpServletRequest request ) + { + // TODO Auto-generated method stub + + } + +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminModel.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminModel.java deleted file mode 100644 index 3ea4c5a36..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminModel.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.models; - -/* - * 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.Configuration; -import org.apache.maven.archiva.configuration.RepositoryConfiguration; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * AdminModel - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AdminModel -{ - private String baseUrl; - - private List managedRepositories = new ArrayList(); - - private List remoteRepositories = new ArrayList(); - - private Map repoMap = new HashMap(); - - public AdminModel() - { - /* do nothing */ - } - - public AdminModel( Configuration configuration ) - { - repoMap.putAll( configuration.createRepositoryMap() ); - - Iterator it = configuration.getRepositories().iterator(); - while ( it.hasNext() ) - { - RepositoryConfiguration repoconfig = (RepositoryConfiguration) it.next(); - if ( repoconfig.isManaged() ) - { - managedRepositories.add( new AdminRepositoryConfiguration( repoconfig ) ); - } - else if ( repoconfig.isRemote() ) - { - remoteRepositories.add( repoconfig ); - } - else - { - // Should never occur, but it is possible that the configuration could - // contain a repository configuration which is null. - } - } - } - - public List getManagedRepositories() - { - return managedRepositories; - } - - public void setManagedRepositories( List managedRepositories ) - { - this.managedRepositories = managedRepositories; - } - - public List getRemoteRepositories() - { - return remoteRepositories; - } - - public void setRemoteRepositories( List remoteRepositories ) - { - this.remoteRepositories = remoteRepositories; - } - - public String getBaseUrl() - { - return baseUrl; - } - - public void setBaseUrl( String baseUrl ) - { - this.baseUrl = baseUrl; - } - - public String toString() - { - return "[ActionModel]"; - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java new file mode 100644 index 000000000..160a93cca --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java @@ -0,0 +1,73 @@ +package org.apache.maven.archiva.web.action.admin.networkproxies; + +/* + * 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.webwork.interceptor.ServletRequestAware; +import com.opensymphony.xwork.ModelDriven; +import com.opensymphony.xwork.Preparable; +import com.opensymphony.xwork.Validateable; + +import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; +import org.codehaus.plexus.xwork.action.PlexusActionSupport; + +import javax.servlet.http.HttpServletRequest; + +/** + * NetworkProxiesAction + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="networkProxiesAction" + */ +public class NetworkProxiesAction +extends PlexusActionSupport +implements ModelDriven, Preparable, Validateable, SecureAction, ServletRequestAware +{ + + public Object getModel() + { + // TODO Auto-generated method stub + return null; + } + + public void prepare() + throws Exception + { + // TODO Auto-generated method stub + + } + + public SecureActionBundle getSecureActionBundle() + throws SecureActionException + { + // TODO Auto-generated method stub + return null; + } + + public void setServletRequest( HttpServletRequest request ) + { + // TODO Auto-generated method stub + + } + +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminRepositoryConfiguration.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AdminRepositoryConfiguration.java similarity index 85% rename from archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminRepositoryConfiguration.java rename to archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AdminRepositoryConfiguration.java index e6857755d..f8fd58943 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/models/AdminRepositoryConfiguration.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AdminRepositoryConfiguration.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.web.action.admin.models; +package org.apache.maven.archiva.web.action.admin.repositories; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -36,8 +36,6 @@ import java.io.File; public class AdminRepositoryConfiguration extends RepositoryConfiguration { - private String directory; - private RepositoryContentStatistics stats; public AdminRepositoryConfiguration() @@ -70,23 +68,33 @@ public class AdminRepositoryConfiguration public boolean isDirectoryExists() { - if ( StringUtils.isBlank( directory ) ) + if ( StringUtils.isBlank( getDirectory() ) ) { return false; } - File dir = new File( directory ); + File dir = new File( getDirectory() ); return ( dir.exists() && dir.isDirectory() ); } public String getDirectory() { - return directory; + if ( this.isManaged() ) + { + if ( StringUtils.isBlank( this.getUrl() ) ) + { + return null; + } + + RepositoryURL url = new RepositoryURL( this.getUrl() ); + return url.getPath(); + } + + return null; } public void setDirectory( String directory ) { - this.directory = directory; this.setUrl( PathUtil.toUrl( directory ) ); } diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java new file mode 100644 index 000000000..f17c8c099 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java @@ -0,0 +1,370 @@ +package org.apache.maven.archiva.web.action.admin.repositories; + +/* + * 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.ActionContext; +import com.opensymphony.xwork.Preparable; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.common.utils.PathUtil; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.InvalidConfigurationException; +import org.apache.maven.archiva.configuration.RepositoryConfiguration; +import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.codehaus.plexus.rbac.profile.RoleProfileException; +import org.codehaus.plexus.rbac.profile.RoleProfileManager; +import org.codehaus.plexus.registry.RegistryException; +import org.codehaus.plexus.security.authorization.AuthorizationException; +import org.codehaus.plexus.security.authorization.AuthorizationResult; +import org.codehaus.plexus.security.rbac.RbacManagerException; +import org.codehaus.plexus.security.rbac.Resource; +import org.codehaus.plexus.security.system.SecuritySession; +import org.codehaus.plexus.security.system.SecuritySystem; +import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; +import org.codehaus.plexus.xwork.action.PlexusActionSupport; + +import java.io.File; +import java.io.IOException; + +/** + * Configures the application repositories. + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureRepositoryAction" + */ +public class ConfigureRepositoryAction + extends PlexusActionSupport + implements Preparable, SecureAction +{ + /** + * @plexus.requirement role-hint="archiva" + */ + private RoleProfileManager roleProfileManager; + + /** + * @plexus.requirement + */ + private SecuritySystem securitySystem; + + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + private String repoid; + + private String mode; + + /** + * The model for this action. + */ + private AdminRepositoryConfiguration repository; + + public String add() + { + getLogger().info( ".add()" ); + this.mode = "add"; + + return INPUT; + } + + public String confirm() + { + getLogger().info( ".confirm()" ); + + if ( operationAllowed( ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, getRepoid() ) ) + { + addActionError( "You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); + return ERROR; + } + + return INPUT; + } + + public String delete() + { + getLogger().info( ".delete()" ); + + if ( operationAllowed( ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, getRepoid() ) ) + { + addActionError( "You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); + return ERROR; + } + + if ( StringUtils.equals( mode, "delete-entry" ) || StringUtils.equals( mode, "delete-contents" ) ) + { + AdminRepositoryConfiguration existingRepository = getRepository(); + if ( existingRepository == null ) + { + addActionError( "A repository with that id does not exist" ); + return ERROR; + } + + // TODO: remove from index too! + + try + { + removeRepository( getRepoid() ); + removeRepositoryRoles( existingRepository ); + saveConfiguration(); + + if ( StringUtils.equals( mode, "delete-contents" ) ) + { + removeContents( existingRepository ); + } + } + catch ( IOException e ) + { + addActionError( "Unable to delete repository: " + e.getMessage() ); + } + catch ( RoleProfileException e ) + { + addActionError( "Unable to delete repository: " + e.getMessage() ); + } + catch ( InvalidConfigurationException e ) + { + addActionError( "Unable to delete repository: " + e.getMessage() ); + } + catch ( RbacManagerException e ) + { + addActionError( "Unable to delete repository: " + e.getMessage() ); + } + catch ( RegistryException e ) + { + addActionError( "Unable to delete repository: " + e.getMessage() ); + } + } + + return SUCCESS; + } + + public String edit() + { + getLogger().info( ".edit()" ); + this.mode = "edit"; + + if ( operationAllowed( ArchivaRoleConstants.OPERATION_EDIT_REPOSITORY, getRepoid() ) ) + { + addActionError( "You do not have the appropriate permissions to edit the " + getRepoid() + " repository." ); + return ERROR; + } + + return INPUT; + } + + public String getMode() + { + return this.mode; + } + + public String getRepoid() + { + return repoid; + } + + public AdminRepositoryConfiguration getRepository() + { + return repository; + } + + public SecureActionBundle getSecureActionBundle() + throws SecureActionException + { + SecureActionBundle bundle = new SecureActionBundle(); + + bundle.setRequiresAuthentication( true ); + bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); + + return bundle; + } + + public void prepare() + throws Exception + { + String id = getRepoid(); + if ( id == null ) + { + this.repository = new AdminRepositoryConfiguration(); + } + + RepositoryConfiguration repoconfig = archivaConfiguration.getConfiguration().findRepositoryById( id ); + if ( repoconfig != null ) + { + this.repository = new AdminRepositoryConfiguration( repoconfig ); + } + } + + public String save() + { + String mode = getMode(); + String repoId = getRepository().getId(); + + getLogger().info( ".save(" + mode + ":" + repoId + ")" ); + + if ( StringUtils.isBlank( repository.getId() ) ) + { + addFieldError( "id", "A repository with a blank id cannot be saved." ); + return SUCCESS; + } + + if ( StringUtils.equalsIgnoreCase( "edit", mode ) ) + { + removeRepository( repoId ); + } + + try + { + addRepository( getRepository() ); + saveConfiguration(); + } + catch ( IOException e ) + { + addActionError( "I/O Exception: " + e.getMessage() ); + } + catch ( RoleProfileException e ) + { + addActionError( "Role Profile Exception: " + e.getMessage() ); + } + catch ( InvalidConfigurationException e ) + { + addActionError( "Invalid Configuration Exception: " + e.getMessage() ); + } + catch ( RbacManagerException e ) + { + addActionError( "RBAC Manager Exception: " + e.getMessage() ); + } + catch ( RegistryException e ) + { + addActionError( "Configuration Registry Exception: " + e.getMessage() ); + } + + return SUCCESS; + } + + public void setMode( String mode ) + { + this.mode = mode; + } + + public void setRepoid( String repoid ) + { + this.repoid = repoid; + } + + public void setRepository( AdminRepositoryConfiguration repository ) + { + this.repository = repository; + } + + private void addRepository( AdminRepositoryConfiguration repository ) + throws IOException, RoleProfileException + { + getLogger().info( ".addRepository(" + repository + ")" ); + + // Fix the URL entry (could possibly be a filesystem path) + String rawUrlEntry = repository.getUrl(); + repository.setUrl( PathUtil.toUrl( rawUrlEntry ) ); + + if ( repository.isManaged() ) + { + // Normalize the path + File file = new File( repository.getDirectory() ); + repository.setDirectory( file.getCanonicalPath() ); + if ( !file.exists() ) + { + file.mkdirs(); + // TODO: error handling when this fails, or is not a directory! + } + } + + archivaConfiguration.getConfiguration().addRepository( repository ); + + // TODO: double check these are configured on start up + roleProfileManager.getDynamicRole( "archiva-repository-manager", repository.getId() ); + + roleProfileManager.getDynamicRole( "archiva-repository-observer", repository.getId() ); + } + + private boolean operationAllowed( String permission, String repoid ) + { + ActionContext context = ActionContext.getContext(); + SecuritySession securitySession = (SecuritySession) context.get( SecuritySession.ROLE ); + + AuthorizationResult authzResult; + try + { + authzResult = securitySystem.authorize( securitySession, permission, repoid ); + + return authzResult.isAuthorized(); + } + catch ( AuthorizationException e ) + { + getLogger().info( + "Unable to authorize permission: " + permission + " against repo: " + repoid + + " due to: " + e.getMessage() ); + return false; + } + } + + private void removeContents( AdminRepositoryConfiguration existingRepository ) + throws IOException + { + if ( existingRepository.isManaged() ) + { + getLogger().info( "Removing " + existingRepository.getDirectory() ); + FileUtils.deleteDirectory( new File( existingRepository.getDirectory() ) ); + } + } + + private void removeRepository( String repoId ) + { + getLogger().info( ".removeRepository()" ); + + RepositoryConfiguration toremove = archivaConfiguration.getConfiguration().findRepositoryById( repoId ); + if ( toremove != null ) + { + archivaConfiguration.getConfiguration().removeRepository( toremove ); + } + } + + private void removeRepositoryRoles( RepositoryConfiguration existingRepository ) + throws RoleProfileException + { + roleProfileManager.deleteDynamicRole( "archiva-repository-manager", existingRepository.getId() ); + roleProfileManager.deleteDynamicRole( "archiva-repository-observer", existingRepository.getId() ); + + getLogger().info( "removed user roles associated with repository " + existingRepository.getId() ); + } + + private String saveConfiguration() + throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, + RegistryException + { + getLogger().info( ".saveConfiguration()" ); + + archivaConfiguration.save( archivaConfiguration.getConfiguration() ); + + addActionMessage( "Successfully saved configuration" ); + + return SUCCESS; + } +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RepositoriesAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java similarity index 56% rename from archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RepositoriesAction.java rename to archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java index e9fcc4199..05254eb49 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RepositoriesAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.web.action.admin; +package org.apache.maven.archiva.web.action.admin.repositories; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -20,17 +20,17 @@ package org.apache.maven.archiva.web.action.admin; */ import com.opensymphony.webwork.interceptor.ServletRequestAware; -import com.opensymphony.xwork.ModelDriven; import com.opensymphony.xwork.Preparable; -import com.opensymphony.xwork.Validateable; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.Transformer; +import org.apache.commons.collections.list.TransformedList; import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics; -import org.apache.maven.archiva.model.RepositoryContentStatistics; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.util.LocalRepositoryPredicate; +import org.apache.maven.archiva.configuration.util.RemoteRepositoryPredicate; +import org.apache.maven.archiva.configuration.util.RepositoryConfigurationComparator; import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.web.action.admin.models.AdminModel; -import org.apache.maven.archiva.web.action.admin.models.AdminRepositoryConfiguration; import org.apache.maven.archiva.web.util.ContextUtils; import org.codehaus.plexus.security.rbac.Resource; import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; @@ -38,7 +38,8 @@ import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; import org.codehaus.plexus.xwork.action.PlexusActionSupport; -import java.util.Iterator; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -53,44 +54,27 @@ import javax.servlet.http.HttpServletRequest; */ public class RepositoriesAction extends PlexusActionSupport - implements ModelDriven, Preparable, Validateable, SecureAction, ServletRequestAware + implements SecureAction, ServletRequestAware, Preparable { /** - * @plexus.requirement role-hint="jdo" + * @plexus.requirement role-hint="adminrepoconfig" */ - private ArchivaDAO dao; + private Transformer repoConfigToAdmin; /** * @plexus.requirement */ private ArchivaConfiguration archivaConfiguration; - private AdminModel model; + private List managedRepositories; + + private List remoteRepositories; private String baseUrl; - public Object getModel() + public void setServletRequest( HttpServletRequest request ) { - return getAdminModel(); - } - - public void prepare() - throws Exception - { - model = null; - getModel(); - } - - public void validate() - { - super.validate(); - } - - public String execute() - throws Exception - { - getLogger().info( ".execute()" ); - return super.execute(); + this.baseUrl = ContextUtils.getBaseURL( request, "repository" ); } public SecureActionBundle getSecureActionBundle() @@ -104,46 +88,33 @@ public class RepositoriesAction return bundle; } - public void setServletRequest( HttpServletRequest request ) + public void prepare() + throws Exception { - this.baseUrl = ContextUtils.getBaseURL( request, "repository" ); + Configuration config = archivaConfiguration.getConfiguration(); + + remoteRepositories = TransformedList.decorate( new ArrayList(), repoConfigToAdmin ); + managedRepositories = TransformedList.decorate( new ArrayList(), repoConfigToAdmin ); + + remoteRepositories.addAll( CollectionUtils.select( config.getRepositories(), RemoteRepositoryPredicate.getInstance() ) ); + managedRepositories.addAll( CollectionUtils.select( config.getRepositories(), LocalRepositoryPredicate.getInstance() ) ); + + Collections.sort( managedRepositories, new RepositoryConfigurationComparator() ); + Collections.sort( remoteRepositories, new RepositoryConfigurationComparator() ); } - public AdminModel getAdminModel() + public List getManagedRepositories() { - if ( model == null ) - { - model = new AdminModel( archivaConfiguration.getConfiguration() ); - model.setBaseUrl( baseUrl ); - updateLastIndexed( model.getManagedRepositories() ); - } - - return model; + return managedRepositories; } - private void updateLastIndexed( List managedRepositories ) + public List getRemoteRepositories() { - Iterator it = managedRepositories.iterator(); - while ( it.hasNext() ) - { - AdminRepositoryConfiguration config = (AdminRepositoryConfiguration) it.next(); - - List results = dao.query( new MostRecentRepositoryScanStatistics( config.getId() ) ); - if ( !results.isEmpty() ) - { - RepositoryContentStatistics stats = (RepositoryContentStatistics) results.get( 0 ); - config.setStats( stats ); - } - } + return remoteRepositories; } - public String getBaseUrlB() + public String getBaseUrl() { return baseUrl; } - - public void setBaseUrlB( String baseUrl ) - { - this.baseUrl = baseUrl; - } } diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryConfigurationAdminTransformer.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryConfigurationAdminTransformer.java new file mode 100644 index 000000000..2d43cfa47 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryConfigurationAdminTransformer.java @@ -0,0 +1,75 @@ +package org.apache.maven.archiva.web.action.admin.repositories; + +/* + * 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.collections.Transformer; +import org.apache.maven.archiva.configuration.RepositoryConfiguration; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics; +import org.apache.maven.archiva.model.RepositoryContentStatistics; + +import java.util.List; + +/** + * RepositoryConfigurationAdminTransformer + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="org.apache.commons.collections.Transformer" + * role-hint="adminrepoconfig" + */ +public class RepositoryConfigurationAdminTransformer + implements Transformer +{ + /** + * @plexus.requirement role-hint="jdo" + */ + private ArchivaDAO dao; + + public Object transform( Object input ) + { + if ( input instanceof RepositoryConfiguration ) + { + RepositoryConfiguration repoconfig = (RepositoryConfiguration) input; + AdminRepositoryConfiguration arepo = new AdminRepositoryConfiguration( repoconfig ); + + if ( arepo.isManaged() ) + { + arepo.setStats( getLatestStats( arepo.getId() ) ); + } + + return arepo; + } + + return null; + } + + private RepositoryContentStatistics getLatestStats( String repoId ) + { + List results = dao.query( new MostRecentRepositoryScanStatistics( repoId ) ); + if ( results.isEmpty() ) + { + return null; + } + + return (RepositoryContentStatistics) results.get( 0 ); + } +} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java new file mode 100644 index 000000000..fb7fa6d5e --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java @@ -0,0 +1,73 @@ +package org.apache.maven.archiva.web.action.admin.scanning; + +/* + * 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.webwork.interceptor.ServletRequestAware; +import com.opensymphony.xwork.ModelDriven; +import com.opensymphony.xwork.Preparable; +import com.opensymphony.xwork.Validateable; + +import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; +import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; +import org.codehaus.plexus.xwork.action.PlexusActionSupport; + +import javax.servlet.http.HttpServletRequest; + +/** + * RepositoryScanningAction + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="repositoryScanningAction" + */ +public class RepositoryScanningAction +extends PlexusActionSupport +implements ModelDriven, Preparable, Validateable, SecureAction, ServletRequestAware +{ + + public Object getModel() + { + // TODO Auto-generated method stub + return null; + } + + public void prepare() + throws Exception + { + // TODO Auto-generated method stub + + } + + public SecureActionBundle getSecureActionBundle() + throws SecureActionException + { + // TODO Auto-generated method stub + return null; + } + + public void setServletRequest( HttpServletRequest request ) + { + // TODO Auto-generated method stub + + } + +} diff --git a/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-web/archiva-webapp/src/main/resources/xwork.xml index 9ca85a62b..7bd0cd23b 100644 --- a/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -36,11 +36,15 @@ - + + + + externalResult + @@ -225,8 +229,11 @@ /WEB-INF/jsp/admin/repositories.jsp + + /WEB-INF/jsp/admin/repositories.jsp + deleteRepository @@ -235,26 +242,85 @@ /WEB-INF/jsp/admin/addRepository.jsp - repositories - + repositories + - + /WEB-INF/jsp/admin/editRepository.jsp repositories repositories - + repositories + - + /WEB-INF/jsp/admin/deleteRepository.jsp - repositories + repositories + + + + + /WEB-INF/jsp/admin/proxyConnectors.jsp + + + + /WEB-INF/jsp/admin/addProxyConnector.jsp + proxyConnectors + + + + + /WEB-INF/jsp/admin/editProxyConnector.jsp + proxyConnectors + + + + + /WEB-INF/jsp/admin/editProxyConnector.jsp + proxyConnectors + + + + + /WEB-INF/jsp/admin/editProxyConnector.jsp + proxyConnectors + + + + + /WEB-INF/jsp/admin/deleteProxyConnector.jsp + proxyConnectors + + + + + + + /WEB-INF/jsp/admin/networkProxies.jsp + + + + + + /WEB-INF/jsp/admin/repositoryScanning.jsp + + + + + + /WEB-INF/jsp/admin/database.jsp + + + + + /WEB-INF/jsp/admin/configure.jsp diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxyConnector.jsp new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addRepository.jsp index 6d4502a3d..8373a3364 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addRepository.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/addRepository.jsp @@ -21,27 +21,28 @@ - Configuration + Admin: Add Repository -

Configuration

+

Admin: Add Repository

-

Add Managed Repository

+

Add Repository

- - - <%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %> + + + + <%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepository.jsp index 310cffbc5..379b178b3 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepository.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepository.jsp @@ -37,11 +37,11 @@ WARNING: This operation can not be undone. - - + + + 'unmodified' : 'Leave the repository unmodified'}" name="mode" theme="archiva"/> diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp new file mode 100644 index 000000000..879347e36 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxyConnector.jsp @@ -0,0 +1,52 @@ +<%-- + ~ 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 : Edit Proxy Connector + + + + + +

Admin : Edit Proxy Connector

+ +
+ +

Edit Proxy Connector

+ + + + + + + <%@ include file="/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf" %> + + + + + +
+ + + \ No newline at end of file diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp index 929246fd6..17af49664 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp @@ -21,28 +21,28 @@ - Configuration + Admin: Edit Repository -

Configuration

+

Admin: Edit Repository

-

Edit Managed Repository

+

Edit Repository

- - - <%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %> + + + <%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf deleted file mode 100644 index ba6a76452..000000000 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxiedRepositoryForm.jspf +++ /dev/null @@ -1,42 +0,0 @@ -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --%> - -<%@ taglib prefix="ww" uri="/webwork" %> - - - - - - - - - - - diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf new file mode 100644 index 000000000..a6a1b2a02 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/proxyConnectorForm.jspf @@ -0,0 +1,196 @@ +<%-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --%> +<%@ taglib prefix="ww" uri="/webwork" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + + + + + + + + + + + + + + +
+ ${policy.key}: + + +
+ + + + + + + + : + + + + + + + + + + + No properties have been set. + + + + + + + + + + + +
+ ${property.key} + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + No black list patterns have been set. + + + + + + + + + +
+ + "${pattern}" + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + No white list patterns have been set. + + + + + + + + + +
+ + "${pattern}" + + + +
+
+
+ + diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf similarity index 65% rename from archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf rename to archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf index f8907b6ca..683bb9dac 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf @@ -19,11 +19,11 @@ <%@ taglib prefix="ww" uri="/webwork" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - + + - - - - + name="repository.layout" label="Type"/> + + + + diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/syncedRepositoryForm.jspf b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/syncedRepositoryForm.jspf deleted file mode 100644 index ee716cb44..000000000 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/syncedRepositoryForm.jspf +++ /dev/null @@ -1,46 +0,0 @@ -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --%> - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp new file mode 100644 index 000000000..a7aad790e --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxyConnectors.jsp @@ -0,0 +1,170 @@ +<%-- + ~ 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" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +<%@ taglib prefix="pss" uri="/plexusSecuritySystem" %> +<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %> + + + + Administration - Proxy Connectors + + + + + +

Administration - Proxy Connectors

+ +
+ + + + +
+ + + + " /> + Add Proxy Connector + + +
+ +

Repository Proxy Connectors

+ + + + No Repository Proxy Connectors Defined. + + + + + + + + + + + + + + + +
+
+ " /> +

${repository.key}

+

${repoMap[repository.key].name}

+
+
+
+
+ + + + + + + + + + + " /> + + + " /> + + +
+ +

Proxy Connector

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Network Proxy: + + + (Direct Connection) + + + ${connector.proxyId} + + +
Policies: + +

${policies.key}: ${policies.value}

+
+
White List: + +

"${pattern}"

+
+
Black List: + +

"${pattern}"

+
+
Properties: + +

${prop.key}: ${prop.value}

+
+
+
+
+
+ " /> +

${connector.targetRepoId}

+

${repoMap[connector.targetRepoId].name}

+

${repoMap[connector.targetRepoId].url}

+
+
+
+
+ +
+ + + diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp index e0a92ae75..9c00884d2 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp @@ -37,28 +37,30 @@ -
-
- <%-- TODO replace with icons --%> - - - Add Repository - +
+
+ <%-- TODO replace with icons --%> + + + + " /> + Add Repository + +
+

Local Repositories

-

Managed Repositories

-
- - <%-- No Managed Repositories. --%> - There are no managed repositories configured yet. + + <%-- No Local Repositories. --%> + There are no local repositories configured yet. <%-- Display the repositories. --%> - + -
+
<%-- TODO: make some icons --%> @@ -69,12 +71,20 @@ - Edit Repository - Delete Repository + + " /> + Edit Repository + + " /> + Delete Repository
-

${repository.name}

+
+ " /> +
+ +

${repository.name}

@@ -93,7 +103,7 @@ - + @@ -179,6 +189,83 @@ +

Remote Repositories

+ + + + <%-- No Remote Repositories. --%> + There are no remote repositories configured yet. + + + <%-- Display the repositories. --%> + + +
+ +
+ <%-- TODO: make some icons --%> + + + + + + + + + " /> + Edit Repository + + " /> + Delete Repository + +
+ +
+ " /> +
+ +

${repository.name}

+ +
WebDAV URL${model.baseUrl}/${repository.id}/${baseUrl}/${repository.id}/
Type
+ + + + + + + + + + + <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%> + + + + + + + + + + +
Identifier + ${repository.id} +
URL${repository.url}
Type + + + Maven 2.x Repository + + + Maven 1.x Repository + + +
Releases Included ${repository.releases}
Snapshots Included ${repository.snapshots}
+ +
+ + + +
diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp index f9d5710bb..a932af783 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp @@ -116,29 +116,35 @@ Appearance + <%-- TODO: future options here. + * Repository Statistics. + * Web Services Statistics. + --%>
Administration
    -
  • - Settings -
  • Repositories
  • - <%--
  • - Proxied Repositories + Proxy Connectors
  • - --%> - - <%-- TODO: add back after synced repos are implemented -
  • - Synced Repositories -
  • - --%> +
  • + Network Proxies +
  • +
  • + Repository Scanning +
  • +
  • + Database +
  • + <%-- TODO: future options here. + * Repository Syncing Connectors. (rsync, ftp, scp, etc...) + * Web Services (enable / disable), role based? + --%>
diff --git a/archiva-web/archiva-webapp/src/main/webapp/css/maven-base.css b/archiva-web/archiva-webapp/src/main/webapp/css/maven-base.css index b2ffabf70..952c9b5a3 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/css/maven-base.css +++ b/archiva-web/archiva-webapp/src/main/webapp/css/maven-base.css @@ -84,7 +84,6 @@ div.clear hr { } #leftColumn { - height: 315px; width: 170px; float: left; overflow: auto; diff --git a/archiva-web/archiva-webapp/src/main/webapp/css/site.css b/archiva-web/archiva-webapp/src/main/webapp/css/site.css index e6d7370f0..fcdd9fc84 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/css/site.css +++ b/archiva-web/archiva-webapp/src/main/webapp/css/site.css @@ -211,3 +211,77 @@ ul.dependencyTree span.artifact-link { background-color: #F3B455 !important; } +div.repository h3 { + border-bottom: 0px !important; + padding-left: 15px !important; +} + +div.repository { + border-bottom: 1px solid #DFDEDE; +} + +tr.proxyConnector { + border-bottom: 1px solid #DFDEDE; +} + +tr.proxyConnector td.managedRepo div, +tr.proxyConnector td.remoteRepo div { + border: 1px dotted gray; + padding: 5px; + background-color: white; +} + +tr.proxyConnector td.managedRepo img, +tr.proxyConnector td.remoteRepo img { + float: left; + border: 0px; +} + +tr.proxyConnector td.managedRepo div p, +tr.proxyConnector td.remoteRepo div p { + margin: 0px; + margin-left: 40px; + padding: 0px; +} + +tr.proxyConnector td.managedRepo div p.id, +tr.proxyConnector td.remoteRepo div p.id { + font-family: monospace; +} + +tr.proxyConnector td.connector { + padding-left: 10px; + padding-right: 10px; +} + +tr.proxyConnector td.connector div.wrap { + margin-left: 10px; + margin-right: 10px; + padding: 5px; + border: 1px solid gray; + background-color: #eeeeee; +} + +tr.proxyConnector td.connector div.controls { + float: right; +} + +tr.proxyConnector td.connector div h4 { + font-size: 1.0em; + margin: 0px; +} + +tr.proxyConnector td.connector table { + border: 0px; + background-color: transparent; + font-size: 0.8em; +} + +tr.proxyConnector td.connector table p { + margin: 0px; + padding: 0px; +} + +tr.seperator td { + border-top: 1px dashed #dddddd !important; +} \ No newline at end of file diff --git a/archiva-web/archiva-webapp/src/main/webapp/images/archiva-splat-32.gif b/archiva-web/archiva-webapp/src/main/webapp/images/archiva-splat-32.gif new file mode 100644 index 0000000000000000000000000000000000000000..8625d2311fed0722993bc3785dc56b6a8e75694c GIT binary patch literal 1294 zcmb8ui&s(y0LSsG;WJbqV>z6u_zubMjZ4ICwPhzFycfnaUxPIi1ZLv zdQZN}0rYr?h@L=j!VCph34dDYGMi8LGUqeR-&{1EAwgRH9gpRF* zj{A=y=&MIhtR7AOW;A1sBx9{4bG;;M1Cz;=WN(t3+$_lnl;&)fo!(keQ6bF@lH~`> z&JbkM!TWY&LuB{9ZXDT3)hWUK%4Wjg^-kP?W_fF2>23@d^a% zpn{d4C{I#Uq$n$rm6ubLm1)W=N0e8N!c{c*>M{80ak!ceSD%1?PlszVR5j_UnvCY= zW)(YA#r^@lmZd_}W~*vXs;_6OuOrP--Nq)_@$$xL;L5i+QtjodyLM`PF+(;S67#=g{5n`)ZN`Z{-Cm_r$^sj zqi<&$I%@fRzTrvTL|2{R>79vZoc{iPfj}_HYneqr zgL1jtB>C4Q6`G_UOtN9~*k_Y`#3UD)6=Jgz(rUG47&617W));sjapO^i&|pQ$Sm41 zi%xFQDJCW+EPAC?4_ggt>*Tm~N@txKw@n*tvqqE2WS^V1nP$vpv)w#rH=FDhgxPAf z+O3xP1y-BQX1CeqZC1P8X1Ckt?Y4QO^N9aFe-p~V9he6;E<9o36M(B7_}EQ|;Bt5+ zu1mg6eZ{TsV@eY)-DIDV1X3F=hf-LlhMWj3P@$!m6!~{0ik(K7yIjuNDB1Jwtn?Cx zTki2s*$qlnyr*v^_m-hI$B(=I@$$yFtMt!3x#@K6&_n~CNAh`Jnw`1W)onNGw42mn z)s?4=$HmvzQ3mS+@ZaaBg)+uI_ME0iQSxRCH)?S7k>{)SjA40k#8U-Xna%rrw#A$i z62mbEA2L3)2$wlJ4=f87VBSa3>UT5oTfzb()2qO{9^V}+g?ng@D{`H|yyU)nKk7rX zkNWVhMf|3R&H$mJPpyy0Me7;}-b}9Vbg}BSe{{yUU*o2XUM+Kb-w8G;`+P6UYx9eN z{E|+3JS^ckReDi5J}39OQP4gC1sn&bi>~QIYYS222=5)R#GRDbv?Vq;Nf1aO6dM_@ zg3z13@Lh9*X7{f{MTEs}*d?gy->rigWbAWvfhP*^1~>)r0Kk3uR?L=U z!({BX5wtPN5eVWAu3QAo&NzKvem%= literal 0 HcmV?d00001 diff --git a/archiva-web/archiva-webapp/src/main/webapp/images/archiva-world.png b/archiva-web/archiva-webapp/src/main/webapp/images/archiva-world.png new file mode 100644 index 0000000000000000000000000000000000000000..8afb6cc93071dfdc63ed93acdbd6a26b71d1f72c GIT binary patch literal 1936 zcmV;B2XFX^P)&;}`v6h#$?WOE$7uHmk6^5(P@xC95nfP)eblmZ5ao z4()XAmv`QC{4g-3ODQdh&&TsVm*4rHbDsAcp|#dLqopz#EX%^}bRwmErX05AI$BB* z2u?B^jS@}7iN+ITvL;GfXf1Hs?YLb|>bzds8XIsq9Lvfpo~D3hDaL{m4BrVLtrS%< zOo>C{44$KS{5|ZhG7=^2q&#bhW+kJdm08n4V_h8^+uQL~Rz5pGU~-b1em{m8q3O<_ z@P*z*Xti|0#(m7Sf1BZmWaz$0M{5f^HgCds!V*0Z;C3Lu$emHv=^Iqf_9N`Y2s43j zd$I2If!hbJDhLmQl|$C`ptDIx+=H$kAbefS#7)k8d zy{sxL8U{_L+FW%1z$bqM-9D+b@Ok?2&LhvHFn(ZiA zg1PRS3kn&A!JeL8t`6O1A{2TYV0>zdWPFz9Xdl+p75LOwu&vpLp1FyTHq_W@baWKk zmhWTh{06e^(7YPa06I3F-Q_&7gmjHbxNX8B}T# zBN4*f^h1o*d(i*>2>{m6TNwNIA)FQHkB(yh%&*X98V%sv3f`_o3qNX~?%u*5Ui%Bd zP>5QuH?P24G)5|wpmypMqM`-S{v~p?yYfX>Z9qFq5uOIb^RHvA`x=&aD@NxL)bv%1 zs`aqp2-fPos9YKuzq=%W+vTF(SHr-Fe|`yOBN040g00w#aQjdl-$IwS6@o-*Gh*wH z(M<>Ql6$++wcEk78WkHu&E3iSIV&;b(v1qBt+9!L;gNZOnP`MnGKQ_94J$PR7z-m> zUx4b(3&)B|Q9VCLm32V%#{8Hv(OM#t!6gBj>+88Q5kzbKP=P3=4uPdIh*j&+V&OkZ z)jx;!teICtE3_HMcK2Uc4g1j2fiZgxF*|_euHgy&tze$wVl2xdkxJ)1mC|T4jWV-X zb$b>K($4vxiWU+b59YfdCdNcR47>{QNn~OIQRGm(-$1C$qB(L_?oj|6DrYUL_(RjX zevOcJWKjuX_wUf&O<3h^XiJITuw(`fm*MZ z@fb)6GWY@F5!z*|fka6MI+sNZpFq9!B8;6x1kR$JRcO1r;5&A2oH}p5TiO8XtG%2_ zD;&wV& zRa%BW;X?Sjk;%ywD;V8vGJ)%rf0)!+t@h|0I;=VJ(q(f z=~M#Cw|&I`n6W2+dt^yZo;^#?#?A*v@ezPE_4W9wd|VuvUU_jqm$xBmw1A?w_J-dx_i+@Y_Eh=kWf$?A_k8H~_$n5kIHS_p^V;F4`I!R|fG3ld%BG(@11y zoZr9p2J2c{_|BKVh!FF~e9>F+wcEp->^slFUAtJ@wC0naS7ei+5Py9A7_AKreDA9- zEhzp(0D!BvZu5_GeKgnAv$uB#CGPoiEXZHsmNH8zPQQPFQ|HdHtGkOMhYv0KHdyju zG8c{U_L;McO-!(*V*?$nZB##a>BvkNZ7)X4q6IODWRm|5T<83yOPHp~%ZCrq+1|ET z`lkatwClsee0XhuA-|srw?S*Ai{kKQ%IenPa=Hm8vP{P_1n1HWPMg$JRk5?Xi+#O4 z3$EbL3{aR|D#ewXL)@L5A`*=<7o8)K&Qe-ZLREPg-pWcguU*UP8sBnLt_HK)@j7&Flsg^7eFb45_%)(;v;%;J|a_R^P{e?qS>c zT?EYLE0(0c{gY7Lw1~A%XO6vM(1M*0g_j5vZf>d)>o$n9o~P0**A{xgDa7FN(zoYh bnRpn^+OoPc@A;AgG?u~B)z4*}Q$iB}OZ!!; literal 0 HcmV?d00001 diff --git a/archiva-web/archiva-webapp/src/main/webapp/images/icons/arrow-left.png b/archiva-web/archiva-webapp/src/main/webapp/images/icons/arrow-left.png new file mode 100644 index 0000000000000000000000000000000000000000..9e37b41284490f8e1fe7c8fc49b6ccea00e6aad6 GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLlVJLn>}fId9IypuoZG&~xO!{mr%} zzgfEG0ZU>g$}8|IxW2fsYE|Bhs|T|hrlgBCxK*?D9Gd3X`LWN>LZ9{CywyxR3|CZH VZ7;lW1iF}k!PC{xWt~$(699IHQ7!-g literal 0 HcmV?d00001 diff --git a/archiva-web/archiva-webapp/src/main/webapp/images/icons/arrow-right.png b/archiva-web/archiva-webapp/src/main/webapp/images/icons/arrow-right.png new file mode 100644 index 0000000000000000000000000000000000000000..00a443dbe512f343ef3c515b977fc858f2e10c86 GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLlv;~`X`IF z7)1S;-tQ>zmorttSRjGzDoe{Me}U#1It#YU{NNNVdxLp?&A}IucMR5lyCaamaBnfI V`(|CnZ9wxFJYD@<);T3K0RYhHQ*HnN literal 0 HcmV?d00001 diff --git a/archiva-web/archiva-webapp/src/main/webapp/images/icons/box.png b/archiva-web/archiva-webapp/src/main/webapp/images/icons/box.png new file mode 100644 index 0000000000000000000000000000000000000000..4d62e48ec9db42cd212595fc26a5bf270e31117d GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLlqTPWy@0^|Jj~!;g{jE_GCMUd+*dXow{~MJ@UMWimJ<=3Ef<5n&vJO>>pS$ t=maVAI|r&hd+B-VtEI!vg!9S=7)o}tO_-;^9}TpC!PC{xWt~$(699>HK)@j7&Flsg^73?X45_#^rQcJCL4b#)z2m=qVab=`lFvmYpNmUxXz4%DF}bf}d|cDunVH>FGrOY- z+D{EEKZPcINzVS9ob?$uHn=&y~n$8D`1 z2l;<(sQc1T_xQ+>|Ns9p5DgT6vM@3*7&7R9bb$QCz*ci$MuCTpRKNR-^bncK1eb^v zqDfrti^MpzbSB1VUt0b}aql73M;xvKD|}WtK1fk5iV!?;_@hVR1O_f%UNKGv4?_+f zX(=fl4i6boi78XK>s@7pr?3jKN=S;#aFP{YATA>-vrJN4*4aRuZH4n{cJUaejf^UUYY#HgTdI?_`o#% z*+4@Yr3$?m{{R1f<9g(4pfb*qAirQB7YrDJ{VRlkfO-F_yT!0mqBbbp2xW7TuJ&zS0$bu?+ca%K2>T guKw7c^^-+{Vf|X37q@5M1bLUi)78&qol`;+0Ag8wng9R* literal 0 HcmV?d00001 diff --git a/archiva-web/archiva-webapp/src/main/webapp/images/icons/security-lock.png b/archiva-web/archiva-webapp/src/main/webapp/images/icons/security-lock.png new file mode 100644 index 0000000000000000000000000000000000000000..be4d4da0362732f356cc89da3479999cec666ab6 GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl9%d# zR;^lf<;s=Yw{Jgw{CLBL4XFB03@7@NkufZDj_Dnnsk0)|XR?%__ Q2U^46>FVdQ&MBb@02fMkQvd(} literal 0 HcmV?d00001 diff --git a/archiva-web/archiva-webapp/src/main/webapp/images/icons/user.png b/archiva-web/archiva-webapp/src/main/webapp/images/icons/user.png new file mode 100644 index 0000000000000000000000000000000000000000..7f4c6d7394380376b7a74dfd76a4afb41da2824f GIT binary patch literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl?_b&5v3m9Fef!>=T0eQ~)^}$%?0@v=|IaTw zwy%BvFVdQ&MBb@0FvOTNB{r; literal 0 HcmV?d00001