[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
This commit is contained in:
Joakim Erdfelt 2007-10-15 20:39:37 +00:00
parent e77cf5da22
commit 05f78c6d42
2 changed files with 32 additions and 5 deletions

View File

@ -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.

View File

@ -46,22 +46,28 @@
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 @@ private Registry readDefaultConfiguration()
try
{
registry.addConfigurationFromResource( "org/apache/maven/archiva/configuration/default-archiva.xml", KEY );
this.isConfigurationDefaulted = true;
}
catch ( RegistryException e )
{
@ -272,7 +285,7 @@ private Registry createDefaultConfigurationFile()
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 String getAltConfigFilename()
{
return altConfigFilename;
}
public boolean isDefaulted()
{
return this.isConfigurationDefaulted;
}
}