diff options
Diffstat (limited to 'archiva-base/archiva-configuration')
2 files changed, 32 insertions, 5 deletions
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 1be1daa15..0705fd654 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 @@ -47,6 +47,15 @@ public interface ArchivaConfiguration */ void save( Configuration configuration ) throws RegistryException, IndeterminateConfigurationException; + + /** + * Determines if the configuration in use was as a result of a defaulted configuration. + * + * @return true if the configuration was created from the default-archiva.xml as opposed + * to being loaded from the usual locations of ${user.home}/.m2/archiva.xml or + * ${appserver.base}/conf/archiva.xml + */ + boolean isDefaulted(); /** * Add a configuration listener to notify of changes to the configuration. 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 b26174e6d..5ca08dc85 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 @@ -46,22 +46,28 @@ import java.util.Map; import java.util.Set; /** + * <p> * Implementation of configuration holder that retrieves it from the registry. - * <p/> + * </p> + * <p> * The registry layers and merges the 2 configuration files: user, and application server. - * <p/> + * </p> + * <p> * 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. - * <p/> + * </p> + * <p> * 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. - * <p/> + * </p> + * <p> * 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. + * </p> * * @plexus.component role="org.apache.maven.archiva.configuration.ArchivaConfiguration" */ @@ -102,6 +108,12 @@ public class DefaultArchivaConfiguration * Registry Listeners we've registered. */ private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>(); + + /** + * Boolean to help determine if the configuration exists as a result of pulling in + * the default-archiva.xml + */ + private boolean isConfigurationDefaulted = false; public synchronized Configuration getConfiguration() { @@ -194,6 +206,7 @@ public class DefaultArchivaConfiguration try { registry.addConfigurationFromResource( "org/apache/maven/archiva/configuration/default-archiva.xml", KEY ); + this.isConfigurationDefaulted = true; } catch ( RegistryException e ) { @@ -272,7 +285,7 @@ public class DefaultArchivaConfiguration throws RegistryException { // TODO: may not be needed under commons-configuration 1.4 - check - // UPDATE: Upgrading to commons-configuration 1.4 breaks half the unit tests. 10/11/2007 (joakime) + // UPDATE: Upgrading to commons-configuration 1.4 breaks half the unit tests. 2007-10-11 (joakime) String contents = "<configuration />"; if ( !writeFile( "user configuration", userConfigFilename, contents ) ) @@ -464,4 +477,9 @@ public class DefaultArchivaConfiguration { return altConfigFilename; } + + public boolean isDefaulted() + { + return this.isConfigurationDefaulted; + } } |