aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-base/archiva-configuration
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-10-15 20:39:37 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-10-15 20:39:37 +0000
commit05f78c6d4200365b38a3ee2fa9f57f25680d8c75 (patch)
tree84158e17aea60e932a1789cd43ac393025013041 /archiva-base/archiva-configuration
parente77cf5da222c7faacc5aa625563456fd3e15eea6 (diff)
downloadarchiva-05f78c6d4200365b38a3ee2fa9f57f25680d8c75.tar.gz
archiva-05f78c6d4200365b38a3ee2fa9f57f25680d8c75.zip
[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
Diffstat (limited to 'archiva-base/archiva-configuration')
-rw-r--r--archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java9
-rw-r--r--archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java28
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;
+ }
}