diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java index a8034a847..b6340af8f 100644 --- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java @@ -27,8 +27,8 @@ import org.codehaus.plexus.registry.RegistryListener; */ public interface ArchivaConfiguration { - public static final String ROLE = ArchivaConfiguration.class.getName(); - + String ROLE = ArchivaConfiguration.class.getName(); + /** * Get the configuration. * @@ -42,9 +42,11 @@ public interface ArchivaConfiguration * @param configuration the configuration to save * @throws org.codehaus.plexus.registry.RegistryException * if there is a problem saving the registry data + * @throws IndeterminateConfigurationException + * if the configuration cannot be saved because it was read from two sources */ void save( Configuration configuration ) - throws RegistryException; + throws RegistryException, IndeterminateConfigurationException; /** * Add a change listener so that registry changes are propogated. @@ -52,6 +54,5 @@ public interface ArchivaConfiguration * @param listener the listener */ void addChangeListener( RegistryListener listener ); - } diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationRuntimeException.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationRuntimeException.java new file mode 100644 index 000000000..5fc44f80d --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationRuntimeException.java @@ -0,0 +1,32 @@ +package org.apache.maven.archiva.configuration; + +/* + * 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. + */ + +/** + * Unrecoverable exception in the configuration mechanism that is the result of a programming error. + */ +public class ConfigurationRuntimeException + extends RuntimeException +{ + public ConfigurationRuntimeException( String msg, Throwable cause ) + { + super( msg, cause ); + } +} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationUpgrade.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationUpgrade.java deleted file mode 100644 index 8ae458516..000000000 --- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ConfigurationUpgrade.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.apache.maven.archiva.configuration; - -/* - * 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.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; -import org.apache.maven.archiva.xml.XMLException; -import org.apache.maven.archiva.xml.XMLReader; -import org.codehaus.plexus.logging.AbstractLogEnabled; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -/** - * A component that is first in the plexus startup that ensure that the configuration - * file format has been upgraded properly. - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.configuration.ConfigurationUpgrade" - */ -public class ConfigurationUpgrade - extends AbstractLogEnabled -{ - public static final int CURRENT_CONFIG_VERSION = 1; - - private boolean performed = false; - - /** - * Perform the upgrade (if needed). - * - * NOTE: This component should *NOT USE* the configuration api to do it's upgrade - */ - public void performUpgrade() - { - performed = true; - File userConfigFile = new File( System.getProperty( "user.home" ), ".m2/archiva.xml" ); - - if ( !userConfigFile.exists() ) - { - writeDefaultConfigFile( userConfigFile ); - return; - } - - boolean configOk = false; - try - { - XMLReader xml = new XMLReader( "configuration", userConfigFile ); - String configVersion = xml.getElementText( "//configuration/version" ); - if ( StringUtils.isNotBlank( configVersion ) ) - { - configOk = true; - - // Found an embedded configuration version. - int version = NumberUtils.toInt( configVersion, 0 ); - if ( version < CURRENT_CONFIG_VERSION ) - { - upgradeVersion( userConfigFile, xml ); - } - } - } - catch ( XMLException e ) - { - getLogger().warn( "Unable to read user configuration XML: " + e.getMessage(), e ); - return; - } - - if ( !configOk ) - { - try - { - FileUtils.copyFile( userConfigFile, new File( userConfigFile.getAbsolutePath() + ".bak" ) ); - writeDefaultConfigFile( userConfigFile ); - return; - } - catch ( IOException e ) - { - getLogger().warn( "Unable to create backup of your configuration file: " + e.getMessage(), e ); - } - } - - return; - } - - private void upgradeVersion( File userConfigFile, XMLReader xml ) - { - // TODO: write implementation when we have a current version greater than 1. - } - - private void writeDefaultConfigFile( File userConfigFile ) - { - URL defaultConfigURL = this.getClass() - .getResource( "/org/apache/maven/archiva/configuration/default-archiva.xml" ); - - if ( defaultConfigURL == null ) - { - try - { - FileWriter writer = new FileWriter( userConfigFile ); - writer.write( "\n" ); - writer.write( "" ); - writer.flush(); - writer.close(); - return; - } - catch ( IOException e ) - { - getLogger().warn( "Unable to write default (generic) configuration file: " + e.getMessage(), e ); - } - } - - // Write default to user config file location. - try - { - FileOutputStream output = new FileOutputStream( userConfigFile ); - InputStream input = defaultConfigURL.openStream(); - IOUtils.copy( input, output ); - output.flush(); - input.close(); - output.close(); - } - catch ( IOException e ) - { - getLogger().warn( "Unable to write default configuration file: " + e.getMessage(), e ); - } - } - - public boolean hasPerformed() - { - return this.performed; - } -} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java index 3472acdf7..6cf53bd0a 100644 --- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.configuration; * under the License. */ +import org.apache.commons.io.FileUtils; import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryReader; import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryWriter; import org.codehaus.plexus.logging.AbstractLogEnabled; @@ -30,10 +31,27 @@ import org.codehaus.plexus.registry.RegistryListener; import org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry; import org.codehaus.plexus.util.StringUtils; +import java.io.File; +import java.io.IOException; import java.util.Iterator; /** * Implementation of configuration holder that retrieves it from the registry. + *

+ * The registry layers and merges the 2 configuration files: user, and application server. + *

+ * Instead of relying on the model defaults, if the registry is empty a default configuration file is loaded and + * applied from a resource. The defaults are not loaded into the registry as the lists (eg repositories) could no longer + * be removed if that was the case. + *

+ * When saving the configuration, it is saved to the location it was read from. If it was read from the defaults, it + * will be saved to the user location. + * However, if the configuration contains information from both sources, an exception is raised as this is currently + * unsupported. The reason for this is that it is not possible to identify where to re-save elements, and can result + * in list configurations (eg repositories) becoming inconsistent. + *

+ * If the configuration is outdated, it will be upgraded when it is loaded. This is done by checking the version flag + * before reading it from the registry. * * @plexus.component role="org.apache.maven.archiva.configuration.ArchivaConfiguration" */ @@ -48,11 +66,6 @@ public class DefaultArchivaConfiguration */ private Registry registry; - /** - * @plexus.requirement - */ - private ConfigurationUpgrade upgrader; - /** * The configuration that has been converted. */ @@ -60,6 +73,16 @@ public class DefaultArchivaConfiguration private static final String KEY = "org.apache.maven.archiva"; + /** + * @plexus.configuration default-value="${user.home}/.m2/archiva.xml" + */ + private String userConfigFilename; + + public String getFilteredUserConfigFilename() + { + return StringUtils.replace( userConfigFilename, "${user.home}", System.getProperty( "user.home" + "" ) ); + } + public synchronized Configuration getConfiguration() { if ( configuration == null ) @@ -71,26 +94,19 @@ public class DefaultArchivaConfiguration private Configuration load() { - if ( !upgrader.hasPerformed() ) + // TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties) + Registry subset = registry.getSubset( KEY ); + if ( subset.getString( "version" ) == null ) { - upgrader.performUpgrade(); - - // HACK: This would be so much easier with a registry.reload() method. - if ( registry instanceof CommonsConfigurationRegistry ) + // a little autodetection of v1, even if version is omitted (this was previously allowed) + if ( subset.getSubset( "repositoryScanning" ).isEmpty() ) { - try - { - ( (CommonsConfigurationRegistry) registry ).initialize(); - } - catch ( InitializationException e ) - { - getLogger().error( "Unable to reinitialize the registry: " + e.getMessage(), e ); - } + // only for empty, or v < 1 + subset = readDefaultConfiguration(); } } - // TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties) - Configuration config = new ConfigurationRegistryReader().read( registry.getSubset( KEY ) ); + Configuration config = new ConfigurationRegistryReader().read( subset ); // TODO: for commons-configuration 1.3 only for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); ) @@ -98,24 +114,76 @@ public class DefaultArchivaConfiguration RepositoryConfiguration c = (RepositoryConfiguration) i.next(); c.setUrl( removeExpressions( c.getUrl() ) ); } - return config; } + private Registry readDefaultConfiguration() + { + // if it contains some old configuration, remove it (Archiva 0.9) + registry.removeSubset( KEY ); + + try + { + registry.addConfigurationFromResource( "org/apache/maven/archiva/configuration/default-archiva.xml", KEY ); + } + catch ( RegistryException e ) + { + throw new ConfigurationRuntimeException( + "Fatal error: Unable to find the built-in default configuration and load it into the registry", e ); + } + return registry.getSubset( KEY ); + } + public void save( Configuration configuration ) - throws RegistryException + throws RegistryException, IndeterminateConfigurationException { Registry section = registry.getSection( KEY + ".user" ); if ( section == null ) { section = registry.getSection( KEY + ".base" ); + if ( section == null ) + { + section = createDefaultConfigurationFile(); + } } + else if ( registry.getSection( KEY + ".base" ) != null ) + { + throw new IndeterminateConfigurationException( + "Configuration can not be saved when it is loaded from two sources" ); + } + new ConfigurationRegistryWriter().write( configuration, section ); section.save(); this.configuration = configuration; } + private Registry createDefaultConfigurationFile() + throws RegistryException + { + // TODO: may not be needed under commons-configuration 1.4 - check + File file = new File( getFilteredUserConfigFilename() ); + try + { + FileUtils.writeStringToFile( file, "", "UTF-8" ); + } + catch ( IOException e ) + { + throw new RegistryException( "Unable to create configuration file: " + e.getMessage(), e ); + } + + try + { + ( (CommonsConfigurationRegistry) registry ).initialize(); + } + catch ( InitializationException e ) + { + throw new RegistryException( "Unable to reinitialize configuration: " + e.getMessage(), e ); + } + + return registry.getSection( KEY + ".user" ); + } + public void addChangeListener( RegistryListener listener ) { Registry section = registry.getSection( KEY + ".user" ); @@ -148,10 +216,10 @@ public class DefaultArchivaConfiguration private String removeExpressions( String directory ) { - String value = StringUtils.replace( directory, "${appserver.base}", registry.getString( "appserver.base", - "${appserver.base}" ) ); - value = StringUtils.replace( value, "${appserver.home}", registry.getString( "appserver.home", - "${appserver.home}" ) ); + String value = StringUtils.replace( directory, "${appserver.base}", + registry.getString( "appserver.base", "${appserver.base}" ) ); + value = StringUtils.replace( value, "${appserver.home}", + registry.getString( "appserver.home", "${appserver.home}" ) ); return value; } diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/IndeterminateConfigurationException.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/IndeterminateConfigurationException.java new file mode 100644 index 000000000..97d5fbdf2 --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/IndeterminateConfigurationException.java @@ -0,0 +1,32 @@ +package org.apache.maven.archiva.configuration; + +/* + * 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. + */ + +/** + * Occurs when the configuration is stored in two locations and the save location can not be determined. + */ +public class IndeterminateConfigurationException + extends Exception +{ + public IndeterminateConfigurationException( String message ) + { + super( message ); + } +} diff --git a/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index 41f9ac895..c7c9f4d06 100644 --- a/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -33,75 +33,75 @@ Configuration 1.0.0+ - - - version - 1.0.0+ - String - true - This is the version of the configuration format. + + + version + 1.0.0+ + String + true + This is the version of the configuration format. repositories 1.0.0+ RepositoryConfiguration - * - + * + The list of repositories that this archiva instance uses. - - - proxyConnectors - 1.0.0+ - - ProxyConnectorConfiguration - * - - The list of proxy connectors for this archiva instance. - + + + proxyConnectors + 1.0.0+ + + ProxyConnectorConfiguration + * + + The list of proxy connectors for this archiva instance. + + + syncConnectors + 1.0.0+ + + SyncConnectorConfiguration + * + + The list of sync connectors for this archiva instance. + + --> networkProxies 1.0.0+ - NetworkProxyConfiguration + NetworkProxyConfiguration * - - The list of network proxies to use for outgoing requests. + + The list of network proxies to use for outgoing requests. - - - repositoryScanning - 1.0.0+ - - RepositoryScanningConfiguration - 1 - - - The repository scanning configuration. - - - databaseScanning - 1.0.0+ - - DatabaseScanningConfiguration - 1 - - - The database scanning configuration. - + + repositoryScanning + 1.0.0+ + + RepositoryScanningConfiguration + 1 + + + The repository scanning configuration. + + + + databaseScanning + 1.0.0+ + + DatabaseScanningConfiguration + 1 + + + The database scanning configuration. + webapp @@ -113,129 +113,129 @@ The webapp configuration. - - - - - 1.0.0+ - - + + + + + 1.0.0+ + + - - - - + + + + RepositoryConfiguration 1.0.0+ - - id - 1.0.0+ - String - true - - The repository identifier. - - - - name - 1.0.0+ - String - true - - The descriptive name of the repository. - - - - url - 1.0.0+ - String - true - - The URL for this repository. - - - - layout - 1.0.0+ - String - true - - The layout of the repository. Valid values are "default" and "legacy". - - - default - - - releases - 1.0.0+ - boolean - True if this repository contains release versioned artifacts. - true - + + id + 1.0.0+ + String + true + + The repository identifier. + + + + name + 1.0.0+ + String + true + + The descriptive name of the repository. + + + + url + 1.0.0+ + String + true + + The URL for this repository. + + + + layout + 1.0.0+ + String + true + + The layout of the repository. Valid values are "default" and "legacy". + + + default + + + releases + 1.0.0+ + boolean + True if this repository contains release versioned artifacts. + true + snapshots 1.0.0+ @@ -249,225 +249,225 @@ boolean True if this repository should be indexed. true - - - indexDir - 1.0.0+ - String - - The directory for the indexes of this repository. - - - - refreshCronExpression - 1.0.0+ - String - - When to run the refresh task. - Default is every hour - - 0 0 * * * ? - - - - - 1.0.0+ - - + + + indexDir + 1.0.0+ + String + + The directory for the indexes of this repository. + + + + refreshCronExpression + 1.0.0+ + String + + When to run the refresh task. + Default is every hour + + 0 0 * * * ? + + + + + 1.0.0+ + + - - - - - - AbstractRepositoryConnectorConfiguration - true - 1.0.0+ - - - sourceRepoId - 1.0.0+ - String - true - - The Repository Source for this connector. - - - - targetRepoId - 1.0.0+ - String - true - - The Repository Target for this connector. - - - - proxyId - 1.0.0+ - String - - The network proxy ID to use for this connector. - - - - blackListPatterns - 1.0.0+ - - String - * - - - The list of blacklisted patterns for this connector. - - - - whiteListPatterns - 1.0.0+ - - String - * - - - The list of whitelisted patterns for this connector. - - - - policies - 1.0.0+ - Map - Policy configuration for the connector. - - String - * - - - - properties - 1.0.0+ - Map - Configuration for the connector. - - String - * - - - - - - 1.0.0+ - - - - - + + + + + + AbstractRepositoryConnectorConfiguration + true + 1.0.0+ + + + sourceRepoId + 1.0.0+ + String + true + + The Repository Source for this connector. + + + + targetRepoId + 1.0.0+ + String + true + + The Repository Target for this connector. + + + + proxyId + 1.0.0+ + String + + The network proxy ID to use for this connector. + + + + blackListPatterns + 1.0.0+ + + String + * + + + The list of blacklisted patterns for this connector. + + + + whiteListPatterns + 1.0.0+ + + String + * + + + The list of whitelisted patterns for this connector. + + + + policies + 1.0.0+ + Map + Policy configuration for the connector. + + String + * + + + + properties + 1.0.0+ + Map + Configuration for the connector. + + String + * + + + + + + 1.0.0+ + + + + + AbstractRepositoryConnectorConfiguration ProxyConnectorConfiguration 1.0.0+ - - - - - 1.0.0+ - - - - - + + + + + 1.0.0+ + + + + + AbstractRepositoryConnectorConfiguration SyncConnectorConfiguration @@ -489,192 +489,193 @@ rsync - - - - + + + + NetworkProxyConfiguration 1.0.0+ - - - id - 1.0.0+ - String - - The ID for this proxy. - - - - protocol - 1.0.0+ - - The network protocol to use with this proxy: "http", "socks-4" - - String - true - http - - - host - 1.0.0+ - - The proxy host. - - String - true - - - port - 1.0.0+ - - The proxy port. - - int - 8080 - + + + id + 1.0.0+ + String + + The ID for this proxy. + + + + protocol + 1.0.0+ + + The network protocol to use with this proxy: "http", "socks-4" + + String + true + http + + + host + 1.0.0+ + + The proxy host. + + String + true + + + port + 1.0.0+ + + The proxy port. + + int + 8080 + username 1.0.0+ - - The proxy user. + + The proxy user. String password 1.0.0+ - - The proxy password. + + The proxy password. String - + - - - - - RepositoryScanningConfiguration - 1.0.0+ - - - fileTypes - 1.0.0+ - true - - FileType - * - - - The FileTypes for the repository scanning configuration. - - - - knownContentConsumers - 1.0.0+ - true - - String - * - - - The list of active consumers IDs for known content. - - - - invalidContentConsumers - 1.0.0+ - true - - String - * - - - The list of active consumer IDs for invalid content. - - - - - - FileType - 1.0.0+ - The FileType object - - - id - 1.0.0+ - true - String - - - patterns - 1.0.0+ - true - - String - * - - - - - - DatabaseScanningConfiguration - 1.0.0+ - - The scanning configuration for unprocessed ArchivaArtifact database objects. - - - - cronExpression - 1.0.0+ - String - When to run the database scanning mechanism. Default is every two hours on the hour. - 0 0 0/2 * * ? - - - unprocessedConsumers - 1.0.0+ - true - - String - * - - - The list of consumers for the unprocessed ArchivaArtifact database objects. - - - - cleanupConsumers - 1.0.0+ - true - - String - * - - - The list of consumers for previously processed ArchivaArtifact database - objects that no longer exist on the filesystem, and might need to - undergo a cleanup. - - - - - + + + + + RepositoryScanningConfiguration + 1.0.0+ + + + fileTypes + 1.0.0+ + true + + FileType + * + + + The FileTypes for the repository scanning configuration. + + + + knownContentConsumers + 1.0.0+ + true + + String + * + + + The list of active consumers IDs for known content. + + + + invalidContentConsumers + 1.0.0+ + true + + String + * + + + The list of active consumer IDs for invalid content. + + + + + + FileType + 1.0.0+ + The FileType object + + + id + 1.0.0+ + true + String + + + patterns + 1.0.0+ + true + + String + * + + + + + + DatabaseScanningConfiguration + 1.0.0+ + + The scanning configuration for unprocessed ArchivaArtifact database objects. + + + + cronExpression + 1.0.0+ + String + When to run the database scanning mechanism. Default is every two hours on the hour. + + 0 0 0/2 * * ? + + + unprocessedConsumers + 1.0.0+ + true + + String + * + + + The list of consumers for the unprocessed ArchivaArtifact database objects. + + + + cleanupConsumers + 1.0.0+ + true + + String + * + + + The list of consumers for previously processed ArchivaArtifact database + objects that no longer exist on the filesystem, and might need to + undergo a cleanup. + + + + + - + WebappConfiguration 1.0.0+ @@ -697,11 +698,11 @@ 1.0.0+ UserInterfaceOptions - + - + UserInterfaceOptions 1.0.0+ @@ -712,20 +713,20 @@ showFindArtifacts true if find artifacts should be enabled - 1.0.0+ - boolean + 1.0.0+ + boolean true appletFindEnabled true if applet behavior for find artifacts should be enabled - 1.0.0+ - boolean + 1.0.0+ + boolean true - + diff --git a/archiva-base/archiva-configuration/src/test/conf/with-proxied-repos.xml b/archiva-base/archiva-configuration/src/test/conf/archiva-0.9.xml similarity index 100% rename from archiva-base/archiva-configuration/src/test/conf/with-proxied-repos.xml rename to archiva-base/archiva-configuration/src/test/conf/archiva-0.9.xml diff --git a/archiva-base/archiva-configuration/src/test/conf/autodetect-v1.xml b/archiva-base/archiva-configuration/src/test/conf/autodetect-v1.xml new file mode 100644 index 000000000..5f35f5d37 --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/conf/autodetect-v1.xml @@ -0,0 +1,189 @@ + + + + + + + internal + Archiva Managed Internal Repository + file://${appserver.base}/repositories/internal + default + true + false + true + 0 0 * * ? + + + snapshots + Archiva Managed Snapshot Repository + file://${appserver.base}/repositories/internal + default + false + true + true + 0 0,30 * * ? + + + central + Central Repository + http://repo1.maven.org/maven2 + default + true + false + false + + + maven2-repository.dev.java.net + Java.net Repository for Maven 2 + https://maven2-repository.dev.java.net/nonav/repository + default + true + false + false + + + + + + internal + central + + disabled + never + not-found + + + internal + maven2-repository.dev.java.net + + disabled + never + not-found + + javax/** + + + + + + + example + http + proxy.mycompany.com + 8080 + myself + mypass + + + + + + + artifacts + + **/*.pom + **/*.jar + **/*.ear + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + **/*.dtd + **/*.tld + **/*.tar.gz + **/*.tar.bz2 + **/*.zip + + + + indexable-content + + **/*.txt + **/*.TXT + **/*.block + **/*.config + **/*.pom + **/*.xml + **/*.xsd + **/*.dtd + **/*.tld + + + + auto-remove + + **/*.bak + **/*~ + **/*- + + + + ignored + + **/.htaccess + **/KEYS + **/*.rb + **/*.sh + **/.svn/** + **/.DAV/** + + + + + update-db-artifact + create-missing-checksums + update-db-repository-metadata + validate-checksum + validate-signature + index-content + auto-remove + auto-rename + + + update-db-bad-content + + + + + 0 0 * * ? + + index-artifact + update-db-project + validate-repository-metadata + index-archive-toc + update-db-bytecode-stats + index-public-methods + + + not-present-remove-db-artifact + not-present-remove-db-project + not-present-remove-indexed + + + + + + true + true + + + + diff --git a/archiva-base/archiva-configuration/src/test/conf/conf-base.xml b/archiva-base/archiva-configuration/src/test/conf/conf-base.xml new file mode 100644 index 000000000..c3dba42b8 --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/conf/conf-base.xml @@ -0,0 +1,69 @@ + + + + + 1 + + + internal + Archiva Managed Internal Repository + file://${appserver.base}/repositories/internal + default + true + false + true + 0 0 * * ? + + + snapshots + Archiva Managed Snapshot Repository + file://${appserver.base}/repositories/internal + default + false + true + true + 0 0,30 * * ? + + + central + Central Repository + http://repo1.maven.org/maven2 + default + true + false + false + + + maven2-repository.dev.java.net + Java.net Repository for Maven 2 + https://maven2-repository.dev.java.net/nonav/repository + default + true + false + false + + + + + + false + + + diff --git a/archiva-base/archiva-configuration/src/test/conf/conf-user.xml b/archiva-base/archiva-configuration/src/test/conf/conf-user.xml new file mode 100644 index 000000000..bceb96d8e --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/conf/conf-user.xml @@ -0,0 +1,49 @@ + + + + 1 + + + internal + central + + disabled + never + not-found + + + internal + maven2-repository.dev.java.net + + disabled + never + not-found + + javax/** + + + + + + + false + + + diff --git a/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml b/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml index 5f35f5d37..01eacf5af 100644 --- a/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml +++ b/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml @@ -19,6 +19,7 @@ --> + 1 internal diff --git a/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java b/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java index 21aaf1b59..6145832bc 100644 --- a/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java @@ -19,8 +19,8 @@ package org.apache.maven.archiva.configuration; * under the License. */ -import org.apache.commons.io.FileUtils; import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.util.FileUtils; import java.io.File; import java.util.List; @@ -33,32 +33,55 @@ import java.util.List; public class ArchivaConfigurationTest extends PlexusTestCase { - public void testDefaults() - throws Exception - { - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-defaults" ); - - Configuration configuration = archivaConfiguration.getConfiguration(); - - // check default configuration - assertNotNull( "check configuration returned", configuration ); - assertTrue( "check configuration has default elements", configuration.getRepositories().isEmpty() ); - } - - public void testGetConfiguration() + public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource() throws Exception { ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); - FileTypes filetypes = (FileTypes) lookup( FileTypes.class.getName() ); + Configuration configuration = archivaConfiguration.getConfiguration(); + assertConfiguration( configuration ); + assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); + + RepositoryConfiguration repository = + (RepositoryConfiguration) configuration.getRepositories().iterator().next(); + + assertEquals( "check managed repositories", "file://${appserver.base}/repositories/internal", + repository.getUrl() ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); + assertEquals( "check managed repositories", "internal", repository.getId() ); + assertEquals( "check managed repositories", "default", repository.getLayout() ); + assertTrue( "check managed repositories", repository.isIndexed() ); + } + + public void testGetConfigurationFromDefaults() + throws Exception + { + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-defaults" ); Configuration configuration = archivaConfiguration.getConfiguration(); + assertConfiguration( configuration ); + assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); + + RepositoryConfiguration repository = + (RepositoryConfiguration) configuration.getRepositories().iterator().next(); + + assertEquals( "check managed repositories", "file://${appserver.base}/data/repositories/internal", + repository.getUrl() ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); + assertEquals( "check managed repositories", "internal", repository.getId() ); + assertEquals( "check managed repositories", "default", repository.getLayout() ); + assertTrue( "check managed repositories", repository.isIndexed() ); + } + + private void assertConfiguration( Configuration configuration ) + throws Exception + { + FileTypes filetypes = (FileTypes) lookup( FileTypes.class.getName() ); assertEquals( "check repositories", 4, configuration.getRepositories().size() ); assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() ); - assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning(); assertNotNull( "check repository scanning", repoScanning ); @@ -75,37 +98,57 @@ public class ArchivaConfigurationTest assertEquals( "check unprocessed consumers", 6, dbScanning.getUnprocessedConsumers().size() ); assertEquals( "check cleanup consumers", 3, dbScanning.getCleanupConsumers().size() ); - RepositoryConfiguration repository = - (RepositoryConfiguration) configuration.getRepositories().iterator().next(); - - assertEquals( "check managed repositories", "file://${appserver.base}/repositories/internal", - repository.getUrl() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isIndexed() ); - - WebappConfiguration webapp = (WebappConfiguration) configuration.getWebapp(); + WebappConfiguration webapp = configuration.getWebapp(); assertNotNull( "check webapp", webapp ); - UserInterfaceOptions ui = (UserInterfaceOptions) webapp.getUi(); + UserInterfaceOptions ui = webapp.getUi(); assertNotNull( "check webapp ui", ui ); assertTrue( "check showFindArtifacts", ui.isShowFindArtifacts() ); assertTrue( "check appletFindEnabled", ui.isAppletFindEnabled() ); } + public void testGetConfigurationFromRegistryWithTwoConfigurationResources() + throws Exception + { + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration-both" ); + + Configuration configuration = archivaConfiguration.getConfiguration(); + + // from base + assertEquals( "check repositories", 4, configuration.getRepositories().size() ); + // from user + assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() ); + + WebappConfiguration webapp = configuration.getWebapp(); + assertNotNull( "check webapp", webapp ); + + UserInterfaceOptions ui = webapp.getUi(); + assertNotNull( "check webapp ui", ui ); + // from base + assertFalse( "check showFindArtifacts", ui.isShowFindArtifacts() ); + // from user + assertFalse( "check appletFindEnabled", ui.isAppletFindEnabled() ); + } + public void testGetConfigurationSystemOverride() throws Exception { ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); - System.setProperty( "org.apache.maven.archiva.localRepository", "system-repository" ); + System.setProperty( "org.apache.maven.archiva.webapp.ui.appletFindEnabled", "false" ); - Configuration configuration = archivaConfiguration.getConfiguration(); + try + { + Configuration configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check localRepository", "system-repository", configuration.getLocalRepository() ); - // assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); + assertFalse( "check boolean", configuration.getWebapp().getUi().isAppletFindEnabled() ); + } + finally + { + System.getProperties().remove( "org.apache.maven.archiva.webapp.ui.appletFindEnabled" ); + } } public void testStoreConfiguration() @@ -117,13 +160,16 @@ public class ArchivaConfigurationTest // TODO: remove with commons-configuration 1.4 file.getParentFile().mkdirs(); - org.codehaus.plexus.util.FileUtils.fileWrite( file.getAbsolutePath(), "" ); + FileUtils.fileWrite( file.getAbsolutePath(), "" ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save" ); Configuration configuration = new Configuration(); - // configuration.setIndexPath( "index-path" ); + configuration.setVersion( "1" ); + configuration.setWebapp( new WebappConfiguration() ); + configuration.getWebapp().setUi( new UserInterfaceOptions() ); + configuration.getWebapp().getUi().setAppletFindEnabled( false ); archivaConfiguration.save( configuration ); @@ -131,12 +177,12 @@ public class ArchivaConfigurationTest // check it configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check value", "index-path", configuration.getIndexPath() ); + assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); // read it back archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-saved" ); configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check value", "index-path", configuration.getIndexPath() ); + assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); } public void testStoreConfigurationUser() @@ -150,15 +196,16 @@ public class ArchivaConfigurationTest userFile.delete(); assertFalse( userFile.exists() ); - // TODO: remove with commons-configuration 1.4 userFile.getParentFile().mkdirs(); - org.codehaus.plexus.util.FileUtils.fileWrite( userFile.getAbsolutePath(), "" ); + FileUtils.fileWrite( userFile.getAbsolutePath(), "" ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); Configuration configuration = new Configuration(); - // configuration.setIndexPath( "index-path" ); + configuration.setWebapp( new WebappConfiguration() ); + configuration.getWebapp().setUi( new UserInterfaceOptions() ); + configuration.getWebapp().getUi().setAppletFindEnabled( false ); archivaConfiguration.save( configuration ); @@ -167,7 +214,46 @@ public class ArchivaConfigurationTest // check it configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check value", "index-path", configuration.getIndexPath() ); + assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + } + + public void testStoreConfigurationLoadedFromDefaults() + throws Exception + { + File baseFile = getTestFile( "target/test/test-file.xml" ); + baseFile.delete(); + assertFalse( baseFile.exists() ); + + File userFile = getTestFile( "target/test/test-file-user.xml" ); + userFile.delete(); + assertFalse( userFile.exists() ); + + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); + + Configuration configuration = new Configuration(); + configuration.setWebapp( new WebappConfiguration() ); + configuration.getWebapp().setUi( new UserInterfaceOptions() ); + configuration.getWebapp().getUi().setAppletFindEnabled( false ); + + archivaConfiguration.save( configuration ); + + assertTrue( "Check file exists", userFile.exists() ); + assertFalse( "Check file not created", baseFile.exists() ); + + // check it + configuration = archivaConfiguration.getConfiguration(); + assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + } + + public void testDefaultUserConfigFilename() + throws Exception + { + DefaultArchivaConfiguration archivaConfiguration = + (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() ); + + assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml", + archivaConfiguration.getFilteredUserConfigFilename() ); } public void testStoreConfigurationFallback() @@ -181,15 +267,16 @@ public class ArchivaConfigurationTest userFile.delete(); assertFalse( userFile.exists() ); - // TODO: remove with commons-configuration 1.4 baseFile.getParentFile().mkdirs(); - org.codehaus.plexus.util.FileUtils.fileWrite( baseFile.getAbsolutePath(), "" ); + FileUtils.fileWrite( baseFile.getAbsolutePath(), "" ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); Configuration configuration = new Configuration(); - // configuration.setIndexPath( "index-path" ); + configuration.setWebapp( new WebappConfiguration() ); + configuration.getWebapp().setUi( new UserInterfaceOptions() ); + configuration.getWebapp().getUi().setAppletFindEnabled( false ); archivaConfiguration.save( configuration ); @@ -198,36 +285,85 @@ public class ArchivaConfigurationTest // check it configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check value", "index-path", configuration.getIndexPath() ); + assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); } - public void testRemoveProxiedRepositoryAndStoreConfiguration() + public void testStoreConfigurationFailsWhenReadFromBothLocations() throws Exception { - // MRM-300 + File baseFile = getTestFile( "target/test/test-file.xml" ); + baseFile.delete(); + assertFalse( baseFile.exists() ); - File src = getTestFile( "src/test/conf/with-proxied-repos.xml" ); - File dest = getTestFile( "target/test/with-proxied-repos.xml" ); - FileUtils.copyFile( src, dest ); + File userFile = getTestFile( "target/test/test-file-user.xml" ); + userFile.delete(); + assertFalse( userFile.exists() ); + + baseFile.getParentFile().mkdirs(); + FileUtils.fileWrite( baseFile.getAbsolutePath(), "" ); + + userFile.getParentFile().mkdirs(); + FileUtils.fileWrite( userFile.getAbsolutePath(), "" ); ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-remove-proxied-repo" ); + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); + + Configuration configuration = new Configuration(); + configuration.setWebapp( new WebappConfiguration() ); + configuration.getWebapp().setUi( new UserInterfaceOptions() ); + configuration.getWebapp().getUi().setAppletFindEnabled( false ); + + try + { + archivaConfiguration.save( configuration ); + fail( "Configuration saving should not succeed if it was loaded from two locations" ); + } + catch ( IndeterminateConfigurationException e ) + { + assertTrue( true ); + } + } + + public void testConfigurationUpgradeFrom09() + throws Exception + { + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-upgrade-09" ); + + // we just use the defaults when upgrading from 0.9 at this point. + Configuration configuration = archivaConfiguration.getConfiguration(); + assertConfiguration( configuration ); + assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); + + RepositoryConfiguration repository = + (RepositoryConfiguration) configuration.getRepositories().iterator().next(); + + assertEquals( "check managed repositories", "file://${appserver.base}/data/repositories/internal", + repository.getUrl() ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); + assertEquals( "check managed repositories", "internal", repository.getId() ); + assertEquals( "check managed repositories", "default", repository.getLayout() ); + assertTrue( "check managed repositories", repository.isIndexed() ); + } + + public void testAutoDetectV1() + throws Exception + { + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-autodetect-v1" ); Configuration configuration = archivaConfiguration.getConfiguration(); - // configuration.getProxiedRepositories().remove( 0 ); + assertConfiguration( configuration ); + assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); - archivaConfiguration.save( configuration ); + RepositoryConfiguration repository = + (RepositoryConfiguration) configuration.getRepositories().iterator().next(); - // check it - configuration = archivaConfiguration.getConfiguration(); - // assertEquals( 1, configuration.getProxiedRepositories().size() ); - - release( archivaConfiguration ); - - // read it back - archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-back-remove-proxied-repo" ); - configuration = archivaConfiguration.getConfiguration(); - // assertEquals( 1, configuration.getProxiedRepositories().size() ); + assertEquals( "check managed repositories", "file://${appserver.base}/repositories/internal", + repository.getUrl() ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); + assertEquals( "check managed repositories", "internal", repository.getId() ); + assertEquals( "check managed repositories", "default", repository.getLayout() ); + assertTrue( "check managed repositories", repository.isIndexed() ); } } diff --git a/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml b/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml index bf757a0d1..9cab0b17f 100644 --- a/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml +++ b/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml @@ -29,13 +29,8 @@ org.codehaus.plexus.registry.Registry empty - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - - org.codehaus.plexus.registry.Registry empty @@ -44,6 +39,29 @@ + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-upgrade-09 + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + upgrade-09 + + + + + org.codehaus.plexus.registry.Registry + upgrade-09 + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration test-configuration @@ -53,10 +71,6 @@ org.codehaus.plexus.registry.Registry configured - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - @@ -72,6 +86,30 @@ + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-autodetect-v1 + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + autodetect-v1 + + + + + org.codehaus.plexus.registry.Registry + autodetect-v1 + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration test-save @@ -81,10 +119,6 @@ org.codehaus.plexus.registry.Registry save - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - @@ -108,11 +142,10 @@ org.codehaus.plexus.registry.Registry save-user - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - + + ${basedir}/target/test/test-file-user.xml + org.codehaus.plexus.registry.Registry @@ -128,6 +161,31 @@ + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-configuration-both + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + configuration-both + + + + + org.codehaus.plexus.registry.Registry + configuration-both + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration test-read-saved @@ -137,11 +195,10 @@ org.codehaus.plexus.registry.Registry read-saved - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - + + ${basedir}/target/test/test-file.xml + org.codehaus.plexus.registry.Registry @@ -154,58 +211,5 @@ - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-remove-proxied-repo - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - read-remove-proxied-repo - - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - - - - - org.codehaus.plexus.registry.Registry - read-remove-proxied-repo - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-read-back-remove-proxied-repo - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - read-back-remove-proxied-repo - - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - - - - - org.codehaus.plexus.registry.Registry - read-back-remove-proxied-repo - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - diff --git a/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumerUtilTest.xml b/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumerUtilTest.xml index 013e5767e..98b210894 100644 --- a/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumerUtilTest.xml +++ b/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumerUtilTest.xml @@ -28,10 +28,6 @@ org.codehaus.plexus.registry.Registry configured - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - diff --git a/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml b/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml index 6a3a0be16..07ff811a5 100644 --- a/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml +++ b/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml @@ -10,10 +10,6 @@ org.codehaus.plexus.registry.Registry configured - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - diff --git a/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml b/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml index 6a3a0be16..07ff811a5 100644 --- a/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml +++ b/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml @@ -10,10 +10,6 @@ org.codehaus.plexus.registry.Registry configured - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - diff --git a/archiva-reporting/archiva-artifact-reports/src/test/resources/META-INF/plexus/components.xml b/archiva-reporting/archiva-artifact-reports/src/test/resources/META-INF/plexus/components.xml index d9d54741b..a8dbacca4 100644 --- a/archiva-reporting/archiva-artifact-reports/src/test/resources/META-INF/plexus/components.xml +++ b/archiva-reporting/archiva-artifact-reports/src/test/resources/META-INF/plexus/components.xml @@ -21,15 +21,15 @@ commons-configuration - + + config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/> + config-at="org.apache.maven.archiva"/> - + config-name="org.apache.maven.archiva.user" config-at="org.apache.maven.archiva"/> + @@ -39,8 +39,8 @@ org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager - - + + plexus @@ -70,6 +70,6 @@ - + diff --git a/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml b/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml index 0692ad70f..c5e313fde 100644 --- a/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml +++ b/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml @@ -42,13 +42,9 @@ org.codehaus.plexus.registry.Registry configured - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - - + org.codehaus.plexus.registry.Registry configured @@ -61,20 +57,20 @@ - + org.apache.maven.archiva.consumers.DatabaseCleanupConsumer test-db-cleanup org.apache.maven.archiva.scheduled.TestDatabaseCleanupConsumer - + org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer test-db-unprocessed org.apache.maven.archiva.scheduled.TestDatabaseUnprocessedConsumer - - + + org.codehaus.plexus.jdo.JdoFactory archiva @@ -89,6 +85,6 @@ - + diff --git a/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml b/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml index 66141d375..aa04d5931 100644 --- a/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml +++ b/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml @@ -23,7 +23,8 @@ org.codehaus.plexus.taskqueue.execution.TaskExecutor test-repository-scanning - org.apache.maven.archiva.scheduled.executors.ArchivaRepositoryScanningTaskExecutor + org.apache.maven.archiva.scheduled.executors.ArchivaRepositoryScanningTaskExecutor + @@ -51,13 +52,9 @@ org.codehaus.plexus.registry.Registry configured - - org.apache.maven.archiva.configuration.ConfigurationUpgrade - upgrader - - + org.codehaus.plexus.registry.Registry configured @@ -70,7 +67,7 @@ - + org.codehaus.plexus.jdo.JdoFactory archiva @@ -85,6 +82,6 @@ - + diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java index 3aaff4fad..0ddc91be7 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java @@ -22,9 +22,9 @@ package org.apache.maven.archiva.web.action.admin; import com.opensymphony.xwork.ModelDriven; import com.opensymphony.xwork.Preparable; import com.opensymphony.xwork.Validateable; - import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.InvalidConfigurationException; import org.apache.maven.archiva.indexer.RepositoryIndexException; import org.apache.maven.archiva.indexer.RepositoryIndexSearchException; @@ -34,7 +34,6 @@ import org.codehaus.plexus.redback.xwork.interceptor.SecureAction; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.plexus.scheduler.CronExpressionValidator; import org.codehaus.plexus.xwork.action.PlexusActionSupport; import java.io.IOException; @@ -57,7 +56,7 @@ public class ConfigureAction * The configuration. */ private Configuration configuration; - + public void validate() { getLogger().info( "validate()" ); @@ -72,10 +71,17 @@ public class ConfigureAction // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded // TODO: if this is changed, do we move the index or recreate it? - archivaConfiguration.save( configuration ); + try + { + archivaConfiguration.save( configuration ); - // TODO: if the repository has changed, we need to check if indexing is needed! - addActionMessage( "Successfully saved configuration" ); + // TODO: if the repository has changed, we need to check if indexing is needed! + addActionMessage( "Successfully saved configuration" ); + } + catch ( IndeterminateConfigurationException e ) + { + addActionError( 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 index da8de754e..0b401d268 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ConfigureProxyConnectorAction.java @@ -20,7 +20,6 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy; */ import com.opensymphony.xwork.Preparable; - import org.apache.commons.collections.Closure; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.functors.IfClosure; @@ -28,9 +27,9 @@ 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.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; -import org.apache.maven.archiva.configuration.functors.NetworkProxySelectionPredicate; import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate; import org.apache.maven.archiva.configuration.functors.RemoteRepositoryPredicate; import org.apache.maven.archiva.configuration.functors.RepositoryIdListClosure; @@ -53,11 +52,10 @@ import java.util.Map; import java.util.Map.Entry; /** - * ConfigureProxyConnectorAction + * ConfigureProxyConnectorAction * * @author Joakim Erdfelt * @version $Id$ - * * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureProxyConnectorAction" */ public class ConfigureProxyConnectorAction @@ -101,7 +99,7 @@ public class ConfigureProxyConnectorAction private String pattern; /** - * The list of possible proxy ids. + * The list of possible proxy ids. */ private List proxyIdOptions = new ArrayList(); @@ -154,13 +152,15 @@ public class ConfigureProxyConnectorAction return SUCCESS; } - ProxyConnectorSelectionPredicate proxyConnectorSelection = new ProxyConnectorSelectionPredicate( source, target ); - ProxyConnectorConfiguration proxyConnectorConfiguration = (ProxyConnectorConfiguration) CollectionUtils.find( config - .getProxyConnectors(), proxyConnectorSelection ); + ProxyConnectorSelectionPredicate proxyConnectorSelection = + new ProxyConnectorSelectionPredicate( source, target ); + ProxyConnectorConfiguration proxyConnectorConfiguration = + (ProxyConnectorConfiguration) CollectionUtils.find( config + .getProxyConnectors(), proxyConnectorSelection ); if ( proxyConnectorConfiguration == null ) { - addActionError( "Unable to remove proxy connector, proxy connector with source [" + source + "] and target [" - + target + "] not found." ); + addActionError( "Unable to remove proxy connector, proxy connector with source [" + source + + "] and target [" + target + "] not found." ); return SUCCESS; } @@ -418,8 +418,8 @@ public class ConfigureProxyConnectorAction RepositoryIdListClosure remoteRepoIdList = new RepositoryIdListClosure( new ArrayList() ); RepositoryIdListClosure localRepoIdList = new RepositoryIdListClosure( new ArrayList() ); - Closure repoIfClosure = IfClosure.getInstance( RemoteRepositoryPredicate.getInstance(), remoteRepoIdList, - localRepoIdList ); + Closure repoIfClosure = + IfClosure.getInstance( RemoteRepositoryPredicate.getInstance(), remoteRepoIdList, localRepoIdList ); CollectionUtils.forAllDo( config.getRepositories(), repoIfClosure ); @@ -447,8 +447,8 @@ public class ConfigureProxyConnectorAction { if ( findProxyConnector( sourceId, targetId ) != null ) { - addActionError( "Unable to add new proxy connector with source [" + sourceId + "] and target [" - + targetId + "] as previously declared proxy connector, go edit that one instead." ); + addActionError( "Unable to add new proxy connector with source [" + sourceId + "] and target [" + + targetId + "] as previously declared proxy connector, go edit that one instead." ); return INPUT; } } @@ -559,8 +559,8 @@ public class ConfigureProxyConnectorAction if ( !options.contains( value ) ) { - addActionError( "Value of [" + value + "] is invalid for policy [" + policyId + "], valid values: " - + options ); + addActionError( + "Value of [" + value + "] is invalid for policy [" + policyId + "], valid values: " + options ); continue; } } @@ -586,6 +586,10 @@ public class ConfigureProxyConnectorAction { addActionError( "Unable to save configuration: " + e.getMessage() ); } + catch ( IndeterminateConfigurationException e ) + { + addActionError( e.getMessage() ); + } return SUCCESS; } 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 index 3b276d7f4..f41da372b 100644 --- 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 @@ -20,11 +20,11 @@ package org.apache.maven.archiva.web.action.admin.database; */ import com.opensymphony.xwork.Preparable; - import org.apache.commons.collections.CollectionUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; +import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.database.updater.DatabaseConsumers; import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.admin.scanning.AdminRepositoryConsumerComparator; @@ -32,17 +32,17 @@ import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.plexus.redback.xwork.interceptor.SecureAction; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; +import org.codehaus.plexus.registry.RegistryException; import org.codehaus.plexus.xwork.action.PlexusActionSupport; import java.util.Collections; import java.util.List; /** - * DatabaseAction + * DatabaseAction * * @author Joakim Erdfelt * @version $Id$ - * * @plexus.component role="com.opensymphony.xwork.Action" role-hint="databaseAction" */ public class DatabaseAction @@ -65,17 +65,17 @@ public class DatabaseAction * List of available {@link AdminDatabaseConsumer} objects for unprocessed artifacts. */ private List unprocessedConsumers; - + /** * List of enabled {@link AdminDatabaseConsumer} objects for unprocessed artifacts. */ private List enabledUnprocessedConsumers; - + /** * List of {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts. */ private List cleanupConsumers; - + /** * List of enabled {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts. */ @@ -90,7 +90,7 @@ public class DatabaseAction this.cron = dbscanning.getCronExpression(); AddAdminDatabaseConsumerClosure addAdminDbConsumer; - + addAdminDbConsumer = new AddAdminDatabaseConsumerClosure( dbscanning.getUnprocessedConsumers() ); CollectionUtils.forAllDo( databaseConsumers.getAvailableUnprocessedConsumers(), addAdminDbConsumer ); this.unprocessedConsumers = addAdminDbConsumer.getList(); @@ -104,25 +104,26 @@ public class DatabaseAction public String updateUnprocessedConsumers() { - archivaConfiguration.getConfiguration().getDatabaseScanning().setUnprocessedConsumers( enabledUnprocessedConsumers ); - + archivaConfiguration.getConfiguration().getDatabaseScanning().setUnprocessedConsumers( + enabledUnprocessedConsumers ); + return saveConfiguration(); } - + public String updateCleanupConsumers() { archivaConfiguration.getConfiguration().getDatabaseScanning().setCleanupConsumers( enabledCleanupConsumers ); - + return saveConfiguration(); } - + public String updateSchedule() { archivaConfiguration.getConfiguration().getDatabaseScanning().setCronExpression( cron ); - + return saveConfiguration(); } - + private String saveConfiguration() { try @@ -130,15 +131,21 @@ public class DatabaseAction archivaConfiguration.save( archivaConfiguration.getConfiguration() ); addActionMessage( "Successfully saved configuration" ); } - catch ( Exception e) + catch ( RegistryException e ) { + getLogger().error( e.getMessage(), e ); addActionError( "Error in saving configuration" ); return INPUT; } - + catch ( IndeterminateConfigurationException e ) + { + addActionError( e.getMessage() ); + return INPUT; + } + return SUCCESS; } - + public SecureActionBundle getSecureActionBundle() throws SecureActionException { diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java index aea9b4f94..ae3f5ff49 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java @@ -20,12 +20,12 @@ package org.apache.maven.archiva.web.action.admin.networkproxies; */ import com.opensymphony.xwork.Preparable; - import org.apache.commons.collections.CollectionUtils; 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.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; import org.apache.maven.archiva.configuration.functors.NetworkProxySelectionPredicate; import org.apache.maven.archiva.security.ArchivaRoleConstants; @@ -37,11 +37,10 @@ import org.codehaus.plexus.registry.RegistryException; import org.codehaus.plexus.xwork.action.PlexusActionSupport; /** - * ConfigureNetworkProxyAction + * ConfigureNetworkProxyAction * * @author Joakim Erdfelt * @version $Id$ - * * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureNetworkProxyAction" */ public class ConfigureNetworkProxyAction @@ -218,6 +217,10 @@ public class ConfigureNetworkProxyAction { addActionError( "Unable to save configuration: " + e.getMessage() ); } + catch ( IndeterminateConfigurationException e ) + { + addActionError( e.getMessage() ); + } return SUCCESS; } 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 index 621d0e5ad..d7259547e 100644 --- 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 @@ -21,12 +21,12 @@ package org.apache.maven.archiva.web.action.admin.repositories; 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.Configuration; +import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.InvalidConfigurationException; import org.apache.maven.archiva.configuration.RepositoryConfiguration; import org.apache.maven.archiva.security.ArchivaRoleConstants; @@ -94,7 +94,8 @@ public class ConfigureRepositoryAction if ( operationAllowed( ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, getRepoid() ) ) { - addActionError( "You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); + addActionError( + "You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); return ERROR; } @@ -107,7 +108,8 @@ public class ConfigureRepositoryAction if ( operationAllowed( ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, getRepoid() ) ) { - addActionError( "You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); + addActionError( + "You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); return ERROR; } @@ -218,13 +220,13 @@ public class ConfigureRepositoryAction getLogger().info( ".save(" + mode + ":" + repoId + ")" ); - containsError = validateFields(mode); + containsError = validateFields( mode ); if ( containsError && StringUtils.equalsIgnoreCase( "add", mode ) ) - { + { return INPUT; } - else if ( containsError && StringUtils.equalsIgnoreCase( "edit", mode )) + else if ( containsError && StringUtils.equalsIgnoreCase( "edit", mode ) ) { return ERROR; } @@ -259,7 +261,7 @@ public class ConfigureRepositoryAction return SUCCESS; } - private boolean validateFields(String mode) + private boolean validateFields( String mode ) { boolean containsError = false; CronExpressionValidator validator = new CronExpressionValidator(); @@ -267,20 +269,21 @@ public class ConfigureRepositoryAction String repoId = getRepository().getId(); if ( StringUtils.isBlank( repoId ) ) - { + { addFieldError( "repository.id", "You must enter a repository identifier." ); containsError = true; } //if edit mode, do not validate existence of repoId - else if ( config.findRepositoryById( repoId ) != null && !StringUtils.equalsIgnoreCase( mode, "edit" ) ) + else if ( config.findRepositoryById( repoId ) != null && !StringUtils.equalsIgnoreCase( mode, "edit" ) ) { - addFieldError( "repository.id", "Unable to add new repository with id [" + repoId + "], that id already exists." ); + addFieldError( "repository.id", + "Unable to add new repository with id [" + repoId + "], that id already exists." ); containsError = true; } if ( StringUtils.isBlank( repository.getUrl() ) ) - { - + { + addFieldError( "repository.url", "You must enter a directory or url." ); containsError = true; } @@ -324,7 +327,7 @@ public class ConfigureRepositoryAction { repository.setUrl( PathUtil.toUrl( rawUrlEntry ) ); } - + if ( repository.isManaged() ) { // Normalize the path @@ -360,9 +363,8 @@ public class ConfigureRepositoryAction } catch ( AuthorizationException e ) { - getLogger().info( - "Unable to authorize permission: " + permission + " against repo: " + repoid - + " due to: " + e.getMessage() ); + getLogger().info( "Unable to authorize permission: " + permission + " against repo: " + repoid + + " due to: " + e.getMessage() ); return false; } } @@ -402,9 +404,15 @@ public class ConfigureRepositoryAction { getLogger().info( ".saveConfiguration()" ); - archivaConfiguration.save( archivaConfiguration.getConfiguration() ); - - addActionMessage( "Successfully saved configuration" ); + try + { + archivaConfiguration.save( archivaConfiguration.getConfiguration() ); + addActionMessage( "Successfully saved configuration" ); + } + catch ( IndeterminateConfigurationException e ) + { + addActionError( e.getMessage() ); + } return SUCCESS; } 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 index df08dbcf7..e780d2b31 100644 --- 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 @@ -21,12 +21,12 @@ package org.apache.maven.archiva.web.action.admin.scanning; import com.opensymphony.xwork.Preparable; import com.opensymphony.xwork.Validateable; - import org.apache.commons.collections.CollectionUtils; 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.FileType; +import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; import org.apache.maven.archiva.configuration.functors.FiletypeSelectionPredicate; import org.apache.maven.archiva.configuration.functors.FiletypeToMapClosure; @@ -45,11 +45,10 @@ import java.util.List; import java.util.Map; /** - * RepositoryScanningAction + * RepositoryScanningAction * * @author Joakim Erdfelt * @version $Id$ - * * @plexus.component role="com.opensymphony.xwork.Action" role-hint="repositoryScanningAction" */ public class RepositoryScanningAction @@ -74,7 +73,7 @@ public class RepositoryScanningAction * List of {@link AdminRepositoryConsumer} objects for consumers of known content. */ private List knownContentConsumers; - + /** * List of enabled {@link AdminRepositoryConsumer} objects for consumers of known content. */ @@ -84,7 +83,7 @@ public class RepositoryScanningAction * List of {@link AdminRepositoryConsumer} objects for consumers of invalid/unknown content. */ private List invalidContentConsumers; - + /** * List of enabled {@link AdminRepositoryConsumer} objects for consumers of invalid/unknown content. */ @@ -99,13 +98,13 @@ public class RepositoryScanningAction super.addActionError( anErrorMessage ); getLogger().warn( "[ActionError] " + anErrorMessage ); } - + public void addActionMessage( String aMessage ) { super.addActionMessage( aMessage ); getLogger().info( "[ActionMessage] " + aMessage ); } - + public String addFiletypePattern() { getLogger().info( "Add New File Type Pattern [" + getFileTypeId() + ":" + getPattern() + "]" ); @@ -239,19 +238,21 @@ public class RepositoryScanningAction public String updateInvalidConsumers() { - addActionMessage("Update Invalid Consumers"); - - archivaConfiguration.getConfiguration().getRepositoryScanning().setInvalidContentConsumers( enabledInvalidContentConsumers ); - + addActionMessage( "Update Invalid Consumers" ); + + archivaConfiguration.getConfiguration().getRepositoryScanning().setInvalidContentConsumers( + enabledInvalidContentConsumers ); + return saveConfiguration(); } public String updateKnownConsumers() { - addActionMessage("Update Known Consumers"); - - archivaConfiguration.getConfiguration().getRepositoryScanning().setKnownContentConsumers( enabledKnownContentConsumers ); - + addActionMessage( "Update Known Consumers" ); + + archivaConfiguration.getConfiguration().getRepositoryScanning().setKnownContentConsumers( + enabledKnownContentConsumers ); + return saveConfiguration(); } @@ -288,6 +289,11 @@ public class RepositoryScanningAction addActionError( "Unable to save configuration: " + e.getMessage() ); return INPUT; } + catch ( IndeterminateConfigurationException e ) + { + addActionError( e.getMessage() ); + return INPUT; + } return SUCCESS; } diff --git a/archiva-web/archiva-webapp/src/main/resources/META-INF/plexus/application.xml b/archiva-web/archiva-webapp/src/main/resources/META-INF/plexus/application.xml index 67f9022d5..dee6be278 100644 --- a/archiva-web/archiva-webapp/src/main/resources/META-INF/plexus/application.xml +++ b/archiva-web/archiva-webapp/src/main/resources/META-INF/plexus/application.xml @@ -59,8 +59,9 @@ - + @@ -68,7 +69,8 @@ config-at="org.codehaus.plexus.redback"/> - @@ -80,7 +82,8 @@ - + @@ -222,16 +225,17 @@ org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager basic - + + PLXREDBACK-81 bad role hint, redefining here until redback alpha-2 is released. + --> org.codehaus.plexus.redback.system.check.EnvironmentCheck locked-admin-check org.codehaus.plexus.redback.xwork.checks.security.LockedAdminEnvironmentCheck LockedAdminEnvironmentCheck: checks if accounts marked as system administrator are locked -and unlocks them on startup. + and unlocks them on startup. + org.codehaus.plexus.redback.users.UserManager