git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@562474 13f79535-47bb-0310-9956-ffa450edef68tags/1.0-beta-1
@@ -27,8 +27,8 @@ import org.codehaus.plexus.registry.RegistryListener; | |||
*/ | |||
public interface ArchivaConfiguration | |||
{ | |||
public static final String ROLE = ArchivaConfiguration.class.getName(); | |||
String ROLE = ArchivaConfiguration.class.getName(); | |||
/** | |||
* Get the configuration. | |||
* | |||
@@ -42,9 +42,11 @@ public interface ArchivaConfiguration | |||
* @param configuration the configuration to save | |||
* @throws org.codehaus.plexus.registry.RegistryException | |||
* if there is a problem saving the registry data | |||
* @throws IndeterminateConfigurationException | |||
* if the configuration cannot be saved because it was read from two sources | |||
*/ | |||
void save( Configuration configuration ) | |||
throws RegistryException; | |||
throws RegistryException, IndeterminateConfigurationException; | |||
/** | |||
* Add a change listener so that registry changes are propogated. | |||
@@ -52,6 +54,5 @@ public interface ArchivaConfiguration | |||
* @param listener the listener | |||
*/ | |||
void addChangeListener( RegistryListener listener ); | |||
} | |||
@@ -0,0 +1,32 @@ | |||
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. | |||
*/ | |||
/** | |||
* Unrecoverable exception in the configuration mechanism that is the result of a programming error. | |||
*/ | |||
public class ConfigurationRuntimeException | |||
extends RuntimeException | |||
{ | |||
public ConfigurationRuntimeException( String msg, Throwable cause ) | |||
{ | |||
super( msg, cause ); | |||
} | |||
} |
@@ -1,156 +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.FileUtils; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.commons.lang.math.NumberUtils; | |||
import org.apache.maven.archiva.xml.XMLException; | |||
import org.apache.maven.archiva.xml.XMLReader; | |||
import org.codehaus.plexus.logging.AbstractLogEnabled; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.io.FileWriter; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.net.URL; | |||
/** | |||
* A component that is first in the plexus startup that ensure that the configuration | |||
* file format has been upgraded properly. | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="org.apache.maven.archiva.configuration.ConfigurationUpgrade" | |||
*/ | |||
public class ConfigurationUpgrade | |||
extends AbstractLogEnabled | |||
{ | |||
public static final int CURRENT_CONFIG_VERSION = 1; | |||
private boolean performed = false; | |||
/** | |||
* Perform the upgrade (if needed). | |||
* | |||
* NOTE: This component should *NOT USE* the configuration api to do it's upgrade | |||
*/ | |||
public void performUpgrade() | |||
{ | |||
performed = true; | |||
File userConfigFile = new File( System.getProperty( "user.home" ), ".m2/archiva.xml" ); | |||
if ( !userConfigFile.exists() ) | |||
{ | |||
writeDefaultConfigFile( userConfigFile ); | |||
return; | |||
} | |||
boolean configOk = false; | |||
try | |||
{ | |||
XMLReader xml = new XMLReader( "configuration", userConfigFile ); | |||
String configVersion = xml.getElementText( "//configuration/version" ); | |||
if ( StringUtils.isNotBlank( configVersion ) ) | |||
{ | |||
configOk = true; | |||
// Found an embedded configuration version. | |||
int version = NumberUtils.toInt( configVersion, 0 ); | |||
if ( version < CURRENT_CONFIG_VERSION ) | |||
{ | |||
upgradeVersion( userConfigFile, xml ); | |||
} | |||
} | |||
} | |||
catch ( XMLException e ) | |||
{ | |||
getLogger().warn( "Unable to read user configuration XML: " + e.getMessage(), e ); | |||
return; | |||
} | |||
if ( !configOk ) | |||
{ | |||
try | |||
{ | |||
FileUtils.copyFile( userConfigFile, new File( userConfigFile.getAbsolutePath() + ".bak" ) ); | |||
writeDefaultConfigFile( userConfigFile ); | |||
return; | |||
} | |||
catch ( IOException e ) | |||
{ | |||
getLogger().warn( "Unable to create backup of your configuration file: " + e.getMessage(), e ); | |||
} | |||
} | |||
return; | |||
} | |||
private void upgradeVersion( File userConfigFile, XMLReader xml ) | |||
{ | |||
// TODO: write implementation when we have a current version greater than 1. | |||
} | |||
private void writeDefaultConfigFile( File userConfigFile ) | |||
{ | |||
URL defaultConfigURL = this.getClass() | |||
.getResource( "/org/apache/maven/archiva/configuration/default-archiva.xml" ); | |||
if ( defaultConfigURL == null ) | |||
{ | |||
try | |||
{ | |||
FileWriter writer = new FileWriter( userConfigFile ); | |||
writer.write( "<?xml version=\"1.0\"?>\n" ); | |||
writer.write( "<configuration />" ); | |||
writer.flush(); | |||
writer.close(); | |||
return; | |||
} | |||
catch ( IOException e ) | |||
{ | |||
getLogger().warn( "Unable to write default (generic) configuration file: " + e.getMessage(), e ); | |||
} | |||
} | |||
// Write default to user config file location. | |||
try | |||
{ | |||
FileOutputStream output = new FileOutputStream( userConfigFile ); | |||
InputStream input = defaultConfigURL.openStream(); | |||
IOUtils.copy( input, output ); | |||
output.flush(); | |||
input.close(); | |||
output.close(); | |||
} | |||
catch ( IOException e ) | |||
{ | |||
getLogger().warn( "Unable to write default configuration file: " + e.getMessage(), e ); | |||
} | |||
} | |||
public boolean hasPerformed() | |||
{ | |||
return this.performed; | |||
} | |||
} |
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.configuration; | |||
* under the License. | |||
*/ | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryReader; | |||
import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryWriter; | |||
import org.codehaus.plexus.logging.AbstractLogEnabled; | |||
@@ -30,10 +31,27 @@ import org.codehaus.plexus.registry.RegistryListener; | |||
import org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry; | |||
import org.codehaus.plexus.util.StringUtils; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Iterator; | |||
/** | |||
* Implementation of configuration holder that retrieves it from the registry. | |||
* <p/> | |||
* The registry layers and merges the 2 configuration files: user, and application server. | |||
* <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/> | |||
* 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/> | |||
* If the configuration is outdated, it will be upgraded when it is loaded. This is done by checking the version flag | |||
* before reading it from the registry. | |||
* | |||
* @plexus.component role="org.apache.maven.archiva.configuration.ArchivaConfiguration" | |||
*/ | |||
@@ -48,11 +66,6 @@ public class DefaultArchivaConfiguration | |||
*/ | |||
private Registry registry; | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ConfigurationUpgrade upgrader; | |||
/** | |||
* The configuration that has been converted. | |||
*/ | |||
@@ -60,6 +73,16 @@ public class DefaultArchivaConfiguration | |||
private static final String KEY = "org.apache.maven.archiva"; | |||
/** | |||
* @plexus.configuration default-value="${user.home}/.m2/archiva.xml" | |||
*/ | |||
private String userConfigFilename; | |||
public String getFilteredUserConfigFilename() | |||
{ | |||
return StringUtils.replace( userConfigFilename, "${user.home}", System.getProperty( "user.home" + "" ) ); | |||
} | |||
public synchronized Configuration getConfiguration() | |||
{ | |||
if ( configuration == null ) | |||
@@ -71,26 +94,19 @@ public class DefaultArchivaConfiguration | |||
private Configuration load() | |||
{ | |||
if ( !upgrader.hasPerformed() ) | |||
// TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties) | |||
Registry subset = registry.getSubset( KEY ); | |||
if ( subset.getString( "version" ) == null ) | |||
{ | |||
upgrader.performUpgrade(); | |||
// HACK: This would be so much easier with a registry.reload() method. | |||
if ( registry instanceof CommonsConfigurationRegistry ) | |||
// a little autodetection of v1, even if version is omitted (this was previously allowed) | |||
if ( subset.getSubset( "repositoryScanning" ).isEmpty() ) | |||
{ | |||
try | |||
{ | |||
( (CommonsConfigurationRegistry) registry ).initialize(); | |||
} | |||
catch ( InitializationException e ) | |||
{ | |||
getLogger().error( "Unable to reinitialize the registry: " + e.getMessage(), e ); | |||
} | |||
// only for empty, or v < 1 | |||
subset = readDefaultConfiguration(); | |||
} | |||
} | |||
// TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties) | |||
Configuration config = new ConfigurationRegistryReader().read( registry.getSubset( KEY ) ); | |||
Configuration config = new ConfigurationRegistryReader().read( subset ); | |||
// TODO: for commons-configuration 1.3 only | |||
for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); ) | |||
@@ -98,24 +114,76 @@ public class DefaultArchivaConfiguration | |||
RepositoryConfiguration c = (RepositoryConfiguration) i.next(); | |||
c.setUrl( removeExpressions( c.getUrl() ) ); | |||
} | |||
return config; | |||
} | |||
private Registry readDefaultConfiguration() | |||
{ | |||
// if it contains some old configuration, remove it (Archiva 0.9) | |||
registry.removeSubset( KEY ); | |||
try | |||
{ | |||
registry.addConfigurationFromResource( "org/apache/maven/archiva/configuration/default-archiva.xml", KEY ); | |||
} | |||
catch ( RegistryException e ) | |||
{ | |||
throw new ConfigurationRuntimeException( | |||
"Fatal error: Unable to find the built-in default configuration and load it into the registry", e ); | |||
} | |||
return registry.getSubset( KEY ); | |||
} | |||
public void save( Configuration configuration ) | |||
throws RegistryException | |||
throws RegistryException, IndeterminateConfigurationException | |||
{ | |||
Registry section = registry.getSection( KEY + ".user" ); | |||
if ( section == null ) | |||
{ | |||
section = registry.getSection( KEY + ".base" ); | |||
if ( section == null ) | |||
{ | |||
section = createDefaultConfigurationFile(); | |||
} | |||
} | |||
else if ( registry.getSection( KEY + ".base" ) != null ) | |||
{ | |||
throw new IndeterminateConfigurationException( | |||
"Configuration can not be saved when it is loaded from two sources" ); | |||
} | |||
new ConfigurationRegistryWriter().write( configuration, section ); | |||
section.save(); | |||
this.configuration = configuration; | |||
} | |||
private Registry createDefaultConfigurationFile() | |||
throws RegistryException | |||
{ | |||
// TODO: may not be needed under commons-configuration 1.4 - check | |||
File file = new File( getFilteredUserConfigFilename() ); | |||
try | |||
{ | |||
FileUtils.writeStringToFile( file, "<configuration/>", "UTF-8" ); | |||
} | |||
catch ( IOException e ) | |||
{ | |||
throw new RegistryException( "Unable to create configuration file: " + e.getMessage(), e ); | |||
} | |||
try | |||
{ | |||
( (CommonsConfigurationRegistry) registry ).initialize(); | |||
} | |||
catch ( InitializationException e ) | |||
{ | |||
throw new RegistryException( "Unable to reinitialize configuration: " + e.getMessage(), e ); | |||
} | |||
return registry.getSection( KEY + ".user" ); | |||
} | |||
public void addChangeListener( RegistryListener listener ) | |||
{ | |||
Registry section = registry.getSection( KEY + ".user" ); | |||
@@ -148,10 +216,10 @@ public class DefaultArchivaConfiguration | |||
private String removeExpressions( String directory ) | |||
{ | |||
String value = StringUtils.replace( directory, "${appserver.base}", registry.getString( "appserver.base", | |||
"${appserver.base}" ) ); | |||
value = StringUtils.replace( value, "${appserver.home}", registry.getString( "appserver.home", | |||
"${appserver.home}" ) ); | |||
String value = StringUtils.replace( directory, "${appserver.base}", | |||
registry.getString( "appserver.base", "${appserver.base}" ) ); | |||
value = StringUtils.replace( value, "${appserver.home}", | |||
registry.getString( "appserver.home", "${appserver.home}" ) ); | |||
return value; | |||
} | |||
@@ -0,0 +1,32 @@ | |||
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. | |||
*/ | |||
/** | |||
* Occurs when the configuration is stored in two locations and the save location can not be determined. | |||
*/ | |||
public class IndeterminateConfigurationException | |||
extends Exception | |||
{ | |||
public IndeterminateConfigurationException( String message ) | |||
{ | |||
super( message ); | |||
} | |||
} |
@@ -0,0 +1,189 @@ | |||
<?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. | |||
--> | |||
<configuration> | |||
<repositories> | |||
<repository> | |||
<id>internal</id> | |||
<name>Archiva Managed Internal Repository</name> | |||
<url>file://${appserver.base}/repositories/internal</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0 * * ?</refreshCronExpression> | |||
</repository> | |||
<repository> | |||
<id>snapshots</id> | |||
<name>Archiva Managed Snapshot Repository</name> | |||
<url>file://${appserver.base}/repositories/internal</url> | |||
<layout>default</layout> | |||
<releases>false</releases> | |||
<snapshots>true</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0,30 * * ?</refreshCronExpression> | |||
</repository> | |||
<repository> | |||
<id>central</id> | |||
<name>Central Repository</name> | |||
<url>http://repo1.maven.org/maven2</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>false</indexed> | |||
</repository> | |||
<repository> | |||
<id>maven2-repository.dev.java.net</id> | |||
<name>Java.net Repository for Maven 2</name> | |||
<url>https://maven2-repository.dev.java.net/nonav/repository</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>false</indexed> | |||
</repository> | |||
</repositories> | |||
<proxyConnectors> | |||
<proxyConnector> | |||
<sourceRepoId>internal</sourceRepoId> | |||
<targetRepoId>central</targetRepoId> | |||
<proxyId/> | |||
<snapshotsPolicy>disabled</snapshotsPolicy> | |||
<releasePolicy>never</releasePolicy> | |||
<failurePolicy>not-found</failurePolicy> | |||
</proxyConnector> | |||
<proxyConnector> | |||
<sourceRepoId>internal</sourceRepoId> | |||
<targetRepoId>maven2-repository.dev.java.net</targetRepoId> | |||
<proxyId/> | |||
<snapshotsPolicy>disabled</snapshotsPolicy> | |||
<releasePolicy>never</releasePolicy> | |||
<failurePolicy>not-found</failurePolicy> | |||
<whiteListPatterns> | |||
<whiteListPattern>javax/**</whiteListPattern> | |||
</whiteListPatterns> | |||
</proxyConnector> | |||
</proxyConnectors> | |||
<networkProxies> | |||
<networkProxy> | |||
<id>example</id> | |||
<protocol>http</protocol> | |||
<host>proxy.mycompany.com</host> | |||
<port>8080</port> | |||
<username>myself</username> | |||
<password>mypass</password> | |||
</networkProxy> | |||
</networkProxies> | |||
<repositoryScanning> | |||
<fileTypes> | |||
<fileType> | |||
<id>artifacts</id> | |||
<patterns> | |||
<pattern>**/*.pom</pattern> | |||
<pattern>**/*.jar</pattern> | |||
<pattern>**/*.ear</pattern> | |||
<pattern>**/*.war</pattern> | |||
<pattern>**/*.car</pattern> | |||
<pattern>**/*.sar</pattern> | |||
<pattern>**/*.mar</pattern> | |||
<pattern>**/*.rar</pattern> | |||
<pattern>**/*.dtd</pattern> | |||
<pattern>**/*.tld</pattern> | |||
<pattern>**/*.tar.gz</pattern> | |||
<pattern>**/*.tar.bz2</pattern> | |||
<pattern>**/*.zip</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>indexable-content</id> | |||
<patterns> | |||
<pattern>**/*.txt</pattern> | |||
<pattern>**/*.TXT</pattern> | |||
<pattern>**/*.block</pattern> | |||
<pattern>**/*.config</pattern> | |||
<pattern>**/*.pom</pattern> | |||
<pattern>**/*.xml</pattern> | |||
<pattern>**/*.xsd</pattern> | |||
<pattern>**/*.dtd</pattern> | |||
<pattern>**/*.tld</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>auto-remove</id> | |||
<patterns> | |||
<pattern>**/*.bak</pattern> | |||
<pattern>**/*~</pattern> | |||
<pattern>**/*-</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>ignored</id> | |||
<patterns> | |||
<pattern>**/.htaccess</pattern> | |||
<pattern>**/KEYS</pattern> | |||
<pattern>**/*.rb</pattern> | |||
<pattern>**/*.sh</pattern> | |||
<pattern>**/.svn/**</pattern> | |||
<pattern>**/.DAV/**</pattern> | |||
</patterns> | |||
</fileType> | |||
</fileTypes> | |||
<knownContentConsumers> | |||
<knownContentConsumer>update-db-artifact</knownContentConsumer> | |||
<knownContentConsumer>create-missing-checksums</knownContentConsumer> | |||
<knownContentConsumer>update-db-repository-metadata</knownContentConsumer> | |||
<knownContentConsumer>validate-checksum</knownContentConsumer> | |||
<knownContentConsumer>validate-signature</knownContentConsumer> | |||
<knownContentConsumer>index-content</knownContentConsumer> | |||
<knownContentConsumer>auto-remove</knownContentConsumer> | |||
<knownContentConsumer>auto-rename</knownContentConsumer> | |||
</knownContentConsumers> | |||
<invalidContentConsumers> | |||
<invalidContentConsumer>update-db-bad-content</invalidContentConsumer> | |||
</invalidContentConsumers> | |||
</repositoryScanning> | |||
<databaseScanning> | |||
<cronExpression>0 0 * * ?</cronExpression> | |||
<unprocessedConsumers> | |||
<unprocessedConsumer>index-artifact</unprocessedConsumer> | |||
<unprocessedConsumer>update-db-project</unprocessedConsumer> | |||
<unprocessedConsumer>validate-repository-metadata</unprocessedConsumer> | |||
<unprocessedConsumer>index-archive-toc</unprocessedConsumer> | |||
<unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer> | |||
<unprocessedConsumer>index-public-methods</unprocessedConsumer> | |||
</unprocessedConsumers> | |||
<cleanupConsumers> | |||
<cleanupConsumer>not-present-remove-db-artifact</cleanupConsumer> | |||
<cleanupConsumer>not-present-remove-db-project</cleanupConsumer> | |||
<cleanupConsumer>not-present-remove-indexed</cleanupConsumer> | |||
</cleanupConsumers> | |||
</databaseScanning> | |||
<webapp> | |||
<ui> | |||
<showFindArtifacts>true</showFindArtifacts> | |||
<appletFindEnabled>true</appletFindEnabled> | |||
</ui> | |||
</webapp> | |||
</configuration> |
@@ -0,0 +1,69 @@ | |||
<?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. | |||
--> | |||
<configuration> | |||
<version>1</version> | |||
<repositories> | |||
<repository> | |||
<id>internal</id> | |||
<name>Archiva Managed Internal Repository</name> | |||
<url>file://${appserver.base}/repositories/internal</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0 * * ?</refreshCronExpression> | |||
</repository> | |||
<repository> | |||
<id>snapshots</id> | |||
<name>Archiva Managed Snapshot Repository</name> | |||
<url>file://${appserver.base}/repositories/internal</url> | |||
<layout>default</layout> | |||
<releases>false</releases> | |||
<snapshots>true</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0,30 * * ?</refreshCronExpression> | |||
</repository> | |||
<repository> | |||
<id>central</id> | |||
<name>Central Repository</name> | |||
<url>http://repo1.maven.org/maven2</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>false</indexed> | |||
</repository> | |||
<repository> | |||
<id>maven2-repository.dev.java.net</id> | |||
<name>Java.net Repository for Maven 2</name> | |||
<url>https://maven2-repository.dev.java.net/nonav/repository</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>false</indexed> | |||
</repository> | |||
</repositories> | |||
<webapp> | |||
<ui> | |||
<showFindArtifacts>false</showFindArtifacts> | |||
</ui> | |||
</webapp> | |||
</configuration> |
@@ -0,0 +1,49 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- | |||
~ 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. | |||
--> | |||
<configuration> | |||
<version>1</version> | |||
<proxyConnectors> | |||
<proxyConnector> | |||
<sourceRepoId>internal</sourceRepoId> | |||
<targetRepoId>central</targetRepoId> | |||
<proxyId/> | |||
<snapshotsPolicy>disabled</snapshotsPolicy> | |||
<releasePolicy>never</releasePolicy> | |||
<failurePolicy>not-found</failurePolicy> | |||
</proxyConnector> | |||
<proxyConnector> | |||
<sourceRepoId>internal</sourceRepoId> | |||
<targetRepoId>maven2-repository.dev.java.net</targetRepoId> | |||
<proxyId/> | |||
<snapshotsPolicy>disabled</snapshotsPolicy> | |||
<releasePolicy>never</releasePolicy> | |||
<failurePolicy>not-found</failurePolicy> | |||
<whiteListPatterns> | |||
<whiteListPattern>javax/**</whiteListPattern> | |||
</whiteListPatterns> | |||
</proxyConnector> | |||
</proxyConnectors> | |||
<webapp> | |||
<ui> | |||
<appletFindEnabled>false</appletFindEnabled> | |||
</ui> | |||
</webapp> | |||
</configuration> |
@@ -19,6 +19,7 @@ | |||
--> | |||
<configuration> | |||
<version>1</version> | |||
<repositories> | |||
<repository> | |||
<id>internal</id> |
@@ -19,8 +19,8 @@ package org.apache.maven.archiva.configuration; | |||
* under the License. | |||
*/ | |||
import org.apache.commons.io.FileUtils; | |||
import org.codehaus.plexus.PlexusTestCase; | |||
import org.codehaus.plexus.util.FileUtils; | |||
import java.io.File; | |||
import java.util.List; | |||
@@ -33,32 +33,55 @@ import java.util.List; | |||
public class ArchivaConfigurationTest | |||
extends PlexusTestCase | |||
{ | |||
public void testDefaults() | |||
public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource() | |||
throws Exception | |||
{ | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-defaults" ); | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
assertConfiguration( configuration ); | |||
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); | |||
RepositoryConfiguration repository = | |||
(RepositoryConfiguration) configuration.getRepositories().iterator().next(); | |||
// check default configuration | |||
assertNotNull( "check configuration returned", configuration ); | |||
assertTrue( "check configuration has default elements", configuration.getRepositories().isEmpty() ); | |||
assertEquals( "check managed repositories", "file://${appserver.base}/repositories/internal", | |||
repository.getUrl() ); | |||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); | |||
assertEquals( "check managed repositories", "internal", repository.getId() ); | |||
assertEquals( "check managed repositories", "default", repository.getLayout() ); | |||
assertTrue( "check managed repositories", repository.isIndexed() ); | |||
} | |||
public void testGetConfiguration() | |||
public void testGetConfigurationFromDefaults() | |||
throws Exception | |||
{ | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); | |||
FileTypes filetypes = (FileTypes) lookup( FileTypes.class.getName() ); | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-defaults" ); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
assertConfiguration( configuration ); | |||
assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); | |||
RepositoryConfiguration repository = | |||
(RepositoryConfiguration) configuration.getRepositories().iterator().next(); | |||
assertEquals( "check managed repositories", "file://${appserver.base}/data/repositories/internal", | |||
repository.getUrl() ); | |||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); | |||
assertEquals( "check managed repositories", "internal", repository.getId() ); | |||
assertEquals( "check managed repositories", "default", repository.getLayout() ); | |||
assertTrue( "check managed repositories", repository.isIndexed() ); | |||
} | |||
private void assertConfiguration( Configuration configuration ) | |||
throws Exception | |||
{ | |||
FileTypes filetypes = (FileTypes) lookup( FileTypes.class.getName() ); | |||
assertEquals( "check repositories", 4, configuration.getRepositories().size() ); | |||
assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() ); | |||
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); | |||
RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning(); | |||
assertNotNull( "check repository scanning", repoScanning ); | |||
@@ -75,37 +98,57 @@ public class ArchivaConfigurationTest | |||
assertEquals( "check unprocessed consumers", 6, dbScanning.getUnprocessedConsumers().size() ); | |||
assertEquals( "check cleanup consumers", 3, dbScanning.getCleanupConsumers().size() ); | |||
RepositoryConfiguration repository = | |||
(RepositoryConfiguration) configuration.getRepositories().iterator().next(); | |||
assertEquals( "check managed repositories", "file://${appserver.base}/repositories/internal", | |||
repository.getUrl() ); | |||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); | |||
assertEquals( "check managed repositories", "internal", repository.getId() ); | |||
assertEquals( "check managed repositories", "default", repository.getLayout() ); | |||
assertTrue( "check managed repositories", repository.isIndexed() ); | |||
WebappConfiguration webapp = (WebappConfiguration) configuration.getWebapp(); | |||
WebappConfiguration webapp = configuration.getWebapp(); | |||
assertNotNull( "check webapp", webapp ); | |||
UserInterfaceOptions ui = (UserInterfaceOptions) webapp.getUi(); | |||
UserInterfaceOptions ui = webapp.getUi(); | |||
assertNotNull( "check webapp ui", ui ); | |||
assertTrue( "check showFindArtifacts", ui.isShowFindArtifacts() ); | |||
assertTrue( "check appletFindEnabled", ui.isAppletFindEnabled() ); | |||
} | |||
public void testGetConfigurationFromRegistryWithTwoConfigurationResources() | |||
throws Exception | |||
{ | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration-both" ); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
// from base | |||
assertEquals( "check repositories", 4, configuration.getRepositories().size() ); | |||
// from user | |||
assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() ); | |||
WebappConfiguration webapp = configuration.getWebapp(); | |||
assertNotNull( "check webapp", webapp ); | |||
UserInterfaceOptions ui = webapp.getUi(); | |||
assertNotNull( "check webapp ui", ui ); | |||
// from base | |||
assertFalse( "check showFindArtifacts", ui.isShowFindArtifacts() ); | |||
// from user | |||
assertFalse( "check appletFindEnabled", ui.isAppletFindEnabled() ); | |||
} | |||
public void testGetConfigurationSystemOverride() | |||
throws Exception | |||
{ | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); | |||
System.setProperty( "org.apache.maven.archiva.localRepository", "system-repository" ); | |||
System.setProperty( "org.apache.maven.archiva.webapp.ui.appletFindEnabled", "false" ); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
try | |||
{ | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
// assertEquals( "check localRepository", "system-repository", configuration.getLocalRepository() ); | |||
// assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); | |||
assertFalse( "check boolean", configuration.getWebapp().getUi().isAppletFindEnabled() ); | |||
} | |||
finally | |||
{ | |||
System.getProperties().remove( "org.apache.maven.archiva.webapp.ui.appletFindEnabled" ); | |||
} | |||
} | |||
public void testStoreConfiguration() | |||
@@ -117,13 +160,16 @@ public class ArchivaConfigurationTest | |||
// TODO: remove with commons-configuration 1.4 | |||
file.getParentFile().mkdirs(); | |||
org.codehaus.plexus.util.FileUtils.fileWrite( file.getAbsolutePath(), "<configuration/>" ); | |||
FileUtils.fileWrite( file.getAbsolutePath(), "<configuration/>" ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save" ); | |||
Configuration configuration = new Configuration(); | |||
// configuration.setIndexPath( "index-path" ); | |||
configuration.setVersion( "1" ); | |||
configuration.setWebapp( new WebappConfiguration() ); | |||
configuration.getWebapp().setUi( new UserInterfaceOptions() ); | |||
configuration.getWebapp().getUi().setAppletFindEnabled( false ); | |||
archivaConfiguration.save( configuration ); | |||
@@ -131,12 +177,12 @@ public class ArchivaConfigurationTest | |||
// check it | |||
configuration = archivaConfiguration.getConfiguration(); | |||
// assertEquals( "check value", "index-path", configuration.getIndexPath() ); | |||
assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); | |||
// read it back | |||
archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-saved" ); | |||
configuration = archivaConfiguration.getConfiguration(); | |||
// assertEquals( "check value", "index-path", configuration.getIndexPath() ); | |||
assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); | |||
} | |||
public void testStoreConfigurationUser() | |||
@@ -150,15 +196,16 @@ public class ArchivaConfigurationTest | |||
userFile.delete(); | |||
assertFalse( userFile.exists() ); | |||
// TODO: remove with commons-configuration 1.4 | |||
userFile.getParentFile().mkdirs(); | |||
org.codehaus.plexus.util.FileUtils.fileWrite( userFile.getAbsolutePath(), "<configuration/>" ); | |||
FileUtils.fileWrite( userFile.getAbsolutePath(), "<configuration/>" ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); | |||
Configuration configuration = new Configuration(); | |||
// configuration.setIndexPath( "index-path" ); | |||
configuration.setWebapp( new WebappConfiguration() ); | |||
configuration.getWebapp().setUi( new UserInterfaceOptions() ); | |||
configuration.getWebapp().getUi().setAppletFindEnabled( false ); | |||
archivaConfiguration.save( configuration ); | |||
@@ -167,7 +214,46 @@ public class ArchivaConfigurationTest | |||
// check it | |||
configuration = archivaConfiguration.getConfiguration(); | |||
// assertEquals( "check value", "index-path", configuration.getIndexPath() ); | |||
assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); | |||
} | |||
public void testStoreConfigurationLoadedFromDefaults() | |||
throws Exception | |||
{ | |||
File baseFile = getTestFile( "target/test/test-file.xml" ); | |||
baseFile.delete(); | |||
assertFalse( baseFile.exists() ); | |||
File userFile = getTestFile( "target/test/test-file-user.xml" ); | |||
userFile.delete(); | |||
assertFalse( userFile.exists() ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); | |||
Configuration configuration = new Configuration(); | |||
configuration.setWebapp( new WebappConfiguration() ); | |||
configuration.getWebapp().setUi( new UserInterfaceOptions() ); | |||
configuration.getWebapp().getUi().setAppletFindEnabled( false ); | |||
archivaConfiguration.save( configuration ); | |||
assertTrue( "Check file exists", userFile.exists() ); | |||
assertFalse( "Check file not created", baseFile.exists() ); | |||
// check it | |||
configuration = archivaConfiguration.getConfiguration(); | |||
assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); | |||
} | |||
public void testDefaultUserConfigFilename() | |||
throws Exception | |||
{ | |||
DefaultArchivaConfiguration archivaConfiguration = | |||
(DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class.getName() ); | |||
assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml", | |||
archivaConfiguration.getFilteredUserConfigFilename() ); | |||
} | |||
public void testStoreConfigurationFallback() | |||
@@ -181,15 +267,16 @@ public class ArchivaConfigurationTest | |||
userFile.delete(); | |||
assertFalse( userFile.exists() ); | |||
// TODO: remove with commons-configuration 1.4 | |||
baseFile.getParentFile().mkdirs(); | |||
org.codehaus.plexus.util.FileUtils.fileWrite( baseFile.getAbsolutePath(), "<configuration/>" ); | |||
FileUtils.fileWrite( baseFile.getAbsolutePath(), "<configuration/>" ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); | |||
Configuration configuration = new Configuration(); | |||
// configuration.setIndexPath( "index-path" ); | |||
configuration.setWebapp( new WebappConfiguration() ); | |||
configuration.getWebapp().setUi( new UserInterfaceOptions() ); | |||
configuration.getWebapp().getUi().setAppletFindEnabled( false ); | |||
archivaConfiguration.save( configuration ); | |||
@@ -198,36 +285,85 @@ public class ArchivaConfigurationTest | |||
// check it | |||
configuration = archivaConfiguration.getConfiguration(); | |||
// assertEquals( "check value", "index-path", configuration.getIndexPath() ); | |||
assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); | |||
} | |||
public void testRemoveProxiedRepositoryAndStoreConfiguration() | |||
public void testStoreConfigurationFailsWhenReadFromBothLocations() | |||
throws Exception | |||
{ | |||
// MRM-300 | |||
File baseFile = getTestFile( "target/test/test-file.xml" ); | |||
baseFile.delete(); | |||
assertFalse( baseFile.exists() ); | |||
File userFile = getTestFile( "target/test/test-file-user.xml" ); | |||
userFile.delete(); | |||
assertFalse( userFile.exists() ); | |||
baseFile.getParentFile().mkdirs(); | |||
FileUtils.fileWrite( baseFile.getAbsolutePath(), "<configuration/>" ); | |||
File src = getTestFile( "src/test/conf/with-proxied-repos.xml" ); | |||
File dest = getTestFile( "target/test/with-proxied-repos.xml" ); | |||
FileUtils.copyFile( src, dest ); | |||
userFile.getParentFile().mkdirs(); | |||
FileUtils.fileWrite( userFile.getAbsolutePath(), "<configuration/>" ); | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-remove-proxied-repo" ); | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); | |||
Configuration configuration = new Configuration(); | |||
configuration.setWebapp( new WebappConfiguration() ); | |||
configuration.getWebapp().setUi( new UserInterfaceOptions() ); | |||
configuration.getWebapp().getUi().setAppletFindEnabled( false ); | |||
try | |||
{ | |||
archivaConfiguration.save( configuration ); | |||
fail( "Configuration saving should not succeed if it was loaded from two locations" ); | |||
} | |||
catch ( IndeterminateConfigurationException e ) | |||
{ | |||
assertTrue( true ); | |||
} | |||
} | |||
public void testConfigurationUpgradeFrom09() | |||
throws Exception | |||
{ | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-upgrade-09" ); | |||
// we just use the defaults when upgrading from 0.9 at this point. | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
// configuration.getProxiedRepositories().remove( 0 ); | |||
assertConfiguration( configuration ); | |||
assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); | |||
archivaConfiguration.save( configuration ); | |||
RepositoryConfiguration repository = | |||
(RepositoryConfiguration) configuration.getRepositories().iterator().next(); | |||
// check it | |||
configuration = archivaConfiguration.getConfiguration(); | |||
// assertEquals( 1, configuration.getProxiedRepositories().size() ); | |||
assertEquals( "check managed repositories", "file://${appserver.base}/data/repositories/internal", | |||
repository.getUrl() ); | |||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); | |||
assertEquals( "check managed repositories", "internal", repository.getId() ); | |||
assertEquals( "check managed repositories", "default", repository.getLayout() ); | |||
assertTrue( "check managed repositories", repository.isIndexed() ); | |||
} | |||
public void testAutoDetectV1() | |||
throws Exception | |||
{ | |||
ArchivaConfiguration archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-autodetect-v1" ); | |||
release( archivaConfiguration ); | |||
Configuration configuration = archivaConfiguration.getConfiguration(); | |||
assertConfiguration( configuration ); | |||
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); | |||
// read it back | |||
archivaConfiguration = | |||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-back-remove-proxied-repo" ); | |||
configuration = archivaConfiguration.getConfiguration(); | |||
// assertEquals( 1, configuration.getProxiedRepositories().size() ); | |||
RepositoryConfiguration repository = | |||
(RepositoryConfiguration) configuration.getRepositories().iterator().next(); | |||
assertEquals( "check managed repositories", "file://${appserver.base}/repositories/internal", | |||
repository.getUrl() ); | |||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); | |||
assertEquals( "check managed repositories", "internal", repository.getId() ); | |||
assertEquals( "check managed repositories", "default", repository.getLayout() ); | |||
assertTrue( "check managed repositories", repository.isIndexed() ); | |||
} | |||
} |
@@ -29,18 +29,36 @@ | |||
<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.commons.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-upgrade-09</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>upgrade-09</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>empty</role-hint> | |||
<role-hint>upgrade-09</role-hint> | |||
<implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<xml fileName="${basedir}/src/test/conf/archiva-0.9.xml" | |||
config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
@@ -53,10 +71,6 @@ | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
@@ -74,54 +88,45 @@ | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-save</role-hint> | |||
<role-hint>test-autodetect-v1</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> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
<role-hint>autodetect-v1</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>save</role-hint> | |||
<role-hint>autodetect-v1</role-hint> | |||
<implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/> | |||
<system/> | |||
<xml fileName="${basedir}/src/test/conf/autodetect-v1.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-user</role-hint> | |||
<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-user</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
<role-hint>save</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>save-user</role-hint> | |||
<role-hint>save</role-hint> | |||
<implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<xml fileName="${basedir}/target/test/test-file-user.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva.user" config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
@@ -130,25 +135,26 @@ | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-read-saved</role-hint> | |||
<role-hint>test-save-user</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> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
<role-hint>save-user</role-hint> | |||
</requirement> | |||
</requirements> | |||
<configuration> | |||
<userConfigFilename>${basedir}/target/test/test-file-user.xml</userConfigFilename> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>read-saved</role-hint> | |||
<role-hint>save-user</role-hint> | |||
<implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<xml fileName="${basedir}/target/test/test-file-user.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva.user" config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
@@ -157,52 +163,50 @@ | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-remove-proxied-repo</role-hint> | |||
<role-hint>test-configuration-both</role-hint> | |||
<implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>read-remove-proxied-repo</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
<role-hint>configuration-both</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>read-remove-proxied-repo</role-hint> | |||
<role-hint>configuration-both</role-hint> | |||
<implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<xml fileName="${basedir}/target/test/with-proxied-repos.xml" | |||
<xml fileName="${basedir}/src/test/conf/conf-user.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva.user" config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${basedir}/src/test/conf/conf-base.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>test-read-back-remove-proxied-repo</role-hint> | |||
<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-back-remove-proxied-repo</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
<role-hint>read-saved</role-hint> | |||
</requirement> | |||
</requirements> | |||
<configuration> | |||
<userConfigFilename>${basedir}/target/test/test-file.xml</userConfigFilename> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>read-back-remove-proxied-repo</role-hint> | |||
<role-hint>read-saved</role-hint> | |||
<implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> | |||
<configuration> | |||
<properties> | |||
<xml fileName="${basedir}/target/test/with-proxied-repos.xml" | |||
<xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true" | |||
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> |
@@ -28,10 +28,6 @@ | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> |
@@ -10,10 +10,6 @@ | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> |
@@ -10,10 +10,6 @@ | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> |
@@ -21,15 +21,15 @@ | |||
<role-hint>commons-configuration</role-hint> | |||
<configuration> | |||
<properties> | |||
<system /> | |||
<system/> | |||
<xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true" | |||
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva" /> | |||
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${appserver.home}/conf/archiva.xml" config-optional="true" | |||
config-at="org.apache.maven.archiva" /> | |||
config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${user.home}/.m2/archiva.xml" config-optional="true" | |||
config-name="org.apache.maven.archiva.user" config-at="org.apache.maven.archiva" /> | |||
<xml fileName="org/apache/maven/archiva/configuration/default-archiva.xml" config-optional="true" | |||
config-at="org.apache.maven.archiva" /> | |||
config-name="org.apache.maven.archiva.user" config-at="org.apache.maven.archiva"/> | |||
<xml fileName="org/apache/maven/archiva/configuration/default-archiva.xml" | |||
config-at="org.apache.maven.archiva"/> | |||
</properties> | |||
</configuration> | |||
</component> | |||
@@ -39,8 +39,8 @@ | |||
<implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation> | |||
</component> | |||
</components> | |||
<lifecycle-handler-manager implementation="org.codehaus.plexus.lifecycle.DefaultLifecycleHandlerManager"> | |||
<lifecycle-handler-manager implementation="org.codehaus.plexus.lifecycle.DefaultLifecycleHandlerManager"> | |||
<default-lifecycle-handler-id>plexus</default-lifecycle-handler-id> | |||
<lifecycle-handlers> | |||
<lifecycle-handler implementation="org.codehaus.plexus.personality.plexus.PlexusLifecycleHandler"> | |||
@@ -70,6 +70,6 @@ | |||
</lifecycle-handler> | |||
</lifecycle-handlers> | |||
</lifecycle-handler-manager> | |||
</component-set> | |||
@@ -42,13 +42,9 @@ | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
@@ -61,20 +57,20 @@ | |||
</properties> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.consumers.DatabaseCleanupConsumer</role> | |||
<role-hint>test-db-cleanup</role-hint> | |||
<implementation>org.apache.maven.archiva.scheduled.TestDatabaseCleanupConsumer</implementation> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer</role> | |||
<role-hint>test-db-unprocessed</role-hint> | |||
<implementation>org.apache.maven.archiva.scheduled.TestDatabaseUnprocessedConsumer</implementation> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.jdo.JdoFactory</role> | |||
<role-hint>archiva</role-hint> | |||
@@ -89,6 +85,6 @@ | |||
</otherProperties> | |||
</configuration> | |||
</component> | |||
</components> | |||
</component-set> |
@@ -23,7 +23,8 @@ | |||
<component> | |||
<role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role> | |||
<role-hint>test-repository-scanning</role-hint> | |||
<implementation>org.apache.maven.archiva.scheduled.executors.ArchivaRepositoryScanningTaskExecutor</implementation> | |||
<implementation>org.apache.maven.archiva.scheduled.executors.ArchivaRepositoryScanningTaskExecutor | |||
</implementation> | |||
<description></description> | |||
<requirements> | |||
<requirement> | |||
@@ -51,13 +52,9 @@ | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
</requirement> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role> | |||
<field-name>upgrader</field-name> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.registry.Registry</role> | |||
<role-hint>configured</role-hint> | |||
@@ -70,7 +67,7 @@ | |||
</properties> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.codehaus.plexus.jdo.JdoFactory</role> | |||
<role-hint>archiva</role-hint> | |||
@@ -85,6 +82,6 @@ | |||
</otherProperties> | |||
</configuration> | |||
</component> | |||
</components> | |||
</component-set> |
@@ -22,9 +22,9 @@ 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.IndeterminateConfigurationException; | |||
import org.apache.maven.archiva.configuration.InvalidConfigurationException; | |||
import org.apache.maven.archiva.indexer.RepositoryIndexException; | |||
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException; | |||
@@ -34,7 +34,6 @@ import org.codehaus.plexus.redback.xwork.interceptor.SecureAction; | |||
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; | |||
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; | |||
import org.codehaus.plexus.registry.RegistryException; | |||
import org.codehaus.plexus.scheduler.CronExpressionValidator; | |||
import org.codehaus.plexus.xwork.action.PlexusActionSupport; | |||
import java.io.IOException; | |||
@@ -57,7 +56,7 @@ public class ConfigureAction | |||
* The configuration. | |||
*/ | |||
private Configuration configuration; | |||
public void validate() | |||
{ | |||
getLogger().info( "validate()" ); | |||
@@ -72,10 +71,17 @@ public class ConfigureAction | |||
// 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? | |||
archivaConfiguration.save( configuration ); | |||
// TODO: if the repository has changed, we need to check if indexing is needed! | |||
addActionMessage( "Successfully saved configuration" ); | |||
try | |||
{ | |||
archivaConfiguration.save( configuration ); | |||
// TODO: if the repository has changed, we need to check if indexing is needed! | |||
addActionMessage( "Successfully saved configuration" ); | |||
} | |||
catch ( IndeterminateConfigurationException e ) | |||
{ | |||
addActionError( e.getMessage() ); | |||
} | |||
return SUCCESS; | |||
} |
@@ -20,7 +20,6 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy; | |||
*/ | |||
import com.opensymphony.xwork.Preparable; | |||
import org.apache.commons.collections.Closure; | |||
import org.apache.commons.collections.CollectionUtils; | |||
import org.apache.commons.collections.functors.IfClosure; | |||
@@ -28,9 +27,9 @@ import org.apache.commons.collections.functors.NotPredicate; | |||
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.IndeterminateConfigurationException; | |||
import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; | |||
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; | |||
import org.apache.maven.archiva.configuration.functors.NetworkProxySelectionPredicate; | |||
import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate; | |||
import org.apache.maven.archiva.configuration.functors.RemoteRepositoryPredicate; | |||
import org.apache.maven.archiva.configuration.functors.RepositoryIdListClosure; | |||
@@ -53,11 +52,10 @@ import java.util.Map; | |||
import java.util.Map.Entry; | |||
/** | |||
* ConfigureProxyConnectorAction | |||
* ConfigureProxyConnectorAction | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureProxyConnectorAction" | |||
*/ | |||
public class ConfigureProxyConnectorAction | |||
@@ -101,7 +99,7 @@ public class ConfigureProxyConnectorAction | |||
private String pattern; | |||
/** | |||
* The list of possible proxy ids. | |||
* The list of possible proxy ids. | |||
*/ | |||
private List proxyIdOptions = new ArrayList(); | |||
@@ -154,13 +152,15 @@ public class ConfigureProxyConnectorAction | |||
return SUCCESS; | |||
} | |||
ProxyConnectorSelectionPredicate proxyConnectorSelection = new ProxyConnectorSelectionPredicate( source, target ); | |||
ProxyConnectorConfiguration proxyConnectorConfiguration = (ProxyConnectorConfiguration) CollectionUtils.find( config | |||
.getProxyConnectors(), proxyConnectorSelection ); | |||
ProxyConnectorSelectionPredicate proxyConnectorSelection = | |||
new ProxyConnectorSelectionPredicate( source, target ); | |||
ProxyConnectorConfiguration proxyConnectorConfiguration = | |||
(ProxyConnectorConfiguration) CollectionUtils.find( config | |||
.getProxyConnectors(), proxyConnectorSelection ); | |||
if ( proxyConnectorConfiguration == null ) | |||
{ | |||
addActionError( "Unable to remove proxy connector, proxy connector with source [" + source + "] and target [" | |||
+ target + "] not found." ); | |||
addActionError( "Unable to remove proxy connector, proxy connector with source [" + source + | |||
"] and target [" + target + "] not found." ); | |||
return SUCCESS; | |||
} | |||
@@ -418,8 +418,8 @@ public class ConfigureProxyConnectorAction | |||
RepositoryIdListClosure remoteRepoIdList = new RepositoryIdListClosure( new ArrayList() ); | |||
RepositoryIdListClosure localRepoIdList = new RepositoryIdListClosure( new ArrayList() ); | |||
Closure repoIfClosure = IfClosure.getInstance( RemoteRepositoryPredicate.getInstance(), remoteRepoIdList, | |||
localRepoIdList ); | |||
Closure repoIfClosure = | |||
IfClosure.getInstance( RemoteRepositoryPredicate.getInstance(), remoteRepoIdList, localRepoIdList ); | |||
CollectionUtils.forAllDo( config.getRepositories(), repoIfClosure ); | |||
@@ -447,8 +447,8 @@ public class ConfigureProxyConnectorAction | |||
{ | |||
if ( findProxyConnector( sourceId, targetId ) != null ) | |||
{ | |||
addActionError( "Unable to add new proxy connector with source [" + sourceId + "] and target [" | |||
+ targetId + "] as previously declared proxy connector, go edit that one instead." ); | |||
addActionError( "Unable to add new proxy connector with source [" + sourceId + "] and target [" + | |||
targetId + "] as previously declared proxy connector, go edit that one instead." ); | |||
return INPUT; | |||
} | |||
} | |||
@@ -559,8 +559,8 @@ public class ConfigureProxyConnectorAction | |||
if ( !options.contains( value ) ) | |||
{ | |||
addActionError( "Value of [" + value + "] is invalid for policy [" + policyId + "], valid values: " | |||
+ options ); | |||
addActionError( | |||
"Value of [" + value + "] is invalid for policy [" + policyId + "], valid values: " + options ); | |||
continue; | |||
} | |||
} | |||
@@ -586,6 +586,10 @@ public class ConfigureProxyConnectorAction | |||
{ | |||
addActionError( "Unable to save configuration: " + e.getMessage() ); | |||
} | |||
catch ( IndeterminateConfigurationException e ) | |||
{ | |||
addActionError( e.getMessage() ); | |||
} | |||
return SUCCESS; | |||
} |
@@ -20,11 +20,11 @@ package org.apache.maven.archiva.web.action.admin.database; | |||
*/ | |||
import com.opensymphony.xwork.Preparable; | |||
import org.apache.commons.collections.CollectionUtils; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; | |||
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; | |||
import org.apache.maven.archiva.database.updater.DatabaseConsumers; | |||
import org.apache.maven.archiva.security.ArchivaRoleConstants; | |||
import org.apache.maven.archiva.web.action.admin.scanning.AdminRepositoryConsumerComparator; | |||
@@ -32,17 +32,17 @@ import org.codehaus.plexus.redback.rbac.Resource; | |||
import org.codehaus.plexus.redback.xwork.interceptor.SecureAction; | |||
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; | |||
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; | |||
import org.codehaus.plexus.registry.RegistryException; | |||
import org.codehaus.plexus.xwork.action.PlexusActionSupport; | |||
import java.util.Collections; | |||
import java.util.List; | |||
/** | |||
* DatabaseAction | |||
* DatabaseAction | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="databaseAction" | |||
*/ | |||
public class DatabaseAction | |||
@@ -65,17 +65,17 @@ public class DatabaseAction | |||
* List of available {@link AdminDatabaseConsumer} objects for unprocessed artifacts. | |||
*/ | |||
private List unprocessedConsumers; | |||
/** | |||
* List of enabled {@link AdminDatabaseConsumer} objects for unprocessed artifacts. | |||
*/ | |||
private List enabledUnprocessedConsumers; | |||
/** | |||
* List of {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts. | |||
*/ | |||
private List cleanupConsumers; | |||
/** | |||
* List of enabled {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts. | |||
*/ | |||
@@ -90,7 +90,7 @@ public class DatabaseAction | |||
this.cron = dbscanning.getCronExpression(); | |||
AddAdminDatabaseConsumerClosure addAdminDbConsumer; | |||
addAdminDbConsumer = new AddAdminDatabaseConsumerClosure( dbscanning.getUnprocessedConsumers() ); | |||
CollectionUtils.forAllDo( databaseConsumers.getAvailableUnprocessedConsumers(), addAdminDbConsumer ); | |||
this.unprocessedConsumers = addAdminDbConsumer.getList(); | |||
@@ -104,25 +104,26 @@ public class DatabaseAction | |||
public String updateUnprocessedConsumers() | |||
{ | |||
archivaConfiguration.getConfiguration().getDatabaseScanning().setUnprocessedConsumers( enabledUnprocessedConsumers ); | |||
archivaConfiguration.getConfiguration().getDatabaseScanning().setUnprocessedConsumers( | |||
enabledUnprocessedConsumers ); | |||
return saveConfiguration(); | |||
} | |||
public String updateCleanupConsumers() | |||
{ | |||
archivaConfiguration.getConfiguration().getDatabaseScanning().setCleanupConsumers( enabledCleanupConsumers ); | |||
return saveConfiguration(); | |||
} | |||
public String updateSchedule() | |||
{ | |||
archivaConfiguration.getConfiguration().getDatabaseScanning().setCronExpression( cron ); | |||
return saveConfiguration(); | |||
} | |||
private String saveConfiguration() | |||
{ | |||
try | |||
@@ -130,15 +131,21 @@ public class DatabaseAction | |||
archivaConfiguration.save( archivaConfiguration.getConfiguration() ); | |||
addActionMessage( "Successfully saved configuration" ); | |||
} | |||
catch ( Exception e) | |||
catch ( RegistryException e ) | |||
{ | |||
getLogger().error( e.getMessage(), e ); | |||
addActionError( "Error in saving configuration" ); | |||
return INPUT; | |||
} | |||
catch ( IndeterminateConfigurationException e ) | |||
{ | |||
addActionError( e.getMessage() ); | |||
return INPUT; | |||
} | |||
return SUCCESS; | |||
} | |||
public SecureActionBundle getSecureActionBundle() | |||
throws SecureActionException | |||
{ |
@@ -20,12 +20,12 @@ package org.apache.maven.archiva.web.action.admin.networkproxies; | |||
*/ | |||
import com.opensymphony.xwork.Preparable; | |||
import org.apache.commons.collections.CollectionUtils; | |||
import org.apache.commons.collections.functors.NotPredicate; | |||
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.IndeterminateConfigurationException; | |||
import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; | |||
import org.apache.maven.archiva.configuration.functors.NetworkProxySelectionPredicate; | |||
import org.apache.maven.archiva.security.ArchivaRoleConstants; | |||
@@ -37,11 +37,10 @@ import org.codehaus.plexus.registry.RegistryException; | |||
import org.codehaus.plexus.xwork.action.PlexusActionSupport; | |||
/** | |||
* ConfigureNetworkProxyAction | |||
* ConfigureNetworkProxyAction | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureNetworkProxyAction" | |||
*/ | |||
public class ConfigureNetworkProxyAction | |||
@@ -218,6 +217,10 @@ public class ConfigureNetworkProxyAction | |||
{ | |||
addActionError( "Unable to save configuration: " + e.getMessage() ); | |||
} | |||
catch ( IndeterminateConfigurationException e ) | |||
{ | |||
addActionError( e.getMessage() ); | |||
} | |||
return SUCCESS; | |||
} |
@@ -21,12 +21,12 @@ package org.apache.maven.archiva.web.action.admin.repositories; | |||
import com.opensymphony.xwork.ActionContext; | |||
import com.opensymphony.xwork.Preparable; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.maven.archiva.common.utils.PathUtil; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; | |||
import org.apache.maven.archiva.configuration.InvalidConfigurationException; | |||
import org.apache.maven.archiva.configuration.RepositoryConfiguration; | |||
import org.apache.maven.archiva.security.ArchivaRoleConstants; | |||
@@ -94,7 +94,8 @@ public class ConfigureRepositoryAction | |||
if ( operationAllowed( ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, getRepoid() ) ) | |||
{ | |||
addActionError( "You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); | |||
addActionError( | |||
"You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); | |||
return ERROR; | |||
} | |||
@@ -107,7 +108,8 @@ public class ConfigureRepositoryAction | |||
if ( operationAllowed( ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, getRepoid() ) ) | |||
{ | |||
addActionError( "You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); | |||
addActionError( | |||
"You do not have the appropriate permissions to delete the " + getRepoid() + " repository." ); | |||
return ERROR; | |||
} | |||
@@ -218,13 +220,13 @@ public class ConfigureRepositoryAction | |||
getLogger().info( ".save(" + mode + ":" + repoId + ")" ); | |||
containsError = validateFields(mode); | |||
containsError = validateFields( mode ); | |||
if ( containsError && StringUtils.equalsIgnoreCase( "add", mode ) ) | |||
{ | |||
{ | |||
return INPUT; | |||
} | |||
else if ( containsError && StringUtils.equalsIgnoreCase( "edit", mode )) | |||
else if ( containsError && StringUtils.equalsIgnoreCase( "edit", mode ) ) | |||
{ | |||
return ERROR; | |||
} | |||
@@ -259,7 +261,7 @@ public class ConfigureRepositoryAction | |||
return SUCCESS; | |||
} | |||
private boolean validateFields(String mode) | |||
private boolean validateFields( String mode ) | |||
{ | |||
boolean containsError = false; | |||
CronExpressionValidator validator = new CronExpressionValidator(); | |||
@@ -267,20 +269,21 @@ public class ConfigureRepositoryAction | |||
String repoId = getRepository().getId(); | |||
if ( StringUtils.isBlank( repoId ) ) | |||
{ | |||
{ | |||
addFieldError( "repository.id", "You must enter a repository identifier." ); | |||
containsError = true; | |||
} | |||
//if edit mode, do not validate existence of repoId | |||
else if ( config.findRepositoryById( repoId ) != null && !StringUtils.equalsIgnoreCase( mode, "edit" ) ) | |||
else if ( config.findRepositoryById( repoId ) != null && !StringUtils.equalsIgnoreCase( mode, "edit" ) ) | |||
{ | |||
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId + "], that id already exists." ); | |||
addFieldError( "repository.id", | |||
"Unable to add new repository with id [" + repoId + "], that id already exists." ); | |||
containsError = true; | |||
} | |||
if ( StringUtils.isBlank( repository.getUrl() ) ) | |||
{ | |||
{ | |||
addFieldError( "repository.url", "You must enter a directory or url." ); | |||
containsError = true; | |||
} | |||
@@ -324,7 +327,7 @@ public class ConfigureRepositoryAction | |||
{ | |||
repository.setUrl( PathUtil.toUrl( rawUrlEntry ) ); | |||
} | |||
if ( repository.isManaged() ) | |||
{ | |||
// Normalize the path | |||
@@ -360,9 +363,8 @@ public class ConfigureRepositoryAction | |||
} | |||
catch ( AuthorizationException e ) | |||
{ | |||
getLogger().info( | |||
"Unable to authorize permission: " + permission + " against repo: " + repoid | |||
+ " due to: " + e.getMessage() ); | |||
getLogger().info( "Unable to authorize permission: " + permission + " against repo: " + repoid + | |||
" due to: " + e.getMessage() ); | |||
return false; | |||
} | |||
} | |||
@@ -402,9 +404,15 @@ public class ConfigureRepositoryAction | |||
{ | |||
getLogger().info( ".saveConfiguration()" ); | |||
archivaConfiguration.save( archivaConfiguration.getConfiguration() ); | |||
addActionMessage( "Successfully saved configuration" ); | |||
try | |||
{ | |||
archivaConfiguration.save( archivaConfiguration.getConfiguration() ); | |||
addActionMessage( "Successfully saved configuration" ); | |||
} | |||
catch ( IndeterminateConfigurationException e ) | |||
{ | |||
addActionError( e.getMessage() ); | |||
} | |||
return SUCCESS; | |||
} |
@@ -21,12 +21,12 @@ package org.apache.maven.archiva.web.action.admin.scanning; | |||
import com.opensymphony.xwork.Preparable; | |||
import com.opensymphony.xwork.Validateable; | |||
import org.apache.commons.collections.CollectionUtils; | |||
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.FileType; | |||
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; | |||
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; | |||
import org.apache.maven.archiva.configuration.functors.FiletypeSelectionPredicate; | |||
import org.apache.maven.archiva.configuration.functors.FiletypeToMapClosure; | |||
@@ -45,11 +45,10 @@ import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* RepositoryScanningAction | |||
* RepositoryScanningAction | |||
* | |||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> | |||
* @version $Id$ | |||
* | |||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="repositoryScanningAction" | |||
*/ | |||
public class RepositoryScanningAction | |||
@@ -74,7 +73,7 @@ public class RepositoryScanningAction | |||
* List of {@link AdminRepositoryConsumer} objects for consumers of known content. | |||
*/ | |||
private List knownContentConsumers; | |||
/** | |||
* List of enabled {@link AdminRepositoryConsumer} objects for consumers of known content. | |||
*/ | |||
@@ -84,7 +83,7 @@ public class RepositoryScanningAction | |||
* List of {@link AdminRepositoryConsumer} objects for consumers of invalid/unknown content. | |||
*/ | |||
private List invalidContentConsumers; | |||
/** | |||
* List of enabled {@link AdminRepositoryConsumer} objects for consumers of invalid/unknown content. | |||
*/ | |||
@@ -99,13 +98,13 @@ public class RepositoryScanningAction | |||
super.addActionError( anErrorMessage ); | |||
getLogger().warn( "[ActionError] " + anErrorMessage ); | |||
} | |||
public void addActionMessage( String aMessage ) | |||
{ | |||
super.addActionMessage( aMessage ); | |||
getLogger().info( "[ActionMessage] " + aMessage ); | |||
} | |||
public String addFiletypePattern() | |||
{ | |||
getLogger().info( "Add New File Type Pattern [" + getFileTypeId() + ":" + getPattern() + "]" ); | |||
@@ -239,19 +238,21 @@ public class RepositoryScanningAction | |||
public String updateInvalidConsumers() | |||
{ | |||
addActionMessage("Update Invalid Consumers"); | |||
archivaConfiguration.getConfiguration().getRepositoryScanning().setInvalidContentConsumers( enabledInvalidContentConsumers ); | |||
addActionMessage( "Update Invalid Consumers" ); | |||
archivaConfiguration.getConfiguration().getRepositoryScanning().setInvalidContentConsumers( | |||
enabledInvalidContentConsumers ); | |||
return saveConfiguration(); | |||
} | |||
public String updateKnownConsumers() | |||
{ | |||
addActionMessage("Update Known Consumers"); | |||
archivaConfiguration.getConfiguration().getRepositoryScanning().setKnownContentConsumers( enabledKnownContentConsumers ); | |||
addActionMessage( "Update Known Consumers" ); | |||
archivaConfiguration.getConfiguration().getRepositoryScanning().setKnownContentConsumers( | |||
enabledKnownContentConsumers ); | |||
return saveConfiguration(); | |||
} | |||
@@ -288,6 +289,11 @@ public class RepositoryScanningAction | |||
addActionError( "Unable to save configuration: " + e.getMessage() ); | |||
return INPUT; | |||
} | |||
catch ( IndeterminateConfigurationException e ) | |||
{ | |||
addActionError( e.getMessage() ); | |||
return INPUT; | |||
} | |||
return SUCCESS; | |||
} |
@@ -59,8 +59,9 @@ | |||
<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.user" | |||
config-at="org.apache.maven.archiva" /> | |||
<xml fileName="${user.home}/.m2/archiva.xml" config-optional="true" | |||
config-name="org.apache.maven.archiva.user" | |||
config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${user.home}/.m2/shared.xml" config-optional="true" | |||
config-name="org.apache.maven.shared.app.user" config-at="org.apache.maven.shared.app" | |||
config-forceCreate="true"/> | |||
@@ -68,7 +69,8 @@ | |||
config-at="org.codehaus.plexus.redback"/> | |||
<properties fileName="${user.home}/.m2/archiva.properties" config-optional="true" | |||
config-at="org.codehaus.plexus.redback"/> | |||
<xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true" config-name="org.apache.maven.archiva.base" | |||
<xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true" | |||
config-name="org.apache.maven.archiva.base" | |||
config-at="org.apache.maven.archiva"/> | |||
<xml fileName="${appserver.base}/conf/shared.xml" config-optional="true" | |||
config-name="org.apache.maven.shared.app.base" config-at="org.apache.maven.shared.app"/> | |||
@@ -80,7 +82,8 @@ | |||
<xml fileName="${appserver.home}/conf/shared.xml" config-optional="true" | |||
config-at="org.apache.maven.shared.app"/> | |||
<xml fileName="${appserver.home}/conf/common.xml" config-optional="true"/> | |||
<xml fileName="org/apache/maven/archiva/configuration/default-archiva.xml" config-at="org.apache.maven.archiva.base"/> | |||
<xml fileName="org/apache/maven/archiva/configuration/default-archiva.xml" | |||
config-at="org.apache.maven.archiva"/> | |||
<properties fileName="${appserver.home}/conf/security.properties" config-optional="true" | |||
config-at="org.codehaus.plexus.redback"/> | |||
<properties fileName="org/apache/maven/archiva/security.properties" config-at="org.codehaus.plexus.redback"/> | |||
@@ -222,16 +225,17 @@ | |||
<implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation> | |||
<lifecycle-handler>basic</lifecycle-handler> | |||
</component> | |||
<!-- | |||
PLXREDBACK-81 bad role hint, redefining here until redback alpha-2 is released. | |||
--> | |||
PLXREDBACK-81 bad role hint, redefining here until redback alpha-2 is released. | |||
--> | |||
<component> | |||
<role>org.codehaus.plexus.redback.system.check.EnvironmentCheck</role> | |||
<role-hint>locked-admin-check</role-hint> | |||
<implementation>org.codehaus.plexus.redback.xwork.checks.security.LockedAdminEnvironmentCheck</implementation> | |||
<description>LockedAdminEnvironmentCheck: checks if accounts marked as system administrator are locked | |||
and unlocks them on startup.</description> | |||
and unlocks them on startup. | |||
</description> | |||
<requirements> | |||
<requirement> | |||
<role>org.codehaus.plexus.redback.users.UserManager</role> |