git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@505329 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-0.9-alpha-1
@@ -51,19 +51,24 @@ | |||
<groupId>commons-io</groupId> | |||
<artifactId>commons-io</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-registry</artifactId> | |||
<version>1.0-SNAPSHOT</version> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.codehaus.modello</groupId> | |||
<artifactId>modello-maven-plugin</artifactId> | |||
<version>1.0-alpha-10</version> | |||
<version>1.0-alpha-14-SNAPSHOT</version> | |||
<executions> | |||
<execution> | |||
<goals> | |||
<goal>xpp3-writer</goal> | |||
<goal>java</goal> | |||
<goal>xpp3-reader</goal> | |||
<goal>registry-reader</goal> | |||
<goal>registry-writer</goal> | |||
</goals> | |||
</execution> | |||
</executions> |
@@ -19,21 +19,35 @@ package org.apache.maven.archiva.configuration; | |||
* under the License. | |||
*/ | |||
import org.codehaus.plexus.registry.RegistryException; | |||
import org.codehaus.plexus.registry.RegistryListener; | |||
/** | |||
* Component capable of noticing configuration changes and adjusting accordingly. | |||
* This is not a Plexus role. | |||
* | |||
* @author <a href="mailto:brett@apache.org">Brett Porter</a> | |||
* Configuration holder for the model read from the registry. | |||
*/ | |||
public interface ConfigurationChangeListener | |||
public interface ArchivaConfiguration | |||
{ | |||
/** | |||
* Notify the object that there has been a configuration change. | |||
* Get the configuration. | |||
* | |||
* @return the configuration | |||
*/ | |||
Configuration getConfiguration(); | |||
/** | |||
* Save any updated configuration. | |||
* | |||
* @param configuration the configuration to save | |||
* @throws org.codehaus.plexus.registry.RegistryException | |||
* if there is a problem saving the registry data | |||
*/ | |||
void save( Configuration configuration ) | |||
throws RegistryException; | |||
/** | |||
* Add a change listener so that registry changes are propogated. | |||
* | |||
* @param configuration the new configuration | |||
* @throws InvalidConfigurationException if there is a problem with the new configuration | |||
* @throws ConfigurationChangeException if there is a problem changing the configuration, but the configuration is valid | |||
* @param listener the listener | |||
*/ | |||
void notifyOfConfigurationChange( Configuration configuration ) | |||
throws InvalidConfigurationException, ConfigurationChangeException; | |||
void addChangeListener( RegistryListener listener ); | |||
} |
@@ -1,34 +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. | |||
*/ | |||
/** | |||
* An error changing the configuration | |||
* | |||
* @author <a href="mailto:brett@apache.org">Brett Porter</a> | |||
*/ | |||
public class ConfigurationChangeException | |||
extends Exception | |||
{ | |||
public ConfigurationChangeException( String message, Throwable cause ) | |||
{ | |||
super( message, cause ); | |||
} | |||
} |
@@ -1,58 +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. | |||
*/ | |||
/** | |||
* A component for loading the configuration into the model. | |||
* | |||
* @author <a href="mailto:brett@apache.org">Brett Porter</a> | |||
* @todo this is something that could possibly be generalised into Modello. | |||
*/ | |||
public interface ConfigurationStore | |||
{ | |||
/** | |||
* The Plexus role for the component. | |||
*/ | |||
String ROLE = ConfigurationStore.class.getName(); | |||
/** | |||
* Get the configuration from the store. A cached version may be used. | |||
* | |||
* @return the configuration | |||
* @throws ConfigurationStoreException if there is a problem loading the configuration | |||
*/ | |||
Configuration getConfigurationFromStore() | |||
throws ConfigurationStoreException; | |||
/** | |||
* Save the configuration to the store. | |||
* | |||
* @param configuration the configuration to store | |||
*/ | |||
void storeConfiguration( Configuration configuration ) | |||
throws ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException; | |||
/** | |||
* Add a configuration change listener. | |||
* | |||
* @param listener the listener | |||
*/ | |||
void addChangeListener( ConfigurationChangeListener listener ); | |||
} |
@@ -1,39 +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. | |||
*/ | |||
/** | |||
* Exception occurring using the configuration store. | |||
* | |||
* @author <a href="mailto:brett@apache.org">Brett Porter</a> | |||
*/ | |||
public class ConfigurationStoreException | |||
extends Exception | |||
{ | |||
public ConfigurationStoreException( String message ) | |||
{ | |||
super( message ); | |||
} | |||
public ConfigurationStoreException( String message, Throwable e ) | |||
{ | |||
super( message, e ); | |||
} | |||
} |
@@ -0,0 +1,85 @@ | |||
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.maven.archiva.configuration.io.registry.ConfigurationRegistryReader; | |||
import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryWriter; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; | |||
import org.codehaus.plexus.registry.Registry; | |||
import org.codehaus.plexus.registry.RegistryException; | |||
import org.codehaus.plexus.registry.RegistryListener; | |||
/** | |||
* Implementation of configuration holder that retrieves it from the registry. | |||
* | |||
* @plexus.component | |||
*/ | |||
public class DefaultArchivaConfiguration | |||
implements ArchivaConfiguration, RegistryListener, Initializable | |||
{ | |||
/** | |||
* Plexus registry to read the configuration from. | |||
* | |||
* @plexus.requirement role-hint="commons-configuration" | |||
*/ | |||
private Registry registry; | |||
/** | |||
* The configuration that has been converted. | |||
*/ | |||
private Configuration configuration; | |||
private static final String KEY = "org.apache.maven.archiva"; | |||
public synchronized Configuration getConfiguration() | |||
{ | |||
if ( configuration == null ) | |||
{ | |||
// TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties) | |||
configuration = new ConfigurationRegistryReader().read( registry.getSubset( KEY ) ); | |||
} | |||
return configuration; | |||
} | |||
public void save( Configuration configuration ) | |||
throws RegistryException | |||
{ | |||
Registry section = registry.getSection( KEY ); | |||
new ConfigurationRegistryWriter().write( configuration, section ); | |||
section.save(); | |||
} | |||
public void addChangeListener( RegistryListener listener ) | |||
{ | |||
registry.addChangeListener( listener ); | |||
} | |||
public synchronized void notifyOfConfigurationChange( Registry registry ) | |||
{ | |||
configuration = null; | |||
} | |||
public void initialize() | |||
throws InitializationException | |||
{ | |||
registry.addChangeListener( this ); | |||
} | |||
} |
@@ -1,162 +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.IOUtils; | |||
import org.apache.maven.archiva.configuration.io.xpp3.ConfigurationXpp3Reader; | |||
import org.apache.maven.archiva.configuration.io.xpp3.ConfigurationXpp3Writer; | |||
import org.codehaus.plexus.logging.AbstractLogEnabled; | |||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; | |||
import java.io.File; | |||
import java.io.FileNotFoundException; | |||
import java.io.FileReader; | |||
import java.io.FileWriter; | |||
import java.io.IOException; | |||
import java.util.Iterator; | |||
import java.util.LinkedList; | |||
import java.util.List; | |||
/** | |||
* Load and store the configuration. No synchronization is used, but it is unnecessary as the old configuration object | |||
* can continue to be used. | |||
* | |||
* @author <a href="mailto:brett@apache.org">Brett Porter</a> | |||
* @todo would be great for plexus to do this for us - so the configuration would be a component itself rather than this store | |||
* @todo would be good to monitor the store file for changes | |||
* @todo support other implementations than XML file | |||
* @plexus.component | |||
*/ | |||
public class DefaultConfigurationStore | |||
extends AbstractLogEnabled | |||
implements ConfigurationStore | |||
{ | |||
/** | |||
* @plexus.configuration default-value="${configuration.store.file}" | |||
*/ | |||
private File file; | |||
/** | |||
* The cached configuration. | |||
*/ | |||
private Configuration configuration; | |||
/** | |||
* List of listeners to configuration changes. | |||
*/ | |||
private List/*<ConfigurationChangeListener>*/ listeners = new LinkedList(); | |||
public Configuration getConfigurationFromStore() | |||
throws ConfigurationStoreException | |||
{ | |||
if ( configuration == null ) | |||
{ | |||
ConfigurationXpp3Reader reader = new ConfigurationXpp3Reader(); | |||
if ( file == null ) | |||
{ | |||
file = new File( System.getProperty( "user.home" ), "/.m2/archiva.xml" ); | |||
// migration for those with the old file | |||
if ( !file.exists() ) | |||
{ | |||
File file = new File( System.getProperty( "user.home" ), "/.m2/repository-manager.xml" ); | |||
if ( file.exists() ) | |||
{ | |||
getLogger().info( "Migrating " + file + " to " + this.file ); | |||
file.renameTo( this.file ); | |||
} | |||
} | |||
} | |||
FileReader fileReader; | |||
try | |||
{ | |||
fileReader = new FileReader( file ); | |||
} | |||
catch ( FileNotFoundException e ) | |||
{ | |||
getLogger().warn( "Configuration file: " + file + " not found. Using defaults." ); | |||
configuration = new Configuration(); | |||
return configuration; | |||
} | |||
getLogger().info( "Reading configuration from " + file ); | |||
try | |||
{ | |||
configuration = reader.read( fileReader, false ); | |||
configuration.sanitize(); | |||
} | |||
catch ( IOException e ) | |||
{ | |||
throw new ConfigurationStoreException( e.getMessage(), e ); | |||
} | |||
catch ( XmlPullParserException e ) | |||
{ | |||
throw new ConfigurationStoreException( e.getMessage(), e ); | |||
} | |||
finally | |||
{ | |||
IOUtils.closeQuietly( fileReader ); | |||
} | |||
} | |||
return configuration; | |||
} | |||
public void storeConfiguration( Configuration configuration ) | |||
throws ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException | |||
{ | |||
for ( Iterator i = listeners.iterator(); i.hasNext(); ) | |||
{ | |||
ConfigurationChangeListener listener = (ConfigurationChangeListener) i.next(); | |||
listener.notifyOfConfigurationChange( configuration ); | |||
} | |||
ConfigurationXpp3Writer writer = new ConfigurationXpp3Writer(); | |||
getLogger().info( "Writing configuration to " + file ); | |||
FileWriter fileWriter = null; | |||
try | |||
{ | |||
//does file directory exist ? | |||
if ( file.getParentFile() != null && !file.getParentFile().exists() ) | |||
{ | |||
file.getParentFile().mkdirs(); | |||
} | |||
fileWriter = new FileWriter( file ); | |||
writer.write( fileWriter, configuration ); | |||
} | |||
catch ( IOException e ) | |||
{ | |||
throw new ConfigurationStoreException( e.getMessage(), e ); | |||
} | |||
finally | |||
{ | |||
IOUtils.closeQuietly( fileWriter ); | |||
} | |||
} | |||
public void addChangeListener( ConfigurationChangeListener listener ) | |||
{ | |||
listeners.add( listener ); | |||
} | |||
} |
@@ -30,8 +30,6 @@ | |||
<proxiedRepository> | |||
<url>http://www.ibiblio.org/maven2/</url> | |||
<managedRepository>local</managedRepository> | |||
<snapshotsInterval></snapshotsInterval> | |||
<releasesInterval></releasesInterval> | |||
<useNetworkProxy>true</useNetworkProxy> | |||
<id>ibiblio</id> | |||
<name>Ibiblio</name> |
@@ -20,7 +20,6 @@ package org.apache.maven.archiva.configuration; | |||
*/ | |||
import org.codehaus.plexus.PlexusTestCase; | |||
import org.easymock.MockControl; | |||
import java.io.File; | |||
import java.util.Properties; | |||
@@ -29,17 +28,17 @@ import java.util.Properties; | |||
* Test the configuration store. | |||
* | |||
* @author <a href="mailto:brett@apache.org">Brett Porter</a> | |||
* @noinspection JavaDoc | |||
*/ | |||
public class ConfigurationStoreTest | |||
public class ArchivaConfigurationTest | |||
extends PlexusTestCase | |||
{ | |||
public void testInvalidFile() | |||
public void testDefaults() | |||
throws Exception | |||
{ | |||
ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "invalid-file" ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-defaults" ); | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
// check default configuration | |||
assertNotNull( "check configuration returned", configuration ); | |||
@@ -49,29 +48,13 @@ public class ConfigurationStoreTest | |||
assertTrue( "check configuration has default elements", configuration.getRepositories().isEmpty() ); | |||
} | |||
public void testCorruptFile() | |||
throws Exception | |||
{ | |||
ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "corrupt-file" ); | |||
try | |||
{ | |||
configurationStore.getConfigurationFromStore(); | |||
fail( "Configuration should not have succeeded" ); | |||
} | |||
catch ( ConfigurationStoreException e ) | |||
{ | |||
// expected | |||
assertTrue( true ); | |||
} | |||
} | |||
public void testGetConfiguration() | |||
throws Exception | |||
{ | |||
ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "default" ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); | |||
assertEquals( "check localRepository", "local-repository", configuration.getLocalRepository() ); | |||
@@ -113,45 +96,44 @@ public class ConfigurationStoreTest | |||
assertEquals( "check synced repositories", properties, syncedRepository.getProperties() ); | |||
} | |||
public void testStoreConfiguration() | |||
public void testGetConfigurationSystemOverride() | |||
throws Exception | |||
{ | |||
ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "save-file" ); | |||
Configuration configuration = new Configuration(); | |||
configuration.setIndexPath( "index-path" ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); | |||
File file = getTestFile( "target/test/test-file.xml" ); | |||
file.delete(); | |||
assertFalse( file.exists() ); | |||
System.setProperty( "org.apache.maven.archiva.localRepository", "system-repository" ); | |||
configurationStore.storeConfiguration( configuration ); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
assertTrue( "Check file exists", file.exists() ); | |||
// read it back | |||
configuration = configurationStore.getConfigurationFromStore(); | |||
assertEquals( "check value", "index-path", configuration.getIndexPath() ); | |||
assertEquals( "check localRepository", "system-repository", configuration.getLocalRepository() ); | |||
assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); | |||
} | |||
/** | |||
* @noinspection JUnitTestMethodWithNoAssertions | |||
*/ | |||
public void testChangeListeners() | |||
public void testStoreConfiguration() | |||
throws Exception | |||
{ | |||
ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE, "save-file" ); | |||
File file = getTestFile( "target/test/test-file.xml" ); | |||
file.delete(); | |||
assertFalse( file.exists() ); | |||
MockControl control = MockControl.createControl( ConfigurationChangeListener.class ); | |||
ConfigurationChangeListener mock = (ConfigurationChangeListener) control.getMock(); | |||
configurationStore.addChangeListener( mock ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save" ); | |||
Configuration configuration = new Configuration(); | |||
mock.notifyOfConfigurationChange( configuration ); | |||
control.replay(); | |||
configuration.setIndexPath( "index-path" ); | |||
configurationStore.storeConfiguration( configuration ); | |||
archivaConfiguration.save( configuration ); | |||
control.verify(); | |||
assertTrue( "Check file exists", file.exists() ); | |||
// check it | |||
configuration = archivaConfiguration.getConfiguration(); | |||
assertEquals( "check value", "index-path", configuration.getIndexPath() ); | |||
// read it back | |||
archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-saved" ); | |||
configuration = archivaConfiguration.getConfiguration(); | |||
assertEquals( "check value", "index-path", configuration.getIndexPath() ); | |||
} | |||
} |
@@ -0,0 +1,112 @@ | |||
<?xml version="1.0" encoding="ISO-8859-1"?> | |||
<!-- | |||
~ 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. | |||
--> | |||
<component-set> | |||
<components> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-defaults</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>empty</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>empty</role-hint> | |||
<implementation>org.codehaus.plexus.registry.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-configuration</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
<implementation>org.codehaus.plexus.registry.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<system/> | |||
<xml fileName="${basedir}/src/test/conf/repository-manager.xml" | |||
config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-save</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>save</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>save</role-hint> | |||
<implementation>org.codehaus.plexus.registry.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-read-saved</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>read-saved</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>read-saved</role-hint> | |||
<implementation>org.codehaus.plexus.registry.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
</components> | |||
</component-set> |
@@ -1,56 +0,0 @@ | |||
<?xml version="1.0" encoding="ISO-8859-1"?> | |||
<!-- | |||
~ 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. | |||
--> | |||
<component-set> | |||
<components> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationStore</role> | |||
<role-hint>default</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultConfigurationStore</implementation> | |||
<configuration> | |||
<file>${basedir}/src/test/conf/repository-manager.xml</file> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationStore</role> | |||
<role-hint>corrupt-file</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultConfigurationStore</implementation> | |||
<configuration> | |||
<file>${basedir}/src/test/conf/corrupt.xml</file> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationStore</role> | |||
<role-hint>invalid-file</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultConfigurationStore</implementation> | |||
<configuration> | |||
<file>${basedir}/src/test/conf/nada.txt</file> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationStore</role> | |||
<role-hint>save-file</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultConfigurationStore</implementation> | |||
<configuration> | |||
<file>${basedir}/target/test/test-file.xml</file> | |||
</configuration> | |||
</component> | |||
</components> | |||
</component-set> |
@@ -27,32 +27,32 @@ import org.apache.maven.project.MavenProject; | |||
import org.apache.maven.project.ProjectBuildingException; | |||
/** | |||
* ActiveManagedRepositories | |||
* ActiveManagedRepositories | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
*/ | |||
public interface ActiveManagedRepositories | |||
{ | |||
public static final String ROLE = ActiveManagedRepositories.class.getName(); | |||
String ROLE = ActiveManagedRepositories.class.getName(); | |||
/** | |||
* Obtain the ArtifactRepository for the specified Repository ID. | |||
* | |||
* | |||
* @param id the ID of the repository. | |||
* @return the ArtifactRepository associated with the provided ID, or null if none found. | |||
*/ | |||
public ArtifactRepository getArtifactRepository( String id ); | |||
ArtifactRepository getArtifactRepository( String id ); | |||
public RepositoryConfiguration getRepositoryConfiguration( String id ); | |||
RepositoryConfiguration getRepositoryConfiguration( String id ); | |||
public MavenProject findProject( String groupId, String artifactId, String version ) | |||
MavenProject findProject( String groupId, String artifactId, String version ) | |||
throws ProjectBuildingException; | |||
public ManagedArtifact findArtifact( String groupId, String artifactId, String version ) | |||
ManagedArtifact findArtifact( String groupId, String artifactId, String version ) | |||
throws ProjectBuildingException; | |||
public ManagedArtifact findArtifact( String groupId, String artifactId, String version, String type ); | |||
ManagedArtifact findArtifact( String groupId, String artifactId, String version, String type ); | |||
public ManagedArtifact findArtifact( Artifact artifact ); | |||
ManagedArtifact findArtifact( Artifact artifact ); | |||
} |
@@ -24,13 +24,9 @@ import org.apache.maven.archiva.artifact.ManagedArtifact; | |||
import org.apache.maven.archiva.artifact.ManagedArtifactTypes; | |||
import org.apache.maven.archiva.artifact.ManagedEjbArtifact; | |||
import org.apache.maven.archiva.artifact.ManagedJavaArtifact; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationChangeException; | |||
import org.apache.maven.archiva.configuration.ConfigurationChangeListener; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; | |||
import org.apache.maven.archiva.configuration.InvalidConfigurationException; | |||
import org.apache.maven.archiva.configuration.RepositoryConfiguration; | |||
import org.apache.maven.artifact.Artifact; | |||
import org.apache.maven.artifact.factory.ArtifactFactory; | |||
@@ -42,20 +38,22 @@ import org.apache.maven.project.ProjectBuildingException; | |||
import org.codehaus.plexus.cache.Cache; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; | |||
import org.codehaus.plexus.registry.Registry; | |||
import org.codehaus.plexus.registry.RegistryListener; | |||
import java.io.File; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
/** | |||
* DefaultActiveManagedRepositories | |||
* DefaultActiveManagedRepositories | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
* @plexus.component role="org.apache.maven.archiva.repositories.ActiveManagedRepositories" | |||
*/ | |||
public class DefaultActiveManagedRepositories | |||
implements ActiveManagedRepositories, ConfigurationChangeListener, Initializable | |||
implements ActiveManagedRepositories, Initializable, RegistryListener | |||
{ | |||
/** | |||
* @plexus.requirement role-hint="artifactCache" | |||
@@ -70,7 +68,7 @@ public class DefaultActiveManagedRepositories | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement | |||
@@ -191,21 +189,8 @@ public class DefaultActiveManagedRepositories | |||
public void initialize() | |||
throws InitializationException | |||
{ | |||
Configuration config; | |||
try | |||
{ | |||
config = configurationStore.getConfigurationFromStore(); | |||
configureSelf( config ); | |||
} | |||
catch ( ConfigurationStoreException e ) | |||
{ | |||
throw new InitializationException( "Unable to load configuration.", e ); | |||
} | |||
} | |||
public void notifyOfConfigurationChange( Configuration config ) | |||
throws InvalidConfigurationException, ConfigurationChangeException | |||
{ | |||
Configuration config = archivaConfiguration.getConfiguration(); | |||
archivaConfiguration.addChangeListener( this ); | |||
configureSelf( config ); | |||
} | |||
@@ -229,7 +214,7 @@ public class DefaultActiveManagedRepositories | |||
this.configuration = config; | |||
this.artifactCache.clear(); | |||
this.projectCache.clear(); | |||
repositories = repositoryFactory.createRepositories( this.configuration ); | |||
localRepository = repositoryFactory.createLocalRepository( this.configuration ); | |||
} | |||
@@ -281,4 +266,9 @@ public class DefaultActiveManagedRepositories | |||
return path; | |||
} | |||
public void notifyOfConfigurationChange( Registry registry ) | |||
{ | |||
configureSelf( archivaConfiguration.getConfiguration() ); | |||
} | |||
} |
@@ -19,12 +19,8 @@ package org.apache.maven.archiva.scheduler; | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationChangeException; | |||
import org.apache.maven.archiva.configuration.ConfigurationChangeListener; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.InvalidConfigurationException; | |||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndex; | |||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory; | |||
import org.apache.maven.archiva.indexer.RepositoryIndexException; | |||
@@ -35,6 +31,8 @@ import org.codehaus.plexus.logging.AbstractLogEnabled; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; | |||
import org.codehaus.plexus.registry.Registry; | |||
import org.codehaus.plexus.registry.RegistryListener; | |||
import org.codehaus.plexus.scheduler.Scheduler; | |||
import org.codehaus.plexus.taskqueue.TaskQueue; | |||
import org.codehaus.plexus.taskqueue.TaskQueueException; | |||
@@ -55,7 +53,7 @@ import java.text.ParseException; | |||
*/ | |||
public class DefaultRepositoryTaskScheduler | |||
extends AbstractLogEnabled | |||
implements RepositoryTaskScheduler, Startable, ConfigurationChangeListener | |||
implements RepositoryTaskScheduler, Startable, RegistryListener | |||
{ | |||
/** | |||
* @plexus.requirement | |||
@@ -75,7 +73,7 @@ public class DefaultRepositoryTaskScheduler | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement | |||
@@ -89,16 +87,8 @@ public class DefaultRepositoryTaskScheduler | |||
public void start() | |||
throws StartingException | |||
{ | |||
Configuration configuration; | |||
try | |||
{ | |||
configuration = configurationStore.getConfigurationFromStore(); | |||
configurationStore.addChangeListener( this ); | |||
} | |||
catch ( ConfigurationStoreException e ) | |||
{ | |||
throw new StartingException( "Unable to read configuration from the store", e ); | |||
} | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
archivaConfiguration.addChangeListener( this ); | |||
try | |||
{ | |||
@@ -166,26 +156,30 @@ public class DefaultRepositoryTaskScheduler | |||
} | |||
} | |||
public void notifyOfConfigurationChange( Configuration configuration ) | |||
throws InvalidConfigurationException, ConfigurationChangeException | |||
public void notifyOfConfigurationChange( Registry registry ) | |||
{ | |||
try | |||
{ | |||
stop(); | |||
scheduleJobs( configuration ); | |||
} | |||
catch ( StoppingException e ) | |||
{ | |||
throw new ConfigurationChangeException( "Unable to unschedule previous tasks", e ); | |||
getLogger().warn( "Error stopping task scheduler: " + e.getMessage(), e ); | |||
} | |||
try | |||
{ | |||
scheduleJobs( archivaConfiguration.getConfiguration() ); | |||
} | |||
catch ( ParseException e ) | |||
{ | |||
throw new InvalidConfigurationException( "indexerCronExpression", "Invalid cron expression", e ); | |||
getLogger().error( | |||
"Error restarting task scheduler after configuration change, due to configuration error: " + | |||
e.getMessage(), e ); | |||
} | |||
catch ( SchedulerException e ) | |||
{ | |||
throw new ConfigurationChangeException( "Unable to schedule new tasks", e ); | |||
getLogger().error( "Error restarting task scheduler after configuration change: " + e.getMessage(), e ); | |||
} | |||
} | |||
@@ -207,15 +201,7 @@ public class DefaultRepositoryTaskScheduler | |||
public void queueNowIfNeeded() | |||
throws org.codehaus.plexus.taskqueue.execution.TaskExecutionException | |||
{ | |||
Configuration configuration; | |||
try | |||
{ | |||
configuration = configurationStore.getConfigurationFromStore(); | |||
} | |||
catch ( ConfigurationStoreException e ) | |||
{ | |||
throw new TaskExecutionException( e.getMessage(), e ); | |||
} | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
File indexPath = new File( configuration.getIndexPath() ); | |||
@@ -19,9 +19,8 @@ package org.apache.maven.archiva.scheduler.executors; | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; | |||
import org.apache.maven.archiva.configuration.RepositoryConfiguration; | |||
import org.apache.maven.archiva.discoverer.ArtifactDiscoverer; | |||
@@ -69,7 +68,7 @@ public class IndexerTaskExecutor | |||
* | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement | |||
@@ -128,15 +127,7 @@ public class IndexerTaskExecutor | |||
public void execute() | |||
throws TaskExecutionException | |||
{ | |||
Configuration configuration; | |||
try | |||
{ | |||
configuration = configurationStore.getConfigurationFromStore(); | |||
} | |||
catch ( ConfigurationStoreException e ) | |||
{ | |||
throw new TaskExecutionException( e.getMessage(), e ); | |||
} | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
File indexPath = new File( configuration.getIndexPath() ); | |||
@@ -146,15 +137,7 @@ public class IndexerTaskExecutor | |||
public void executeNowIfNeeded() | |||
throws TaskExecutionException | |||
{ | |||
Configuration configuration; | |||
try | |||
{ | |||
configuration = configurationStore.getConfigurationFromStore(); | |||
} | |||
catch ( ConfigurationStoreException e ) | |||
{ | |||
throw new TaskExecutionException( e.getMessage(), e ); | |||
} | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
File indexPath = new File( configuration.getIndexPath() ); | |||
@@ -241,8 +224,8 @@ public class IndexerTaskExecutor | |||
for ( int j = 0; j < artifacts.size(); j += ARTIFACT_BUFFER_SIZE ) | |||
{ | |||
int end = j + ARTIFACT_BUFFER_SIZE; | |||
List currentArtifacts = artifacts.subList( j, end > artifacts.size() ? artifacts.size() | |||
: end ); | |||
List currentArtifacts = | |||
artifacts.subList( j, end > artifacts.size() ? artifacts.size() : end ); | |||
// TODO: proper queueing of this in case it was triggered externally (not harmful to do so at present, but not optimal) | |||
@@ -262,8 +245,8 @@ public class IndexerTaskExecutor | |||
MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers | |||
.get( layoutProperty ); | |||
List metadata = metadataDiscoverer.discoverMetadata( repository, blacklistedPatterns, | |||
metadataFilter ); | |||
List metadata = | |||
metadataDiscoverer.discoverMetadata( repository, blacklistedPatterns, metadataFilter ); | |||
if ( !metadata.isEmpty() ) | |||
{ |
@@ -25,7 +25,7 @@ import org.apache.maven.archiva.artifact.ManagedJavaArtifact; | |||
import org.codehaus.plexus.PlexusTestCase; | |||
/** | |||
* DefaultActiveManagedRepositoriesTest | |||
* DefaultActiveManagedRepositoriesTest | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
@@ -40,11 +40,11 @@ public class DefaultActiveManagedRepositoriesTest | |||
{ | |||
super.setUp(); | |||
managedRepos = (DefaultActiveManagedRepositories) lookup( ActiveManagedRepositories.ROLE ); | |||
managedRepos = (ActiveManagedRepositories) lookup( ActiveManagedRepositories.ROLE ); | |||
} | |||
/** | |||
* Test a simple java find artifact with extras (sources / javadoc). | |||
* Test a simple java find artifact with extras (sources / javadoc). | |||
*/ | |||
public void testFindArtifactJavaWithExtras() | |||
{ | |||
@@ -53,8 +53,8 @@ public class DefaultActiveManagedRepositoriesTest | |||
if ( !( artifact instanceof ManagedJavaArtifact ) ) | |||
{ | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" | |||
+ artifact.getClass().getName() + ">." ); | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" + | |||
artifact.getClass().getName() + ">." ); | |||
} | |||
ManagedJavaArtifact javaArtifact = (ManagedJavaArtifact) artifact; | |||
@@ -68,7 +68,7 @@ public class DefaultActiveManagedRepositoriesTest | |||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-javadoc.jar", javaArtifact.getJavadocPath() ); | |||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-sources.jar", javaArtifact.getSourcesPath() ); | |||
} | |||
/** | |||
* Test a simple java find artifact with no extras. | |||
*/ | |||
@@ -79,8 +79,8 @@ public class DefaultActiveManagedRepositoriesTest | |||
if ( !( artifact instanceof ManagedJavaArtifact ) ) | |||
{ | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" | |||
+ artifact.getClass().getName() + ">." ); | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" + | |||
artifact.getClass().getName() + ">." ); | |||
} | |||
ManagedJavaArtifact javaArtifact = (ManagedJavaArtifact) artifact; | |||
@@ -93,10 +93,10 @@ public class DefaultActiveManagedRepositoriesTest | |||
assertEquals( pathPrefix + "/" + pathArtifactVersion + ".jar", javaArtifact.getPath() ); | |||
assertNull( "should have no javadoc jar.", javaArtifact.getJavadocPath() ); | |||
assertNull( "should have no sources jar.", javaArtifact.getSourcesPath() ); | |||
} | |||
} | |||
/** | |||
* Test a java find of a snapshot artifact that uses a timestamp format. | |||
* Test a java find of a snapshot artifact that uses a timestamp format. | |||
*/ | |||
public void testFindArtifactJavaSnapshotTimestamp() | |||
{ | |||
@@ -106,8 +106,8 @@ public class DefaultActiveManagedRepositoriesTest | |||
if ( !( artifact instanceof ManagedJavaArtifact ) ) | |||
{ | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" | |||
+ artifact.getClass().getName() + ">." ); | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" + | |||
artifact.getClass().getName() + ">." ); | |||
} | |||
ManagedJavaArtifact javaArtifact = (ManagedJavaArtifact) artifact; | |||
@@ -123,7 +123,7 @@ public class DefaultActiveManagedRepositoriesTest | |||
} | |||
/** | |||
* Test a java find of a snapshot artifact. | |||
* Test a java find of a snapshot artifact. | |||
*/ | |||
public void testFindArtifactJavaSnapshot() | |||
{ | |||
@@ -133,8 +133,8 @@ public class DefaultActiveManagedRepositoriesTest | |||
if ( !( artifact instanceof ManagedJavaArtifact ) ) | |||
{ | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" | |||
+ artifact.getClass().getName() + ">." ); | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" + | |||
artifact.getClass().getName() + ">." ); | |||
} | |||
ManagedJavaArtifact javaArtifact = (ManagedJavaArtifact) artifact; | |||
@@ -150,18 +150,18 @@ public class DefaultActiveManagedRepositoriesTest | |||
} | |||
/** | |||
* Test a ejb find of a snapshot artifact that also has a client jar available. | |||
* Test a ejb find of a snapshot artifact that also has a client jar available. | |||
*/ | |||
public void testFindArtifactEjbSnapshot() | |||
{ | |||
ManagedArtifact artifact = managedRepos.findArtifact( "org.apache.geronimo.daytrader", "daytrader-ejb", | |||
"2.0-SNAPSHOT", "ejb" ); | |||
ManagedArtifact artifact = | |||
managedRepos.findArtifact( "org.apache.geronimo.daytrader", "daytrader-ejb", "2.0-SNAPSHOT", "ejb" ); | |||
assertNotNull( artifact ); | |||
if ( !( artifact instanceof ManagedEjbArtifact ) ) | |||
{ | |||
fail( "Expected artifact to be type <" + ManagedEjbArtifact.class.getName() + "> but was actually <" | |||
+ artifact.getClass().getName() + ">." ); | |||
fail( "Expected artifact to be type <" + ManagedEjbArtifact.class.getName() + "> but was actually <" + | |||
artifact.getClass().getName() + ">." ); | |||
} | |||
ManagedEjbArtifact ejbArtifact = (ManagedEjbArtifact) artifact; | |||
@@ -176,7 +176,7 @@ public class DefaultActiveManagedRepositoriesTest | |||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-javadoc.jar", ejbArtifact.getJavadocPath() ); | |||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-sources.jar", ejbArtifact.getSourcesPath() ); | |||
} | |||
/** | |||
* Test a simple java find artifact with no extras. | |||
*/ | |||
@@ -187,8 +187,8 @@ public class DefaultActiveManagedRepositoriesTest | |||
if ( !( artifact instanceof ManagedJavaArtifact ) ) | |||
{ | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" | |||
+ artifact.getClass().getName() + ">." ); | |||
fail( "Expected artifact to be type <" + ManagedJavaArtifact.class.getName() + "> but was actually <" + | |||
artifact.getClass().getName() + ">." ); | |||
} | |||
ManagedJavaArtifact warArtifact = (ManagedJavaArtifact) artifact; | |||
@@ -201,5 +201,5 @@ public class DefaultActiveManagedRepositoriesTest | |||
assertEquals( pathPrefix + "/" + pathArtifactVersion + ".war", warArtifact.getPath() ); | |||
assertEquals( pathPrefix + "/" + pathArtifactVersion + "-javadoc.jar", warArtifact.getJavadocPath() ); | |||
assertNull( "should have no sources jar.", warArtifact.getSourcesPath() ); | |||
} | |||
} | |||
} |
@@ -20,9 +20,8 @@ package org.apache.maven.archiva.scheduler.executors; | |||
*/ | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.scheduler.task.IndexerTask; | |||
import org.codehaus.plexus.PlexusTestCase; | |||
import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; | |||
@@ -31,7 +30,7 @@ import org.codehaus.plexus.taskqueue.execution.TaskExecutor; | |||
import java.io.File; | |||
/** | |||
* IndexerTaskExecutorTest | |||
* IndexerTaskExecutorTest | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
@@ -48,8 +47,9 @@ public class IndexerTaskExecutorTest | |||
taskExecutor = (TaskExecutor) lookup( "org.codehaus.plexus.taskqueue.execution.TaskExecutor", "indexer" ); | |||
ConfigurationStore configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE ); | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() ); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
File indexPath = new File( configuration.getIndexPath() ); | |||
if ( indexPath.exists() ) |
@@ -21,10 +21,14 @@ | |||
<component-set> | |||
<components> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationStore</role> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultConfigurationStore</implementation> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<implementation>org.codehaus.plexus.registry.CommonsConfigurationRegistry</implementation> | |||
<role-hint>commons-configuration</role-hint> | |||
<configuration> | |||
<file>${basedir}/src/test/conf/archiva.xml</file> | |||
<properties> | |||
<xml fileName="${basedir}/src/test/conf/archiva.xml" | |||
config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
</components> |
@@ -21,10 +21,14 @@ | |||
<component-set> | |||
<components> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationStore</role> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultConfigurationStore</implementation> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<implementation>org.codehaus.plexus.registry.CommonsConfigurationRegistry</implementation> | |||
<role-hint>commons-configuration</role-hint> | |||
<configuration> | |||
<file>${basedir}/src/test/conf/archiva.xml</file> | |||
<properties> | |||
<xml fileName="${basedir}/src/test/conf/archiva.xml" | |||
config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
</components> |
@@ -76,7 +76,7 @@ | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-naming</artifactId> | |||
<version>1.0-alpha-2</version> | |||
<version>1.0-alpha-3-SNAPSHOT</version> | |||
<scope>runtime</scope> | |||
</dependency> | |||
<dependency> | |||
@@ -118,6 +118,7 @@ | |||
<additionalCoreArtifact>directory-naming:naming-core</additionalCoreArtifact> | |||
<additionalCoreArtifact>directory-naming:naming-factory</additionalCoreArtifact> | |||
<additionalCoreArtifact>directory-naming:naming-java</additionalCoreArtifact> | |||
<additionalCoreArtifact>directory-naming:naming-config</additionalCoreArtifact> | |||
<additionalCoreArtifact>javax.mail:mail</additionalCoreArtifact> | |||
<additionalCoreArtifact>javax.activation:activation</additionalCoreArtifact> | |||
</additionalCoreArtifacts> |
@@ -31,6 +31,15 @@ | |||
<implementation>org.codehaus.plexus.naming.DefaultNaming</implementation> | |||
<role-hint>dataSources</role-hint> | |||
<configuration> | |||
<!-- Example override: | |||
<environments> | |||
<environment> | |||
<name>org/apache/maven/archiva/indexPath</name> | |||
<value>${user.home}/.m2/my-index</value> | |||
<type>java.lang.String</type> | |||
</environment> | |||
</environments> | |||
--> | |||
<resources> | |||
<!-- | |||
Mail Session |
@@ -83,7 +83,7 @@ | |||
<plugin> | |||
<groupId>org.codehaus.modello</groupId> | |||
<artifactId>modello-maven-plugin</artifactId> | |||
<version>1.0-alpha-10</version> | |||
<version>1.0-alpha-14-SNAPSHOT</version> | |||
<executions> | |||
<execution> | |||
<goals> |
@@ -19,9 +19,8 @@ package org.apache.maven.archiva.web.action; | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; | |||
import org.apache.maven.artifact.repository.ArtifactRepository; | |||
import org.codehaus.plexus.xwork.action.PlexusActionSupport; | |||
@@ -37,12 +36,11 @@ public abstract class AbstractConfiguredAction | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
protected ArtifactRepository createLocalRepository() | |||
throws ConfigurationStoreException | |||
{ | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
return repositoryFactory.createLocalRepository( configuration ); | |||
} |
@@ -20,9 +20,8 @@ package org.apache.maven.archiva.web.action; | |||
*/ | |||
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.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; | |||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndex; | |||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory; | |||
@@ -62,7 +61,7 @@ public class BrowseAction | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
private List groups; | |||
@@ -81,7 +80,7 @@ public class BrowseAction | |||
private static long groupCacheTime; | |||
public String browse() | |||
throws ConfigurationStoreException, RepositoryIndexException, IOException | |||
throws RepositoryIndexException, IOException | |||
{ | |||
RepositoryArtifactIndex index = getIndex(); | |||
@@ -99,7 +98,7 @@ public class BrowseAction | |||
} | |||
public String browseGroup() | |||
throws ConfigurationStoreException, RepositoryIndexException, IOException, RepositoryIndexSearchException | |||
throws RepositoryIndexException, IOException, RepositoryIndexSearchException | |||
{ | |||
RepositoryArtifactIndex index = getIndex(); | |||
@@ -146,7 +145,7 @@ public class BrowseAction | |||
} | |||
public String browseArtifact() | |||
throws ConfigurationStoreException, RepositoryIndexException, IOException, RepositoryIndexSearchException | |||
throws RepositoryIndexException, IOException, RepositoryIndexSearchException | |||
{ | |||
RepositoryArtifactIndex index = getIndex(); | |||
@@ -245,9 +244,9 @@ public class BrowseAction | |||
} | |||
private RepositoryArtifactIndex getIndex() | |||
throws ConfigurationStoreException, RepositoryIndexException | |||
throws RepositoryIndexException | |||
{ | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
File indexPath = new File( configuration.getIndexPath() ); | |||
return factory.createStandardIndex( indexPath ); |
@@ -20,8 +20,8 @@ package org.apache.maven.archiva.web.action; | |||
*/ | |||
import com.opensymphony.xwork.Preparable; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; | |||
import org.apache.maven.archiva.configuration.RepositoryConfiguration; | |||
import org.apache.maven.archiva.discoverer.DiscovererException; | |||
@@ -58,7 +58,7 @@ public class ReportsAction | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement | |||
@@ -209,7 +209,7 @@ public class ReportsAction | |||
public void prepare() | |||
throws Exception | |||
{ | |||
configuration = configurationStore.getConfigurationFromStore(); | |||
configuration = archivaConfiguration.getConfiguration(); | |||
} | |||
public Configuration getConfiguration() |
@@ -23,9 +23,8 @@ import org.apache.lucene.index.Term; | |||
import org.apache.lucene.queryParser.MultiFieldQueryParser; | |||
import org.apache.lucene.queryParser.ParseException; | |||
import org.apache.lucene.search.TermQuery; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; | |||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndex; | |||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory; | |||
@@ -77,7 +76,7 @@ public class SearchAction | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
private static final String RESULTS = "results"; | |||
@@ -86,8 +85,7 @@ public class SearchAction | |||
private String infoMessage; | |||
public String quickSearch() | |||
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException, | |||
ConfigurationStoreException, ParseException | |||
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException, ParseException | |||
{ | |||
// TODO: give action message if indexing is in progress | |||
@@ -153,9 +151,9 @@ public class SearchAction | |||
} | |||
private RepositoryArtifactIndex getIndex() | |||
throws ConfigurationStoreException, RepositoryIndexException | |||
throws RepositoryIndexException | |||
{ | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
File indexPath = new File( configuration.getIndexPath() ); | |||
return factory.createStandardIndex( indexPath ); |
@@ -22,9 +22,8 @@ package org.apache.maven.archiva.web.action; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.lucene.index.Term; | |||
import org.apache.lucene.search.TermQuery; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; | |||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndex; | |||
import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory; | |||
@@ -91,7 +90,7 @@ public class ShowArtifactAction | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement | |||
@@ -134,8 +133,8 @@ public class ShowArtifactAction | |||
private List mailingLists; | |||
public String artifact() | |||
throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException, | |||
ResourceDoesNotExistException, ProxyException, ArtifactResolutionException | |||
throws IOException, XmlPullParserException, ProjectBuildingException, ResourceDoesNotExistException, | |||
ProxyException, ArtifactResolutionException | |||
{ | |||
if ( !checkParameters() ) | |||
{ | |||
@@ -150,7 +149,7 @@ public class ShowArtifactAction | |||
} | |||
public String dependencies() | |||
throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException | |||
throws IOException, XmlPullParserException, ProjectBuildingException | |||
{ | |||
if ( !checkParameters() ) | |||
{ | |||
@@ -168,7 +167,7 @@ public class ShowArtifactAction | |||
} | |||
public String mailingLists() | |||
throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException | |||
throws IOException, XmlPullParserException, ProjectBuildingException | |||
{ | |||
if ( !checkParameters() ) | |||
{ | |||
@@ -178,15 +177,15 @@ public class ShowArtifactAction | |||
MavenProject project = readProject(); | |||
model = project.getModel(); | |||
this.mailingLists = project.getMailingLists(); | |||
return SUCCESS; | |||
} | |||
public String dependees() | |||
throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException, | |||
RepositoryIndexException, RepositoryIndexSearchException | |||
throws IOException, XmlPullParserException, ProjectBuildingException, RepositoryIndexException, | |||
RepositoryIndexSearchException | |||
{ | |||
if ( !checkParameters() ) | |||
{ | |||
@@ -208,15 +207,14 @@ public class ShowArtifactAction | |||
} | |||
public String dependencyTree() | |||
throws ConfigurationStoreException, ProjectBuildingException, InvalidDependencyVersionException, | |||
ArtifactResolutionException | |||
throws ProjectBuildingException, InvalidDependencyVersionException, ArtifactResolutionException | |||
{ | |||
if ( !checkParameters() ) | |||
{ | |||
return ERROR; | |||
} | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
List repositories = repositoryFactory.createRepositories( configuration ); | |||
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); | |||
@@ -228,7 +226,7 @@ public class ShowArtifactAction | |||
getLogger().debug( " processing : " + groupId + ":" + artifactId + ":" + version ); | |||
DependencyTree dependencies = collectDependencies( project, artifact, localRepository, repositories ); | |||
DependencyTree dependencies = collectDependencies( project, localRepository ); | |||
this.dependencyTree = new ArrayList(); | |||
@@ -249,10 +247,8 @@ public class ShowArtifactAction | |||
} | |||
} | |||
private DependencyTree collectDependencies( MavenProject project, Artifact artifact, | |||
ArtifactRepository localRepository, List repositories ) | |||
throws ArtifactResolutionException, ProjectBuildingException, InvalidDependencyVersionException, | |||
ConfigurationStoreException | |||
private DependencyTree collectDependencies( MavenProject project, ArtifactRepository localRepository ) | |||
throws ArtifactResolutionException, ProjectBuildingException, InvalidDependencyVersionException | |||
{ | |||
try | |||
{ | |||
@@ -272,18 +268,18 @@ public class ShowArtifactAction | |||
} | |||
private RepositoryArtifactIndex getIndex() | |||
throws ConfigurationStoreException, RepositoryIndexException | |||
throws RepositoryIndexException | |||
{ | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
File indexPath = new File( configuration.getIndexPath() ); | |||
return factory.createStandardIndex( indexPath ); | |||
} | |||
private MavenProject readProject() | |||
throws ConfigurationStoreException, ProjectBuildingException | |||
throws ProjectBuildingException | |||
{ | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
List repositories = repositoryFactory.createRepositories( configuration ); | |||
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); | |||
@@ -466,7 +462,7 @@ public class ShowArtifactAction | |||
return false; | |||
} | |||
if ( getQualifier() != null ? !getQualifier().equals( that.getQualifier() ) | |||
: that.getQualifier() != null ) | |||
: that.getQualifier() != null ) | |||
{ | |||
return false; | |||
} |
@@ -22,14 +22,13 @@ package org.apache.maven.archiva.web.action.admin; | |||
import com.opensymphony.xwork.ModelDriven; | |||
import com.opensymphony.xwork.Preparable; | |||
import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationChangeException; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.InvalidConfigurationException; | |||
import org.apache.maven.archiva.security.ArchivaRoleConstants; | |||
import org.codehaus.plexus.rbac.profile.RoleProfileException; | |||
import org.codehaus.plexus.rbac.profile.RoleProfileManager; | |||
import org.codehaus.plexus.registry.RegistryException; | |||
import org.codehaus.plexus.security.rbac.RbacManagerException; | |||
import org.codehaus.plexus.security.rbac.Resource; | |||
import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; | |||
@@ -51,7 +50,7 @@ public abstract class AbstractConfigureRepositoryAction | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement role-hint="archiva" | |||
@@ -74,8 +73,7 @@ public abstract class AbstractConfigureRepositoryAction | |||
protected Configuration configuration; | |||
public String add() | |||
throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException, | |||
RbacManagerException, RoleProfileException | |||
throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, RegistryException | |||
{ | |||
// TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded | |||
@@ -90,8 +88,7 @@ public abstract class AbstractConfigureRepositoryAction | |||
} | |||
public String edit() | |||
throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException, | |||
RbacManagerException, RoleProfileException | |||
throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, RegistryException | |||
{ | |||
// TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded | |||
@@ -106,12 +103,11 @@ public abstract class AbstractConfigureRepositoryAction | |||
protected abstract AbstractRepositoryConfiguration getRepository( String id ); | |||
private String saveConfiguration() | |||
throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException, | |||
RbacManagerException, RoleProfileException | |||
throws IOException, InvalidConfigurationException, RbacManagerException, RoleProfileException, RegistryException | |||
{ | |||
addRepository(); | |||
configurationStore.storeConfiguration( configuration ); | |||
archivaConfiguration.save( configuration ); | |||
// TODO: do we need to check if indexing is needed? | |||
@@ -136,9 +132,8 @@ public abstract class AbstractConfigureRepositoryAction | |||
protected abstract AbstractRepositoryConfiguration createRepository(); | |||
public void prepare() | |||
throws ConfigurationStoreException | |||
{ | |||
configuration = configurationStore.getConfigurationFromStore(); | |||
configuration = archivaConfiguration.getConfiguration(); | |||
if ( repository == null ) | |||
{ |
@@ -20,13 +20,12 @@ package org.apache.maven.archiva.web.action.admin; | |||
*/ | |||
import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationChangeException; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.InvalidConfigurationException; | |||
import org.apache.maven.archiva.security.ArchivaRoleConstants; | |||
import org.codehaus.plexus.rbac.profile.RoleProfileManager; | |||
import org.codehaus.plexus.registry.RegistryException; | |||
import org.codehaus.plexus.security.rbac.Resource; | |||
import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; | |||
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; | |||
@@ -47,7 +46,7 @@ public abstract class AbstractDeleteRepositoryAction | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* The repository ID to lookup when editing a repository. | |||
@@ -65,13 +64,13 @@ public abstract class AbstractDeleteRepositoryAction | |||
protected RoleProfileManager roleProfileManager; | |||
public String execute() | |||
throws ConfigurationStoreException, IOException, InvalidConfigurationException, ConfigurationChangeException | |||
throws IOException, InvalidConfigurationException, RegistryException | |||
{ | |||
// TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded | |||
if ( "delete-entry".equals( operation ) || "delete-contents".equals( operation ) ) | |||
{ | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
AbstractRepositoryConfiguration existingRepository = getRepository( configuration ); | |||
if ( existingRepository == null ) | |||
@@ -84,7 +83,7 @@ public abstract class AbstractDeleteRepositoryAction | |||
removeRepository( configuration, existingRepository ); | |||
configurationStore.storeConfiguration( configuration ); | |||
archivaConfiguration.save( configuration ); | |||
if ( "delete-contents".equals( operation ) ) | |||
{ |
@@ -22,15 +22,14 @@ 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.ConfigurationChangeException; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.InvalidConfigurationException; | |||
import org.apache.maven.archiva.indexer.RepositoryIndexException; | |||
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException; | |||
import org.apache.maven.archiva.scheduler.executors.IndexerTaskExecutor; | |||
import org.apache.maven.archiva.security.ArchivaRoleConstants; | |||
import org.codehaus.plexus.registry.RegistryException; | |||
import org.codehaus.plexus.scheduler.CronExpressionValidator; | |||
import org.codehaus.plexus.security.rbac.Resource; | |||
import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; | |||
@@ -54,7 +53,7 @@ public class ConfigureAction | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" role-hint="indexer" | |||
@@ -96,8 +95,8 @@ public class ConfigureAction | |||
} | |||
public String execute() | |||
throws IOException, RepositoryIndexException, RepositoryIndexSearchException, ConfigurationStoreException, | |||
InvalidConfigurationException, ConfigurationChangeException | |||
throws IOException, RepositoryIndexException, RepositoryIndexSearchException, InvalidConfigurationException, | |||
RegistryException | |||
{ | |||
// 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? | |||
@@ -115,7 +114,7 @@ public class ConfigureAction | |||
// Just double checking that our validation routines line up with what is expected in the configuration | |||
assert configuration.isValid(); | |||
configurationStore.storeConfiguration( configuration ); | |||
archivaConfiguration.save( configuration ); | |||
// TODO: if the repository has changed, we need to check if indexing is needed! | |||
@@ -176,9 +175,8 @@ public class ConfigureAction | |||
} | |||
public void prepare() | |||
throws ConfigurationStoreException | |||
{ | |||
configuration = configurationStore.getConfigurationFromStore(); | |||
configuration = archivaConfiguration.getConfiguration(); | |||
} | |||
public String getLastIndexingTime() |
@@ -80,8 +80,7 @@ public class ConfigureAppearanceAction | |||
} | |||
public void prepare() | |||
throws ConfigurationStoreException, ProjectBuildingException, ArtifactMetadataRetrievalException, | |||
org.apache.maven.archiva.configuration.ConfigurationStoreException | |||
throws ConfigurationStoreException, ProjectBuildingException, ArtifactMetadataRetrievalException | |||
{ | |||
configuration = appConfigurationStore.getConfigurationFromStore(); | |||
@@ -70,7 +70,7 @@ public class EditPomAction | |||
public String execute() | |||
throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException, | |||
ArtifactInstallationException, org.apache.maven.archiva.configuration.ConfigurationStoreException | |||
ArtifactInstallationException | |||
{ | |||
// TODO: hack for passed in String[] | |||
String[] logo = (String[]) companyModel.getProperties().get( "organization.logo" ); | |||
@@ -90,8 +90,7 @@ public class EditPomAction | |||
} | |||
public void prepare() | |||
throws ConfigurationStoreException, ProjectBuildingException, ArtifactMetadataRetrievalException, | |||
org.apache.maven.archiva.configuration.ConfigurationStoreException | |||
throws ConfigurationStoreException, ProjectBuildingException, ArtifactMetadataRetrievalException | |||
{ | |||
configuration = appConfigurationStore.getConfigurationFromStore(); | |||
@@ -19,8 +19,8 @@ package org.apache.maven.archiva.web.check; | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.RepositoryConfiguration; | |||
import org.codehaus.plexus.logging.AbstractLogEnabled; | |||
import org.codehaus.plexus.rbac.profile.RoleProfileException; | |||
@@ -49,14 +49,14 @@ public class RoleExistanceEnvironmentCheck | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement role-hint="archiva" | |||
*/ | |||
private RoleProfileManager roleProfileManager; | |||
private boolean checked = false; | |||
private boolean checked; | |||
public void validateEnvironment( List list ) | |||
{ | |||
@@ -65,9 +65,10 @@ public class RoleExistanceEnvironmentCheck | |||
try | |||
{ | |||
// check if there is potential for role/repo disconnect | |||
if ( configurationStore.getConfigurationFromStore().isValid() ) | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
if ( configuration.isValid() ) | |||
{ | |||
List repos = configurationStore.getConfigurationFromStore().getRepositories(); | |||
List repos = configuration.getRepositories(); | |||
for ( Iterator i = repos.iterator(); i.hasNext(); ) | |||
{ | |||
@@ -79,11 +80,6 @@ public class RoleExistanceEnvironmentCheck | |||
} | |||
} | |||
} | |||
catch ( ConfigurationStoreException cse ) | |||
{ | |||
list.add( this.getClass().getName() + " error loading configuration store: " + cse.getMessage() ); | |||
getLogger().info( "error loading configuration store", cse ); | |||
} | |||
catch ( RoleProfileException rpe ) | |||
{ | |||
list.add( this.getClass().getName() + "error initializing roles: " + rpe.getMessage() ); |
@@ -21,8 +21,8 @@ package org.apache.maven.archiva.web.interceptor; | |||
import com.opensymphony.xwork.ActionInvocation; | |||
import com.opensymphony.xwork.interceptor.Interceptor; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.codehaus.plexus.logging.AbstractLogEnabled; | |||
/** | |||
@@ -39,7 +39,7 @@ public class ConfigurationInterceptor | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @param actionInvocation | |||
@@ -49,7 +49,7 @@ public class ConfigurationInterceptor | |||
public String intercept( ActionInvocation actionInvocation ) | |||
throws Exception | |||
{ | |||
Configuration configuration = configurationStore.getConfigurationFromStore(); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
if ( !configuration.isValid() ) | |||
{ |
@@ -20,9 +20,8 @@ package org.apache.maven.archiva.web.repository; | |||
*/ | |||
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.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; | |||
import org.apache.maven.archiva.configuration.ProxiedRepositoryConfiguration; | |||
import org.apache.maven.archiva.configuration.Proxy; | |||
@@ -38,25 +37,23 @@ import org.codehaus.plexus.webdav.DavServerException; | |||
import org.codehaus.plexus.webdav.servlet.DavServerRequest; | |||
import org.codehaus.plexus.webdav.util.WebdavMethodUtil; | |||
import javax.servlet.ServletConfig; | |||
import javax.servlet.ServletException; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import javax.servlet.ServletConfig; | |||
import javax.servlet.ServletException; | |||
import javax.servlet.http.HttpServletResponse; | |||
/** | |||
* ProxiedDavServer | |||
* ProxiedDavServer | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="org.codehaus.plexus.webdav.DavServerComponent" | |||
* role-hint="proxied" | |||
* instantiation-strategy="per-lookup" | |||
* @plexus.component role="org.codehaus.plexus.webdav.DavServerComponent" | |||
* role-hint="proxied" | |||
* instantiation-strategy="per-lookup" | |||
*/ | |||
public class ProxiedDavServer | |||
extends AbstractDavServerComponent | |||
@@ -69,7 +66,7 @@ public class ProxiedDavServer | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationStore configurationStore; | |||
private ArchivaConfiguration archivaConfiguration; | |||
/** | |||
* @plexus.requirement role="org.apache.maven.archiva.proxy.ProxyRequestHandler" | |||
@@ -117,30 +114,23 @@ public class ProxiedDavServer | |||
proxiedRepositories = new ArrayList(); | |||
try | |||
{ | |||
Configuration config = configurationStore.getConfigurationFromStore(); | |||
Configuration config = archivaConfiguration.getConfiguration(); | |||
wagonProxy = createWagonProxy( config.getProxy() ); | |||
wagonProxy = createWagonProxy( config.getProxy() ); | |||
repositoryConfiguration = config.getRepositoryByUrlName( getPrefix() ); | |||
repositoryConfiguration = config.getRepositoryByUrlName( getPrefix() ); | |||
managedRepository = repositoryFactory.createRepository( repositoryConfiguration ); | |||
managedRepository = repositoryFactory.createRepository( repositoryConfiguration ); | |||
for ( Iterator i = config.getProxiedRepositories().iterator(); i.hasNext(); ) | |||
{ | |||
ProxiedRepositoryConfiguration proxiedRepoConfig = (ProxiedRepositoryConfiguration) i.next(); | |||
for ( Iterator i = config.getProxiedRepositories().iterator(); i.hasNext(); ) | |||
{ | |||
ProxiedRepositoryConfiguration proxiedRepoConfig = (ProxiedRepositoryConfiguration) i.next(); | |||
if ( proxiedRepoConfig.getManagedRepository().equals( repositoryConfiguration.getId() ) ) | |||
{ | |||
proxiedRepositories.add( repositoryFactory.createProxiedRepository( proxiedRepoConfig ) ); | |||
} | |||
if ( proxiedRepoConfig.getManagedRepository().equals( repositoryConfiguration.getId() ) ) | |||
{ | |||
proxiedRepositories.add( repositoryFactory.createProxiedRepository( proxiedRepoConfig ) ); | |||
} | |||
} | |||
catch ( ConfigurationStoreException e ) | |||
{ | |||
throw new DavServerException( "Unable to obtain configuration.", e ); | |||
} | |||
} | |||
public void process( DavServerRequest request, HttpServletResponse response ) |
@@ -19,14 +19,12 @@ package org.apache.maven.archiva.web.repository; | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ConfigurationChangeException; | |||
import org.apache.maven.archiva.configuration.ConfigurationChangeListener; | |||
import org.apache.maven.archiva.configuration.ConfigurationStore; | |||
import org.apache.maven.archiva.configuration.ConfigurationStoreException; | |||
import org.apache.maven.archiva.configuration.InvalidConfigurationException; | |||
import org.apache.maven.archiva.configuration.RepositoryConfiguration; | |||
import org.apache.maven.archiva.security.ArchivaRoleConstants; | |||
import org.codehaus.plexus.registry.Registry; | |||
import org.codehaus.plexus.registry.RegistryListener; | |||
import org.codehaus.plexus.security.authentication.AuthenticationException; | |||
import org.codehaus.plexus.security.authentication.AuthenticationResult; | |||
import org.codehaus.plexus.security.authorization.AuthorizationException; | |||
@@ -42,25 +40,24 @@ import org.codehaus.plexus.webdav.servlet.DavServerRequest; | |||
import org.codehaus.plexus.webdav.servlet.multiplexed.MultiplexedWebDavServlet; | |||
import org.codehaus.plexus.webdav.util.WebdavMethodUtil; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import javax.servlet.ServletConfig; | |||
import javax.servlet.ServletException; | |||
import javax.servlet.http.HttpServletRequest; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
/** | |||
* RepositoryServlet | |||
* RepositoryServlet | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
*/ | |||
public class RepositoryServlet | |||
extends MultiplexedWebDavServlet | |||
implements ConfigurationChangeListener | |||
implements RegistryListener | |||
{ | |||
/** | |||
* @plexus.requirement | |||
@@ -77,49 +74,42 @@ public class RepositoryServlet | |||
*/ | |||
private AuditLog audit; | |||
private Configuration config; | |||
private Configuration configuration; | |||
private ArchivaConfiguration archivaConfiguration; | |||
public void initComponents() | |||
throws ServletException | |||
{ | |||
super.initComponents(); | |||
ConfigurationStore configurationStore; | |||
configurationStore = (ConfigurationStore) lookup( ConfigurationStore.ROLE ); | |||
securitySystem = (SecuritySystem) lookup( SecuritySystem.ROLE ); | |||
httpAuth = (HttpAuthenticator) lookup( HttpAuthenticator.ROLE, "basic" ); | |||
audit = (AuditLog) lookup( AuditLog.ROLE ); | |||
try | |||
{ | |||
config = configurationStore.getConfigurationFromStore(); | |||
configurationStore.addChangeListener( this ); | |||
} | |||
catch ( ConfigurationStoreException e ) | |||
{ | |||
throw new ServletException( "Unable to obtain configuration.", e ); | |||
} | |||
archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() ); | |||
configuration = archivaConfiguration.getConfiguration(); | |||
archivaConfiguration.addChangeListener( this ); | |||
} | |||
public void initServers( ServletConfig servletConfig ) | |||
throws DavServerException | |||
{ | |||
List repositories = config.getRepositories(); | |||
List repositories = configuration.getRepositories(); | |||
Iterator itrepos = repositories.iterator(); | |||
while ( itrepos.hasNext() ) | |||
{ | |||
RepositoryConfiguration repoConfig = (RepositoryConfiguration) itrepos.next(); | |||
DavServerComponent server = createServer( repoConfig.getUrlName(), new File( repoConfig.getDirectory() ), | |||
servletConfig ); | |||
DavServerComponent server = | |||
createServer( repoConfig.getUrlName(), new File( repoConfig.getDirectory() ), servletConfig ); | |||
server.addListener( audit ); | |||
} | |||
} | |||
public RepositoryConfiguration getRepositoryConfiguration( DavServerRequest request ) | |||
{ | |||
return config.getRepositoryByUrlName( request.getPrefix() ); | |||
return configuration.getRepositoryByUrlName( request.getPrefix() ); | |||
} | |||
public String getRepositoryName( DavServerRequest request ) | |||
@@ -189,16 +179,16 @@ public class RepositoryServlet | |||
permission = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD; | |||
} | |||
AuthorizationResult authzResult = securitySystem.authorize( securitySession, permission, | |||
getRepositoryConfiguration( davRequest ) | |||
.getId() ); | |||
AuthorizationResult authzResult = | |||
securitySystem.authorize( securitySession, permission, getRepositoryConfiguration( davRequest ) | |||
.getId() ); | |||
if ( !authzResult.isAuthorized() ) | |||
{ | |||
if ( authzResult.getException() != null ) | |||
{ | |||
log( "Authorization Denied [ip=" + request.getRemoteAddr() + ",isWriteRequest=" + isWriteRequest | |||
+ ",permission=" + permission + "] : " + authzResult.getException().getMessage() ); | |||
log( "Authorization Denied [ip=" + request.getRemoteAddr() + ",isWriteRequest=" + isWriteRequest + | |||
",permission=" + permission + "] : " + authzResult.getException().getMessage() ); | |||
} | |||
// Issue HTTP Challenge. | |||
@@ -214,11 +204,10 @@ public class RepositoryServlet | |||
return true; | |||
} | |||
public void notifyOfConfigurationChange( Configuration newConfiguration ) | |||
throws InvalidConfigurationException, ConfigurationChangeException | |||
public void notifyOfConfigurationChange( Registry registry ) | |||
{ | |||
config = newConfiguration; | |||
configuration = archivaConfiguration.getConfiguration(); | |||
getDavManager().removeAllServers(); | |||
@@ -228,7 +217,7 @@ public class RepositoryServlet | |||
} | |||
catch ( DavServerException e ) | |||
{ | |||
throw new ConfigurationChangeException( "Unable to process configuration change.", e ); | |||
log( "Error restarting WebDAV server after configuration change - service disabled: " + e.getMessage(), e ); | |||
} | |||
} | |||
} |
@@ -22,14 +22,27 @@ | |||
<components> | |||
<component> | |||
<role>org.codehaus.plexus.security.configuration.UserConfiguration</role> | |||
<implementation>org.codehaus.plexus.security.configuration.UserConfiguration</implementation> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<implementation>org.codehaus.plexus.registry.CommonsConfigurationRegistry</implementation> | |||
<role-hint>commons-configuration</role-hint> | |||
<configuration> | |||
<configs> | |||
<config>${user.home}/.m2/security.properties</config> | |||
<config>${user.home}/.m2/archiva.properties</config> | |||
<config>/org/apache/maven/archiva/security.properties</config> | |||
</configs> | |||
<properties> | |||
<system/> | |||
<jndi prefix="java:comp/env" config-optional="true"/> | |||
<xml fileName="${user.home}/.m2/archiva.xml" config-optional="true" config-name="org.apache.maven.archiva" | |||
config-at="org.apache.maven.archiva" config-forceCreate="true"/> | |||
<xml fileName="${user.home}/.m2/shared.xml" config-optional="true"/> | |||
<properties fileName="${user.home}/.m2/security.properties" config-optional="true" | |||
config-at="org.codehaus.plexus.security"/> | |||
<properties fileName="${user.home}/.m2/archiva.properties" config-optional="true" | |||
config-at="org.codehaus.plexus.security"/> | |||
<xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true" | |||
config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${appserver.base}/conf/common.xml" config-optional="true"/> | |||
<xml fileName="${appserver.home}/conf/archiva.xml" config-optional="true" | |||
config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${appserver.home}/conf/common.xml" config-optional="true"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
@@ -40,7 +53,7 @@ | |||
<jndiSessionName>java:comp/env/mail/Session</jndiSessionName> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.webdav.DavServerManager</role> | |||
<role-hint>default</role-hint> |