*/
public interface ArchivaConfiguration
{
- public static final String ROLE = ArchivaConfiguration.class.getName();
-
+ String ROLE = ArchivaConfiguration.class.getName();
+
/**
* Get the configuration.
*
* @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.
* @param listener the listener
*/
void addChangeListener( RegistryListener listener );
-
}
--- /dev/null
+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 );
+ }
+}
+++ /dev/null
-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;
- }
-}
* 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;
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"
*/
*/
private Registry registry;
- /**
- * @plexus.requirement
- */
- private ConfigurationUpgrade upgrader;
-
/**
* The configuration that has been converted.
*/
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 )
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(); )
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" );
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;
}
--- /dev/null
+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 );
+ }
+}
<class rootElement="true" xml.tagName="configuration">\r
<name>Configuration</name>\r
<version>1.0.0+</version>\r
- <fields>
- <field>
- <name>version</name>
- <version>1.0.0+</version>
- <type>String</type>
- <required>true</required>
- <description>This is the version of the configuration format.</description>
+ <fields>\r
+ <field>\r
+ <name>version</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ <description>This is the version of the configuration format.</description>\r
</field>\r
<field>\r
<name>repositories</name>\r
<version>1.0.0+</version>\r
<association>\r
<type>RepositoryConfiguration</type>\r
- <multiplicity>*</multiplicity>
- </association>
+ <multiplicity>*</multiplicity>\r
+ </association>\r
<description>The list of repositories that this archiva instance uses.</description>\r
- </field>
- <field>
- <name>proxyConnectors</name>
- <version>1.0.0+</version>
- <association>
- <type>ProxyConnectorConfiguration</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>The list of proxy connectors for this archiva instance.</description>
- </field>
+ </field>\r
+ <field>\r
+ <name>proxyConnectors</name>\r
+ <version>1.0.0+</version>\r
+ <association>\r
+ <type>ProxyConnectorConfiguration</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>The list of proxy connectors for this archiva instance.</description>\r
+ </field>\r
<!-- To be introduced later.\r
- <field>
- <name>syncConnectors</name>
- <version>1.0.0+</version>
- <association>
- <type>SyncConnectorConfiguration</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>The list of sync connectors for this archiva instance.</description>
- </field>
- -->
+ <field>\r
+ <name>syncConnectors</name>\r
+ <version>1.0.0+</version>\r
+ <association>\r
+ <type>SyncConnectorConfiguration</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>The list of sync connectors for this archiva instance.</description>\r
+ </field>\r
+ -->\r
<field>\r
<name>networkProxies</name>\r
<version>1.0.0+</version>\r
<association>\r
- <type>NetworkProxyConfiguration</type>
+ <type>NetworkProxyConfiguration</type>\r
<multiplicity>*</multiplicity>\r
</association>\r
- <description>
- The list of network proxies to use for outgoing requests.
+ <description>\r
+ The list of network proxies to use for outgoing requests.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>repositoryScanning</name>\r
+ <version>1.0.0+</version>\r
+ <association>\r
+ <type>RepositoryScanningConfiguration</type>\r
+ <multiplicity>1</multiplicity>\r
+ </association>\r
+ <description>\r
+ The repository scanning configuration.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>databaseScanning</name>\r
+ <version>1.0.0+</version>\r
+ <association>\r
+ <type>DatabaseScanningConfiguration</type>\r
+ <multiplicity>1</multiplicity>\r
+ </association>\r
+ <description>\r
+ The database scanning configuration.\r
</description>\r
- </field>
- <field>
- <name>repositoryScanning</name>
- <version>1.0.0+</version>
- <association>
- <type>RepositoryScanningConfiguration</type>
- <multiplicity>1</multiplicity>
- </association>
- <description>
- The repository scanning configuration.
- </description>
- </field>\r
- <field>
- <name>databaseScanning</name>
- <version>1.0.0+</version>
- <association>
- <type>DatabaseScanningConfiguration</type>
- <multiplicity>1</multiplicity>
- </association>
- <description>
- The database scanning configuration.
- </description>
</field>\r
<field>\r
<name>webapp</name>\r
<description>\r
The webapp configuration.\r
</description>\r
- </field>
- </fields>
- <codeSegments>
- <codeSegment>
- <version>1.0.0+</version>
- <code><![CDATA[
- /**
- * Find {@link RepositoryConfiguration} with specified Id.
- *
- * @param id the id of the repository to find.
- * @return the repository configuration.
- */
- public RepositoryConfiguration findRepositoryById( String id )
- {
- // null id = null repo config.
- if ( id == null )
- {
- return null;
- }
-
- // empty id = null repo config.
- if ( id.trim().length() <= 0 )
- {
- return null;
- }
-
- return (RepositoryConfiguration) createRepositoryMap().get( id );
- }
-
- /**
- * Create a RepositoryMap of the current repositories.
- *
- * @return the map of repository id's, to repository configurations.
- */
- public java.util.Map createRepositoryMap()
- {
- java.util.Map ret = new java.util.HashMap();
-
- // null repository list = null repo config.
- if ( getRepositories() == null )
- {
- return ret;
- }
-
- // empty repository list == null repo config.
- if ( getRepositories().isEmpty() )
- {
- return ret;
- }
-
- java.util.Iterator it = getRepositories().iterator();
- while ( it.hasNext() )
- {
- RepositoryConfiguration repoConfig = (RepositoryConfiguration) it.next();
- ret.put( repoConfig.getId(), repoConfig );
- }
-
- return ret;
- }
- ]]></code>
- </codeSegment>
+ </field>\r
+ </fields>\r
+ <codeSegments>\r
+ <codeSegment>\r
+ <version>1.0.0+</version>\r
+ <code><![CDATA[\r
+ /**\r
+ * Find {@link RepositoryConfiguration} with specified Id.\r
+ * \r
+ * @param id the id of the repository to find.\r
+ * @return the repository configuration.\r
+ */\r
+ public RepositoryConfiguration findRepositoryById( String id )\r
+ {\r
+ // null id = null repo config.\r
+ if ( id == null )\r
+ {\r
+ return null;\r
+ }\r
+\r
+ // empty id = null repo config.\r
+ if ( id.trim().length() <= 0 )\r
+ {\r
+ return null;\r
+ }\r
+ \r
+ return (RepositoryConfiguration) createRepositoryMap().get( id );\r
+ }\r
+\r
+ /**\r
+ * Create a RepositoryMap of the current repositories.\r
+ * \r
+ * @return the map of repository id's, to repository configurations.\r
+ */\r
+ public java.util.Map createRepositoryMap()\r
+ {\r
+ java.util.Map ret = new java.util.HashMap();\r
+ \r
+ // null repository list = null repo config.\r
+ if ( getRepositories() == null )\r
+ {\r
+ return ret;\r
+ }\r
+\r
+ // empty repository list == null repo config.\r
+ if ( getRepositories().isEmpty() )\r
+ {\r
+ return ret;\r
+ }\r
+ \r
+ java.util.Iterator it = getRepositories().iterator();\r
+ while ( it.hasNext() )\r
+ {\r
+ RepositoryConfiguration repoConfig = (RepositoryConfiguration) it.next();\r
+ ret.put( repoConfig.getId(), repoConfig );\r
+ }\r
+ \r
+ return ret;\r
+ }\r
+ ]]></code>\r
+ </codeSegment>\r
</codeSegments>\r
- </class>
-
- <!--
- ____ _ _
- | _ \ ___ _ __ ___ ___(_) |_ ___ _ __ _ _
- | |_) / _ \ '_ \ / _ \/ __| | __/ _ \| '__| | | |
- | _ < __/ |_) | (_) \__ \ | || (_) | | | |_| |
- |_| \_\___| .__/ \___/|___/_|\__\___/|_| \__, |
- |_| |___/
-
- -->
- \r
+ </class>\r
+\r
+ <!-- \r
+ ____ _ _\r
+ | _ \ ___ _ __ ___ ___(_) |_ ___ _ __ _ _\r
+ | |_) / _ \ '_ \ / _ \/ __| | __/ _ \| '__| | | |\r
+ | _ < __/ |_) | (_) \__ \ | || (_) | | | |_| |\r
+ |_| \_\___| .__/ \___/|___/_|\__\___/|_| \__, |\r
+ |_| |___/\r
+\r
+ -->\r
+\r
<class>\r
<name>RepositoryConfiguration</name>\r
<version>1.0.0+</version>\r
<fields>\r
- <field>
- <name>id</name>
- <version>1.0.0+</version>
- <type>String</type>
- <required>true</required>
- <description>
- The repository identifier.
- </description>
- </field>
- <field>
- <name>name</name>
- <version>1.0.0+</version>
- <type>String</type>
- <required>true</required>
- <description>
- The descriptive name of the repository.
- </description>
- </field>
- <field>
- <name>url</name>
- <version>1.0.0+</version>
- <type>String</type>
- <required>true</required>
- <description>
- The URL for this repository.
- </description>
- </field>
- <field>
- <name>layout</name>
- <version>1.0.0+</version>
- <type>String</type>
- <required>true</required>
- <description>
- The layout of the repository. Valid values are "default" and "legacy".
- </description>
- <!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) -->
- <defaultValue>default</defaultValue>
- </field>
- <field>
- <name>releases</name>
- <version>1.0.0+</version>
- <type>boolean</type>
- <description>True if this repository contains release versioned artifacts.</description>
- <defaultValue>true</defaultValue>
- </field>
+ <field>\r
+ <name>id</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ <description>\r
+ The repository identifier.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>name</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ <description>\r
+ The descriptive name of the repository.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>url</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ <description>\r
+ The URL for this repository.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>layout</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ <description>\r
+ The layout of the repository. Valid values are "default" and "legacy".\r
+ </description>\r
+ <!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) -->\r
+ <defaultValue>default</defaultValue>\r
+ </field>\r
+ <field>\r
+ <name>releases</name>\r
+ <version>1.0.0+</version>\r
+ <type>boolean</type>\r
+ <description>True if this repository contains release versioned artifacts.</description>\r
+ <defaultValue>true</defaultValue>\r
+ </field>\r
<field>\r
<name>snapshots</name>\r
<version>1.0.0+</version>\r
<type>boolean</type>\r
<description>True if this repository should be indexed.</description>\r
<defaultValue>true</defaultValue>\r
- </field>
- <field>
- <name>indexDir</name>
- <version>1.0.0+</version>
- <type>String</type>
- <description>
- The directory for the indexes of this repository.
- </description>
- </field>
- <field>
- <name>refreshCronExpression</name>
- <version>1.0.0+</version>
- <type>String</type>
- <description>
- When to run the refresh task.
- Default is every hour
- </description>
- <defaultValue>0 0 * * * ?</defaultValue>
- </field>
- </fields>
- <codeSegments>
- <codeSegment>
- <version>1.0.0+</version>
- <code><![CDATA[
- /**
- * Utility method to help determine if configuration refers to a remote repository.
- *
- * @return true if configuration belongs to a remote repository.
- * (note: false does not automatically mean this is a managed repository,
- * you must use {@link #isManaged()} to test for that.)
- */
- public boolean isRemote()
- {
- if ( this.url == null )
- {
- return false;
- }
-
- return !this.url.startsWith( "file" );
- }
-
- /**
- * Utility method to help determine if configuration refers to a managed repository.
- *
- * @return true if configuration belongs to a managed repository.
- * (note: false does not automatically mean this is a remote repository,
- * you must use {@link #isRemote()} to test for that.)
- */
- public boolean isManaged()
- {
- if ( this.url == null )
- {
- return false;
- }
-
- return this.url.startsWith( "file" );
- }
- ]]></code>
- </codeSegment>
+ </field>\r
+ <field>\r
+ <name>indexDir</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <description>\r
+ The directory for the indexes of this repository.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>refreshCronExpression</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <description>\r
+ When to run the refresh task.\r
+ Default is every hour\r
+ </description>\r
+ <defaultValue>0 0 * * * ?</defaultValue>\r
+ </field>\r
+ </fields>\r
+ <codeSegments>\r
+ <codeSegment>\r
+ <version>1.0.0+</version>\r
+ <code><![CDATA[\r
+ /**\r
+ * Utility method to help determine if configuration refers to a remote repository.\r
+ * \r
+ * @return true if configuration belongs to a remote repository. \r
+ * (note: false does not automatically mean this is a managed repository,\r
+ * you must use {@link #isManaged()} to test for that.)\r
+ */\r
+ public boolean isRemote()\r
+ {\r
+ if ( this.url == null )\r
+ {\r
+ return false;\r
+ }\r
+\r
+ return !this.url.startsWith( "file" );\r
+ }\r
+\r
+ /**\r
+ * Utility method to help determine if configuration refers to a managed repository.\r
+ * \r
+ * @return true if configuration belongs to a managed repository. \r
+ * (note: false does not automatically mean this is a remote repository,\r
+ * you must use {@link #isRemote()} to test for that.)\r
+ */\r
+ public boolean isManaged()\r
+ {\r
+ if ( this.url == null )\r
+ {\r
+ return false;\r
+ }\r
+\r
+ return this.url.startsWith( "file" );\r
+ } \r
+ ]]></code>\r
+ </codeSegment>\r
</codeSegments>\r
- </class>
-
- <!--
- ____ _
- / ___|___ _ __ _ __ ___ ___| |_ ___ _ __ ___
- | | / _ \| '_ \| '_ \ / _ \/ __| __/ _ \| '__/ __|
- | |__| (_) | | | | | | | __/ (__| || (_) | | \__ \
- \____\___/|_| |_|_| |_|\___|\___|\__\___/|_| |___/
-
- -->
-
- <class>
- <name>AbstractRepositoryConnectorConfiguration</name>
- <abstract>true</abstract>
- <version>1.0.0+</version>
- <fields>
- <field>
- <name>sourceRepoId</name>
- <version>1.0.0+</version>
- <type>String</type>
- <required>true</required>
- <description>
- The Repository Source for this connector.
- </description>
- </field>
- <field>
- <name>targetRepoId</name>
- <version>1.0.0+</version>
- <type>String</type>
- <required>true</required>
- <description>
- The Repository Target for this connector.
- </description>
- </field>
- <field>
- <name>proxyId</name>
- <version>1.0.0+</version>
- <type>String</type>
- <description>
- The network proxy ID to use for this connector.
- </description>
- </field>
- <field>
- <name>blackListPatterns</name>
- <version>1.0.0+</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- The list of blacklisted patterns for this connector.
- </description>
- </field>
- <field>
- <name>whiteListPatterns</name>
- <version>1.0.0+</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- The list of whitelisted patterns for this connector.
- </description>
- </field>
- <field>
- <name>policies</name>
- <version>1.0.0+</version>
- <type>Map</type>
- <description>Policy configuration for the connector.</description>
- <association xml.mapStyle="inline">
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
- <name>properties</name>
- <version>1.0.0+</version>
- <type>Map</type>
- <description>Configuration for the connector.</description>
- <association xml.mapStyle="inline">
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- </fields>
- <codeSegments>
- <codeSegment>
- <version>1.0.0+</version>
- <code><![CDATA[
- /**
- * Obtain a specific policy from the underlying connector.
- *
- * @param policyId the policy id to fetch.
- * @param defaultValue the default value for the policy id.
- * @return the configured policy value (or default value if not found).
- */
- public String getPolicy( String policyId, String defaultValue )
- {
- if ( this.getPolicies() == null )
- {
- return null;
- }
-
- Object value = this.getPolicies().get( policyId );
-
- if ( value == null )
- {
- return defaultValue;
- }
-
- return (String) value;
- }
- ]]></code>
- </codeSegment>
- </codeSegments>
- </class>
- \r
+ </class>\r
+\r
+ <!-- \r
+ ____ _\r
+ / ___|___ _ __ _ __ ___ ___| |_ ___ _ __ ___\r
+ | | / _ \| '_ \| '_ \ / _ \/ __| __/ _ \| '__/ __|\r
+ | |__| (_) | | | | | | | __/ (__| || (_) | | \__ \\r
+ \____\___/|_| |_|_| |_|\___|\___|\__\___/|_| |___/\r
+\r
+ -->\r
+\r
+ <class>\r
+ <name>AbstractRepositoryConnectorConfiguration</name>\r
+ <abstract>true</abstract>\r
+ <version>1.0.0+</version>\r
+ <fields>\r
+ <field>\r
+ <name>sourceRepoId</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ <description>\r
+ The Repository Source for this connector.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>targetRepoId</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ <description>\r
+ The Repository Target for this connector.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>proxyId</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <description>\r
+ The network proxy ID to use for this connector.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>blackListPatterns</name>\r
+ <version>1.0.0+</version>\r
+ <association>\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>\r
+ The list of blacklisted patterns for this connector.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>whiteListPatterns</name>\r
+ <version>1.0.0+</version>\r
+ <association>\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>\r
+ The list of whitelisted patterns for this connector.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>policies</name>\r
+ <version>1.0.0+</version>\r
+ <type>Map</type>\r
+ <description>Policy configuration for the connector.</description>\r
+ <association xml.mapStyle="inline">\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ </field>\r
+ <field>\r
+ <name>properties</name>\r
+ <version>1.0.0+</version>\r
+ <type>Map</type>\r
+ <description>Configuration for the connector.</description>\r
+ <association xml.mapStyle="inline">\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ </field>\r
+ </fields>\r
+ <codeSegments>\r
+ <codeSegment>\r
+ <version>1.0.0+</version>\r
+ <code><![CDATA[\r
+ /**\r
+ * Obtain a specific policy from the underlying connector.\r
+ * \r
+ * @param policyId the policy id to fetch.\r
+ * @param defaultValue the default value for the policy id.\r
+ * @return the configured policy value (or default value if not found).\r
+ */\r
+ public String getPolicy( String policyId, String defaultValue )\r
+ {\r
+ if ( this.getPolicies() == null )\r
+ {\r
+ return null;\r
+ }\r
+\r
+ Object value = this.getPolicies().get( policyId );\r
+\r
+ if ( value == null )\r
+ {\r
+ return defaultValue;\r
+ }\r
+\r
+ return (String) value;\r
+ }\r
+ ]]></code>\r
+ </codeSegment>\r
+ </codeSegments>\r
+ </class>\r
+\r
<class>\r
<superClass>AbstractRepositoryConnectorConfiguration</superClass>\r
<name>ProxyConnectorConfiguration</name>\r
<version>1.0.0+</version>\r
- <fields>
- </fields>
- <codeSegments>
- <codeSegment>
- <version>1.0.0+</version>
- <code><![CDATA[
- /**
- * The policy key {@link #getPolicies()} for snapshot handling.
- * See {@link org.apache.maven.archiva.policies.SnapshotsPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_SNAPSHOTS = "snapshots";
-
- /**
- * The policy key {@link #getPolicies()} for releases handling.
- * See {@link org.apache.maven.archiva.policies.ReleasesPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_RELEASES = "releases";
-
- /**
- * The policy key {@link #getPolicies()} for checksum handling.
- * See {@link org.apache.maven.archiva.policies.ChecksumPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_CHECKSUM = "checksum";
-
- /**
- * The policy key {@link #getPolicies()} for cache-failures handling.
- * See {@link org.apache.maven.archiva.policies.CachedFailuresPolicy}
- * for details on potential values to this policy key.
- */
- public static final String POLICY_CACHE_FAILURES = "cache-failures";
- ]]></code>
- </codeSegment>
- </codeSegments>
- </class>
- \r
+ <fields>\r
+ </fields>\r
+ <codeSegments>\r
+ <codeSegment>\r
+ <version>1.0.0+</version>\r
+ <code><![CDATA[\r
+ /**\r
+ * The policy key {@link #getPolicies()} for snapshot handling.\r
+ * See {@link org.apache.maven.archiva.policies.SnapshotsPolicy} \r
+ * for details on potential values to this policy key.\r
+ */\r
+ public static final String POLICY_SNAPSHOTS = "snapshots";\r
+\r
+ /**\r
+ * The policy key {@link #getPolicies()} for releases handling.\r
+ * See {@link org.apache.maven.archiva.policies.ReleasesPolicy}\r
+ * for details on potential values to this policy key.\r
+ */\r
+ public static final String POLICY_RELEASES = "releases";\r
+\r
+ /**\r
+ * The policy key {@link #getPolicies()} for checksum handling.\r
+ * See {@link org.apache.maven.archiva.policies.ChecksumPolicy}\r
+ * for details on potential values to this policy key.\r
+ */\r
+ public static final String POLICY_CHECKSUM = "checksum";\r
+\r
+ /**\r
+ * The policy key {@link #getPolicies()} for cache-failures handling.\r
+ * See {@link org.apache.maven.archiva.policies.CachedFailuresPolicy}\r
+ * for details on potential values to this policy key.\r
+ */\r
+ public static final String POLICY_CACHE_FAILURES = "cache-failures";\r
+ ]]></code>\r
+ </codeSegment>\r
+ </codeSegments>\r
+ </class>\r
+\r
<class>\r
<superClass>AbstractRepositoryConnectorConfiguration</superClass>\r
<name>SyncConnectorConfiguration</name>\r
<defaultValue>rsync</defaultValue>\r
</field>\r
</fields>\r
- </class>
-
- <!--
- ____ _
- | _ \ _ __ _____ _(_) ___ ___
- | |_) | '__/ _ \ \/ / |/ _ \/ __|
- | __/| | | (_) > <| | __/\__ \
- |_| |_| \___/_/\_\_|\___||___/
-
- -->
- \r
+ </class>\r
+\r
+ <!-- \r
+ ____ _\r
+ | _ \ _ __ _____ _(_) ___ ___\r
+ | |_) | '__/ _ \ \/ / |/ _ \/ __|\r
+ | __/| | | (_) > <| | __/\__ \\r
+ |_| |_| \___/_/\_\_|\___||___/\r
+\r
+ -->\r
+\r
<class>\r
<name>NetworkProxyConfiguration</name>\r
<version>1.0.0+</version>\r
- <fields>
- <field>
- <name>id</name>
- <version>1.0.0+</version>
- <type>String</type>
- <description>
- The ID for this proxy.
- </description>
- </field>
- <field>
- <name>protocol</name>
- <version>1.0.0+</version>
- <description>
- The network protocol to use with this proxy: "http", "socks-4"
- </description>
- <type>String</type>
- <required>true</required>
- <defaultValue>http</defaultValue>
- </field>
- <field>
- <name>host</name>
- <version>1.0.0+</version>
- <description>
- The proxy host.
- </description>
- <type>String</type>
- <required>true</required>
- </field>
- <field>
- <name>port</name>
- <version>1.0.0+</version>
- <description>
- The proxy port.
- </description>
- <type>int</type>
- <defaultValue>8080</defaultValue>
- </field>
+ <fields>\r
+ <field>\r
+ <name>id</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <description>\r
+ The ID for this proxy.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>protocol</name>\r
+ <version>1.0.0+</version>\r
+ <description>\r
+ The network protocol to use with this proxy: "http", "socks-4"\r
+ </description>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ <defaultValue>http</defaultValue>\r
+ </field>\r
+ <field>\r
+ <name>host</name>\r
+ <version>1.0.0+</version>\r
+ <description>\r
+ The proxy host.\r
+ </description>\r
+ <type>String</type>\r
+ <required>true</required>\r
+ </field>\r
+ <field>\r
+ <name>port</name>\r
+ <version>1.0.0+</version>\r
+ <description>\r
+ The proxy port.\r
+ </description>\r
+ <type>int</type>\r
+ <defaultValue>8080</defaultValue>\r
+ </field>\r
<field>\r
<name>username</name>\r
<version>1.0.0+</version>\r
- <description>
- The proxy user.
+ <description>\r
+ The proxy user.\r
</description>\r
<type>String</type>\r
</field>\r
<field>\r
<name>password</name>\r
<version>1.0.0+</version>\r
- <description>
- The proxy password.
+ <description>\r
+ The proxy password.\r
</description>\r
<type>String</type>\r
- </field>
+ </field>\r
</fields>\r
- </class>
-
- <!--
- ____ _
- / ___| ___ __ _ _ __ _ __ (_)_ __ __ _
- \___ \ / __/ _` | '_ \| '_ \| | '_ \ / _` |
- ___) | (_| (_| | | | | | | | | | | | (_| |
- |____/ \___\__,_|_| |_|_| |_|_|_| |_|\__, |
- |___/
-
- -->
- <class>
- <name>RepositoryScanningConfiguration</name>
- <version>1.0.0+</version>
- <fields>
- <field>
- <name>fileTypes</name>
- <version>1.0.0+</version>
- <required>true</required>
- <association>
- <type>FileType</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- The FileTypes for the repository scanning configuration.
- </description>
- </field>
- <field>
- <name>knownContentConsumers</name>
- <version>1.0.0+</version>
- <required>true</required>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- The list of active consumers IDs for known content.
- </description>
- </field>
- <field>
- <name>invalidContentConsumers</name>
- <version>1.0.0+</version>
- <required>true</required>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- The list of active consumer IDs for invalid content.
- </description>
- </field>
- </fields>
- </class>
- <class>
- <name>FileType</name>
- <version>1.0.0+</version>
- <description>The FileType object</description>
- <fields>
- <field>
- <name>id</name>
- <version>1.0.0+</version>
- <required>true</required>
- <type>String</type>
- </field>
- <field>
- <name>patterns</name>
- <version>1.0.0+</version>
- <required>true</required>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- </fields>
- </class>
- <class>
- <name>DatabaseScanningConfiguration</name>
- <version>1.0.0+</version>
- <description>
- The scanning configuration for unprocessed ArchivaArtifact database objects.
- </description>
- <fields>
- <field>
- <name>cronExpression</name>
- <version>1.0.0+</version>
- <type>String</type>
- <description>When to run the database scanning mechanism. Default is every two hours on the hour.</description>
- <defaultValue>0 0 0/2 * * ?</defaultValue>
- </field>
- <field>
- <name>unprocessedConsumers</name>
- <version>1.0.0+</version>
- <required>true</required>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- The list of consumers for the unprocessed ArchivaArtifact database objects.
- </description>
- </field>
- <field>
- <name>cleanupConsumers</name>
- <version>1.0.0+</version>
- <required>true</required>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- The list of consumers for previously processed ArchivaArtifact database
- objects that no longer exist on the filesystem, and might need to
- undergo a cleanup.
- </description>
- </field>
- </fields>
- </class>
- \r
+ </class>\r
+\r
+ <!-- \r
+ ____ _\r
+ / ___| ___ __ _ _ __ _ __ (_)_ __ __ _\r
+ \___ \ / __/ _` | '_ \| '_ \| | '_ \ / _` |\r
+ ___) | (_| (_| | | | | | | | | | | | (_| |\r
+ |____/ \___\__,_|_| |_|_| |_|_|_| |_|\__, |\r
+ |___/\r
+\r
+ -->\r
+ <class>\r
+ <name>RepositoryScanningConfiguration</name>\r
+ <version>1.0.0+</version>\r
+ <fields>\r
+ <field>\r
+ <name>fileTypes</name>\r
+ <version>1.0.0+</version>\r
+ <required>true</required>\r
+ <association>\r
+ <type>FileType</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>\r
+ The FileTypes for the repository scanning configuration.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>knownContentConsumers</name>\r
+ <version>1.0.0+</version>\r
+ <required>true</required>\r
+ <association>\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>\r
+ The list of active consumers IDs for known content.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>invalidContentConsumers</name>\r
+ <version>1.0.0+</version>\r
+ <required>true</required>\r
+ <association>\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>\r
+ The list of active consumer IDs for invalid content.\r
+ </description>\r
+ </field>\r
+ </fields>\r
+ </class>\r
+ <class>\r
+ <name>FileType</name>\r
+ <version>1.0.0+</version>\r
+ <description>The FileType object</description>\r
+ <fields>\r
+ <field>\r
+ <name>id</name>\r
+ <version>1.0.0+</version>\r
+ <required>true</required>\r
+ <type>String</type>\r
+ </field>\r
+ <field>\r
+ <name>patterns</name>\r
+ <version>1.0.0+</version>\r
+ <required>true</required>\r
+ <association>\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ </field>\r
+ </fields>\r
+ </class>\r
+ <class>\r
+ <name>DatabaseScanningConfiguration</name>\r
+ <version>1.0.0+</version>\r
+ <description>\r
+ The scanning configuration for unprocessed ArchivaArtifact database objects.\r
+ </description>\r
+ <fields>\r
+ <field>\r
+ <name>cronExpression</name>\r
+ <version>1.0.0+</version>\r
+ <type>String</type>\r
+ <description>When to run the database scanning mechanism. Default is every two hours on the hour.\r
+ </description>\r
+ <defaultValue>0 0 0/2 * * ?</defaultValue>\r
+ </field>\r
+ <field>\r
+ <name>unprocessedConsumers</name>\r
+ <version>1.0.0+</version>\r
+ <required>true</required>\r
+ <association>\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>\r
+ The list of consumers for the unprocessed ArchivaArtifact database objects.\r
+ </description>\r
+ </field>\r
+ <field>\r
+ <name>cleanupConsumers</name>\r
+ <version>1.0.0+</version>\r
+ <required>true</required>\r
+ <association>\r
+ <type>String</type>\r
+ <multiplicity>*</multiplicity>\r
+ </association>\r
+ <description>\r
+ The list of consumers for previously processed ArchivaArtifact database\r
+ objects that no longer exist on the filesystem, and might need to\r
+ undergo a cleanup.\r
+ </description>\r
+ </field>\r
+ </fields>\r
+ </class>\r
+\r
<!-- \r
__ _______ ____ _ ____ ____ \r
\ \ / / ____| __ ) / \ | _ \| _ \ \r
\_/\_/ |_____|____/_/ \_\_| |_| \r
\r
-->\r
- \r
+\r
<class>\r
<name>WebappConfiguration</name>\r
<version>1.0.0+</version>\r
<version>1.0.0+</version>\r
<association>\r
<type>UserInterfaceOptions</type>\r
- </association> \r
+ </association>\r
</field>\r
</fields>\r
</class>\r
- \r
+\r
<class>\r
<name>UserInterfaceOptions</name>\r
<version>1.0.0+</version>\r
<field>\r
<name>showFindArtifacts</name>\r
<description>true if find artifacts should be enabled</description>\r
- <version>1.0.0+</version> \r
- <type>boolean</type> \r
+ <version>1.0.0+</version>\r
+ <type>boolean</type>\r
<defaultValue>true</defaultValue>\r
</field>\r
<field>\r
<name>appletFindEnabled</name>\r
<description>true if applet behavior for find artifacts should be enabled</description>\r
- <version>1.0.0+</version> \r
- <type>boolean</type> \r
+ <version>1.0.0+</version>\r
+ <type>boolean</type>\r
<defaultValue>true</defaultValue>\r
</field>\r
</fields>\r
</class>\r
- \r
+\r
</classes>\r
</model>\r
\r
--- /dev/null
+<?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>
+ <directory>managed-repository</directory>
+ <id>local</id>
+ <name>local</name>
+ </repository>
+ </repositories>
+ <proxiedRepositories>
+ <proxiedRepository>
+ <url>http://www.ibiblio.org/maven2/</url>
+ <managedRepository>local</managedRepository>
+ <useNetworkProxy>true</useNetworkProxy>
+ <id>ibiblio</id>
+ <name>Ibiblio</name>
+ </proxiedRepository>
+ <proxiedRepository>
+ <url>http://repository.codehaus.org/</url>
+ <managedRepository>local</managedRepository>
+ <id>codehaus</id>
+ <name>Codehaus</name>
+ </proxiedRepository>
+ </proxiedRepositories>
+</configuration>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
-->
<configuration>
+ <version>1</version>
<repositories>
<repository>
<id>internal</id>
+++ /dev/null
-<?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>
- <directory>managed-repository</directory>
- <id>local</id>
- <name>local</name>
- </repository>
- </repositories>
- <proxiedRepositories>
- <proxiedRepository>
- <url>http://www.ibiblio.org/maven2/</url>
- <managedRepository>local</managedRepository>
- <useNetworkProxy>true</useNetworkProxy>
- <id>ibiblio</id>
- <name>Ibiblio</name>
- </proxiedRepository>
- <proxiedRepository>
- <url>http://repository.codehaus.org/</url>
- <managedRepository>local</managedRepository>
- <id>codehaus</id>
- <name>Codehaus</name>
- </proxiedRepository>
- </proxiedRepositories>
-</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;
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 );
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()
// 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 );
// 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()
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 );
// 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()
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 );
// 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() );
}
}
<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>
<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>
<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>
<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>
<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>
<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>
</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>
</requirement>
- <requirement>
- <role>org.apache.maven.archiva.configuration.ConfigurationUpgrade</role>
- <field-name>upgrader</field-name>
- </requirement>
</requirements>
</component>
<component>
<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>
<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">
</lifecycle-handler>
</lifecycle-handlers>
</lifecycle-handler-manager>
-
+
</component-set>
<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>
</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>
</otherProperties>
</configuration>
</component>
-
+
</components>
</component-set>
<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>
<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>
</properties>
</configuration>
</component>
-
+
<component>
<role>org.codehaus.plexus.jdo.JdoFactory</role>
<role-hint>archiva</role-hint>
</otherProperties>
</configuration>
</component>
-
+
</components>
</component-set>
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;
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;
* The configuration.
*/
private Configuration configuration;
-
+
public void validate()
{
getLogger().info( "validate()" );
// 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;
}
*/
import com.opensymphony.xwork.Preparable;
-
import org.apache.commons.collections.Closure;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.functors.IfClosure;
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;
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
private String pattern;
/**
- * The list of possible proxy ids.
+ * The list of possible proxy ids.
*/
private List proxyIdOptions = new ArrayList();
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;
}
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 );
{
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;
}
}
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;
}
}
{
addActionError( "Unable to save configuration: " + e.getMessage() );
}
+ catch ( IndeterminateConfigurationException e )
+ {
+ addActionError( e.getMessage() );
+ }
return SUCCESS;
}
*/
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;
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
* 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.
*/
this.cron = dbscanning.getCronExpression();
AddAdminDatabaseConsumerClosure addAdminDbConsumer;
-
+
addAdminDbConsumer = new AddAdminDatabaseConsumerClosure( dbscanning.getUnprocessedConsumers() );
CollectionUtils.forAllDo( databaseConsumers.getAvailableUnprocessedConsumers(), addAdminDbConsumer );
this.unprocessedConsumers = addAdminDbConsumer.getList();
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
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
{
*/
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;
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
{
addActionError( "Unable to save configuration: " + e.getMessage() );
}
+ catch ( IndeterminateConfigurationException e )
+ {
+ addActionError( e.getMessage() );
+ }
return SUCCESS;
}
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;
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;
}
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;
}
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;
}
return SUCCESS;
}
- private boolean validateFields(String mode)
+ private boolean validateFields( String mode )
{
boolean containsError = false;
CronExpressionValidator validator = new CronExpressionValidator();
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;
}
{
repository.setUrl( PathUtil.toUrl( rawUrlEntry ) );
}
-
+
if ( repository.isManaged() )
{
// Normalize the path
}
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;
}
}
{
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;
}
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;
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
* List of {@link AdminRepositoryConsumer} objects for consumers of known content.
*/
private List knownContentConsumers;
-
+
/**
* List of enabled {@link AdminRepositoryConsumer} objects for consumers of known content.
*/
* 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.
*/
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() + "]" );
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();
}
addActionError( "Unable to save configuration: " + e.getMessage() );
return INPUT;
}
+ catch ( IndeterminateConfigurationException e )
+ {
+ addActionError( e.getMessage() );
+ return INPUT;
+ }
return SUCCESS;
}
<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"/>
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"/>
<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"/>
<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>