From 05f78c6d4200365b38a3ee2fa9f57f25680d8c75 Mon Sep 17 00:00:00 2001
From: Joakim Erdfelt
Date: Mon, 15 Oct 2007 20:39:37 +0000
Subject: [MRM-398] configure guest access by default for pre-configured
repositories Reverted partially r584279. (some good fixes for related bugs in
place) Introduced ArchivaConfiguration.isDefaulted() to aide
SecuritySynchronization (startup task in archiva-webapp) to add guest user
read-only roles if the configuration was set to default for some reason.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@584904 13f79535-47bb-0310-9956-ffa450edef68
---
.../configuration/ArchivaConfiguration.java | 9 +++++++
.../configuration/DefaultArchivaConfiguration.java | 28 ++++++++++++++++++----
2 files changed, 32 insertions(+), 5 deletions(-)
(limited to 'archiva-base/archiva-configuration')
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;
/**
+ *
* 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"
*/
@@ -102,6 +108,12 @@ public class DefaultArchivaConfiguration
* Registry Listeners we've registered.
*/
private Set registryListeners = new HashSet();
+
+ /**
+ * 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 = "";
if ( !writeFile( "user configuration", userConfigFilename, contents ) )
@@ -464,4 +477,9 @@ public class DefaultArchivaConfiguration
{
return altConfigFilename;
}
+
+ public boolean isDefaulted()
+ {
+ return this.isConfigurationDefaulted;
+ }
}
--
cgit v1.2.3