mirror of
https://github.com/apache/archiva.git
synced 2025-02-07 10:39:02 +00:00
[MRM-462] separate repository configuration (not yet applied to web application screens)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@567269 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d2d0e7eb37
commit
a353e20d87
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility methods for testing the configuration property name.
|
||||
* Utility methods for testing the configuration property name.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
@ -37,9 +37,14 @@ public static boolean isRepositoryScanning( String propertyName )
|
||||
return startsWith( "repositoryScanning.", propertyName );
|
||||
}
|
||||
|
||||
public static boolean isRepositories( String propertyName )
|
||||
public static boolean isManagedRepositories( String propertyName )
|
||||
{
|
||||
return startsWith( "repositories.", propertyName );
|
||||
return startsWith( "managedRepositories.", propertyName );
|
||||
}
|
||||
|
||||
public static boolean isRemoteRepositories( String propertyName )
|
||||
{
|
||||
return startsWith( "remoteRepositories.", propertyName );
|
||||
}
|
||||
|
||||
public static boolean isProxyConnector( String propertyName )
|
||||
|
@ -118,6 +118,29 @@ private Configuration load()
|
||||
|
||||
Configuration config = new ConfigurationRegistryReader().read( subset );
|
||||
|
||||
if ( !config.getRepositories().isEmpty() )
|
||||
{
|
||||
for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); )
|
||||
{
|
||||
V1RepositoryConfiguration r = (V1RepositoryConfiguration) i.next();
|
||||
|
||||
if ( r.getUrl().startsWith( "file://" ) )
|
||||
{
|
||||
r.setLocation( r.getUrl().substring( 7 ) );
|
||||
config.addManagedRepository( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
|
||||
repo.setId( r.getId() );
|
||||
repo.setLayout( r.getLayout() );
|
||||
repo.setName( r.getName() );
|
||||
repo.setUrl( r.getUrl() );
|
||||
config.addRemoteRepository( repo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@ -163,7 +186,8 @@ else if ( baseSection != null )
|
||||
// that configuration
|
||||
if ( key.startsWith( "repositories" ) || key.startsWith( "proxyConnectors" ) ||
|
||||
key.startsWith( "networkProxies" ) || key.startsWith( "repositoryScanning" ) ||
|
||||
key.startsWith( "databaseScanning" ) )
|
||||
key.startsWith( "databaseScanning" ) || key.startsWith( "remoteRepositories" ) ||
|
||||
key.startsWith( "managedRepositories" ) )
|
||||
{
|
||||
foundList = true;
|
||||
}
|
||||
@ -279,10 +303,10 @@ private String escapeCronExpression( String cronExpression )
|
||||
private Configuration processExpressions( Configuration config )
|
||||
{
|
||||
// TODO: for commons-configuration 1.3 only
|
||||
for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); )
|
||||
for ( Iterator i = config.getManagedRepositories().iterator(); i.hasNext(); )
|
||||
{
|
||||
RepositoryConfiguration c = (RepositoryConfiguration) i.next();
|
||||
c.setUrl( removeExpressions( c.getUrl() ) );
|
||||
ManagedRepositoryConfiguration c = (ManagedRepositoryConfiguration) i.next();
|
||||
c.setLocation( removeExpressions( c.getLocation() ) );
|
||||
c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression() ) );
|
||||
}
|
||||
|
||||
@ -298,9 +322,9 @@ private Configuration processExpressions( Configuration config )
|
||||
|
||||
private Configuration escapeCronExpressions( Configuration config )
|
||||
{
|
||||
for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); )
|
||||
for ( Iterator i = config.getManagedRepositories().iterator(); i.hasNext(); )
|
||||
{
|
||||
RepositoryConfiguration c = (RepositoryConfiguration) i.next();
|
||||
ManagedRepositoryConfiguration c = (ManagedRepositoryConfiguration) i.next();
|
||||
|
||||
c.setRefreshCronExpression( escapeCronExpression( c.getRefreshCronExpression() ) );
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
import org.apache.maven.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.maven.archiva.policies.SnapshotsPolicy;
|
||||
|
||||
@ -48,11 +47,14 @@ public void load( Properties props, Configuration configuration )
|
||||
// set up the managed repository
|
||||
String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE );
|
||||
|
||||
RepositoryConfiguration config = new RepositoryConfiguration();
|
||||
config.setUrl( PathUtil.toUrl( localCachePath ) );
|
||||
ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration();
|
||||
config.setLocation( localCachePath );
|
||||
config.setName( "Imported Maven-Proxy Cache" );
|
||||
config.setId( "maven-proxy" );
|
||||
configuration.addRepository( config );
|
||||
config.setIndexed( false );
|
||||
config.setReleases( true );
|
||||
config.setSnapshots( false );
|
||||
configuration.addManagedRepository( config );
|
||||
|
||||
// Add the network proxies.
|
||||
String propertyList = props.getProperty( PROXY_LIST );
|
||||
@ -91,26 +93,21 @@ public void load( Properties props, Configuration configuration )
|
||||
|
||||
int cachePeriod = Integer.parseInt( repoProps.getProperty( "cache.period", "60" ) );
|
||||
|
||||
RepositoryConfiguration repository = new RepositoryConfiguration();
|
||||
RemoteRepositoryConfiguration repository = new RemoteRepositoryConfiguration();
|
||||
repository.setId( key );
|
||||
repository.setName( "Imported Maven-Proxy Remote Proxy" );
|
||||
repository.setUrl( url );
|
||||
repository.setLayout( "legacy" );
|
||||
repository.setIndexed( false );
|
||||
repository.setReleases( true );
|
||||
repository.setSnapshots( false );
|
||||
|
||||
configuration.addRepository( repository );
|
||||
configuration.addRemoteRepository( repository );
|
||||
|
||||
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
|
||||
proxyConnector.setSourceRepoId( "maven-proxy" );
|
||||
proxyConnector.setTargetRepoId( key );
|
||||
proxyConnector.setProxyId( proxyKey );
|
||||
// TODO: convert cachePeriod to closest "daily" or "hourly"
|
||||
proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS,
|
||||
SnapshotsPolicy.DAILY );
|
||||
proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES,
|
||||
ReleasesPolicy.IGNORED );
|
||||
proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_SNAPSHOTS, SnapshotsPolicy.DAILY );
|
||||
proxyConnector.addPolicy( ProxyConnectorConfiguration.POLICY_RELEASES, ReleasesPolicy.IGNORED );
|
||||
|
||||
configuration.addProxyConnector( proxyConnector );
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
package org.apache.maven.archiva.configuration.functors;
|
||||
|
||||
/*
|
||||
* 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.collections.Predicate;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
|
||||
/**
|
||||
* Predicate for Repositories with their Indexed setting set to true.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class IndexedRepositoryPredicate
|
||||
implements Predicate
|
||||
{
|
||||
private static IndexedRepositoryPredicate INSTANCE = new IndexedRepositoryPredicate();
|
||||
|
||||
public static IndexedRepositoryPredicate getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public boolean evaluate( Object object )
|
||||
{
|
||||
boolean satisfies = false;
|
||||
|
||||
if ( object instanceof RepositoryConfiguration )
|
||||
{
|
||||
RepositoryConfiguration repoconfig = (RepositoryConfiguration) object;
|
||||
return repoconfig.isIndexed();
|
||||
}
|
||||
|
||||
return satisfies;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package org.apache.maven.archiva.configuration.functors;
|
||||
|
||||
/*
|
||||
* 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.collections.Predicate;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
|
||||
/**
|
||||
* Predicate for {@link RepositoryConfiguration} objects that are local (aka managed)
|
||||
* {@link RepositoryConfiguration#isManaged()}
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class LocalRepositoryPredicate
|
||||
implements Predicate
|
||||
{
|
||||
public static final Predicate INSTANCE = new LocalRepositoryPredicate();
|
||||
|
||||
public static Predicate getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public boolean evaluate( Object object )
|
||||
{
|
||||
boolean satisfies = false;
|
||||
|
||||
if ( object instanceof RepositoryConfiguration )
|
||||
{
|
||||
RepositoryConfiguration repoconfig = (RepositoryConfiguration) object;
|
||||
return repoconfig.isManaged();
|
||||
}
|
||||
|
||||
return satisfies;
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package org.apache.maven.archiva.configuration.functors;
|
||||
|
||||
/*
|
||||
* 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.collections.Predicate;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
|
||||
/**
|
||||
* Predicate for {@link RepositoryConfiguration} objects that are remote
|
||||
* {@link RepositoryConfiguration#isRemote()}
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RemoteRepositoryPredicate
|
||||
implements Predicate
|
||||
{
|
||||
public static final Predicate INSTANCE = new RemoteRepositoryPredicate();
|
||||
|
||||
public static Predicate getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public boolean evaluate( Object object )
|
||||
{
|
||||
boolean satisfies = false;
|
||||
|
||||
if ( object instanceof RepositoryConfiguration )
|
||||
{
|
||||
RepositoryConfiguration repoconfig = (RepositoryConfiguration) object;
|
||||
return repoconfig.isRemote();
|
||||
}
|
||||
|
||||
return satisfies;
|
||||
}
|
||||
}
|
@ -19,45 +19,36 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* RepositoryConfigurationComparator
|
||||
* RepositoryConfigurationComparator
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RepositoryConfigurationComparator
|
||||
implements Comparator
|
||||
implements Comparator<AbstractRepositoryConfiguration>
|
||||
{
|
||||
|
||||
public int compare( Object o1, Object o2 )
|
||||
public int compare( AbstractRepositoryConfiguration o1, AbstractRepositoryConfiguration o2 )
|
||||
{
|
||||
if ( o1 == null && o2 == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( o1 == null && o2 != null )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( o1 != null && o2 == null )
|
||||
if ( o1 == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( ( o1 instanceof RepositoryConfiguration ) && ( o2 instanceof RepositoryConfiguration ) )
|
||||
if ( o2 == null )
|
||||
{
|
||||
String id1 = ( (RepositoryConfiguration) o1 ).getId();
|
||||
String id2 = ( (RepositoryConfiguration) o2 ).getId();
|
||||
return id1.compareToIgnoreCase( id2 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return o1.getId().compareToIgnoreCase( o2.getId() );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
package org.apache.maven.archiva.configuration.functors;
|
||||
|
||||
/*
|
||||
* 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.collections.Closure;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* RepositoryConfigurationToMapClosure
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RepositoryConfigurationToMapClosure
|
||||
implements Closure
|
||||
{
|
||||
private Map map = new HashMap();
|
||||
|
||||
public void execute( Object input )
|
||||
{
|
||||
if ( input instanceof RepositoryConfiguration )
|
||||
{
|
||||
RepositoryConfiguration repo = (RepositoryConfiguration) input;
|
||||
map.put( repo.getId(), repo );
|
||||
}
|
||||
}
|
||||
|
||||
public Map getMap()
|
||||
{
|
||||
return map;
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package org.apache.maven.archiva.configuration.functors;
|
||||
|
||||
/*
|
||||
* 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.collections.Closure;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* RepositoryIdListClosure
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RepositoryIdListClosure
|
||||
implements Closure
|
||||
{
|
||||
private List list;
|
||||
|
||||
public RepositoryIdListClosure( List list )
|
||||
{
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public void execute( Object input )
|
||||
{
|
||||
if ( input instanceof RepositoryConfiguration )
|
||||
{
|
||||
RepositoryConfiguration repoconfig = (RepositoryConfiguration) input;
|
||||
list.add( repoconfig.getId() );
|
||||
}
|
||||
}
|
||||
|
||||
public List getList()
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
@ -43,13 +43,30 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>repositories</name>
|
||||
<version>1.0.0</version>
|
||||
<association>
|
||||
<type>V1RepositoryConfiguration</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>managedRepositories</name>
|
||||
<version>1.0.0+</version>
|
||||
<association>
|
||||
<type>RepositoryConfiguration</type>
|
||||
<type>ManagedRepositoryConfiguration</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
<description>The list of repositories that this archiva instance uses.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>remoteRepositories</name>
|
||||
<version>1.0.0+</version>
|
||||
<association>
|
||||
<type>RemoteRepositoryConfiguration</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
<description>The list of repositories that this archiva can retrieve from or publish to.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>proxyConnectors</name>
|
||||
<version>1.0.0+</version>
|
||||
@ -119,58 +136,78 @@
|
||||
<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 )
|
||||
public java.util.Map<String, NetworkProxyConfiguration> getNetworkProxiesAsMap()
|
||||
{
|
||||
// null id = null repo config.
|
||||
if ( id == null )
|
||||
java.util.Map<String, NetworkProxyConfiguration> map = new java.util.HashMap<String, NetworkProxyConfiguration>();
|
||||
if ( networkProxies != null )
|
||||
{
|
||||
return null;
|
||||
for ( java.util.Iterator i = networkProxies.iterator(); i.hasNext(); )
|
||||
{
|
||||
NetworkProxyConfiguration proxy = (NetworkProxyConfiguration) i.next();
|
||||
map.put( proxy.getId(), proxy );
|
||||
}
|
||||
}
|
||||
|
||||
// empty id = null repo config.
|
||||
if ( id.trim().length() <= 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (RepositoryConfiguration) createRepositoryMap().get( id );
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a RepositoryMap of the current repositories.
|
||||
*
|
||||
* @return the map of repository id's, to repository configurations.
|
||||
*/
|
||||
public java.util.Map createRepositoryMap()
|
||||
public java.util.Map<String, RemoteRepositoryConfiguration> getRemoteRepositoriesAsMap()
|
||||
{
|
||||
java.util.Map ret = new java.util.HashMap();
|
||||
|
||||
// null repository list = null repo config.
|
||||
if ( getRepositories() == null )
|
||||
java.util.Map<String, RemoteRepositoryConfiguration> map = new java.util.HashMap<String, RemoteRepositoryConfiguration>();
|
||||
if ( remoteRepositories != null )
|
||||
{
|
||||
return ret;
|
||||
for ( java.util.Iterator i = remoteRepositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
RemoteRepositoryConfiguration repo = (RemoteRepositoryConfiguration) i.next();
|
||||
map.put( repo.getId(), repo );
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// empty repository list == null repo config.
|
||||
if ( getRepositories().isEmpty() )
|
||||
public RemoteRepositoryConfiguration findRemoteRepositoryById( String id )
|
||||
{
|
||||
if ( remoteRepositories != null )
|
||||
{
|
||||
return ret;
|
||||
for ( java.util.Iterator i = remoteRepositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
RemoteRepositoryConfiguration repo = (RemoteRepositoryConfiguration) i.next();
|
||||
if ( repo.getId().equals( id ) )
|
||||
{
|
||||
return repo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java.util.Iterator it = getRepositories().iterator();
|
||||
while ( it.hasNext() )
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.util.Map<String, ManagedRepositoryConfiguration> getManagedRepositoriesAsMap()
|
||||
{
|
||||
java.util.Map<String, ManagedRepositoryConfiguration> map = new java.util.HashMap<String, ManagedRepositoryConfiguration>();
|
||||
if ( managedRepositories != null )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = (RepositoryConfiguration) it.next();
|
||||
ret.put( repoConfig.getId(), repoConfig );
|
||||
for ( java.util.Iterator i = managedRepositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
ManagedRepositoryConfiguration repo = (ManagedRepositoryConfiguration) i.next();
|
||||
map.put( repo.getId(), repo );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return map;
|
||||
}
|
||||
|
||||
public ManagedRepositoryConfiguration findManagedRepositoryById( String id )
|
||||
{
|
||||
if ( managedRepositories != null )
|
||||
{
|
||||
for ( java.util.Iterator i = managedRepositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
ManagedRepositoryConfiguration repo = (ManagedRepositoryConfiguration) i.next();
|
||||
if ( repo.getId().equals( id ) )
|
||||
{
|
||||
return repo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
@ -188,8 +225,9 @@
|
||||
-->
|
||||
|
||||
<class>
|
||||
<name>RepositoryConfiguration</name>
|
||||
<name>AbstractRepositoryConfiguration</name>
|
||||
<version>1.0.0+</version>
|
||||
<abstract>true</abstract>
|
||||
<fields>
|
||||
<field>
|
||||
<name>id</name>
|
||||
@ -209,15 +247,6 @@
|
||||
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>
|
||||
@ -229,6 +258,38 @@
|
||||
<!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) -->
|
||||
<defaultValue>default</defaultValue>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>RemoteRepositoryConfiguration</name>
|
||||
<version>1.0.0+</version>
|
||||
<superClass>AbstractRepositoryConfiguration</superClass>
|
||||
<fields>
|
||||
<field>
|
||||
<name>url</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<required>true</required>
|
||||
<description>
|
||||
The URL for this repository.
|
||||
</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>ManagedRepositoryConfiguration</name>
|
||||
<version>1.0.0+</version>
|
||||
<superClass>AbstractRepositoryConfiguration</superClass>
|
||||
<fields>
|
||||
<field>
|
||||
<name>location</name>
|
||||
<version>1.0.0+</version>
|
||||
<type>String</type>
|
||||
<required>true</required>
|
||||
<description>
|
||||
The file system location for this repository.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>releases</name>
|
||||
<version>1.0.0+</version>
|
||||
@ -243,6 +304,7 @@
|
||||
<description>True if this repository contains snapshot versioned artifacts.</description>
|
||||
<defaultValue>false</defaultValue>
|
||||
</field>
|
||||
<!-- TODO! is indexed better named as scanned? check it's usages (or lack of usages) when iterating repos -->
|
||||
<field>
|
||||
<name>indexed</name>
|
||||
<version>1.0.0+</version>
|
||||
@ -273,7 +335,7 @@
|
||||
<version>1.0.0+</version>
|
||||
<type>int</type>
|
||||
<description>
|
||||
The total count of the artifact to be retained for each snapshot.
|
||||
The total count of the artifact to be retained for each snapshot.
|
||||
</description>
|
||||
<defaultValue>2</defaultValue>
|
||||
</field>
|
||||
@ -282,7 +344,7 @@
|
||||
<version>1.0.0+</version>
|
||||
<type>int</type>
|
||||
<description>
|
||||
The number of days old which will be the basis for removing a snapshot.
|
||||
The number of days old which will be the basis for removing a snapshot.
|
||||
</description>
|
||||
<defaultValue>100</defaultValue>
|
||||
</field>
|
||||
@ -291,52 +353,27 @@
|
||||
<version>1.0.0+</version>
|
||||
<type>boolean</type>
|
||||
<description>
|
||||
True if the released snapshots are to be removed from the repo during repository purge.
|
||||
True if the released snapshots are to be removed from the repo during repository purge.
|
||||
</description>
|
||||
<defaultValue>false</defaultValue>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
</class>
|
||||
<class>
|
||||
<name>V1RepositoryConfiguration</name>
|
||||
<version>1.0.0</version>
|
||||
<superClass>ManagedRepositoryConfiguration</superClass>
|
||||
<fields>
|
||||
<field>
|
||||
<name>url</name>
|
||||
<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>
|
||||
</codeSegments>
|
||||
<type>String</type>
|
||||
<required>true</required>
|
||||
<description>
|
||||
The URL for this repository.
|
||||
</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
<!--
|
||||
|
@ -1,48 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<version>1</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<version>2</version>
|
||||
<managedRepositories>
|
||||
<managedRepository>
|
||||
<id>internal</id>
|
||||
<name>Archiva Managed Internal Repository</name>
|
||||
<url>file://${appserver.base}/data/repositories/internal</url>
|
||||
<location>${appserver.base}/data/repositories/internal</location>
|
||||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0 0 * * ?</refreshCronExpression>
|
||||
<daysOlder>30</daysOlder>
|
||||
</repository>
|
||||
<repository>
|
||||
</managedRepository>
|
||||
<managedRepository>
|
||||
<id>snapshots</id>
|
||||
<name>Archiva Managed Snapshot Repository</name>
|
||||
<url>file://${appserver.base}/data/repositories/snapshots</url>
|
||||
<location>${appserver.base}/data/repositories/snapshots</location>
|
||||
<layout>default</layout>
|
||||
<releases>false</releases>
|
||||
<snapshots>true</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0\,30 0 * * ?</refreshCronExpression>
|
||||
<daysOlder>30</daysOlder>
|
||||
</repository>
|
||||
<repository>
|
||||
</managedRepository>
|
||||
</managedRepositories>
|
||||
<remoteRepositories>
|
||||
<remoteRepository>
|
||||
<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>
|
||||
</remoteRepository>
|
||||
<remoteRepository>
|
||||
<id>maven2-repository.dev.java.net</id>
|
||||
<name>Java.net Repository for Maven 2</name>
|
||||
<url>http://download.java.net/maven/2/</url>
|
||||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<indexed>false</indexed>
|
||||
</repository>
|
||||
</repositories>
|
||||
</remoteRepository>
|
||||
</remoteRepositories>
|
||||
|
||||
<proxyConnectors>
|
||||
<proxyConnector>
|
||||
|
@ -0,0 +1,189 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
~ distributed with this work for additional information
|
||||
~ regarding copyright ownership. The ASF licenses this file
|
||||
~ to you under the Apache License, Version 2.0 (the
|
||||
~ "License"); you may not use this file except in compliance
|
||||
~ with the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>internal</id>
|
||||
<name>Archiva Managed Internal Repository</name>
|
||||
<url>file://${appserver.base}/repositories/internal</url>
|
||||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0 * * ?</refreshCronExpression>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>snapshots</id>
|
||||
<name>Archiva Managed Snapshot Repository</name>
|
||||
<url>file://${appserver.base}/repositories/internal</url>
|
||||
<layout>default</layout>
|
||||
<releases>false</releases>
|
||||
<snapshots>true</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0,30 * * ?</refreshCronExpression>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>Central Repository</name>
|
||||
<url>http://repo1.maven.org/maven2</url>
|
||||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<indexed>false</indexed>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>maven2-repository.dev.java.net</id>
|
||||
<name>Java.net Repository for Maven 2</name>
|
||||
<url>https://maven2-repository.dev.java.net/nonav/repository</url>
|
||||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<indexed>false</indexed>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<proxyConnectors>
|
||||
<proxyConnector>
|
||||
<sourceRepoId>internal</sourceRepoId>
|
||||
<targetRepoId>central</targetRepoId>
|
||||
<proxyId/>
|
||||
<snapshotsPolicy>disabled</snapshotsPolicy>
|
||||
<releasePolicy>never</releasePolicy>
|
||||
<failurePolicy>not-found</failurePolicy>
|
||||
</proxyConnector>
|
||||
<proxyConnector>
|
||||
<sourceRepoId>internal</sourceRepoId>
|
||||
<targetRepoId>maven2-repository.dev.java.net</targetRepoId>
|
||||
<proxyId/>
|
||||
<snapshotsPolicy>disabled</snapshotsPolicy>
|
||||
<releasePolicy>never</releasePolicy>
|
||||
<failurePolicy>not-found</failurePolicy>
|
||||
<whiteListPatterns>
|
||||
<whiteListPattern>javax/**</whiteListPattern>
|
||||
</whiteListPatterns>
|
||||
</proxyConnector>
|
||||
</proxyConnectors>
|
||||
|
||||
<networkProxies>
|
||||
<networkProxy>
|
||||
<id>example</id>
|
||||
<protocol>http</protocol>
|
||||
<host>proxy.mycompany.com</host>
|
||||
<port>8080</port>
|
||||
<username>myself</username>
|
||||
<password>mypass</password>
|
||||
</networkProxy>
|
||||
</networkProxies>
|
||||
|
||||
<repositoryScanning>
|
||||
<fileTypes>
|
||||
<fileType>
|
||||
<id>artifacts</id>
|
||||
<patterns>
|
||||
<pattern>**/*.pom</pattern>
|
||||
<pattern>**/*.jar</pattern>
|
||||
<pattern>**/*.ear</pattern>
|
||||
<pattern>**/*.war</pattern>
|
||||
<pattern>**/*.car</pattern>
|
||||
<pattern>**/*.sar</pattern>
|
||||
<pattern>**/*.mar</pattern>
|
||||
<pattern>**/*.rar</pattern>
|
||||
<pattern>**/*.dtd</pattern>
|
||||
<pattern>**/*.tld</pattern>
|
||||
<pattern>**/*.tar.gz</pattern>
|
||||
<pattern>**/*.tar.bz2</pattern>
|
||||
<pattern>**/*.zip</pattern>
|
||||
</patterns>
|
||||
</fileType>
|
||||
<fileType>
|
||||
<id>indexable-content</id>
|
||||
<patterns>
|
||||
<pattern>**/*.txt</pattern>
|
||||
<pattern>**/*.TXT</pattern>
|
||||
<pattern>**/*.block</pattern>
|
||||
<pattern>**/*.config</pattern>
|
||||
<pattern>**/*.pom</pattern>
|
||||
<pattern>**/*.xml</pattern>
|
||||
<pattern>**/*.xsd</pattern>
|
||||
<pattern>**/*.dtd</pattern>
|
||||
<pattern>**/*.tld</pattern>
|
||||
</patterns>
|
||||
</fileType>
|
||||
<fileType>
|
||||
<id>auto-remove</id>
|
||||
<patterns>
|
||||
<pattern>**/*.bak</pattern>
|
||||
<pattern>**/*~</pattern>
|
||||
<pattern>**/*-</pattern>
|
||||
</patterns>
|
||||
</fileType>
|
||||
<fileType>
|
||||
<id>ignored</id>
|
||||
<patterns>
|
||||
<pattern>**/.htaccess</pattern>
|
||||
<pattern>**/KEYS</pattern>
|
||||
<pattern>**/*.rb</pattern>
|
||||
<pattern>**/*.sh</pattern>
|
||||
<pattern>**/.svn/**</pattern>
|
||||
<pattern>**/.DAV/**</pattern>
|
||||
</patterns>
|
||||
</fileType>
|
||||
</fileTypes>
|
||||
<knownContentConsumers>
|
||||
<knownContentConsumer>update-db-artifact</knownContentConsumer>
|
||||
<knownContentConsumer>create-missing-checksums</knownContentConsumer>
|
||||
<knownContentConsumer>update-db-repository-metadata</knownContentConsumer>
|
||||
<knownContentConsumer>validate-checksum</knownContentConsumer>
|
||||
<knownContentConsumer>validate-signature</knownContentConsumer>
|
||||
<knownContentConsumer>index-content</knownContentConsumer>
|
||||
<knownContentConsumer>auto-remove</knownContentConsumer>
|
||||
<knownContentConsumer>auto-rename</knownContentConsumer>
|
||||
</knownContentConsumers>
|
||||
<invalidContentConsumers>
|
||||
<invalidContentConsumer>update-db-bad-content</invalidContentConsumer>
|
||||
</invalidContentConsumers>
|
||||
</repositoryScanning>
|
||||
|
||||
<databaseScanning>
|
||||
<cronExpression>0 0 * * ?</cronExpression>
|
||||
<unprocessedConsumers>
|
||||
<unprocessedConsumer>index-artifact</unprocessedConsumer>
|
||||
<unprocessedConsumer>update-db-project</unprocessedConsumer>
|
||||
<unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
|
||||
<unprocessedConsumer>index-archive-toc</unprocessedConsumer>
|
||||
<unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
|
||||
<unprocessedConsumer>index-public-methods</unprocessedConsumer>
|
||||
</unprocessedConsumers>
|
||||
<cleanupConsumers>
|
||||
<cleanupConsumer>not-present-remove-db-artifact</cleanupConsumer>
|
||||
<cleanupConsumer>not-present-remove-db-project</cleanupConsumer>
|
||||
<cleanupConsumer>not-present-remove-indexed</cleanupConsumer>
|
||||
</cleanupConsumers>
|
||||
</databaseScanning>
|
||||
|
||||
<webapp>
|
||||
<ui>
|
||||
<showFindArtifacts>true</showFindArtifacts>
|
||||
<appletFindEnabled>true</appletFindEnabled>
|
||||
</ui>
|
||||
</webapp>
|
||||
|
||||
</configuration>
|
@ -19,47 +19,43 @@
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<version>1</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<version>2</version>
|
||||
<managedRepositories>
|
||||
<managedRepository>
|
||||
<id>internal</id>
|
||||
<name>Archiva Managed Internal Repository</name>
|
||||
<url>file://${appserver.base}/repositories/internal</url>
|
||||
<location>${appserver.base}/repositories/internal</location>
|
||||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0 * * ?</refreshCronExpression>
|
||||
</repository>
|
||||
<repository>
|
||||
</managedRepository>
|
||||
<managedRepository>
|
||||
<id>snapshots</id>
|
||||
<name>Archiva Managed Snapshot Repository</name>
|
||||
<url>file://${appserver.base}/repositories/internal</url>
|
||||
<location>${appserver.base}/repositories/snapshots</location>
|
||||
<layout>default</layout>
|
||||
<releases>false</releases>
|
||||
<snapshots>true</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0,30 * * ?</refreshCronExpression>
|
||||
</repository>
|
||||
<repository>
|
||||
</managedRepository>
|
||||
</managedRepositories>
|
||||
<remoteRepositories>
|
||||
<remoteRepository>
|
||||
<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>
|
||||
</remoteRepository>
|
||||
<remoteRepository>
|
||||
<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>
|
||||
</remoteRepository>
|
||||
</remoteRepositories>
|
||||
|
||||
<webapp>
|
||||
<ui>
|
||||
|
@ -18,7 +18,7 @@
|
||||
~ under the License.
|
||||
-->
|
||||
<configuration>
|
||||
<version>1</version>
|
||||
<version>2</version>
|
||||
<proxyConnectors>
|
||||
<proxyConnector>
|
||||
<sourceRepoId>internal</sourceRepoId>
|
||||
|
@ -18,17 +18,17 @@
|
||||
~ under the License.
|
||||
-->
|
||||
<configuration>
|
||||
<version>1</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<version>2</version>
|
||||
<managedRepositories>
|
||||
<managedRepository>
|
||||
<id>snapshots</id>
|
||||
<name>Archiva Managed Snapshot Repository</name>
|
||||
<url>file://${appserver.base}/repositories/internal</url>
|
||||
<location>file://${appserver.base}/repositories/internal</location>
|
||||
<releases>false</releases>
|
||||
<snapshots>true</snapshots>
|
||||
<refreshCronExpression>0 0\,30 * * ?</refreshCronExpression>
|
||||
</repository>
|
||||
</repositories>
|
||||
</managedRepository>
|
||||
</managedRepositories>
|
||||
<databaseScanning>
|
||||
<cronExpression>0 0 0 * * ?</cronExpression>
|
||||
<unprocessedConsumers>
|
||||
|
@ -19,47 +19,43 @@
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<version>1</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<version>2</version>
|
||||
<managedRepositories>
|
||||
<managedRepository>
|
||||
<id>internal</id>
|
||||
<name>Archiva Managed Internal Repository</name>
|
||||
<url>file://${appserver.base}/repositories/internal</url>
|
||||
<location>${appserver.base}/repositories/internal</location>
|
||||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0 * * ?</refreshCronExpression>
|
||||
</repository>
|
||||
<repository>
|
||||
</managedRepository>
|
||||
<managedRepository>
|
||||
<id>snapshots</id>
|
||||
<name>Archiva Managed Snapshot Repository</name>
|
||||
<url>file://${appserver.base}/repositories/internal</url>
|
||||
<location>${appserver.base}/repositories/internal</location>
|
||||
<layout>default</layout>
|
||||
<releases>false</releases>
|
||||
<snapshots>true</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0,30 * * ?</refreshCronExpression>
|
||||
</repository>
|
||||
<repository>
|
||||
</managedRepository>
|
||||
</managedRepositories>
|
||||
<remoteRepositories>
|
||||
<remoteRepository>
|
||||
<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>
|
||||
</remoteRepository>
|
||||
<remoteRepository>
|
||||
<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>
|
||||
</remoteRepository>
|
||||
</remoteRepositories>
|
||||
|
||||
<proxyConnectors>
|
||||
<proxyConnector>
|
||||
|
@ -57,11 +57,11 @@ public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResourc
|
||||
assertConfiguration( configuration );
|
||||
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
|
||||
|
||||
RepositoryConfiguration repository =
|
||||
(RepositoryConfiguration) configuration.getRepositories().iterator().next();
|
||||
ManagedRepositoryConfiguration repository =
|
||||
(ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
|
||||
|
||||
assertEquals( "check managed repositories", "file://${appserver.base}/repositories/internal",
|
||||
repository.getUrl() );
|
||||
assertEquals( "check managed repositories", "${appserver.base}/repositories/internal",
|
||||
repository.getLocation() );
|
||||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() );
|
||||
assertEquals( "check managed repositories", "internal", repository.getId() );
|
||||
assertEquals( "check managed repositories", "default", repository.getLayout() );
|
||||
@ -78,11 +78,11 @@ public void testGetConfigurationFromDefaults()
|
||||
assertConfiguration( configuration );
|
||||
assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() );
|
||||
|
||||
RepositoryConfiguration repository =
|
||||
(RepositoryConfiguration) configuration.getRepositories().iterator().next();
|
||||
ManagedRepositoryConfiguration repository =
|
||||
(ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
|
||||
|
||||
assertEquals( "check managed repositories", "file://${appserver.base}/data/repositories/internal",
|
||||
repository.getUrl() );
|
||||
assertEquals( "check managed repositories", "${appserver.base}/data/repositories/internal",
|
||||
repository.getLocation() );
|
||||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() );
|
||||
assertEquals( "check managed repositories", "internal", repository.getId() );
|
||||
assertEquals( "check managed repositories", "default", repository.getLayout() );
|
||||
@ -94,7 +94,8 @@ private void assertConfiguration( Configuration configuration )
|
||||
{
|
||||
FileTypes filetypes = (FileTypes) lookup( FileTypes.class.getName() );
|
||||
|
||||
assertEquals( "check repositories", 4, configuration.getRepositories().size() );
|
||||
assertEquals( "check repositories", 2, configuration.getManagedRepositories().size() );
|
||||
assertEquals( "check repositories", 2, configuration.getRemoteRepositories().size() );
|
||||
assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() );
|
||||
|
||||
RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning();
|
||||
@ -130,7 +131,8 @@ public void testGetConfigurationFromRegistryWithTwoConfigurationResources()
|
||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
||||
|
||||
// from base
|
||||
assertEquals( "check repositories", 4, configuration.getRepositories().size() );
|
||||
assertEquals( "check repositories", 2, configuration.getManagedRepositories().size() );
|
||||
assertEquals( "check repositories", 2, configuration.getRemoteRepositories().size() );
|
||||
// from user
|
||||
assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() );
|
||||
|
||||
@ -475,11 +477,11 @@ public void testConfigurationUpgradeFrom09()
|
||||
assertConfiguration( configuration );
|
||||
assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() );
|
||||
|
||||
RepositoryConfiguration repository =
|
||||
(RepositoryConfiguration) configuration.getRepositories().iterator().next();
|
||||
ManagedRepositoryConfiguration repository =
|
||||
(ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
|
||||
|
||||
assertEquals( "check managed repositories", "file://${appserver.base}/data/repositories/internal",
|
||||
repository.getUrl() );
|
||||
assertEquals( "check managed repositories", "${appserver.base}/data/repositories/internal",
|
||||
repository.getLocation() );
|
||||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() );
|
||||
assertEquals( "check managed repositories", "internal", repository.getId() );
|
||||
assertEquals( "check managed repositories", "default", repository.getLayout() );
|
||||
@ -496,11 +498,32 @@ public void testAutoDetectV1()
|
||||
assertConfiguration( configuration );
|
||||
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
|
||||
|
||||
RepositoryConfiguration repository =
|
||||
(RepositoryConfiguration) configuration.getRepositories().iterator().next();
|
||||
ManagedRepositoryConfiguration repository =
|
||||
(ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
|
||||
|
||||
assertEquals( "check managed repositories", "file://${appserver.base}/repositories/internal",
|
||||
repository.getUrl() );
|
||||
assertEquals( "check managed repositories", "${appserver.base}/repositories/internal",
|
||||
repository.getLocation() );
|
||||
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 testArchivaV1()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaConfiguration archivaConfiguration =
|
||||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-archiva-v1" );
|
||||
|
||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
||||
assertConfiguration( configuration );
|
||||
assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() );
|
||||
|
||||
ManagedRepositoryConfiguration repository =
|
||||
(ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
|
||||
|
||||
assertEquals( "check managed repositories", "${appserver.base}/repositories/internal",
|
||||
repository.getLocation() );
|
||||
assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() );
|
||||
assertEquals( "check managed repositories", "internal", repository.getId() );
|
||||
assertEquals( "check managed repositories", "default", repository.getLayout() );
|
||||
@ -527,10 +550,10 @@ public void testCronExpressionsWithComma()
|
||||
ArchivaConfiguration archivaConfiguration =
|
||||
(ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-cron-expressions" );
|
||||
|
||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
||||
|
||||
RepositoryConfiguration repository =
|
||||
(RepositoryConfiguration) configuration.getRepositories().iterator().next();
|
||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
||||
|
||||
ManagedRepositoryConfiguration repository =
|
||||
(ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 );
|
||||
|
||||
assertEquals( "check cron expression", "0 0,30 * * ?", repository.getRefreshCronExpression().trim() );
|
||||
|
||||
@ -539,9 +562,9 @@ public void testCronExpressionsWithComma()
|
||||
archivaConfiguration.save( configuration );
|
||||
|
||||
configuration = archivaConfiguration.getConfiguration();
|
||||
|
||||
|
||||
assertEquals( "check cron expression", "0 0,15 0 * * ?",
|
||||
configuration.getDatabaseScanning().getCronExpression() );
|
||||
configuration.getDatabaseScanning().getCronExpression() );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,144 @@
|
||||
package org.apache.maven.archiva.configuration;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test the generated Configuration class from Modello. This is primarily to test the hand coded methods.
|
||||
*/
|
||||
public class ConfigurationTest
|
||||
extends TestCase
|
||||
{
|
||||
private Configuration configuration = new Configuration();
|
||||
|
||||
public void testNetworkProxyRetrieval()
|
||||
{
|
||||
NetworkProxyConfiguration proxy1 = createNetworkProxy( "id1", "host1", 8080 );
|
||||
configuration.addNetworkProxy( proxy1 );
|
||||
NetworkProxyConfiguration proxy2 = createNetworkProxy( "id2", "host2", 9090 );
|
||||
configuration.addNetworkProxy( proxy2 );
|
||||
|
||||
Map<String, NetworkProxyConfiguration> map = configuration.getNetworkProxiesAsMap();
|
||||
assertNotNull( map );
|
||||
assertEquals( 2, map.size() );
|
||||
assertEquals( new HashSet<String>( Arrays.asList( "id1", "id2" ) ), map.keySet() );
|
||||
assertEquals( new HashSet<NetworkProxyConfiguration>( Arrays.asList( proxy1, proxy2 ) ),
|
||||
new HashSet<NetworkProxyConfiguration>( map.values() ) );
|
||||
}
|
||||
|
||||
private NetworkProxyConfiguration createNetworkProxy( String id, String host, int port )
|
||||
{
|
||||
NetworkProxyConfiguration proxy = new NetworkProxyConfiguration();
|
||||
proxy.setId( id );
|
||||
proxy.setHost( host );
|
||||
proxy.setPort( port );
|
||||
proxy.setProtocol( "http" );
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public void testRemoteRepositoryRetrieval()
|
||||
{
|
||||
RemoteRepositoryConfiguration repo1 = createRemoteRepository( "id1", "name 1", "url 1" );
|
||||
configuration.addRemoteRepository( repo1 );
|
||||
RemoteRepositoryConfiguration repo2 = createRemoteRepository( "id2", "name 2", "url 2" );
|
||||
configuration.addRemoteRepository( repo2 );
|
||||
|
||||
Map<String, RemoteRepositoryConfiguration> map = configuration.getRemoteRepositoriesAsMap();
|
||||
assertNotNull( map );
|
||||
assertEquals( 2, map.size() );
|
||||
assertEquals( new HashSet<String>( Arrays.asList( "id1", "id2" ) ), map.keySet() );
|
||||
assertEquals( new HashSet<RemoteRepositoryConfiguration>( Arrays.asList( repo1, repo2 ) ),
|
||||
new HashSet<RemoteRepositoryConfiguration>( map.values() ) );
|
||||
|
||||
assertEquals( repo1, configuration.findRemoteRepositoryById( "id1" ) );
|
||||
assertEquals( repo2, configuration.findRemoteRepositoryById( "id2" ) );
|
||||
assertNull( configuration.findRemoteRepositoryById( "id3" ) );
|
||||
}
|
||||
|
||||
private RemoteRepositoryConfiguration createRemoteRepository( String id, String name, String url )
|
||||
{
|
||||
RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
|
||||
repo.setId( id );
|
||||
repo.setName( name );
|
||||
repo.setLayout( "default" );
|
||||
repo.setUrl( url );
|
||||
return repo;
|
||||
}
|
||||
|
||||
public void testManagedRepositoryRetrieval()
|
||||
{
|
||||
ManagedRepositoryConfiguration repo1 = createManagedRepository( "id1", "name 1", "path 1", false );
|
||||
configuration.addManagedRepository( repo1 );
|
||||
ManagedRepositoryConfiguration repo2 = createManagedRepository( "id2", "name 2", "path 2", true );
|
||||
configuration.addManagedRepository( repo2 );
|
||||
|
||||
Map<String, ManagedRepositoryConfiguration> map = configuration.getManagedRepositoriesAsMap();
|
||||
assertNotNull( map );
|
||||
assertEquals( 2, map.size() );
|
||||
assertEquals( new HashSet<String>( Arrays.asList( "id1", "id2" ) ), map.keySet() );
|
||||
assertEquals( new HashSet<ManagedRepositoryConfiguration>( Arrays.asList( repo1, repo2 ) ),
|
||||
new HashSet<ManagedRepositoryConfiguration>( map.values() ) );
|
||||
|
||||
assertEquals( repo1, configuration.findManagedRepositoryById( "id1" ) );
|
||||
assertEquals( repo2, configuration.findManagedRepositoryById( "id2" ) );
|
||||
assertNull( configuration.findManagedRepositoryById( "id3" ) );
|
||||
}
|
||||
|
||||
private ManagedRepositoryConfiguration createManagedRepository( String id, String name, String location,
|
||||
boolean indexed )
|
||||
{
|
||||
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
|
||||
repo.setId( id );
|
||||
repo.setName( name );
|
||||
repo.setLocation( location );
|
||||
repo.setIndexed( indexed );
|
||||
return repo;
|
||||
}
|
||||
|
||||
public void testNetworkProxyRetrievalWhenEmpty()
|
||||
{
|
||||
Map<String, NetworkProxyConfiguration> map = configuration.getNetworkProxiesAsMap();
|
||||
assertNotNull( map );
|
||||
assertTrue( map.isEmpty() );
|
||||
}
|
||||
|
||||
public void testRemoteRepositoryRetrievalWhenEmpty()
|
||||
{
|
||||
Map<String, RemoteRepositoryConfiguration> map = configuration.getRemoteRepositoriesAsMap();
|
||||
assertNotNull( map );
|
||||
assertTrue( map.isEmpty() );
|
||||
|
||||
assertNull( configuration.findRemoteRepositoryById( "id" ) );
|
||||
}
|
||||
|
||||
public void testManagedRepositoryRetrievalWhenEmpty()
|
||||
{
|
||||
Map<String, ManagedRepositoryConfiguration> map = configuration.getManagedRepositoriesAsMap();
|
||||
assertNotNull( map );
|
||||
assertTrue( map.isEmpty() );
|
||||
|
||||
assertNull( configuration.findManagedRepositoryById( "id" ) );
|
||||
}
|
||||
}
|
@ -24,20 +24,19 @@
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author Edwin Punzalan
|
||||
*/
|
||||
public class MavenProxyPropertyLoaderTest extends PlexusTestCase
|
||||
public class MavenProxyPropertyLoaderTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
private MavenProxyPropertyLoader loader;
|
||||
|
||||
public void testLoadValidMavenProxyConfiguration() throws IOException, InvalidConfigurationException
|
||||
public void testLoadValidMavenProxyConfiguration()
|
||||
throws IOException, InvalidConfigurationException
|
||||
{
|
||||
File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" );
|
||||
|
||||
@ -48,27 +47,30 @@ public void testLoadValidMavenProxyConfiguration() throws IOException, InvalidCo
|
||||
|
||||
loader.load( new FileInputStream( confFile ), configuration );
|
||||
|
||||
List repos = configuration.getRepositories();
|
||||
assertEquals( "Count repositories", 5, repos.size() );
|
||||
Map<String, ManagedRepositoryConfiguration> repositoryIdMap = configuration.getManagedRepositoriesAsMap();
|
||||
assertEquals( "Count repositories", 1, repositoryIdMap.size() );
|
||||
assertRepositoryExists( "maven-proxy", "target", repositoryIdMap.get( "maven-proxy" ) );
|
||||
|
||||
Map repositoryIdMap = new HashMap();
|
||||
|
||||
for ( Iterator itRepo = repos.iterator(); itRepo.hasNext(); )
|
||||
{
|
||||
RepositoryConfiguration repo = (RepositoryConfiguration) itRepo.next();
|
||||
repositoryIdMap.put( repo.getId(), repo );
|
||||
}
|
||||
|
||||
assertRepositoryExists( repositoryIdMap, "local-repo", "file://target" );
|
||||
|
||||
assertRepositoryExists( repositoryIdMap, "www-ibiblio-org", "http://www.ibiblio.org/maven2" );
|
||||
assertRepositoryExists( repositoryIdMap, "dist-codehaus-org", "http://dist.codehaus.org" );
|
||||
assertRepositoryExists( repositoryIdMap, "private-example-com", "http://private.example.com/internal" );
|
||||
Map<String, RemoteRepositoryConfiguration> remoteRepositoryMap = configuration.getRemoteRepositoriesAsMap();
|
||||
assertEquals( "Count repositories", 4, remoteRepositoryMap.size() );
|
||||
assertRepositoryExists( "local-repo", "file://target", remoteRepositoryMap.get( "local-repo" ) );
|
||||
assertRepositoryExists( "www-ibiblio-org", "http://www.ibiblio.org/maven2",
|
||||
remoteRepositoryMap.get( "www-ibiblio-org" ) );
|
||||
assertRepositoryExists( "dist-codehaus-org", "http://dist.codehaus.org",
|
||||
remoteRepositoryMap.get( "dist-codehaus-org" ) );
|
||||
assertRepositoryExists( "private-example-com", "http://private.example.com/internal",
|
||||
remoteRepositoryMap.get( "private-example-com" ) );
|
||||
}
|
||||
|
||||
private void assertRepositoryExists( Map repoMap, String id, String expectedUrl )
|
||||
private void assertRepositoryExists( String id, String expectedLocation, ManagedRepositoryConfiguration repo )
|
||||
{
|
||||
assertNotNull( "Repository id [" + id + "] should not be null", repo );
|
||||
assertEquals( "Repository id", id, repo.getId() );
|
||||
assertEquals( "Repository url", expectedLocation, repo.getLocation() );
|
||||
}
|
||||
|
||||
private void assertRepositoryExists( String id, String expectedUrl, RemoteRepositoryConfiguration repo )
|
||||
{
|
||||
RepositoryConfiguration repo = (RepositoryConfiguration) repoMap.get( id );
|
||||
assertNotNull( "Repository id [" + id + "] should not be null", repo );
|
||||
assertEquals( "Repository id", id, repo.getId() );
|
||||
assertEquals( "Repository url", expectedUrl, repo.getUrl() );
|
||||
@ -88,7 +90,8 @@ public void testInvalidConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
loader = new MavenProxyPropertyLoader();
|
||||
|
@ -0,0 +1,52 @@
|
||||
package org.apache.maven.archiva.configuration.functors;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test the repositry comparator.
|
||||
*/
|
||||
public class RepositoryConfigurationComparatorTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testComparator()
|
||||
{
|
||||
Comparator<AbstractRepositoryConfiguration> comparator = new RepositoryConfigurationComparator();
|
||||
|
||||
assertEquals( 0, comparator.compare( null, null ) );
|
||||
assertEquals( 1, comparator.compare( createRepository( "id" ), null ) );
|
||||
assertEquals( -1, comparator.compare( null, createRepository( "id" ) ) );
|
||||
assertEquals( 0, comparator.compare( createRepository( "id1" ), createRepository( "id1" ) ) );
|
||||
assertEquals( -1, comparator.compare( createRepository( "id1" ), createRepository( "id2" ) ) );
|
||||
assertEquals( 1, comparator.compare( createRepository( "id2" ), createRepository( "id1" ) ) );
|
||||
}
|
||||
|
||||
private ManagedRepositoryConfiguration createRepository( String id )
|
||||
{
|
||||
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
|
||||
repo.setId( id );
|
||||
return repo;
|
||||
}
|
||||
}
|
@ -110,6 +110,30 @@
|
||||
</configuration>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
|
||||
<role-hint>test-archiva-v1</role-hint>
|
||||
<implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.registry.Registry</role>
|
||||
<role-hint>archiva-v1</role-hint>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.registry.Registry</role>
|
||||
<role-hint>archiva-v1</role-hint>
|
||||
<implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
|
||||
<configuration>
|
||||
<properties>
|
||||
<system/>
|
||||
<xml fileName="${basedir}/src/test/conf/archiva-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</role-hint>
|
||||
@ -236,6 +260,6 @@
|
||||
config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
|
||||
</properties>
|
||||
</configuration>
|
||||
</component>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
||||
|
@ -46,10 +46,11 @@
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* role-hint="create-missing-checksums"
|
||||
* instantiation-strategy="per-lookup"
|
||||
* role-hint="create-missing-checksums"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ArtifactMissingChecksumsConsumer extends AbstractMonitoredConsumer
|
||||
public class ArtifactMissingChecksumsConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
implements KnownRepositoryContentConsumer, RegistryListener, Initializable
|
||||
{
|
||||
/**
|
||||
@ -66,7 +67,7 @@ public class ArtifactMissingChecksumsConsumer extends AbstractMonitoredConsumer
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
@ -123,22 +124,18 @@ public boolean isPermanent()
|
||||
return false;
|
||||
}
|
||||
|
||||
public void beginScan( ArchivaRepository repository ) throws ConsumerException
|
||||
public void beginScan( ArchivaRepository repository )
|
||||
throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repository = repository;
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
|
||||
String layoutName = repository.getModel().getLayoutName();
|
||||
if ( !bidirectionalLayoutMap.containsKey( layoutName ) )
|
||||
{
|
||||
throw new ConsumerException( "Unable to process repository with layout [" + layoutName
|
||||
+ "] as there is no coresponding " + BidirectionalRepositoryLayout.class.getName()
|
||||
+ " implementation available." );
|
||||
throw new ConsumerException( "Unable to process repository with layout [" + layoutName +
|
||||
"] as there is no coresponding " + BidirectionalRepositoryLayout.class.getName() +
|
||||
" implementation available." );
|
||||
}
|
||||
|
||||
this.layout = (BidirectionalRepositoryLayout) bidirectionalLayoutMap.get( layoutName );
|
||||
@ -159,7 +156,8 @@ public List getIncludes()
|
||||
return includes;
|
||||
}
|
||||
|
||||
public void processFile( String path ) throws ConsumerException
|
||||
public void processFile( String path )
|
||||
throws ConsumerException
|
||||
{
|
||||
createIfMissing( path, digestSha1 );
|
||||
createIfMissing( path, digestMd5 );
|
||||
@ -177,19 +175,19 @@ private void createIfMissing( String path, Digester digester )
|
||||
}
|
||||
catch ( DigesterException e )
|
||||
{
|
||||
triggerConsumerError( TYPE_CHECKSUM_CANNOT_CALC, "Cannot calculate checksum for file " + checksumFile
|
||||
+ ": " + e.getMessage() );
|
||||
triggerConsumerError( TYPE_CHECKSUM_CANNOT_CALC,
|
||||
"Cannot calculate checksum for file " + checksumFile + ": " + e.getMessage() );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
triggerConsumerError( TYPE_CHECKSUM_CANNOT_CREATE, "Cannot create checksum for file " + checksumFile
|
||||
+ ": " + e.getMessage() );
|
||||
triggerConsumerError( TYPE_CHECKSUM_CANNOT_CREATE,
|
||||
"Cannot create checksum for file " + checksumFile + ": " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
else if ( !checksumFile.isFile() )
|
||||
{
|
||||
triggerConsumerWarning( TYPE_CHECKSUM_NOT_FILE, "Checksum file " + checksumFile.getAbsolutePath()
|
||||
+ " is not a file." );
|
||||
triggerConsumerWarning( TYPE_CHECKSUM_NOT_FILE,
|
||||
"Checksum file " + checksumFile.getAbsolutePath() + " is not a file." );
|
||||
}
|
||||
|
||||
}
|
||||
@ -210,11 +208,12 @@ public void beforeConfigurationChange( Registry registry, String propertyName, O
|
||||
private void initIncludes()
|
||||
{
|
||||
includes.clear();
|
||||
|
||||
|
||||
includes.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
|
||||
}
|
||||
|
||||
public void initialize() throws InitializationException
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
propertyNameTriggers = new ArrayList();
|
||||
propertyNameTriggers.add( "repositoryScanning" );
|
||||
|
@ -35,14 +35,13 @@
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AutoRemoveConsumer
|
||||
* AutoRemoveConsumer
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* role-hint="auto-remove"
|
||||
* instantiation-strategy="per-lookup"
|
||||
* role-hint="auto-remove"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class AutoRemoveConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
@ -62,7 +61,7 @@ public class AutoRemoveConsumer
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
@ -92,11 +91,6 @@ public boolean isPermanent()
|
||||
public void beginScan( ArchivaRepository repository )
|
||||
throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
}
|
||||
|
||||
@ -142,7 +136,7 @@ public void beforeConfigurationChange( Registry registry, String propertyName, O
|
||||
private void initIncludes()
|
||||
{
|
||||
includes.clear();
|
||||
|
||||
|
||||
includes.addAll( filetypes.getFileTypePatterns( FileTypes.AUTO_REMOVE ) );
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
@ -35,14 +34,13 @@
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AutoRenameConsumer
|
||||
* AutoRenameConsumer
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* role-hint="auto-rename"
|
||||
* instantiation-strategy="per-lookup"
|
||||
* role-hint="auto-rename"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class AutoRenameConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
@ -95,11 +93,6 @@ public boolean isPermanent()
|
||||
public void beginScan( ArchivaRepository repository )
|
||||
throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
}
|
||||
|
||||
@ -139,8 +132,8 @@ public void processFile( String path )
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
triggerConsumerWarning( RENAME_FAILURE, "Unable to rename " + path + " to " + correctedPath
|
||||
+ ": " + e.getMessage() );
|
||||
triggerConsumerWarning( RENAME_FAILURE, "Unable to rename " + path + " to " + correctedPath +
|
||||
": " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.codehaus.plexus.digest.ChecksumFile;
|
||||
import org.codehaus.plexus.digest.Digester;
|
||||
@ -38,16 +37,16 @@
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ValidateChecksumConsumer - validate the provided checksum against the file it represents.
|
||||
* ValidateChecksumConsumer - validate the provided checksum against the file it represents.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* role-hint="validate-checksum"
|
||||
* instantiation-strategy="per-lookup"
|
||||
* role-hint="validate-checksum"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ValidateChecksumConsumer extends AbstractMonitoredConsumer
|
||||
public class ValidateChecksumConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
implements KnownRepositoryContentConsumer, Initializable
|
||||
{
|
||||
private static final String NOT_VALID_CHECKSUM = "checksum-not-valid";
|
||||
@ -99,13 +98,9 @@ public boolean isPermanent()
|
||||
return false;
|
||||
}
|
||||
|
||||
public void beginScan( ArchivaRepository repository ) throws ConsumerException
|
||||
public void beginScan( ArchivaRepository repository )
|
||||
throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repository = repository;
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
}
|
||||
@ -125,7 +120,8 @@ public List getIncludes()
|
||||
return this.includes;
|
||||
}
|
||||
|
||||
public void processFile( String path ) throws ConsumerException
|
||||
public void processFile( String path )
|
||||
throws ConsumerException
|
||||
{
|
||||
File checksumFile = new File( this.repositoryDir, path );
|
||||
try
|
||||
@ -141,7 +137,8 @@ public void processFile( String path ) throws ConsumerException
|
||||
}
|
||||
catch ( DigesterException e )
|
||||
{
|
||||
triggerConsumerError( CHECKSUM_DIGESTER_FAILURE, "Digester failure during checksum validation on " + checksumFile );
|
||||
triggerConsumerError( CHECKSUM_DIGESTER_FAILURE,
|
||||
"Digester failure during checksum validation on " + checksumFile );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
@ -149,7 +146,8 @@ public void processFile( String path ) throws ConsumerException
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() throws InitializationException
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
for ( Iterator itDigesters = digesterList.iterator(); itDigesters.hasNext(); )
|
||||
{
|
||||
|
@ -19,35 +19,31 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
|
||||
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
|
||||
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.common.utils.VersionComparator;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.FilenameParts;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.common.utils.VersionComparator;
|
||||
import org.apache.maven.archiva.indexer.RepositoryIndexException;
|
||||
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
|
||||
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
|
||||
import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* M2 implementation for cleaning up the released snapshots.
|
||||
*
|
||||
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
|
||||
* @version
|
||||
*/
|
||||
public class CleanupReleasedSnapshotsRepositoryPurge
|
||||
extends AbstractRepositoryPurge
|
||||
@ -60,7 +56,7 @@ public CleanupReleasedSnapshotsRepositoryPurge( ArchivaRepository repository, Bi
|
||||
ArtifactDAO artifactDao )
|
||||
{
|
||||
super( repository, layout, artifactDao );
|
||||
metadataReader = new RepositoryMetadataReader();
|
||||
metadataReader = new RepositoryMetadataReader();
|
||||
}
|
||||
|
||||
public void process( String path )
|
||||
|
@ -19,37 +19,31 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.FilenameParts;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.indexer.RepositoryIndexException;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.io.File;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Purge repository for snapshots older than the specified days in the repository configuration.
|
||||
*
|
||||
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
|
||||
* @version
|
||||
*/
|
||||
public class DaysOldRepositoryPurge
|
||||
extends AbstractRepositoryPurge
|
||||
{
|
||||
private RepositoryConfiguration repoConfig;
|
||||
{
|
||||
private int daysOlder;
|
||||
|
||||
public DaysOldRepositoryPurge( ArchivaRepository repository,
|
||||
BidirectionalRepositoryLayout layout, ArtifactDAO artifactDao,
|
||||
RepositoryConfiguration repoConfig)
|
||||
public DaysOldRepositoryPurge( ArchivaRepository repository, BidirectionalRepositoryLayout layout,
|
||||
ArtifactDAO artifactDao, int daysOlder )
|
||||
{
|
||||
super( repository, layout, artifactDao );
|
||||
this.repoConfig = repoConfig;
|
||||
this.daysOlder = daysOlder;
|
||||
}
|
||||
|
||||
public void process( String path )
|
||||
@ -59,7 +53,7 @@ public void process( String path )
|
||||
{
|
||||
File artifactFile = new File( repository.getUrl().getPath(), path );
|
||||
|
||||
if( !artifactFile.exists() )
|
||||
if ( !artifactFile.exists() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -69,7 +63,7 @@ public void process( String path )
|
||||
if ( VersionUtil.isSnapshot( parts.version ) )
|
||||
{
|
||||
Calendar olderThanThisDate = Calendar.getInstance();
|
||||
olderThanThisDate.add( Calendar.DATE, ( -1 * repoConfig.getDaysOlder() ) );
|
||||
olderThanThisDate.add( Calendar.DATE, ( -1 * daysOlder ) );
|
||||
|
||||
if ( artifactFile.lastModified() < olderThanThisDate.getTimeInMillis() )
|
||||
{
|
||||
@ -86,5 +80,5 @@ public void process( String path )
|
||||
throw new RepositoryPurgeException( le.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,26 +19,24 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.FileTypes;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndex;
|
||||
import org.codehaus.plexus.registry.RegistryListener;
|
||||
import org.codehaus.plexus.registry.Registry;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||
import org.codehaus.plexus.registry.Registry;
|
||||
import org.codehaus.plexus.registry.RegistryListener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Consumer for removing old snapshots in the repository based on the criteria
|
||||
@ -83,8 +81,6 @@ public class RepositoryPurgeConsumer
|
||||
*/
|
||||
private FileTypes filetypes;
|
||||
|
||||
private ArchivaRepository repository;
|
||||
|
||||
private List includes = new ArrayList();
|
||||
|
||||
private List propertyNameTriggers = new ArrayList();
|
||||
@ -93,6 +89,8 @@ public class RepositoryPurgeConsumer
|
||||
|
||||
private RepositoryPurge cleanUp;
|
||||
|
||||
private boolean deleteReleasedSnapshots;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
@ -121,15 +119,7 @@ public List getIncludes()
|
||||
public void beginScan( ArchivaRepository repository )
|
||||
throws ConsumerException
|
||||
{
|
||||
BidirectionalRepositoryLayout repositoryLayout = null;
|
||||
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repository = repository;
|
||||
|
||||
BidirectionalRepositoryLayout repositoryLayout;
|
||||
try
|
||||
{
|
||||
repositoryLayout = layoutFactory.getLayout( repository.getLayoutType() );
|
||||
@ -140,18 +130,23 @@ public void beginScan( ArchivaRepository repository )
|
||||
"Unable to initialize consumer due to unknown repository layout: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
RepositoryConfiguration repoConfig = configuration.getConfiguration().findRepositoryById( repository.getId() );
|
||||
ManagedRepositoryConfiguration repoConfig =
|
||||
configuration.getConfiguration().findManagedRepositoryById( repository.getId() );
|
||||
|
||||
if ( repoConfig.getDaysOlder() != 0 )
|
||||
{
|
||||
repoPurge = new DaysOldRepositoryPurge( repository, repositoryLayout, dao.getArtifactDAO(), repoConfig );
|
||||
repoPurge = new DaysOldRepositoryPurge( repository, repositoryLayout, dao.getArtifactDAO(),
|
||||
repoConfig.getDaysOlder() );
|
||||
}
|
||||
else
|
||||
{
|
||||
repoPurge =
|
||||
new RetentionCountRepositoryPurge( repository, repositoryLayout, dao.getArtifactDAO(), repoConfig );
|
||||
repoPurge = new RetentionCountRepositoryPurge( repository, repositoryLayout, dao.getArtifactDAO(),
|
||||
repoConfig.getRetentionCount() );
|
||||
}
|
||||
|
||||
cleanUp = new CleanupReleasedSnapshotsRepositoryPurge( repository, repositoryLayout, dao.getArtifactDAO() );
|
||||
|
||||
deleteReleasedSnapshots = repoConfig.isDeleteReleasedSnapshots();
|
||||
}
|
||||
|
||||
public void processFile( String path )
|
||||
@ -159,9 +154,7 @@ public void processFile( String path )
|
||||
{
|
||||
try
|
||||
{
|
||||
RepositoryConfiguration repoConfig =
|
||||
configuration.getConfiguration().findRepositoryById( repository.getId() );
|
||||
if ( repoConfig.isDeleteReleasedSnapshots() )
|
||||
if ( deleteReleasedSnapshots )
|
||||
{
|
||||
cleanUp.process( path );
|
||||
}
|
||||
|
@ -19,49 +19,44 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.FilenameParts;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.indexer.RepositoryIndexException;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Purge the repository by retention count. Retain only the specified number of snapshots.
|
||||
*
|
||||
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
|
||||
* @version
|
||||
*/
|
||||
public class RetentionCountRepositoryPurge
|
||||
extends AbstractRepositoryPurge
|
||||
{
|
||||
private RepositoryConfiguration repoConfig;
|
||||
private int retentionCount;
|
||||
|
||||
public RetentionCountRepositoryPurge( ArchivaRepository repository,
|
||||
BidirectionalRepositoryLayout layout, ArtifactDAO artifactDao,
|
||||
RepositoryConfiguration repoConfig )
|
||||
public RetentionCountRepositoryPurge( ArchivaRepository repository, BidirectionalRepositoryLayout layout,
|
||||
ArtifactDAO artifactDao, int retentionCount )
|
||||
{
|
||||
super( repository, layout, artifactDao );
|
||||
this.repoConfig = repoConfig;
|
||||
this.retentionCount = retentionCount;
|
||||
}
|
||||
|
||||
public void process( String path )
|
||||
throws RepositoryPurgeException
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
File artifactFile = new File( repository.getUrl().getPath(), path );
|
||||
|
||||
if( !artifactFile.exists() )
|
||||
if ( !artifactFile.exists() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -69,7 +64,7 @@ public void process( String path )
|
||||
FilenameParts parts = getFilenameParts( path );
|
||||
|
||||
if ( VersionUtil.isSnapshot( parts.version ) )
|
||||
{
|
||||
{
|
||||
File parentDir = artifactFile.getParentFile();
|
||||
|
||||
if ( parentDir.isDirectory() )
|
||||
@ -78,13 +73,13 @@ public void process( String path )
|
||||
List uniqueVersionFilenames = getUniqueVersions( files );
|
||||
Collections.sort( uniqueVersionFilenames );
|
||||
|
||||
if ( uniqueVersionFilenames.size() > repoConfig.getRetentionCount() )
|
||||
if ( uniqueVersionFilenames.size() > retentionCount )
|
||||
{
|
||||
int count = uniqueVersionFilenames.size();
|
||||
for ( Iterator iter = uniqueVersionFilenames.iterator(); iter.hasNext(); )
|
||||
{
|
||||
String filename = (String) iter.next();
|
||||
if ( count > repoConfig.getRetentionCount() )
|
||||
if ( count > retentionCount )
|
||||
{
|
||||
File[] artifactFiles = getFiles( parentDir, filename );
|
||||
purge( artifactFiles );
|
||||
|
@ -19,46 +19,43 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
|
||||
import org.codehaus.plexus.jdo.JdoFactory;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
import org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.jpox.SchemaTool;
|
||||
|
||||
import javax.jdo.PersistenceManagerFactory;
|
||||
import javax.jdo.PersistenceManager;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import javax.jdo.PersistenceManagerFactory;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.net.URL;
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
|
||||
*/
|
||||
public class AbstractRepositoryPurgeTest
|
||||
public abstract class AbstractRepositoryPurgeTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
public static final String TEST_REPO_ID = "test-repo";
|
||||
|
||||
public static final String TEST_REPO_NAME = "Test Repository";
|
||||
|
||||
public static final String TEST_REPO_URL = "file://" + getBasedir() + "/target/test-classes/test-repo/";
|
||||
public static final String TEST_REPO_URL = getBasedir() + "/target/test-classes/test-repo/";
|
||||
|
||||
public static final int TEST_RETENTION_COUNT = 2;
|
||||
|
||||
public static final int TEST_DAYS_OLDER = 30;
|
||||
|
||||
private RepositoryConfiguration config;
|
||||
private ManagedRepositoryConfiguration config;
|
||||
|
||||
private ArchivaRepository repo;
|
||||
|
||||
@ -136,17 +133,17 @@ protected void setUp()
|
||||
dao = (ArtifactDAO) lookup( ArtifactDAO.class.getName(), "jdo" );
|
||||
}
|
||||
|
||||
public RepositoryConfiguration getRepoConfiguration()
|
||||
public ManagedRepositoryConfiguration getRepoConfiguration()
|
||||
{
|
||||
if ( config == null )
|
||||
{
|
||||
config = new RepositoryConfiguration();
|
||||
config = new ManagedRepositoryConfiguration();
|
||||
}
|
||||
|
||||
config.setId( TEST_REPO_ID );
|
||||
config.setName( TEST_REPO_NAME );
|
||||
config.setDaysOlder( TEST_DAYS_OLDER );
|
||||
config.setUrl( TEST_REPO_URL );
|
||||
config.setLocation( TEST_REPO_URL );
|
||||
config.setReleases( true );
|
||||
config.setSnapshots( true );
|
||||
config.setRetentionCount( TEST_RETENTION_COUNT );
|
||||
@ -158,7 +155,7 @@ public ArchivaRepository getRepository()
|
||||
{
|
||||
if ( repo == null )
|
||||
{
|
||||
repo = new ArchivaRepository( TEST_REPO_ID, TEST_REPO_NAME, TEST_REPO_URL );
|
||||
repo = new ArchivaRepository( TEST_REPO_ID, TEST_REPO_NAME, PathUtil.toUrl( TEST_REPO_URL ) );
|
||||
}
|
||||
|
||||
return repo;
|
||||
|
@ -1,24 +1,9 @@
|
||||
package org.apache.maven.archiva.consumers.core.repository;
|
||||
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
|
||||
import org.codehaus.plexus.jdo.JdoFactory;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifactModel;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.jdo.JdoAccess;
|
||||
|
||||
import javax.jdo.JDOFatalUserException;
|
||||
import javax.jdo.JDOHelper;
|
||||
import javax.jdo.spi.JDOImplHelper;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
@ -35,7 +20,8 @@ protected void setUp()
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
repoPurge = new DaysOldRepositoryPurge( getRepository(), getLayout(), dao, getRepoConfiguration() );
|
||||
repoPurge =
|
||||
new DaysOldRepositoryPurge( getRepository(), getLayout(), dao, getRepoConfiguration().getDaysOlder() );
|
||||
}
|
||||
|
||||
private void setLastModified()
|
||||
@ -53,7 +39,7 @@ public void testIfAJarIsFound()
|
||||
throws Exception
|
||||
{
|
||||
populateDb();
|
||||
|
||||
|
||||
setLastModified();
|
||||
|
||||
repoPurge.process( PATH_TO_BY_DAYS_OLD_ARTIFACT );
|
||||
@ -97,8 +83,7 @@ private void populateDb()
|
||||
assertNotNull( savedArtifact );
|
||||
|
||||
//POM
|
||||
artifact =
|
||||
dao.createArtifact( "org.apache.maven.plugins", "maven-install-plugin", "2.2-SNAPSHOT", "", "pom" );
|
||||
artifact = dao.createArtifact( "org.apache.maven.plugins", "maven-install-plugin", "2.2-SNAPSHOT", "", "pom" );
|
||||
assertNotNull( artifact );
|
||||
artifact.getModel().setLastModified( new Date() );
|
||||
artifact.getModel().setOrigin( "test" );
|
||||
|
@ -44,7 +44,8 @@ protected void setUp()
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
repoPurge = new RetentionCountRepositoryPurge( getRepository(), getLayout(), dao, getRepoConfiguration() );
|
||||
repoPurge = new RetentionCountRepositoryPurge( getRepository(), getLayout(), dao,
|
||||
getRepoConfiguration().getRetentionCount() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,10 +49,9 @@
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* role-hint="update-db-artifact"
|
||||
* instantiation-strategy="per-lookup"
|
||||
* role-hint="update-db-artifact"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ArtifactUpdateDatabaseConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
@ -140,11 +139,6 @@ public List getIncludes()
|
||||
public void beginScan( ArchivaRepository repository )
|
||||
throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repository = repository;
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
|
||||
@ -180,7 +174,8 @@ public void processFile( String path )
|
||||
}
|
||||
catch ( DigesterException e )
|
||||
{
|
||||
triggerConsumerWarning( CHECKSUM_CALCULATION, "Unable to calculate the MD5 checksum: " + e.getMessage() );
|
||||
triggerConsumerWarning( CHECKSUM_CALCULATION,
|
||||
"Unable to calculate the MD5 checksum: " + e.getMessage() );
|
||||
}
|
||||
|
||||
try
|
||||
@ -189,8 +184,8 @@ public void processFile( String path )
|
||||
}
|
||||
catch ( DigesterException e )
|
||||
{
|
||||
triggerConsumerWarning( CHECKSUM_CALCULATION, "Unable to calculate the SHA1 checksum: "
|
||||
+ e.getMessage() );
|
||||
triggerConsumerWarning( CHECKSUM_CALCULATION,
|
||||
"Unable to calculate the SHA1 checksum: " + e.getMessage() );
|
||||
}
|
||||
|
||||
artifact.getModel().setLastModified( new Date( artifactFile.lastModified() ) );
|
||||
@ -207,11 +202,11 @@ public void processFile( String path )
|
||||
|
||||
/**
|
||||
* Get a Live Artifact from a Path.
|
||||
*
|
||||
* <p/>
|
||||
* Will resolve the artifact details from the path, and then return a database live version
|
||||
* of that artifact. Suitable for modification and saving (without the need to check for
|
||||
* existance in database prior to save.)
|
||||
*
|
||||
*
|
||||
* @param path the path to work from.
|
||||
* @return the artifact that is suitable for database saving.
|
||||
*/
|
||||
@ -231,8 +226,8 @@ public ArchivaArtifact getLiveArtifact( String path )
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
triggerConsumerError( TYPE_NOT_ARTIFACT, "Path " + path + " cannot be converted to artifact: "
|
||||
+ e.getMessage() );
|
||||
triggerConsumerError( TYPE_NOT_ARTIFACT,
|
||||
"Path " + path + " cannot be converted to artifact: " + e.getMessage() );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,10 @@
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer;
|
||||
@ -31,7 +33,6 @@
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.RepositoryProblem;
|
||||
import org.apache.maven.archiva.model.RepositoryURL;
|
||||
import org.apache.maven.archiva.reporting.artifact.CorruptArtifactReport;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
|
||||
@ -42,7 +43,6 @@
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelFilter;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.filters.EffectiveProjectModelFilter;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -146,7 +146,7 @@ public void processArchivaArtifact( ArchivaArtifact artifact )
|
||||
}
|
||||
|
||||
File artifactFile = toFile( artifact );
|
||||
RepositoryConfiguration repo = getRepository( artifact );
|
||||
AbstractRepositoryConfiguration repo = getRepository( artifact );
|
||||
ProjectModelReader reader = project400Reader;
|
||||
|
||||
if ( StringUtils.equals( "legacy", repo.getLayout() ) )
|
||||
@ -223,15 +223,15 @@ private boolean hasProjectModelInDatabase( String groupId, String artifactId, St
|
||||
}
|
||||
}
|
||||
|
||||
private RepositoryConfiguration getRepository( ArchivaArtifact artifact )
|
||||
private ManagedRepositoryConfiguration getRepository( ArchivaArtifact artifact )
|
||||
{
|
||||
String repoId = artifact.getModel().getRepositoryId();
|
||||
return archivaConfiguration.getConfiguration().findRepositoryById( repoId );
|
||||
return archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
|
||||
}
|
||||
|
||||
private File toFile( ArchivaArtifact artifact )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = getRepository( artifact );
|
||||
ManagedRepositoryConfiguration repoConfig = getRepository( artifact );
|
||||
|
||||
BidirectionalRepositoryLayout layout = null;
|
||||
|
||||
@ -245,9 +245,7 @@ private File toFile( ArchivaArtifact artifact )
|
||||
return null;
|
||||
}
|
||||
|
||||
String path = layout.toPath( artifact );
|
||||
RepositoryURL url = new RepositoryURL( repoConfig.getUrl() );
|
||||
return new File( url.getPath(), path );
|
||||
return new File( repoConfig.getLocation(), layout.toPath( artifact ) );
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
|
@ -22,7 +22,7 @@
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer;
|
||||
@ -45,14 +45,13 @@
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* IndexArtifactConsumer
|
||||
* IndexArtifactConsumer
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer"
|
||||
* role-hint="index-artifact"
|
||||
* instantiation-strategy="per-lookup"
|
||||
* role-hint="index-artifact"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class IndexArtifactConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
@ -129,8 +128,8 @@ private IndexedRepositoryDetails getIndexedRepositoryDetails( ArchivaArtifact ar
|
||||
String repoId = artifact.getModel().getRepositoryId();
|
||||
if ( StringUtils.isBlank( repoId ) )
|
||||
{
|
||||
throw new IllegalStateException( "Unable to process artifact [" + artifact
|
||||
+ "] as it has no repository id associated with it." );
|
||||
throw new IllegalStateException(
|
||||
"Unable to process artifact [" + artifact + "] as it has no repository id associated with it." );
|
||||
}
|
||||
|
||||
return getIndexedRepositoryDetails( repoId );
|
||||
@ -158,7 +157,7 @@ public boolean isPermanent()
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isRepositories( propertyName ) )
|
||||
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
|
||||
{
|
||||
initRepositoryMap();
|
||||
}
|
||||
@ -182,14 +181,10 @@ private void initRepositoryMap()
|
||||
{
|
||||
this.repositoryMap.clear();
|
||||
|
||||
Iterator it = configuration.getConfiguration().getRepositories().iterator();
|
||||
Iterator it = configuration.getConfiguration().getManagedRepositories().iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
RepositoryConfiguration repoconfig = (RepositoryConfiguration) it.next();
|
||||
if ( !repoconfig.isManaged() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ManagedRepositoryConfiguration repoconfig = (ManagedRepositoryConfiguration) it.next();
|
||||
|
||||
ArchivaRepository repository = ArchivaConfigurationAdaptor.toArchivaRepository( repoconfig );
|
||||
IndexedRepositoryDetails pnl = new IndexedRepositoryDetails();
|
||||
|
@ -45,14 +45,13 @@
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IndexContentConsumer - generic full file content indexing consumer.
|
||||
* IndexContentConsumer - generic full file content indexing consumer.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
|
||||
* role-hint="index-content"
|
||||
* instantiation-strategy="per-lookup"
|
||||
* role-hint="index-content"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class IndexContentConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
@ -132,11 +131,6 @@ public List getIncludes()
|
||||
public void beginScan( ArchivaRepository repository )
|
||||
throws ConsumerException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ConsumerException( "Consumer requires managed repository." );
|
||||
}
|
||||
|
||||
this.repository = repository;
|
||||
this.repositoryDir = new File( repository.getUrl().getPath() );
|
||||
this.index = indexFactory.createFileContentIndex( repository );
|
||||
@ -147,8 +141,8 @@ public void beginScan( ArchivaRepository repository )
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new ConsumerException( "Unable to initialize consumer due to unknown repository layout: "
|
||||
+ e.getMessage(), e );
|
||||
throw new ConsumerException(
|
||||
"Unable to initialize consumer due to unknown repository layout: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndex;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory;
|
||||
import org.apache.maven.archiva.indexer.bytecode.BytecodeHandlers;
|
||||
@ -36,7 +36,6 @@
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.indexer.RepositoryContentIndexFactory" role-hint="lucene"
|
||||
*/
|
||||
public class LuceneRepositoryContentIndexFactory
|
||||
@ -66,21 +65,17 @@ public RepositoryContentIndex createHashcodeIndex( ArchivaRepository repository
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the index directory for the provided repository.
|
||||
*
|
||||
* Obtain the index directory for the provided repository.
|
||||
*
|
||||
* @param repository the repository to obtain the index directory from.
|
||||
* @param indexId the id of the index
|
||||
* @param indexId the id of the index
|
||||
* @return the directory to put the index into.
|
||||
*/
|
||||
private File toIndexDir( ArchivaRepository repository, String indexId )
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new IllegalArgumentException( "Only supports managed repositories." );
|
||||
}
|
||||
|
||||
// Attempt to get the specified indexDir in the configuration first.
|
||||
RepositoryConfiguration repoConfig = configuration.getConfiguration().findRepositoryById( repository.getId() );
|
||||
ManagedRepositoryConfiguration repoConfig =
|
||||
configuration.getConfiguration().findManagedRepositoryById( repository.getId() );
|
||||
File indexDir;
|
||||
|
||||
if ( repoConfig == null )
|
||||
|
@ -22,7 +22,6 @@
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.commons.collections.functors.AndPredicate;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.queryParser.MultiFieldQueryParser;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
@ -32,9 +31,7 @@
|
||||
import org.apache.lucene.search.Searchable;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.functors.IndexedRepositoryPredicate;
|
||||
import org.apache.maven.archiva.configuration.functors.LocalRepositoryPredicate;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndex;
|
||||
import org.apache.maven.archiva.indexer.bytecode.BytecodeHandlers;
|
||||
import org.apache.maven.archiva.indexer.filecontent.FileContentHandlers;
|
||||
@ -53,11 +50,10 @@
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DefaultCrossRepositorySearch
|
||||
* DefaultCrossRepositorySearch
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
@ -105,7 +101,7 @@ public SearchResults searchForChecksum( String checksum, SearchResultLimits limi
|
||||
|
||||
try
|
||||
{
|
||||
QueryParser parser = new MultiFieldQueryParser( new String[] { HashcodesKeys.MD5, HashcodesKeys.SHA1 },
|
||||
QueryParser parser = new MultiFieldQueryParser( new String[]{HashcodesKeys.MD5, HashcodesKeys.SHA1},
|
||||
new HashcodesHandlers().getAnalyzer() );
|
||||
LuceneQuery query = new LuceneQuery( parser.parse( checksum ) );
|
||||
SearchResults results = searchAll( query, limits, indexes );
|
||||
@ -256,7 +252,7 @@ private SearchResults searchAll( LuceneQuery luceneQuery, SearchResultLimits lim
|
||||
}
|
||||
catch ( IOException ie )
|
||||
{
|
||||
getLogger().error( "Unable to close index searcher: " + ie.getMessage(), ie );
|
||||
getLogger().error( "Unable to close index searcher: " + ie.getMessage(), ie );
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,7 +308,7 @@ public List getHashcodeIndexes()
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isRepositories( propertyName ) )
|
||||
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
|
||||
{
|
||||
initRepositories();
|
||||
}
|
||||
@ -329,28 +325,14 @@ private void initRepositories()
|
||||
{
|
||||
this.localIndexedRepositories.clear();
|
||||
|
||||
Predicate localIndexedRepos = AndPredicate.getInstance( LocalRepositoryPredicate.getInstance(),
|
||||
IndexedRepositoryPredicate.getInstance() );
|
||||
|
||||
Collection repos = CollectionUtils.select( configuration.getConfiguration().getRepositories(),
|
||||
localIndexedRepos );
|
||||
|
||||
Transformer toArchivaRepository = new Transformer()
|
||||
List<ManagedRepositoryConfiguration> repos = configuration.getConfiguration().getManagedRepositories();
|
||||
for ( ManagedRepositoryConfiguration repo : repos )
|
||||
{
|
||||
|
||||
public Object transform( Object input )
|
||||
if ( repo.isIndexed() )
|
||||
{
|
||||
if ( input instanceof RepositoryConfiguration )
|
||||
{
|
||||
return ArchivaConfigurationAdaptor.toArchivaRepository( (RepositoryConfiguration) input );
|
||||
}
|
||||
return input;
|
||||
localIndexedRepositories.add( ArchivaConfigurationAdaptor.toArchivaRepository( repo ) );
|
||||
}
|
||||
};
|
||||
|
||||
CollectionUtils.transform( repos, toArchivaRepository );
|
||||
|
||||
this.localIndexedRepositories.addAll( repos );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneIndexHandlers;
|
||||
import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
@ -41,7 +41,7 @@
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AbstractIndexerTestCase
|
||||
* AbstractIndexerTestCase
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
@ -53,6 +53,10 @@ public abstract class AbstractIndexerTestCase
|
||||
|
||||
protected LuceneIndexHandlers indexHandlers;
|
||||
|
||||
private static final String TEST_DEFAULT_REPOSITORY_NAME = "Test Default Repository";
|
||||
|
||||
private static final String TEST_DEFAULT_REPO_ID = "testDefaultRepo";
|
||||
|
||||
public abstract String getIndexName();
|
||||
|
||||
protected void assertRecord( LuceneRepositoryContentRecord expectedRecord, Document luceneDocument )
|
||||
@ -78,9 +82,9 @@ protected void setUp()
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
RepositoryContentIndexFactory indexFactory = (RepositoryContentIndexFactory) lookup(
|
||||
RepositoryContentIndexFactory.class
|
||||
.getName(), "lucene" );
|
||||
RepositoryContentIndexFactory indexFactory =
|
||||
(RepositoryContentIndexFactory) lookup( RepositoryContentIndexFactory.class
|
||||
.getName(), "lucene" );
|
||||
|
||||
ArchivaRepository repository = createTestIndex( getIndexName() );
|
||||
|
||||
@ -90,7 +94,7 @@ protected void setUp()
|
||||
}
|
||||
|
||||
private ArchivaRepository createTestIndex( String indexName )
|
||||
throws Exception, IOException
|
||||
throws Exception
|
||||
{
|
||||
File repoDir = new File( getBasedir(), "src/test/managed-repository" );
|
||||
File testIndexesDir = new File( getBasedir(), "target/test-indexes" );
|
||||
@ -104,16 +108,17 @@ private ArchivaRepository createTestIndex( String indexName )
|
||||
|
||||
String repoUri = "file://" + StringUtils.replace( repoDir.getAbsolutePath(), "\\", "/" );
|
||||
|
||||
ArchivaRepository repository = new ArchivaRepository( "testDefaultRepo", "Test Default Repository", repoUri );
|
||||
ArchivaRepository repository =
|
||||
new ArchivaRepository( TEST_DEFAULT_REPO_ID, TEST_DEFAULT_REPOSITORY_NAME, repoUri );
|
||||
|
||||
File indexLocation = new File( testIndexesDir, "/index-" + indexName + "-" + getName() + "/" );
|
||||
|
||||
MockConfiguration config = (MockConfiguration) lookup( ArchivaConfiguration.class.getName(), "mock" );
|
||||
|
||||
RepositoryConfiguration repoConfig = new RepositoryConfiguration();
|
||||
repoConfig.setId( repository.getId() );
|
||||
repoConfig.setName( repository.getModel().getName() );
|
||||
repoConfig.setUrl( repository.getModel().getUrl() );
|
||||
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
|
||||
repoConfig.setId( TEST_DEFAULT_REPO_ID );
|
||||
repoConfig.setName( TEST_DEFAULT_REPOSITORY_NAME );
|
||||
repoConfig.setLocation( repoDir.getAbsolutePath() );
|
||||
repoConfig.setIndexDir( indexLocation.getAbsolutePath() );
|
||||
|
||||
if ( indexLocation.exists() )
|
||||
@ -121,7 +126,7 @@ private ArchivaRepository createTestIndex( String indexName )
|
||||
FileUtils.deleteDirectory( indexLocation );
|
||||
}
|
||||
|
||||
config.getConfiguration().addRepository( repoConfig );
|
||||
config.getConfiguration().addManagedRepository( repoConfig );
|
||||
return repository;
|
||||
}
|
||||
|
||||
@ -130,8 +135,8 @@ protected Map getArchivaArtifactDumpMap()
|
||||
Map dumps = new HashMap();
|
||||
|
||||
// archiva-common-1.0.jar.txt
|
||||
dumps.put( "archiva-common", createArchivaArtifact( "org.apache.maven.archiva", "archiva-common", "1.0", "",
|
||||
"jar" ) );
|
||||
dumps.put( "archiva-common",
|
||||
createArchivaArtifact( "org.apache.maven.archiva", "archiva-common", "1.0", "", "jar" ) );
|
||||
|
||||
// continuum-webapp-1.0.3-SNAPSHOT.war.txt
|
||||
dumps.put( "continuum-webapp", createArchivaArtifact( "org.apache.maven.continuum", "continuum-webapp",
|
||||
@ -198,8 +203,8 @@ protected File getDumpFile( ArchivaArtifact artifact )
|
||||
return dumpFile;
|
||||
}
|
||||
|
||||
private ArchivaArtifact createArchivaArtifact( String groupId, String artifactId, String version,
|
||||
String classifier, String type )
|
||||
private ArchivaArtifact createArchivaArtifact( String groupId, String artifactId, String version, String classifier,
|
||||
String type )
|
||||
{
|
||||
ArchivaArtifact artifact = new ArchivaArtifact( groupId, artifactId, version, classifier, type );
|
||||
return artifact;
|
||||
|
@ -25,7 +25,7 @@
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.Searcher;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.indexer.MockConfiguration;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndex;
|
||||
import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory;
|
||||
@ -37,7 +37,7 @@
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* DefaultCrossRepositorySearchTest
|
||||
* DefaultCrossRepositorySearchTest
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
@ -45,15 +45,18 @@
|
||||
public class DefaultCrossRepositorySearchTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
private static final String TEST_DEFAULT_REPOSITORY_NAME = "Test Default Repository";
|
||||
|
||||
private static final String TEST_DEFAULT_REPO_ID = "testDefaultRepo";
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
RepositoryContentIndexFactory indexFactory = (RepositoryContentIndexFactory) lookup(
|
||||
RepositoryContentIndexFactory.class
|
||||
.getName(), "lucene" );
|
||||
RepositoryContentIndexFactory indexFactory =
|
||||
(RepositoryContentIndexFactory) lookup( RepositoryContentIndexFactory.class
|
||||
.getName(), "lucene" );
|
||||
|
||||
File repoDir = new File( getBasedir(), "src/test/managed-repository" );
|
||||
|
||||
@ -61,16 +64,17 @@ protected void setUp()
|
||||
|
||||
String repoUri = "file://" + StringUtils.replace( repoDir.getAbsolutePath(), "\\", "/" );
|
||||
|
||||
ArchivaRepository repository = new ArchivaRepository( "testDefaultRepo", "Test Default Repository", repoUri );
|
||||
ArchivaRepository repository =
|
||||
new ArchivaRepository( TEST_DEFAULT_REPO_ID, TEST_DEFAULT_REPOSITORY_NAME, repoUri );
|
||||
|
||||
File indexLocation = new File( "target/index-crossrepo-" + getName() + "/" );
|
||||
|
||||
MockConfiguration config = (MockConfiguration) lookup( ArchivaConfiguration.class.getName(), "mock" );
|
||||
|
||||
RepositoryConfiguration repoConfig = new RepositoryConfiguration();
|
||||
repoConfig.setId( repository.getId() );
|
||||
repoConfig.setName( repository.getModel().getName() );
|
||||
repoConfig.setUrl( repository.getModel().getUrl() );
|
||||
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
|
||||
repoConfig.setId( TEST_DEFAULT_REPO_ID );
|
||||
repoConfig.setName( TEST_DEFAULT_REPOSITORY_NAME );
|
||||
repoConfig.setLocation( repoDir.getAbsolutePath() );
|
||||
repoConfig.setIndexDir( indexLocation.getAbsolutePath() );
|
||||
repoConfig.setIndexed( true );
|
||||
|
||||
@ -79,7 +83,7 @@ protected void setUp()
|
||||
FileUtils.deleteDirectory( indexLocation );
|
||||
}
|
||||
|
||||
config.getConfiguration().addRepository( repoConfig );
|
||||
config.getConfiguration().addManagedRepository( repoConfig );
|
||||
|
||||
// Create the (empty) indexes.
|
||||
RepositoryContentIndex indexHashcode = indexFactory.createHashcodeIndex( repository );
|
||||
@ -115,7 +119,8 @@ private void assertRecordCount( RepositoryContentIndex index, int expectedCount
|
||||
private CrossRepositorySearch lookupCrossRepositorySearch()
|
||||
throws Exception
|
||||
{
|
||||
CrossRepositorySearch search = (CrossRepositorySearch) lookup( CrossRepositorySearch.class.getName(), "default" );
|
||||
CrossRepositorySearch search =
|
||||
(CrossRepositorySearch) lookup( CrossRepositorySearch.class.getName(), "default" );
|
||||
assertNotNull( "CrossRepositorySearch:default should not be null.", search );
|
||||
return search;
|
||||
}
|
||||
|
@ -18,7 +18,8 @@
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-base</artifactId>
|
||||
@ -89,7 +90,7 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>jpox-maven-plugin</artifactId>
|
||||
<version>1.1.6</version>
|
||||
<dependencies>
|
||||
@ -100,44 +101,44 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<!-- TODO: put this into a profile!
|
||||
<execution>
|
||||
<id>create-ddl</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<goals>
|
||||
<goal>schema-create</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputFile>${basedir}/target/classes/org/apache/maven/archiva/model/schema.ddl</outputFile>
|
||||
<toolProperties>
|
||||
<property>
|
||||
<name>javax.jdo.option.ConnectionDriverName</name>
|
||||
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>javax.jdo.option.ConnectionURL</name>
|
||||
<value>jdbc:derby:target/jdo-schema-create;create=true</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>javax.jdo.option.ConnectionUserName</name>
|
||||
<value>sa</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>javax.jdo.option.ConnectionPassword</name>
|
||||
<value></value>
|
||||
</property>
|
||||
<property>
|
||||
<name>log4j.configuration</name>
|
||||
<value>${basedir}/src/test/resources/log4j.xml</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>org.jpox.autoCreateTables</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</toolProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
-->
|
||||
<!-- TODO: put this into a profile
|
||||
<execution>
|
||||
<id>create-ddl</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<goals>
|
||||
<goal>schema-create</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputFile>${basedir}/target/classes/org/apache/maven/archiva/model/schema.ddl</outputFile>
|
||||
<toolProperties>
|
||||
<property>
|
||||
<name>javax.jdo.option.ConnectionDriverName</name>
|
||||
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>javax.jdo.option.ConnectionURL</name>
|
||||
<value>jdbc:derby:target/jdo-schema-create;create=true</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>javax.jdo.option.ConnectionUserName</name>
|
||||
<value>sa</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>javax.jdo.option.ConnectionPassword</name>
|
||||
<value></value>
|
||||
</property>
|
||||
<property>
|
||||
<name>log4j.configuration</name>
|
||||
<value>${basedir}/src/test/resources/log4j.xml</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>org.jpox.autoCreateTables</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</toolProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
-->
|
||||
<execution>
|
||||
<id>enhance</id>
|
||||
<goals>
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* ArchivaRepository
|
||||
* ArchivaRepository
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
@ -35,10 +35,10 @@ public class ArchivaRepository
|
||||
|
||||
/**
|
||||
* Construct a Repository.
|
||||
*
|
||||
* @param id the unique identifier for this repository.
|
||||
* @param name the name for this repository.
|
||||
* @param url the base URL for this repository (this should point to the top level URL for the entire repository)
|
||||
*
|
||||
* @param id the unique identifier for this repository.
|
||||
* @param name the name for this repository.
|
||||
* @param url the base URL for this repository (this should point to the top level URL for the entire repository)
|
||||
* @param layout the layout technique for this repository.
|
||||
*/
|
||||
public ArchivaRepository( String id, String name, String url )
|
||||
@ -52,7 +52,7 @@ public ArchivaRepository( String id, String name, String url )
|
||||
|
||||
/**
|
||||
* Construct a Repository.
|
||||
*
|
||||
*
|
||||
* @param model the model to use
|
||||
*/
|
||||
public ArchivaRepository( ArchivaRepositoryModel model )
|
||||
@ -93,16 +93,6 @@ public void setBlacklisted( boolean blacklisted )
|
||||
this.blacklisted = blacklisted;
|
||||
}
|
||||
|
||||
public boolean isRemote()
|
||||
{
|
||||
return this.url.getProtocol().equals( "file" );
|
||||
}
|
||||
|
||||
public boolean isManaged()
|
||||
{
|
||||
return this.url.getProtocol().equals( "file" );
|
||||
}
|
||||
|
||||
public String getLayoutType()
|
||||
{
|
||||
return this.model.getLayoutName();
|
||||
|
@ -1,53 +0,0 @@
|
||||
package org.apache.maven.archiva.model.functors;
|
||||
|
||||
/*
|
||||
* 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.collections.Predicate;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
|
||||
/**
|
||||
* ManagedRepositoryPredicate
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ManagedRepositoryPredicate
|
||||
implements Predicate
|
||||
{
|
||||
public static final Predicate INSTANCE = new ManagedRepositoryPredicate();
|
||||
|
||||
public static Predicate getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public boolean evaluate( Object object )
|
||||
{
|
||||
boolean satisfies = false;
|
||||
|
||||
if ( object instanceof ArchivaRepository )
|
||||
{
|
||||
ArchivaRepository repo = (ArchivaRepository) object;
|
||||
return repo.isManaged();
|
||||
}
|
||||
|
||||
return satisfies;
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
</defaults>
|
||||
|
||||
<classes>
|
||||
<class stash.storable="false"
|
||||
<class stash.storable="false"
|
||||
rootElement="true"
|
||||
jpox.enabled="false">
|
||||
<name>ArchivaAll</name>
|
||||
@ -25,6 +25,7 @@
|
||||
This object is not serialized to the Database.
|
||||
</description>
|
||||
<fields>
|
||||
<!-- TODO! check it -->
|
||||
<field>
|
||||
<name>repositories</name>
|
||||
<version>1.0.0+</version>
|
||||
@ -121,6 +122,7 @@
|
||||
The Name of the repository.
|
||||
</description>
|
||||
</field>
|
||||
<!-- TODO! check it -->
|
||||
<field stash.maxSize="250">
|
||||
<name>url</name>
|
||||
<identifier>false</identifier>
|
||||
@ -527,16 +529,16 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<!-- _______________________________________________________________
|
||||
__ __ _ _ _
|
||||
| \/ | ___| |_ __ _ __| | __ _| |_ __ _
|
||||
| |\/| |/ _ \ __/ _` |/ _` |/ _` | __/ _` |
|
||||
| | | | __/ || (_| | (_| | (_| | || (_| |
|
||||
|_| |_|\___|\__\__,_|\__,_|\__,_|\__\__,_|
|
||||
|
||||
-->
|
||||
|
||||
__ __ _ _ _
|
||||
| \/ | ___| |_ __ _ __| | __ _| |_ __ _
|
||||
| |\/| |/ _ \ __/ _` |/ _` |/ _` | __/ _` |
|
||||
| | | | __/ || (_| | (_| | (_| | || (_| |
|
||||
|_| |_|\___|\__\__,_|\__,_|\__,_|\__\__,_|
|
||||
|
||||
-->
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.use-identifiers-as-primary-key="false"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
@ -695,21 +697,21 @@
|
||||
<code>
|
||||
public void updateTimestamp()
|
||||
{
|
||||
setLastUpdatedTimestamp( new java.util.Date() );
|
||||
setLastUpdatedTimestamp( new java.util.Date() );
|
||||
}
|
||||
|
||||
public void setLastUpdatedTimestamp( java.util.Date date )
|
||||
{
|
||||
java.util.TimeZone timezone = java.util.TimeZone.getTimeZone( "UTC" );
|
||||
java.text.DateFormat fmt = new java.text.SimpleDateFormat( "yyyyMMddHHmmss" );
|
||||
fmt.setTimeZone( timezone );
|
||||
setLastUpdated( fmt.format( date ) );
|
||||
java.util.TimeZone timezone = java.util.TimeZone.getTimeZone( "UTC" );
|
||||
java.text.DateFormat fmt = new java.text.SimpleDateFormat( "yyyyMMddHHmmss" );
|
||||
fmt.setTimeZone( timezone );
|
||||
setLastUpdated( fmt.format( date ) );
|
||||
}
|
||||
</code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="REPOSITORY_METADATA_SNAPSHOTS">
|
||||
@ -724,7 +726,7 @@
|
||||
<identifier>false</identifier>
|
||||
<required>true</required>
|
||||
<description>
|
||||
The unique timestamp for the snapshot version.
|
||||
The unique timestamp for the snapshot version.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
@ -744,16 +746,15 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- _______________________________________________________________
|
||||
____ __
|
||||
| _ \ ___ / _| ___ _ __ ___ _ __ ___ ___ ___
|
||||
| |_) / _ \ |_ / _ \ '__/ _ \ '_ \ / __/ _ \/ __|
|
||||
| _ ( __/ _| __/ | | __/ | | | (_| __/\__ \
|
||||
|_| \_\___|_| \___|_| \___|_| |_|\___\___||___/
|
||||
-->
|
||||
____ __
|
||||
| _ \ ___ / _| ___ _ __ ___ _ __ ___ ___ ___
|
||||
| |_) / _ \ |_ / _ \ '__/ _ \ '_ \ / __/ _ \/ __|
|
||||
| _ ( __/ _| __/ | | __/ | | | (_| __/\__ \
|
||||
|_| \_\___|_| \___|_| \___|_| |_|\___\___||___/
|
||||
-->
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
@ -818,7 +819,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="VERSIONED_REFERENCE">
|
||||
@ -894,7 +895,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="ARTIFACT_REFERENCE">
|
||||
@ -1431,7 +1432,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="MAILING_LISTS">
|
||||
@ -1489,7 +1490,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="ORGANIZATION">
|
||||
@ -1533,7 +1534,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="LICENSES">
|
||||
@ -1584,7 +1585,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="ISSUE_MANAGEMENT">
|
||||
@ -1617,7 +1618,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class jpox.not-persisted-fields="modelEncoding">
|
||||
<name>CiManagement</name>
|
||||
<version>1.0.0+</version>
|
||||
@ -1648,7 +1649,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding">
|
||||
<name>Individual</name>
|
||||
@ -1942,7 +1943,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="EXCLUSIONS">
|
||||
@ -1973,7 +1974,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="SCM">
|
||||
@ -2019,7 +2020,7 @@
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
|
||||
<class stash.storable="true"
|
||||
jpox.not-persisted-fields="modelEncoding"
|
||||
jpox.table="PROJECT_REPOSITORIES">
|
||||
@ -2119,7 +2120,7 @@
|
||||
The repository associated with this path and problem.
|
||||
</description>
|
||||
</field>
|
||||
<field stash.maxSize="250"
|
||||
<field stash.maxSize="250"
|
||||
jpox.column="REPO_PATH">
|
||||
<name>path</name>
|
||||
<version>1.0.0+</version>
|
||||
|
@ -23,15 +23,17 @@
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.ProjectReference;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.policies.DownloadPolicy;
|
||||
import org.apache.maven.archiva.policies.urlcache.UrlFailureCache;
|
||||
import org.apache.maven.archiva.repository.ArchivaConfigurationAdaptor;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
|
||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
|
||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||
@ -58,15 +60,14 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* DefaultRepositoryProxyConnectors
|
||||
* DefaultRepositoryProxyConnectors
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role-hint="default"
|
||||
*/
|
||||
public class DefaultRepositoryProxyConnectors
|
||||
@ -110,11 +111,6 @@ public class DefaultRepositoryProxyConnectors
|
||||
public File fetchFromProxies( ArchivaRepository repository, ArtifactReference artifact )
|
||||
throws ProxyException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ProxyException( "Can only proxy managed repositories." );
|
||||
}
|
||||
|
||||
File localFile;
|
||||
try
|
||||
{
|
||||
@ -124,8 +120,8 @@ public File fetchFromProxies( ArchivaRepository repository, ArtifactReference ar
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new ProxyException( "Unable to proxy due to bad source repository layout definition: "
|
||||
+ e.getMessage(), e );
|
||||
throw new ProxyException(
|
||||
"Unable to proxy due to bad source repository layout definition: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
Properties requestProperties = new Properties();
|
||||
@ -140,15 +136,15 @@ public File fetchFromProxies( ArchivaRepository repository, ArtifactReference ar
|
||||
ArchivaRepository targetRepository = connector.getTargetRepository();
|
||||
try
|
||||
{
|
||||
BidirectionalRepositoryLayout targetLayout = layoutFactory.getLayout( targetRepository.getLayoutType() );
|
||||
BidirectionalRepositoryLayout targetLayout =
|
||||
layoutFactory.getLayout( targetRepository.getLayoutType() );
|
||||
String targetPath = targetLayout.toPath( artifact );
|
||||
|
||||
getLogger().debug(
|
||||
"Using target repository: " + targetRepository.getId() + " - layout: "
|
||||
+ targetRepository.getLayoutType() + " - targetPath: " + targetPath );
|
||||
getLogger().debug( "Using target repository: " + targetRepository.getId() + " - layout: " +
|
||||
targetRepository.getLayoutType() + " - targetPath: " + targetPath );
|
||||
|
||||
File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile,
|
||||
requestProperties );
|
||||
File downloadedFile =
|
||||
transferFile( connector, targetRepository, targetPath, localFile, requestProperties );
|
||||
|
||||
if ( fileExists( downloadedFile ) )
|
||||
{
|
||||
@ -169,11 +165,6 @@ public File fetchFromProxies( ArchivaRepository repository, ArtifactReference ar
|
||||
public File fetchFromProxies( ArchivaRepository repository, VersionedReference metadata )
|
||||
throws ProxyException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ProxyException( "Can only proxy managed repositories." );
|
||||
}
|
||||
|
||||
File localFile;
|
||||
try
|
||||
{
|
||||
@ -183,8 +174,8 @@ public File fetchFromProxies( ArchivaRepository repository, VersionedReference m
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new ProxyException( "Unable to proxy due to bad source repository layout definition: "
|
||||
+ e.getMessage(), e );
|
||||
throw new ProxyException(
|
||||
"Unable to proxy due to bad source repository layout definition: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
Properties requestProperties = new Properties();
|
||||
@ -197,11 +188,12 @@ public File fetchFromProxies( ArchivaRepository repository, VersionedReference m
|
||||
ArchivaRepository targetRepository = connector.getTargetRepository();
|
||||
try
|
||||
{
|
||||
BidirectionalRepositoryLayout targetLayout = layoutFactory.getLayout( targetRepository.getLayoutType() );
|
||||
BidirectionalRepositoryLayout targetLayout =
|
||||
layoutFactory.getLayout( targetRepository.getLayoutType() );
|
||||
String targetPath = targetLayout.toPath( metadata );
|
||||
|
||||
File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile,
|
||||
requestProperties );
|
||||
File downloadedFile =
|
||||
transferFile( connector, targetRepository, targetPath, localFile, requestProperties );
|
||||
|
||||
if ( fileExists( downloadedFile ) )
|
||||
{
|
||||
@ -222,11 +214,6 @@ public File fetchFromProxies( ArchivaRepository repository, VersionedReference m
|
||||
public File fetchFromProxies( ArchivaRepository repository, ProjectReference metadata )
|
||||
throws ProxyException
|
||||
{
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
throw new ProxyException( "Can only proxy managed repositories." );
|
||||
}
|
||||
|
||||
File localFile;
|
||||
try
|
||||
{
|
||||
@ -236,8 +223,8 @@ public File fetchFromProxies( ArchivaRepository repository, ProjectReference met
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new ProxyException( "Unable to proxy due to bad source repository layout definition: "
|
||||
+ e.getMessage(), e );
|
||||
throw new ProxyException(
|
||||
"Unable to proxy due to bad source repository layout definition: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
Properties requestProperties = new Properties();
|
||||
@ -250,11 +237,12 @@ public File fetchFromProxies( ArchivaRepository repository, ProjectReference met
|
||||
ArchivaRepository targetRepository = connector.getTargetRepository();
|
||||
try
|
||||
{
|
||||
BidirectionalRepositoryLayout targetLayout = layoutFactory.getLayout( targetRepository.getLayoutType() );
|
||||
BidirectionalRepositoryLayout targetLayout =
|
||||
layoutFactory.getLayout( targetRepository.getLayoutType() );
|
||||
String targetPath = targetLayout.toPath( metadata );
|
||||
|
||||
File downloadedFile = transferFile( connector, targetRepository, targetPath, localFile,
|
||||
requestProperties );
|
||||
File downloadedFile =
|
||||
transferFile( connector, targetRepository, targetPath, localFile, requestProperties );
|
||||
|
||||
if ( fileExists( downloadedFile ) )
|
||||
{
|
||||
@ -294,14 +282,14 @@ private boolean fileExists( File file )
|
||||
|
||||
/**
|
||||
* Perform the transfer of the file.
|
||||
*
|
||||
*
|
||||
* @param connector
|
||||
* @param targetRepository
|
||||
* @param targetPath
|
||||
* @param localFile
|
||||
* @param requestProperties
|
||||
* @return
|
||||
* @throws ProxyException
|
||||
* @throws ProxyException
|
||||
*/
|
||||
private File transferFile( ProxyConnector connector, ArchivaRepository targetRepository, String targetPath,
|
||||
File localFile, Properties requestProperties )
|
||||
@ -431,7 +419,8 @@ private void transferChecksum( Wagon wagon, ArchivaRepository targetRepository,
|
||||
}
|
||||
}
|
||||
|
||||
private File transferSimpleFile( Wagon wagon, ArchivaRepository targetRepository, String targetPath, File localFile )
|
||||
private File transferSimpleFile( Wagon wagon, ArchivaRepository targetRepository, String targetPath,
|
||||
File localFile )
|
||||
throws ProxyException, WagonException
|
||||
{
|
||||
// Transfer the file.
|
||||
@ -464,8 +453,7 @@ private File transferSimpleFile( Wagon wagon, ArchivaRepository targetRepository
|
||||
if ( !success )
|
||||
{
|
||||
getLogger().debug(
|
||||
"Not downloaded, as local file is newer than remote side: "
|
||||
+ localFile.getAbsolutePath() );
|
||||
"Not downloaded, as local file is newer than remote side: " + localFile.getAbsolutePath() );
|
||||
}
|
||||
else if ( temp.exists() )
|
||||
{
|
||||
@ -563,7 +551,8 @@ private boolean connectToRepository( ProxyConnector connector, Wagon wagon, Arch
|
||||
|
||||
try
|
||||
{
|
||||
Repository wagonRepository = new Repository( targetRepository.getId(), targetRepository.getUrl().toString() );
|
||||
Repository wagonRepository =
|
||||
new Repository( targetRepository.getId(), targetRepository.getUrl().toString() );
|
||||
if ( networkProxy != null )
|
||||
{
|
||||
wagon.connect( wagonRepository, networkProxy );
|
||||
@ -629,8 +618,10 @@ public boolean hasProxies( ArchivaRepository repository )
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isNetworkProxy( propertyName ) || ConfigurationNames.isRepositories( propertyName )
|
||||
|| ConfigurationNames.isProxyConnector( propertyName ) )
|
||||
if ( ConfigurationNames.isNetworkProxy( propertyName ) ||
|
||||
ConfigurationNames.isManagedRepositories( propertyName ) ||
|
||||
ConfigurationNames.isRemoteRepositories( propertyName ) ||
|
||||
ConfigurationNames.isProxyConnector( propertyName ) )
|
||||
{
|
||||
initConnectorsAndNetworkProxies();
|
||||
}
|
||||
@ -658,8 +649,8 @@ private void initConnectorsAndNetworkProxies()
|
||||
|
||||
// Create connector object.
|
||||
ProxyConnector connector = new ProxyConnector();
|
||||
connector.setSourceRepository( getRepository( proxyConfig.getSourceRepoId() ) );
|
||||
connector.setTargetRepository( getRepository( proxyConfig.getTargetRepoId() ) );
|
||||
connector.setSourceRepository( getManagedRepository( proxyConfig.getSourceRepoId() ) );
|
||||
connector.setTargetRepository( getRemoteRepository( proxyConfig.getTargetRepoId() ) );
|
||||
connector.setProxyId( proxyConfig.getProxyId() );
|
||||
connector.setPolicies( proxyConfig.getPolicies() );
|
||||
|
||||
@ -729,19 +720,24 @@ private boolean isEmpty( Collection collection )
|
||||
return collection.size() == 0;
|
||||
}
|
||||
|
||||
private ArchivaRepository getRepository( String repoId )
|
||||
private ArchivaRepository getRemoteRepository( String repoId )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = archivaConfiguration.getConfiguration().findRepositoryById( repoId );
|
||||
if ( repoConfig == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
RemoteRepositoryConfiguration repoConfig =
|
||||
archivaConfiguration.getConfiguration().findRemoteRepositoryById( repoId );
|
||||
|
||||
ArchivaRepository repo = new ArchivaRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl() );
|
||||
repo.getModel().setLayoutName( repoConfig.getLayout() );
|
||||
return repo;
|
||||
}
|
||||
|
||||
private ArchivaRepository getManagedRepository( String repoId )
|
||||
{
|
||||
ManagedRepositoryConfiguration repoConfig =
|
||||
archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
|
||||
|
||||
return ArchivaConfigurationAdaptor.toArchivaRepository( repoConfig );
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
|
@ -22,8 +22,9 @@
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
@ -48,12 +49,12 @@
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* AbstractProxyTestCase
|
||||
* AbstractProxyTestCase
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AbstractProxyTestCase
|
||||
public abstract class AbstractProxyTestCase
|
||||
extends PlexusTestCase
|
||||
{
|
||||
protected static final String ID_LEGACY_PROXIED = "legacy-proxied";
|
||||
@ -162,7 +163,7 @@ protected void assertNoTempFiles( File expectedFile )
|
||||
return;
|
||||
}
|
||||
|
||||
Collection tmpFiles = FileUtils.listFiles( workingDir, new String[] { "tmp" }, false );
|
||||
Collection tmpFiles = FileUtils.listFiles( workingDir, new String[]{"tmp"}, false );
|
||||
if ( !tmpFiles.isEmpty() )
|
||||
{
|
||||
StringBuffer emsg = new StringBuffer();
|
||||
@ -221,8 +222,8 @@ else if ( file.isDirectory() )
|
||||
{
|
||||
if ( !destination.exists() && !destination.mkdirs() )
|
||||
{
|
||||
throw new IOException( "Could not create destination directory '"
|
||||
+ destination.getAbsolutePath() + "'." );
|
||||
throw new IOException(
|
||||
"Could not create destination directory '" + destination.getAbsolutePath() + "'." );
|
||||
}
|
||||
|
||||
copyDirectoryStructure( file, destination );
|
||||
@ -269,19 +270,19 @@ protected ArchivaRepository createProxiedLegacyRepository()
|
||||
"Test Proxied (Legacy) Repository", "legacy" );
|
||||
}
|
||||
|
||||
protected RepositoryConfiguration createRepoConfig( ArchivaRepository repo )
|
||||
protected ManagedRepositoryConfiguration createRepoConfig( ArchivaRepository repo )
|
||||
{
|
||||
return createRepoConfig( repo.getId(), repo.getName(), repo.getUrl().toString(), repo.getLayoutType() );
|
||||
}
|
||||
|
||||
protected RepositoryConfiguration createRepoConfig( String id, String name, String path, String layout )
|
||||
protected ManagedRepositoryConfiguration createRepoConfig( String id, String name, String path, String layout )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = new RepositoryConfiguration();
|
||||
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
|
||||
|
||||
repoConfig.setId( id );
|
||||
repoConfig.setName( name );
|
||||
|
||||
repoConfig.setUrl( PathUtil.toUrl( path ) );
|
||||
repoConfig.setLocation( path );
|
||||
repoConfig.setLayout( layout );
|
||||
|
||||
return repoConfig;
|
||||
@ -332,8 +333,8 @@ protected String readChecksumFile( File checksumFile )
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy,
|
||||
String releasePolicy, String snapshotPolicy, String cacheFailuresPolicy )
|
||||
protected void saveConnector( String sourceRepoId, String targetRepoId, String checksumPolicy, String releasePolicy,
|
||||
String snapshotPolicy, String cacheFailuresPolicy )
|
||||
{
|
||||
ProxyConnectorConfiguration connectorConfig = new ProxyConnectorConfiguration();
|
||||
connectorConfig.setSourceRepoId( sourceRepoId );
|
||||
@ -357,24 +358,33 @@ protected void saveConnector( String sourceRepoId, String targetRepoId, String c
|
||||
config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
|
||||
}
|
||||
|
||||
protected void saveRepositoryConfig( String id, String name, String path, String layout )
|
||||
protected void saveManagedRepositoryConfig( String id, String name, String path, String layout )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = new RepositoryConfiguration();
|
||||
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
|
||||
|
||||
repoConfig.setId( id );
|
||||
repoConfig.setName( name );
|
||||
|
||||
if ( path.startsWith( "test://" ) )
|
||||
{
|
||||
repoConfig.setUrl( path );
|
||||
}
|
||||
else
|
||||
{
|
||||
repoConfig.setUrl( PathUtil.toUrl( path ) );
|
||||
}
|
||||
repoConfig.setLayout( layout );
|
||||
|
||||
config.getConfiguration().addRepository( repoConfig );
|
||||
repoConfig.setLocation( path );
|
||||
|
||||
config.getConfiguration().addManagedRepository( repoConfig );
|
||||
|
||||
config.triggerChange( "repository", "" );
|
||||
}
|
||||
|
||||
protected void saveRemoteRepositoryConfig( String id, String name, String path, String layout )
|
||||
{
|
||||
RemoteRepositoryConfiguration repoConfig = new RemoteRepositoryConfiguration();
|
||||
|
||||
repoConfig.setId( id );
|
||||
repoConfig.setName( name );
|
||||
repoConfig.setLayout( layout );
|
||||
|
||||
repoConfig.setUrl( path );
|
||||
|
||||
config.getConfiguration().addRemoteRepository( repoConfig );
|
||||
|
||||
config.triggerChange( "repository", "" );
|
||||
}
|
||||
|
||||
@ -385,7 +395,7 @@ protected File saveTargetedRepositoryConfig( String id, String originalPath, Str
|
||||
FileUtils.deleteDirectory( repoLocation );
|
||||
copyDirectoryStructure( getTestFile( originalPath ), repoLocation );
|
||||
|
||||
saveRepositoryConfig( id, "Target Repo-" + id, targetPath, layout );
|
||||
saveRemoteRepositoryConfig( id, "Target Repo-" + id, targetPath, layout );
|
||||
|
||||
return repoLocation;
|
||||
}
|
||||
@ -399,7 +409,6 @@ protected void setUp()
|
||||
.getName() );
|
||||
|
||||
config = (MockConfiguration) lookup( ArchivaConfiguration.class.getName(), "mock" );
|
||||
RepositoryConfiguration repoConfig;
|
||||
|
||||
// Setup source repository (using default layout)
|
||||
File repoLocation = getTestFile( REPOPATH_DEFAULT_MANAGED_TARGET );
|
||||
@ -412,9 +421,9 @@ protected void setUp()
|
||||
|
||||
managedDefaultDir = new File( managedDefaultRepository.getUrl().getPath() );
|
||||
|
||||
repoConfig = createRepoConfig( managedDefaultRepository );
|
||||
ManagedRepositoryConfiguration repoConfig = createRepoConfig( managedDefaultRepository );
|
||||
|
||||
config.getConfiguration().addRepository( repoConfig );
|
||||
config.getConfiguration().addManagedRepository( repoConfig );
|
||||
|
||||
// Setup source repository (using legacy layout)
|
||||
repoLocation = getTestFile( REPOPATH_LEGACY_MANAGED_TARGET );
|
||||
@ -428,16 +437,19 @@ protected void setUp()
|
||||
|
||||
repoConfig = createRepoConfig( managedLegacyRepository );
|
||||
|
||||
config.getConfiguration().addRepository( repoConfig );
|
||||
config.getConfiguration().addManagedRepository( repoConfig );
|
||||
|
||||
// Setup target (proxied to) repository.
|
||||
saveRepositoryConfig( ID_PROXIED1, "Proxied Repository 1", REPOPATH_PROXIED1, "default" );
|
||||
saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
|
||||
new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
|
||||
|
||||
// Setup target (proxied to) repository.
|
||||
saveRepositoryConfig( ID_PROXIED2, "Proxied Repository 2", REPOPATH_PROXIED2, "default" );
|
||||
saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
|
||||
new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
|
||||
|
||||
// Setup target (proxied to) repository using legacy layout.
|
||||
saveRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository", REPOPATH_PROXIED_LEGACY, "legacy" );
|
||||
saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository",
|
||||
new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
|
||||
|
||||
// Setup the proxy handler.
|
||||
proxyHandler = (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
|
||||
|
@ -23,7 +23,7 @@
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* IDE Provided Utility Class for all tests.
|
||||
* IDE Provided Utility Class for all tests.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
@ -36,12 +36,12 @@ public static Test suite()
|
||||
TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.proxy" );
|
||||
//$JUnit-BEGIN$
|
||||
suite.addTestSuite( ChecksumTransferTest.class );
|
||||
suite.addTestSuite( MetadataTransferTest.class );
|
||||
// suite.addTestSuite( MetadataTransferTest.class );
|
||||
suite.addTestSuite( CacheFailuresTransferTest.class );
|
||||
suite.addTestSuite( ManagedDefaultTransferTest.class );
|
||||
suite.addTestSuite( SnapshotTransferTest.class );
|
||||
suite.addTestSuite( ManagedLegacyTransferTest.class );
|
||||
suite.addTestSuite( RelocateTransferTest.class );
|
||||
// suite.addTestSuite( RelocateTransferTest.class );
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* CacheFailuresTransferTest
|
||||
* CacheFailuresTransferTest
|
||||
*
|
||||
* @author Brett Porter
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
@ -51,8 +51,8 @@ public void testGetWithCacheFailuresOn()
|
||||
assertFalse( expectedFile.exists() );
|
||||
|
||||
// Configure Repository (usually done within archiva.xml configuration)
|
||||
saveRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
||||
saveRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/repo/", "default" );
|
||||
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
||||
saveRemoteRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/repo/", "default" );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.IGNORED,
|
||||
@ -85,8 +85,8 @@ public void testGetWithCacheFailuresOff()
|
||||
assertFalse( expectedFile.exists() );
|
||||
|
||||
// Configure Repository (usually done within archiva.xml configuration)
|
||||
saveRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
||||
saveRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/repo/", "default" );
|
||||
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
||||
saveRemoteRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/repo/", "default" );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.IGNORED,
|
||||
|
@ -30,7 +30,7 @@
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* ChecksumTransferTest
|
||||
* ChecksumTransferTest
|
||||
*
|
||||
* @author Brett Porter
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
@ -81,7 +81,8 @@ public void testGetChecksumCorrectSha1NoMd5()
|
||||
File proxied1File = new File( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile, proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar", null );
|
||||
assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
|
||||
null );
|
||||
}
|
||||
|
||||
public void testGetChecksumNoSha1CorrectMd5()
|
||||
@ -359,7 +360,7 @@ public void testGetChecksumTransferFailed()
|
||||
assertFalse( expectedFile.getParentFile().exists() );
|
||||
assertFalse( expectedFile.exists() );
|
||||
|
||||
saveRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" );
|
||||
saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
|
||||
@ -387,7 +388,8 @@ public void testGetChecksumTransferFailed()
|
||||
File proxied1File = new File( REPOPATH_PROXIED1, path );
|
||||
assertFileEquals( expectedFile, downloadedFile, proxied1File );
|
||||
assertNoTempFiles( expectedFile );
|
||||
assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar", null );
|
||||
assertChecksums( expectedFile, "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
|
||||
null );
|
||||
}
|
||||
|
||||
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting()
|
||||
|
@ -31,7 +31,7 @@
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* ManagedDefaultTransferTest
|
||||
* ManagedDefaultTransferTest
|
||||
*
|
||||
* @author Brett Porter
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
@ -65,9 +65,9 @@ public void testGetDefaultLayoutNotPresent()
|
||||
|
||||
/**
|
||||
* The attempt here should result in no file being transferred.
|
||||
*
|
||||
* <p/>
|
||||
* The file exists locally, and the policy is ONCE.
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testGetDefaultLayoutAlreadyPresentPolicyOnce()
|
||||
@ -93,9 +93,9 @@ public void testGetDefaultLayoutAlreadyPresentPolicyOnce()
|
||||
|
||||
/**
|
||||
* The attempt here should result in file being transferred.
|
||||
*
|
||||
* <p/>
|
||||
* The file exists locally, and the policy is IGNORE.
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testGetDefaultLayoutAlreadyPresentPolicyIgnored()
|
||||
@ -129,15 +129,15 @@ public void testGetDefaultLayoutAlreadyPresentPolicyIgnored()
|
||||
* This delta is the amount of milliseconds of 'fudge factor' we allow for
|
||||
* the unit test to still be considered 'passed'.
|
||||
*/
|
||||
int delta = 1100;
|
||||
int delta = 20000;
|
||||
|
||||
long hirange = originalModificationTime + ( delta / 2 );
|
||||
long lorange = originalModificationTime - ( delta / 2 );
|
||||
|
||||
if ( ( downloadedLastModified < lorange ) || ( downloadedLastModified > hirange ) )
|
||||
{
|
||||
fail( "Check file timestamp is that of original managed file: expected within range lo:<" + lorange
|
||||
+ "> hi:<" + hirange + "> but was:<" + downloadedLastModified + ">" );
|
||||
fail( "Check file timestamp is that of original managed file: expected within range lo:<" + lorange +
|
||||
"> hi:<" + hirange + "> but was:<" + downloadedLastModified + ">" );
|
||||
}
|
||||
}
|
||||
assertNoTempFiles( expectedFile );
|
||||
@ -145,9 +145,9 @@ public void testGetDefaultLayoutAlreadyPresentPolicyIgnored()
|
||||
|
||||
/**
|
||||
* The attempt here should result in file being transferred.
|
||||
*
|
||||
* <p/>
|
||||
* The file exists locally, is over 6 years old, and the policy is DAILY.
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testGetDefaultLayoutRemoteUpdate()
|
||||
@ -161,8 +161,8 @@ public void testGetDefaultLayoutRemoteUpdate()
|
||||
expectedFile.setLastModified( getPastDate().getTime() );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.DAILY,
|
||||
SnapshotsPolicy.DAILY, CachedFailuresPolicy.IGNORED );
|
||||
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.DAILY, SnapshotsPolicy.DAILY,
|
||||
CachedFailuresPolicy.IGNORED );
|
||||
|
||||
// Attempt the proxy fetch.
|
||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||
@ -199,8 +199,8 @@ public void testGetWhenInBothProxiedRepos()
|
||||
// TODO: is this check even needed if it passes above?
|
||||
String actualContents = FileUtils.readFileToString( downloadedFile, null );
|
||||
String badContents = FileUtils.readFileToString( proxied2File, null );
|
||||
assertFalse( "Downloaded file contents should not be that of proxy 2", StringUtils.equals( actualContents,
|
||||
badContents ) );
|
||||
assertFalse( "Downloaded file contents should not be that of proxy 2",
|
||||
StringUtils.equals( actualContents, badContents ) );
|
||||
}
|
||||
|
||||
public void testGetInSecondProxiedRepo()
|
||||
@ -247,7 +247,8 @@ public void testNotFoundInAnyProxies()
|
||||
// Attempt the proxy fetch.
|
||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||
|
||||
assertNull( "File returned was: " + downloadedFile + "; should have got a not found exception", downloadedFile );
|
||||
assertNull( "File returned was: " + downloadedFile + "; should have got a not found exception",
|
||||
downloadedFile );
|
||||
assertNoTempFiles( expectedFile );
|
||||
}
|
||||
|
||||
@ -262,7 +263,7 @@ public void testGetInSecondProxiedRepoFirstFails()
|
||||
assertFalse( expectedFile.exists() );
|
||||
|
||||
// Configure Repository (usually done within archiva.xml configuration)
|
||||
saveRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" );
|
||||
saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" );
|
||||
|
||||
wagonMock.getIfNewer( path, new File( expectedFile.getAbsolutePath() + ".tmp" ), 0 );
|
||||
wagonMockControl.setThrowable( new TransferFailedException( "transfer failed" ) );
|
||||
@ -295,8 +296,8 @@ public void testGetAllRepositoriesFail()
|
||||
assertFalse( expectedFile.exists() );
|
||||
|
||||
// Configure Repository (usually done within archiva.xml configuration)
|
||||
saveRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
||||
saveRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://dead.machine.com/repo/", "default" );
|
||||
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
||||
saveRemoteRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://dead.machine.com/repo/", "default" );
|
||||
|
||||
// Configure Connector (usually done within archiva.xml configuration)
|
||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.IGNORED,
|
||||
@ -338,8 +339,8 @@ public void testLegacyProxyRepoGetAlreadyPresent()
|
||||
|
||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||
|
||||
File proxiedFile = new File( REPOPATH_PROXIED_LEGACY,
|
||||
"org.apache.maven.test/jars/get-default-layout-present-1.0.jar" );
|
||||
File proxiedFile =
|
||||
new File( REPOPATH_PROXIED_LEGACY, "org.apache.maven.test/jars/get-default-layout-present-1.0.jar" );
|
||||
assertFileEquals( expectedFile, downloadedFile, proxiedFile );
|
||||
assertNoTempFiles( expectedFile );
|
||||
}
|
||||
|
@ -19,31 +19,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
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.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.ProjectReference;
|
||||
import org.apache.maven.archiva.policies.CachedFailuresPolicy;
|
||||
import org.apache.maven.archiva.policies.ChecksumPolicy;
|
||||
import org.apache.maven.archiva.policies.ReleasesPolicy;
|
||||
import org.apache.maven.archiva.policies.SnapshotsPolicy;
|
||||
import org.apache.maven.archiva.policies.urlcache.UrlFailureCache;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.apache.maven.wagon.TransferFailedException;
|
||||
import org.apache.maven.wagon.Wagon;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* RelocateTransferTest
|
||||
* RelocateTransferTest
|
||||
*
|
||||
* @author Brett Porter
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
|
@ -1,98 +0,0 @@
|
||||
package org.apache.maven.archiva.repository;
|
||||
|
||||
/*
|
||||
* 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.collections.CollectionUtils;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.functors.LocalRepositoryPredicate;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||
import org.codehaus.plexus.registry.Registry;
|
||||
import org.codehaus.plexus.registry.RegistryListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A component that provides a real-time listing of the active managed repositories within archiva.
|
||||
* This object is internally consistent and will return maintain a consistent list of managed repositories internally.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.repository.ActiveManagedRepositories"
|
||||
*/
|
||||
public class ActiveManagedRepositories
|
||||
implements RegistryListener, Initializable
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration archivaConfiguration;
|
||||
|
||||
private List allManagedRepositories = new ArrayList();
|
||||
|
||||
/**
|
||||
* Get the {@link List} of {@link RepositoryConfiguration} objects representing managed repositories.
|
||||
*
|
||||
* @return the {@link List} of {@link RepositoryConfiguration} objects.
|
||||
*/
|
||||
public List getAllManagedRepositories()
|
||||
{
|
||||
synchronized ( allManagedRepositories )
|
||||
{
|
||||
return Collections.unmodifiableList( allManagedRepositories );
|
||||
}
|
||||
}
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isRepositories( propertyName ) )
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
update();
|
||||
archivaConfiguration.addChangeListener( this );
|
||||
}
|
||||
|
||||
private void update()
|
||||
{
|
||||
synchronized ( allManagedRepositories )
|
||||
{
|
||||
allManagedRepositories.clear();
|
||||
|
||||
List configRepos = archivaConfiguration.getConfiguration().getRepositories();
|
||||
CollectionUtils.filter( configRepos, LocalRepositoryPredicate.getInstance() );
|
||||
}
|
||||
}
|
||||
}
|
@ -20,11 +20,12 @@
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
|
||||
/**
|
||||
* ArchivaConfigurationAdaptor
|
||||
* ArchivaConfigurationAdaptor
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
@ -32,7 +33,11 @@
|
||||
*/
|
||||
public class ArchivaConfigurationAdaptor
|
||||
{
|
||||
public static ArchivaRepository toArchivaRepository( RepositoryConfiguration config )
|
||||
private ArchivaConfigurationAdaptor()
|
||||
{
|
||||
}
|
||||
|
||||
public static ArchivaRepository toArchivaRepository( ManagedRepositoryConfiguration config )
|
||||
{
|
||||
if ( config == null )
|
||||
{
|
||||
@ -44,13 +49,14 @@ public static ArchivaRepository toArchivaRepository( RepositoryConfiguration con
|
||||
throw new IllegalArgumentException( "Unable to repository config with blank ID to archiva repository." );
|
||||
}
|
||||
|
||||
if ( StringUtils.isBlank( config.getUrl() ) )
|
||||
if ( StringUtils.isBlank( config.getLocation() ) )
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to convert repository config with blank URL to archiva repository." );
|
||||
"Unable to convert repository config with blank location to archiva repository." );
|
||||
}
|
||||
|
||||
ArchivaRepository repository = new ArchivaRepository( config.getId(), config.getName(), config.getUrl() );
|
||||
ArchivaRepository repository =
|
||||
new ArchivaRepository( config.getId(), config.getName(), PathUtil.toUrl( config.getLocation() ) );
|
||||
|
||||
repository.getModel().setLayoutName( config.getLayout() );
|
||||
repository.getModel().setReleasePolicy( config.isReleases() );
|
||||
|
@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
@ -98,13 +98,13 @@ public BidirectionalRepositoryLayout getLayout( ArchivaArtifact artifact )
|
||||
throw new LayoutException( "Cannot determine layout using artifact with no repository id: " + artifact );
|
||||
}
|
||||
|
||||
RepositoryConfiguration repo = (RepositoryConfiguration) this.repositoryMap.get( repoId );
|
||||
AbstractRepositoryConfiguration repo = (AbstractRepositoryConfiguration) this.repositoryMap.get( repoId );
|
||||
return getLayout( repo.getLayout() );
|
||||
}
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isRepositories( propertyName ) )
|
||||
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
|
||||
{
|
||||
initRepositoryMap();
|
||||
}
|
||||
@ -120,7 +120,7 @@ private void initRepositoryMap()
|
||||
synchronized ( this.repositoryMap )
|
||||
{
|
||||
this.repositoryMap.clear();
|
||||
this.repositoryMap.putAll( configuration.getConfiguration().createRepositoryMap() );
|
||||
this.repositoryMap.putAll( configuration.getConfiguration().getManagedRepositoriesAsMap() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,10 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
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.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.functors.LocalRepositoryPredicate;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.repository.ArchivaConfigurationAdaptor;
|
||||
import org.apache.maven.archiva.repository.RepositoryException;
|
||||
@ -40,16 +38,13 @@
|
||||
import org.codehaus.plexus.registry.Registry;
|
||||
import org.codehaus.plexus.registry.RegistryListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Factory for ProjectModelResolver objects
|
||||
* Factory for ProjectModelResolver objects
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelResolverFactory"
|
||||
*/
|
||||
public class ProjectModelResolverFactory
|
||||
@ -80,7 +75,7 @@ public class ProjectModelResolverFactory
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isRepositories( propertyName ) )
|
||||
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
|
||||
{
|
||||
update();
|
||||
}
|
||||
@ -106,12 +101,6 @@ public void initialize()
|
||||
private RepositoryProjectResolver toResolver( ArchivaRepository repo )
|
||||
throws RepositoryException
|
||||
{
|
||||
if ( !repo.isManaged() )
|
||||
{
|
||||
throw new RepositoryException( "Unable to create RepositoryProjectResolver from non-managed repository: "
|
||||
+ repo );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BidirectionalRepositoryLayout layout = layoutFactory.getLayout( repo.getLayoutType() );
|
||||
@ -127,8 +116,8 @@ private RepositoryProjectResolver toResolver( ArchivaRepository repo )
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new RepositoryException( "Unable to create RepositoryProjectResolver due to invalid layout spec: "
|
||||
+ repo );
|
||||
throw new RepositoryException(
|
||||
"Unable to create RepositoryProjectResolver due to invalid layout spec: " + repo );
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,15 +127,11 @@ private void update()
|
||||
{
|
||||
this.currentResolverStack.clearResolvers();
|
||||
|
||||
List configLocalRepos = new ArrayList();
|
||||
CollectionUtils.select( archivaConfiguration.getConfiguration().getRepositories(), LocalRepositoryPredicate
|
||||
.getInstance(), configLocalRepos );
|
||||
|
||||
Iterator it = configLocalRepos.iterator();
|
||||
while ( it.hasNext() )
|
||||
List<ManagedRepositoryConfiguration> list =
|
||||
archivaConfiguration.getConfiguration().getManagedRepositories();
|
||||
for ( ManagedRepositoryConfiguration repositoryConfiguration : list )
|
||||
{
|
||||
RepositoryConfiguration repoconfig = (RepositoryConfiguration) it.next();
|
||||
ArchivaRepository repo = ArchivaConfigurationAdaptor.toArchivaRepository( repoconfig );
|
||||
ArchivaRepository repo = ArchivaConfigurationAdaptor.toArchivaRepository( repositoryConfiguration );
|
||||
try
|
||||
{
|
||||
RepositoryProjectResolver resolver = toResolver( repo );
|
||||
|
@ -34,11 +34,10 @@
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DefaultRepositoryScanner
|
||||
* DefaultRepositoryScanner
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.repository.scanner.RepositoryScanner"
|
||||
*/
|
||||
public class DefaultRepositoryScanner
|
||||
@ -75,7 +74,7 @@ public RepositoryContentStatistics scan( ArchivaRepository repository, List know
|
||||
throw new IllegalArgumentException( "Unable to operate on a null repository." );
|
||||
}
|
||||
|
||||
if ( !repository.isManaged() )
|
||||
if ( !"file".equals( repository.getUrl().getProtocol() ) )
|
||||
{
|
||||
throw new UnsupportedOperationException( "Only filesystem repositories are supported." );
|
||||
}
|
||||
@ -84,14 +83,14 @@ public RepositoryContentStatistics scan( ArchivaRepository repository, List know
|
||||
|
||||
if ( !repositoryBase.exists() )
|
||||
{
|
||||
throw new UnsupportedOperationException( "Unable to scan a repository, directory "
|
||||
+ repositoryBase.getAbsolutePath() + " does not exist." );
|
||||
throw new UnsupportedOperationException(
|
||||
"Unable to scan a repository, directory " + repositoryBase.getAbsolutePath() + " does not exist." );
|
||||
}
|
||||
|
||||
if ( !repositoryBase.isDirectory() )
|
||||
{
|
||||
throw new UnsupportedOperationException( "Unable to scan a repository, path "
|
||||
+ repositoryBase.getAbsolutePath() + " is not a directory." );
|
||||
throw new UnsupportedOperationException(
|
||||
"Unable to scan a repository, path " + repositoryBase.getAbsolutePath() + " is not a directory." );
|
||||
}
|
||||
|
||||
// Setup Includes / Excludes.
|
||||
@ -116,8 +115,8 @@ public RepositoryContentStatistics scan( ArchivaRepository repository, List know
|
||||
dirWalker.setExcludes( allExcludes );
|
||||
|
||||
// Setup the Scan Instance
|
||||
RepositoryScannerInstance scannerInstance = new RepositoryScannerInstance( repository, knownContentConsumers,
|
||||
invalidContentConsumers, getLogger() );
|
||||
RepositoryScannerInstance scannerInstance =
|
||||
new RepositoryScannerInstance( repository, knownContentConsumers, invalidContentConsumers, getLogger() );
|
||||
scannerInstance.setOnlyModifiedAfterTimestamp( changesSince );
|
||||
|
||||
dirWalker.addDirectoryWalkListener( scannerInstance );
|
||||
|
@ -30,12 +30,12 @@
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* AbstractBidirectionalRepositoryLayoutTestCase
|
||||
* AbstractBidirectionalRepositoryLayoutTestCase
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AbstractBidirectionalRepositoryLayoutTestCase
|
||||
public abstract class AbstractBidirectionalRepositoryLayoutTestCase
|
||||
extends PlexusTestCase
|
||||
{
|
||||
protected ArchivaRepository repository;
|
||||
@ -60,9 +60,7 @@ protected ArchivaRepository createTestRepository()
|
||||
|
||||
String repoUri = "file://" + StringUtils.replace( testRepo.getAbsolutePath(), "\\", "/" );
|
||||
|
||||
ArchivaRepository repo = new ArchivaRepository( "testRepo", "Test Repository", repoUri );
|
||||
|
||||
return repo;
|
||||
return new ArchivaRepository( "testRepo", "Test Repository", repoUri );
|
||||
}
|
||||
|
||||
protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier,
|
||||
@ -99,8 +97,8 @@ protected void assertArtifact( ArchivaArtifact actualArtifact, String groupId, S
|
||||
protected void assertArtifactReference( ArtifactReference actualReference, String groupId, String artifactId,
|
||||
String version, String classifier, String type )
|
||||
{
|
||||
String expectedId = "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier
|
||||
+ ":" + type;
|
||||
String expectedId =
|
||||
"ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type;
|
||||
|
||||
assertNotNull( expectedId + " - Should not be null.", actualReference );
|
||||
|
||||
|
@ -23,19 +23,17 @@
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* AllTests - Useful for developers using IDEs.
|
||||
* AllTests - Useful for developers using IDEs.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AllTests
|
||||
{
|
||||
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.repository.layout" );
|
||||
//$JUnit-BEGIN$
|
||||
suite.addTestSuite( AbstractBidirectionalRepositoryLayoutTestCase.class );
|
||||
suite.addTestSuite( BidirectionalRepositoryLayoutFactoryTest.class );
|
||||
suite.addTestSuite( LegacyBidirectionalRepositoryLayoutTest.class );
|
||||
suite.addTestSuite( DefaultBidirectionalRepositoryLayoutTest.class );
|
||||
|
@ -492,7 +492,6 @@
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<check>
|
||||
<!-- TODO! raise to 85/100 -->
|
||||
<totalLineRate>77</totalLineRate>
|
||||
<totalBranchRate>95</totalBranchRate>
|
||||
</check>
|
||||
|
@ -321,7 +321,6 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<!-- TODO! add unit tests -->
|
||||
<configuration>
|
||||
<instrumentation>
|
||||
<excludes>
|
||||
|
@ -74,13 +74,13 @@
|
||||
</site>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh-external</artifactId>
|
||||
<version>1.0-alpha-5</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh-external</artifactId>
|
||||
<version>1.0-alpha-5</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
@ -431,7 +431,6 @@
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<check>
|
||||
<!-- TODO! raise to 85/100 -->
|
||||
<totalLineRate>77</totalLineRate>
|
||||
<totalBranchRate>95</totalBranchRate>
|
||||
</check>
|
||||
|
@ -483,7 +483,6 @@
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<check>
|
||||
<!-- TODO! raise to 85/100 -->
|
||||
<totalLineRate>77</totalLineRate>
|
||||
<totalBranchRate>95</totalBranchRate>
|
||||
</check>
|
||||
|
@ -1,9 +1,28 @@
|
||||
package org.apache.maven.archiva.database.constraints;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.database.Constraint;
|
||||
|
||||
/**
|
||||
* ArchivaRepositoryByUrlConstraint
|
||||
* ArchivaRepositoryByUrlConstraint
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
|
@ -23,7 +23,7 @@
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.FileTypes;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ArchivaArtifactConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
@ -48,10 +48,8 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
@ -62,9 +60,8 @@
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.consumers.ArchivaArtifactConsumer"
|
||||
* role-hint="validate-artifacts-location"
|
||||
* role-hint="validate-artifacts-location"
|
||||
*/
|
||||
public class LocationArtifactsConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
@ -84,7 +81,7 @@ public class LocationArtifactsConsumer
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
@ -146,11 +143,6 @@ public void processArchivaArtifact( ArchivaArtifact artifact )
|
||||
throws ConsumerException
|
||||
{
|
||||
ArchivaRepository repository = findRepository( artifact );
|
||||
if ( !repository.isManaged() )
|
||||
{
|
||||
getLogger().warn( "Artifact Location Validation Cannot operate against a non-managed Repository." );
|
||||
return;
|
||||
}
|
||||
|
||||
File artifactFile = new File( repository.getUrl().toString(), toPath( artifact ) );
|
||||
ArchivaProjectModel fsModel = readFilesystemModel( artifactFile );
|
||||
@ -167,23 +159,23 @@ private void validateAppropriateModel( String location, ArchivaArtifact artifact
|
||||
{
|
||||
if ( !StringUtils.equals( model.getGroupId(), artifact.getGroupId() ) )
|
||||
{
|
||||
addProblem( artifact, "The groupId of the " + location
|
||||
+ " project model doesn't match with the artifact, expected <" + artifact.getGroupId()
|
||||
+ ">, but was actually <" + model.getGroupId() + ">" );
|
||||
addProblem( artifact, "The groupId of the " + location +
|
||||
" project model doesn't match with the artifact, expected <" + artifact.getGroupId() +
|
||||
">, but was actually <" + model.getGroupId() + ">" );
|
||||
}
|
||||
|
||||
|
||||
if ( !StringUtils.equals( model.getArtifactId(), artifact.getArtifactId() ) )
|
||||
{
|
||||
addProblem( artifact, "The artifactId of the " + location
|
||||
+ " project model doesn't match with the artifact, expected <" + artifact.getArtifactId()
|
||||
+ ">, but was actually <" + model.getArtifactId() + ">" );
|
||||
addProblem( artifact, "The artifactId of the " + location +
|
||||
" project model doesn't match with the artifact, expected <" + artifact.getArtifactId() +
|
||||
">, but was actually <" + model.getArtifactId() + ">" );
|
||||
}
|
||||
|
||||
|
||||
if ( !StringUtils.equals( model.getVersion(), artifact.getVersion() ) )
|
||||
{
|
||||
addProblem( artifact, "The version of the " + location
|
||||
+ " project model doesn't match with the artifact, expected <" + artifact.getVersion()
|
||||
+ ">, but was actually <" + model.getVersion() + ">" );
|
||||
addProblem( artifact, "The version of the " + location +
|
||||
" project model doesn't match with the artifact, expected <" + artifact.getVersion() +
|
||||
">, but was actually <" + model.getVersion() + ">" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,18 +188,18 @@ private ArchivaProjectModel readEmbeddedModel( ArchivaArtifact artifact, File ar
|
||||
JarFile jar = new JarFile( artifactFile );
|
||||
|
||||
// Get the entry and its input stream.
|
||||
JarEntry expectedEntry = jar.getJarEntry( "META-INF/maven/" + artifact.getGroupId() + "/"
|
||||
+ artifact.getArtifactId() + "/pom.xml" );
|
||||
JarEntry expectedEntry = jar.getJarEntry(
|
||||
"META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/pom.xml" );
|
||||
|
||||
if ( expectedEntry != null )
|
||||
{
|
||||
// TODO: read and resolve model here.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/* Expected Entry not found, look for alternate that might
|
||||
* indicate that the artifact is, indeed located in the wrong place.
|
||||
*/
|
||||
* indicate that the artifact is, indeed located in the wrong place.
|
||||
*/
|
||||
|
||||
List actualPomXmls = findJarEntryPattern( jar, "META-INF/maven/**/pom.xml" );
|
||||
if ( actualPomXmls.isEmpty() )
|
||||
@ -215,7 +207,7 @@ private ArchivaProjectModel readEmbeddedModel( ArchivaArtifact artifact, File ar
|
||||
// No check needed.
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO: test for invalid actual pom.xml
|
||||
// TODO: test
|
||||
}
|
||||
@ -276,7 +268,7 @@ private ArchivaProjectModel readFilesystemModel( File artifactFile )
|
||||
File pomFile = createPomFileReference( artifactFile );
|
||||
|
||||
// TODO: read and resolve model here.
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -316,7 +308,7 @@ private String toPath( ArchivaArtifact artifact )
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isRepositories( propertyName ) )
|
||||
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
|
||||
{
|
||||
initRepositoryMap();
|
||||
}
|
||||
@ -345,14 +337,12 @@ private void initRepositoryMap()
|
||||
{
|
||||
this.repositoryMap.clear();
|
||||
|
||||
Iterator it = configuration.getConfiguration().createRepositoryMap().entrySet().iterator();
|
||||
while ( it.hasNext() )
|
||||
Map<String, ManagedRepositoryConfiguration> map =
|
||||
configuration.getConfiguration().getManagedRepositoriesAsMap();
|
||||
for ( Map.Entry<String, ManagedRepositoryConfiguration> entry : map.entrySet() )
|
||||
{
|
||||
Map.Entry entry = (Entry) it.next();
|
||||
String key = (String) entry.getKey();
|
||||
RepositoryConfiguration repoConfig = (RepositoryConfiguration) entry.getValue();
|
||||
ArchivaRepository repository = ArchivaConfigurationAdaptor.toArchivaRepository( repoConfig );
|
||||
this.repositoryMap.put( key, repository );
|
||||
ArchivaRepository repository = ArchivaConfigurationAdaptor.toArchivaRepository( entry.getValue() );
|
||||
this.repositoryMap.put( entry.getKey(), repository );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,8 @@
|
||||
*/
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.ArchivaArtifactConsumer;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
@ -35,7 +34,7 @@
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DuplicateArtifactReportTest
|
||||
* DuplicateArtifactReportTest
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
@ -62,19 +61,19 @@ protected void setUp()
|
||||
|
||||
ArchivaConfiguration config = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "default" );
|
||||
|
||||
RepositoryConfiguration repoConfig = new RepositoryConfiguration();
|
||||
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
|
||||
repoConfig.setId( TESTABLE_REPO );
|
||||
repoConfig.setLayout( "default" );
|
||||
File testRepoDir = new File( getBasedir(), "target/test-repository" );
|
||||
FileUtils.forceMkdir( testRepoDir );
|
||||
repoConfig.setUrl( PathUtil.toUrl( testRepoDir ) );
|
||||
config.getConfiguration().addRepository( repoConfig );
|
||||
repoConfig.setLocation( testRepoDir.getAbsolutePath() );
|
||||
config.getConfiguration().addManagedRepository( repoConfig );
|
||||
}
|
||||
|
||||
public ArchivaArtifact createArtifact( String artifactId, String version )
|
||||
{
|
||||
ArchivaArtifact artifact = artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version,
|
||||
"", "jar" );
|
||||
ArchivaArtifact artifact =
|
||||
artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version, "", "jar" );
|
||||
artifact.getModel().setLastModified( new Date() );
|
||||
artifact.getModel().setRepositoryId( TESTABLE_REPO );
|
||||
return artifact;
|
||||
@ -120,8 +119,8 @@ public void testSimpleReport()
|
||||
List allArtifacts = artifactDao.queryArtifacts( null );
|
||||
assertEquals( "Total Artifact Count", 7, allArtifacts.size() );
|
||||
|
||||
DuplicateArtifactReport report = (DuplicateArtifactReport) lookup( DynamicReportSource.class.getName(),
|
||||
"duplicate-artifacts" );
|
||||
DuplicateArtifactReport report =
|
||||
(DuplicateArtifactReport) lookup( DynamicReportSource.class.getName(), "duplicate-artifacts" );
|
||||
|
||||
List results = report.getData();
|
||||
|
||||
@ -137,10 +136,9 @@ public void testSimpleReport()
|
||||
int hash1Count = 4;
|
||||
int hash2Count = 2;
|
||||
int hash3Count = 1;
|
||||
|
||||
int totals = ( ( hash1Count * hash1Count ) - hash1Count ) +
|
||||
( ( hash2Count * hash2Count ) - hash2Count ) +
|
||||
( ( hash3Count * hash3Count ) - hash3Count );
|
||||
|
||||
int totals = ( ( hash1Count * hash1Count ) - hash1Count ) + ( ( hash2Count * hash2Count ) - hash2Count ) +
|
||||
( ( hash3Count * hash3Count ) - hash3Count );
|
||||
assertEquals( "Total report hits.", totals, results.size() );
|
||||
}
|
||||
|
||||
@ -148,8 +146,8 @@ private void pretendToRunDuplicateArtifactsConsumer()
|
||||
throws Exception
|
||||
{
|
||||
List artifacts = dao.getArtifactDAO().queryArtifacts( null );
|
||||
ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) lookup( ArchivaArtifactConsumer.class.getName(),
|
||||
"duplicate-artifacts" );
|
||||
ArchivaArtifactConsumer consumer =
|
||||
(ArchivaArtifactConsumer) lookup( ArchivaArtifactConsumer.class.getName(), "duplicate-artifacts" );
|
||||
consumer.beginScan();
|
||||
try
|
||||
{
|
||||
|
@ -52,12 +52,7 @@ public void queueDatabaseTask( DatabaseTask task )
|
||||
public void queueRepositoryTask( RepositoryTask task )
|
||||
throws TaskQueueException;
|
||||
|
||||
public void scheduleAllRepositoryTasks()
|
||||
throws TaskExecutionException;
|
||||
|
||||
public void scheduleDatabaseTasks()
|
||||
throws TaskExecutionException;
|
||||
|
||||
public void scheduleRepositoryTask( String repositoryId )
|
||||
throws TaskExecutionException;
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.maven.archiva.common.ArchivaException;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
|
||||
import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
|
||||
import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
|
||||
@ -48,7 +48,7 @@
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Default implementation of a scheduling component for archiva..
|
||||
* Default implementation of a scheduling component for archiva.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @author <a href="mailto:jmcconnell@apache.org">Jesse McConnell</a>
|
||||
@ -97,13 +97,13 @@ public void start()
|
||||
{
|
||||
try
|
||||
{
|
||||
List repositories = archivaConfiguration.getConfiguration().getRepositories();
|
||||
List repositories = archivaConfiguration.getConfiguration().getManagedRepositories();
|
||||
|
||||
for ( Iterator i = repositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = (RepositoryConfiguration) i.next();
|
||||
ManagedRepositoryConfiguration repoConfig = (ManagedRepositoryConfiguration) i.next();
|
||||
|
||||
if ( repoConfig.isManaged() && repoConfig.isIndexed() )
|
||||
if ( repoConfig.isIndexed() )
|
||||
{
|
||||
scheduleRepositoryJobs( repoConfig );
|
||||
}
|
||||
@ -117,7 +117,7 @@ public void start()
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleRepositoryJobs( RepositoryConfiguration repoConfig )
|
||||
private void scheduleRepositoryJobs( ManagedRepositoryConfiguration repoConfig )
|
||||
throws SchedulerException
|
||||
{
|
||||
if ( repoConfig.getRefreshCronExpression() == null )
|
||||
@ -132,15 +132,14 @@ private void scheduleRepositoryJobs( RepositoryConfiguration repoConfig )
|
||||
CronExpressionValidator cronValidator = new CronExpressionValidator();
|
||||
if ( !cronValidator.validate( cronString ) )
|
||||
{
|
||||
getLogger().warn(
|
||||
"Cron expression [" + cronString + "] for repository [" + repoConfig.getId()
|
||||
+ "] is invalid. Defaulting to hourly." );
|
||||
getLogger().warn( "Cron expression [" + cronString + "] for repository [" + repoConfig.getId() +
|
||||
"] is invalid. Defaulting to hourly." );
|
||||
cronString = CRON_HOURLY;
|
||||
}
|
||||
|
||||
// setup the unprocessed artifact job
|
||||
JobDetail repositoryJob = new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP,
|
||||
RepositoryTaskJob.class );
|
||||
JobDetail repositoryJob =
|
||||
new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP, RepositoryTaskJob.class );
|
||||
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put( RepositoryTaskJob.TASK_QUEUE, repositoryScanningQueue );
|
||||
@ -150,16 +149,16 @@ private void scheduleRepositoryJobs( RepositoryConfiguration repoConfig )
|
||||
|
||||
try
|
||||
{
|
||||
CronTrigger trigger = new CronTrigger( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId(),
|
||||
REPOSITORY_SCAN_GROUP, cronString );
|
||||
CronTrigger trigger =
|
||||
new CronTrigger( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP, cronString );
|
||||
|
||||
scheduler.scheduleJob( repositoryJob, trigger );
|
||||
}
|
||||
catch ( ParseException e )
|
||||
{
|
||||
getLogger().error(
|
||||
"ParseException in repository scanning cron expression, disabling repository scanning for '"
|
||||
+ repoConfig.getId() + "': " + e.getMessage() );
|
||||
"ParseException in repository scanning cron expression, disabling repository scanning for '" +
|
||||
repoConfig.getId() + "': " + e.getMessage() );
|
||||
}
|
||||
|
||||
}
|
||||
@ -180,8 +179,7 @@ private void scheduleDatabaseJobs()
|
||||
if ( !cronValidator.validate( cronString ) )
|
||||
{
|
||||
getLogger().warn(
|
||||
"Cron expression [" + cronString
|
||||
+ "] for database update is invalid. Defaulting to hourly." );
|
||||
"Cron expression [" + cronString + "] for database update is invalid. Defaulting to hourly." );
|
||||
cronString = CRON_HOURLY;
|
||||
}
|
||||
|
||||
@ -194,8 +192,7 @@ private void scheduleDatabaseJobs()
|
||||
catch ( ParseException e )
|
||||
{
|
||||
getLogger().error(
|
||||
"ParseException in database scanning cron expression, disabling database scanning: "
|
||||
+ e.getMessage() );
|
||||
"ParseException in database scanning cron expression, disabling database scanning: " + e.getMessage() );
|
||||
}
|
||||
|
||||
}
|
||||
@ -219,7 +216,7 @@ public void beforeConfigurationChange( Registry registry, String propertyName, O
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
@ -245,11 +242,11 @@ public void afterConfigurationChange( Registry registry, String propertyName, Ob
|
||||
// currently we have to reschedule all repo jobs because we don't know where the changed one came from
|
||||
if ( "refreshCronExpression".equals( propertyName ) )
|
||||
{
|
||||
List repositories = archivaConfiguration.getConfiguration().getRepositories();
|
||||
List repositories = archivaConfiguration.getConfiguration().getManagedRepositories();
|
||||
|
||||
for ( Iterator i = repositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = (RepositoryConfiguration) i.next();
|
||||
ManagedRepositoryConfiguration repoConfig = (ManagedRepositoryConfiguration) i.next();
|
||||
|
||||
if ( repoConfig.getRefreshCronExpression() != null )
|
||||
{
|
||||
@ -268,27 +265,6 @@ public void afterConfigurationChange( Registry registry, String propertyName, Ob
|
||||
}
|
||||
}
|
||||
|
||||
public void scheduleAllRepositoryTasks()
|
||||
throws TaskExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
List repositories = archivaConfiguration.getConfiguration().getRepositories();
|
||||
|
||||
for ( Iterator i = repositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = (RepositoryConfiguration) i.next();
|
||||
|
||||
scheduleRepositoryJobs( repoConfig );
|
||||
}
|
||||
|
||||
}
|
||||
catch ( SchedulerException e )
|
||||
{
|
||||
throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public void scheduleDatabaseTasks()
|
||||
throws TaskExecutionException
|
||||
{
|
||||
@ -303,22 +279,6 @@ public void scheduleDatabaseTasks()
|
||||
}
|
||||
}
|
||||
|
||||
public void scheduleRepositoryTask( String repositoryId )
|
||||
throws TaskExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
RepositoryConfiguration repoConfig = archivaConfiguration.getConfiguration()
|
||||
.findRepositoryById( repositoryId );
|
||||
|
||||
scheduleRepositoryJobs( repoConfig );
|
||||
}
|
||||
catch ( SchedulerException e )
|
||||
{
|
||||
throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isProcessingAnyRepositoryTask()
|
||||
throws ArchivaException
|
||||
{
|
||||
|
@ -20,19 +20,14 @@
|
||||
*/
|
||||
|
||||
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.collections.functors.NotPredicate;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
|
||||
import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
|
||||
import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate;
|
||||
import org.apache.maven.archiva.configuration.functors.RemoteRepositoryPredicate;
|
||||
import org.apache.maven.archiva.configuration.functors.RepositoryIdListClosure;
|
||||
import org.apache.maven.archiva.policies.DownloadPolicy;
|
||||
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
@ -106,7 +101,7 @@ public class ConfigureProxyConnectorAction
|
||||
/**
|
||||
* The list of local repository ids.
|
||||
*/
|
||||
private List localRepoIdList = new ArrayList();
|
||||
private List managedRepoIdList = new ArrayList();
|
||||
|
||||
/**
|
||||
* The list of remote repository ids.
|
||||
@ -301,9 +296,9 @@ public ProxyConnectorConfiguration getConnector()
|
||||
return connector;
|
||||
}
|
||||
|
||||
public List getLocalRepoIdList()
|
||||
public List getManagedRepoIdList()
|
||||
{
|
||||
return localRepoIdList;
|
||||
return managedRepoIdList;
|
||||
}
|
||||
|
||||
public String getMode()
|
||||
@ -396,35 +391,13 @@ public void prepare()
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
|
||||
// Gather Network Proxy Ids.
|
||||
|
||||
this.proxyIdOptions = new ArrayList();
|
||||
this.proxyIdOptions.add( DIRECT_CONNECTION );
|
||||
|
||||
Closure addProxyIds = new Closure()
|
||||
{
|
||||
public void execute( Object input )
|
||||
{
|
||||
if ( input instanceof NetworkProxyConfiguration )
|
||||
{
|
||||
NetworkProxyConfiguration netproxy = (NetworkProxyConfiguration) input;
|
||||
proxyIdOptions.add( netproxy.getId() );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CollectionUtils.forAllDo( config.getNetworkProxies(), addProxyIds );
|
||||
this.proxyIdOptions.addAll( config.getNetworkProxiesAsMap().keySet() );
|
||||
|
||||
// Gather Local & Remote Repo Ids.
|
||||
|
||||
RepositoryIdListClosure remoteRepoIdList = new RepositoryIdListClosure( new ArrayList() );
|
||||
RepositoryIdListClosure localRepoIdList = new RepositoryIdListClosure( new ArrayList() );
|
||||
Closure repoIfClosure =
|
||||
IfClosure.getInstance( RemoteRepositoryPredicate.getInstance(), remoteRepoIdList, localRepoIdList );
|
||||
|
||||
CollectionUtils.forAllDo( config.getRepositories(), repoIfClosure );
|
||||
|
||||
this.remoteRepoIdList = remoteRepoIdList.getList();
|
||||
this.localRepoIdList = localRepoIdList.getList();
|
||||
this.remoteRepoIdList = new ArrayList( config.getRemoteRepositoriesAsMap().keySet() );
|
||||
this.managedRepoIdList = new ArrayList( config.getManagedRepositoriesAsMap().keySet() );
|
||||
}
|
||||
|
||||
public String save()
|
||||
@ -472,9 +445,9 @@ public void setConnector( ProxyConnectorConfiguration connector )
|
||||
this.connector = connector;
|
||||
}
|
||||
|
||||
public void setLocalRepoIdList( List localRepoIdList )
|
||||
public void setManagedRepoIdList( List managedRepoIdList )
|
||||
{
|
||||
this.localRepoIdList = localRepoIdList;
|
||||
this.managedRepoIdList = managedRepoIdList;
|
||||
}
|
||||
|
||||
public void setMode( String mode )
|
||||
|
@ -20,14 +20,12 @@
|
||||
*/
|
||||
|
||||
import com.opensymphony.xwork.Preparable;
|
||||
|
||||
import org.apache.commons.collections.Closure;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||
import org.apache.maven.archiva.web.action.admin.repositories.AdminRepositoryConfiguration;
|
||||
import org.codehaus.plexus.redback.rbac.Resource;
|
||||
@ -42,11 +40,10 @@
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ProxyConnectorsAction
|
||||
* ProxyConnectorsAction
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="proxyConnectorsAction"
|
||||
*/
|
||||
public class ProxyConnectorsAction
|
||||
@ -81,16 +78,14 @@ public void prepare()
|
||||
{
|
||||
public void execute( Object input )
|
||||
{
|
||||
if ( input instanceof RepositoryConfiguration )
|
||||
{
|
||||
AdminRepositoryConfiguration arepo = (AdminRepositoryConfiguration) repoConfigToAdmin
|
||||
.transform( input );
|
||||
repoMap.put( arepo.getId(), arepo );
|
||||
}
|
||||
AdminRepositoryConfiguration arepo =
|
||||
(AdminRepositoryConfiguration) repoConfigToAdmin.transform( input );
|
||||
repoMap.put( arepo.getId(), arepo );
|
||||
}
|
||||
};
|
||||
|
||||
CollectionUtils.forAllDo( config.getRepositories(), addToRepoMap );
|
||||
CollectionUtils.forAllDo( config.getManagedRepositories(), addToRepoMap );
|
||||
CollectionUtils.forAllDo( config.getRemoteRepositories(), addToRepoMap );
|
||||
|
||||
proxyConnectorMap = new HashMap();
|
||||
|
||||
@ -109,7 +104,7 @@ public void execute( Object input )
|
||||
connectors = new ArrayList();
|
||||
proxyConnectorMap.put( key, connectors );
|
||||
}
|
||||
|
||||
|
||||
connectors.add( proxyConfig );
|
||||
}
|
||||
}
|
||||
|
@ -20,37 +20,35 @@
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.RepositoryContentStatistics;
|
||||
import org.apache.maven.archiva.model.RepositoryURL;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* AdminRepositoryConfiguration
|
||||
* AdminRepositoryConfiguration
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
* @todo! split from remote repo (which shouldn't need stats, use native class)
|
||||
*/
|
||||
public class AdminRepositoryConfiguration
|
||||
extends RepositoryConfiguration
|
||||
extends ManagedRepositoryConfiguration
|
||||
{
|
||||
private RepositoryContentStatistics stats;
|
||||
|
||||
public AdminRepositoryConfiguration()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Constructor.
|
||||
*/
|
||||
public AdminRepositoryConfiguration( RepositoryConfiguration repoconfig )
|
||||
public AdminRepositoryConfiguration( ManagedRepositoryConfiguration repoconfig )
|
||||
{
|
||||
this.setId( repoconfig.getId() );
|
||||
this.setName( repoconfig.getName() );
|
||||
this.setUrl( repoconfig.getUrl() );
|
||||
this.setLocation( repoconfig.getLocation() );
|
||||
this.setLayout( repoconfig.getLayout() );
|
||||
this.setIndexed( repoconfig.isIndexed() );
|
||||
this.setReleases( repoconfig.isReleases() );
|
||||
@ -62,44 +60,19 @@ public AdminRepositoryConfiguration( RepositoryConfiguration repoconfig )
|
||||
this.setDaysOlder( repoconfig.getDaysOlder() );
|
||||
this.setRetentionCount( repoconfig.getRetentionCount() );
|
||||
this.setDeleteReleasedSnapshots( repoconfig.isDeleteReleasedSnapshots() );
|
||||
|
||||
if ( repoconfig.isManaged() )
|
||||
{
|
||||
RepositoryURL url = new RepositoryURL( repoconfig.getUrl() );
|
||||
this.setDirectory( url.getPath() );
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: needed? used by repositories.jsp only
|
||||
public boolean isDirectoryExists()
|
||||
{
|
||||
if ( StringUtils.isBlank( getDirectory() ) )
|
||||
String directory = getLocation();
|
||||
if ( StringUtils.isBlank( directory ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
File dir = new File( getDirectory() );
|
||||
return ( dir.exists() && dir.isDirectory() );
|
||||
}
|
||||
|
||||
public String getDirectory()
|
||||
{
|
||||
if ( this.isManaged() )
|
||||
{
|
||||
if ( StringUtils.isBlank( this.getUrl() ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
RepositoryURL url = new RepositoryURL( this.getUrl() );
|
||||
return url.getPath();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDirectory( String directory )
|
||||
{
|
||||
this.setUrl( PathUtil.toUrl( directory ) );
|
||||
File dir = new File( directory );
|
||||
return dir.exists() && dir.isDirectory();
|
||||
}
|
||||
|
||||
public RepositoryContentStatistics getStats()
|
||||
|
@ -23,12 +23,11 @@
|
||||
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.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||
import org.codehaus.plexus.redback.authorization.AuthorizationException;
|
||||
import org.codehaus.plexus.redback.authorization.AuthorizationResult;
|
||||
@ -218,7 +217,9 @@ public void prepare()
|
||||
this.repository.setIndexed( false );
|
||||
}
|
||||
|
||||
RepositoryConfiguration repoconfig = archivaConfiguration.getConfiguration().findRepositoryById( id );
|
||||
// TODO! others?
|
||||
ManagedRepositoryConfiguration repoconfig =
|
||||
archivaConfiguration.getConfiguration().findManagedRepositoryById( id );
|
||||
if ( repoconfig != null )
|
||||
{
|
||||
this.repository = new AdminRepositoryConfiguration( repoconfig );
|
||||
@ -292,16 +293,18 @@ private boolean validateFields( String mode )
|
||||
containsError = true;
|
||||
}
|
||||
//if edit mode, do not validate existence of repoId
|
||||
else if ( config.findRepositoryById( repoId ) != null && !StringUtils.equalsIgnoreCase( mode, "edit" ) )
|
||||
else if ( ( config.getManagedRepositoriesAsMap().containsKey( repoId ) ||
|
||||
config.getRemoteRepositoriesAsMap().containsKey( repoId ) ) &&
|
||||
!StringUtils.equalsIgnoreCase( mode, "edit" ) )
|
||||
{
|
||||
addFieldError( "repository.id",
|
||||
"Unable to add new repository with id [" + repoId + "], that id already exists." );
|
||||
containsError = true;
|
||||
}
|
||||
|
||||
if ( StringUtils.isBlank( repository.getUrl() ) )
|
||||
// TODO! split
|
||||
if ( StringUtils.isBlank( repository.getLocation() ) )
|
||||
{
|
||||
|
||||
addFieldError( "repository.url", "You must enter a directory or url." );
|
||||
containsError = true;
|
||||
}
|
||||
@ -340,6 +343,7 @@ private void addRepository( AdminRepositoryConfiguration repository )
|
||||
getLogger().info( ".addRepository(" + repository + ")" );
|
||||
|
||||
// Fix the URL entry (could possibly be a filesystem path)
|
||||
/* TODO! reinstate
|
||||
String rawUrlEntry = repository.getUrl();
|
||||
if ( !rawUrlEntry.startsWith( "http://" ) )
|
||||
{
|
||||
@ -357,8 +361,10 @@ private void addRepository( AdminRepositoryConfiguration repository )
|
||||
// TODO: error handling when this fails, or is not a directory!
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
archivaConfiguration.getConfiguration().addRepository( repository );
|
||||
// TODO! others
|
||||
archivaConfiguration.getConfiguration().addManagedRepository( repository );
|
||||
|
||||
// TODO: double check these are configured on start up
|
||||
roleManager.createTemplatedRole( "archiva-repository-manager", repository.getId() );
|
||||
@ -390,25 +396,24 @@ private boolean operationAllowed( String permission, String repoid )
|
||||
private void removeContents( AdminRepositoryConfiguration existingRepository )
|
||||
throws IOException
|
||||
{
|
||||
if ( existingRepository.isManaged() )
|
||||
{
|
||||
getLogger().info( "Removing " + existingRepository.getDirectory() );
|
||||
FileUtils.deleteDirectory( new File( existingRepository.getDirectory() ) );
|
||||
}
|
||||
getLogger().info( "Removing " + existingRepository.getLocation() );
|
||||
FileUtils.deleteDirectory( new File( existingRepository.getLocation() ) );
|
||||
}
|
||||
|
||||
private void removeRepository( String repoId )
|
||||
{
|
||||
getLogger().info( ".removeRepository()" );
|
||||
|
||||
RepositoryConfiguration toremove = archivaConfiguration.getConfiguration().findRepositoryById( repoId );
|
||||
// TODO! what about others?
|
||||
ManagedRepositoryConfiguration toremove =
|
||||
archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
|
||||
if ( toremove != null )
|
||||
{
|
||||
archivaConfiguration.getConfiguration().removeRepository( toremove );
|
||||
archivaConfiguration.getConfiguration().removeManagedRepository( toremove );
|
||||
}
|
||||
}
|
||||
|
||||
private void removeRepositoryRoles( RepositoryConfiguration existingRepository )
|
||||
private void removeRepositoryRoles( ManagedRepositoryConfiguration existingRepository )
|
||||
throws RoleManagerException
|
||||
{
|
||||
roleManager.removeTemplatedRole( "archiva-repository-manager", existingRepository.getId() );
|
||||
|
@ -21,14 +21,10 @@
|
||||
|
||||
import com.opensymphony.webwork.interceptor.ServletRequestAware;
|
||||
import com.opensymphony.xwork.Preparable;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.commons.collections.list.TransformedList;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.functors.LocalRepositoryPredicate;
|
||||
import org.apache.maven.archiva.configuration.functors.RemoteRepositoryPredicate;
|
||||
import org.apache.maven.archiva.configuration.functors.RepositoryConfigurationComparator;
|
||||
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||
import org.apache.maven.archiva.web.util.ContextUtils;
|
||||
@ -38,18 +34,15 @@
|
||||
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
|
||||
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Shows the Repositories Tab for the administrator.
|
||||
* Shows the Repositories Tab for the administrator.
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="repositoriesAction"
|
||||
*/
|
||||
public class RepositoriesAction
|
||||
@ -93,11 +86,8 @@ public void prepare()
|
||||
{
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
|
||||
remoteRepositories = TransformedList.decorate( new ArrayList(), repoConfigToAdmin );
|
||||
managedRepositories = TransformedList.decorate( new ArrayList(), repoConfigToAdmin );
|
||||
|
||||
remoteRepositories.addAll( CollectionUtils.select( config.getRepositories(), RemoteRepositoryPredicate.getInstance() ) );
|
||||
managedRepositories.addAll( CollectionUtils.select( config.getRepositories(), LocalRepositoryPredicate.getInstance() ) );
|
||||
remoteRepositories = TransformedList.decorate( config.getRemoteRepositories(), repoConfigToAdmin );
|
||||
managedRepositories = TransformedList.decorate( config.getManagedRepositories(), repoConfigToAdmin );
|
||||
|
||||
Collections.sort( managedRepositories, new RepositoryConfigurationComparator() );
|
||||
Collections.sort( remoteRepositories, new RepositoryConfigurationComparator() );
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
import org.apache.commons.collections.Transformer;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
|
||||
import org.apache.maven.archiva.model.RepositoryContentStatistics;
|
||||
@ -28,13 +28,13 @@
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* RepositoryConfigurationAdminTransformer
|
||||
* RepositoryConfigurationAdminTransformer
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @todo check usages!
|
||||
* @plexus.component role="org.apache.commons.collections.Transformer"
|
||||
* role-hint="adminrepoconfig"
|
||||
* role-hint="adminrepoconfig"
|
||||
*/
|
||||
public class RepositoryConfigurationAdminTransformer
|
||||
implements Transformer
|
||||
@ -46,15 +46,12 @@ public class RepositoryConfigurationAdminTransformer
|
||||
|
||||
public Object transform( Object input )
|
||||
{
|
||||
if ( input instanceof RepositoryConfiguration )
|
||||
if ( input instanceof ManagedRepositoryConfiguration )
|
||||
{
|
||||
RepositoryConfiguration repoconfig = (RepositoryConfiguration) input;
|
||||
ManagedRepositoryConfiguration repoconfig = (ManagedRepositoryConfiguration) input;
|
||||
AdminRepositoryConfiguration arepo = new AdminRepositoryConfiguration( repoconfig );
|
||||
|
||||
if ( arepo.isManaged() )
|
||||
{
|
||||
arepo.setStats( getLatestStats( arepo.getId() ) );
|
||||
}
|
||||
arepo.setStats( getLatestStats( arepo.getId() ) );
|
||||
|
||||
return arepo;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
||||
@ -68,22 +67,20 @@ public void validateEnvironment( List list )
|
||||
{
|
||||
List repos = dao.getRepositoryDAO().getRepositories();
|
||||
|
||||
if ( hasManagedRepository( repos ) )
|
||||
// TODO! this be skipping non-managed repos
|
||||
Iterator it = repos.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Iterator it = repos.iterator();
|
||||
while ( it.hasNext() )
|
||||
ArchivaRepository repository = (ArchivaRepository) it.next();
|
||||
|
||||
if ( !roleManager.templatedRoleExists( "archiva-repository-manager", repository.getId() ) )
|
||||
{
|
||||
ArchivaRepository repository = (ArchivaRepository) it.next();
|
||||
roleManager.createTemplatedRole( "archiva-repository-manager", repository.getId() );
|
||||
}
|
||||
|
||||
if ( !roleManager.templatedRoleExists( "archiva-repository-manager", repository.getId() ) )
|
||||
{
|
||||
roleManager.createTemplatedRole( "archiva-repository-manager", repository.getId() );
|
||||
}
|
||||
|
||||
if ( !roleManager.templatedRoleExists( "archiva-repository-observer", repository.getId() ) )
|
||||
{
|
||||
roleManager.createTemplatedRole( "archiva-repository-observer", repository.getId() );
|
||||
}
|
||||
if ( !roleManager.templatedRoleExists( "archiva-repository-observer", repository.getId() ) )
|
||||
{
|
||||
roleManager.createTemplatedRole( "archiva-repository-observer", repository.getId() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -94,7 +91,8 @@ public void validateEnvironment( List list )
|
||||
}
|
||||
catch ( ObjectNotFoundException e )
|
||||
{
|
||||
list.add( this.getClass().getName() + "error initializing roles (repository not found): " + e.getMessage() );
|
||||
list.add(
|
||||
this.getClass().getName() + "error initializing roles (repository not found): " + e.getMessage() );
|
||||
getLogger().info( "error initializing roles", e );
|
||||
}
|
||||
catch ( ArchivaDatabaseException e )
|
||||
@ -107,18 +105,4 @@ public void validateEnvironment( List list )
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasManagedRepository( List repos )
|
||||
{
|
||||
Iterator it = repos.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ArchivaRepository repo = (ArchivaRepository) it.next();
|
||||
if ( repo.isManaged() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -22,16 +22,10 @@
|
||||
import com.opensymphony.webwork.ServletActionContext;
|
||||
import com.opensymphony.xwork.ActionInvocation;
|
||||
import com.opensymphony.xwork.interceptor.Interceptor;
|
||||
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
/**
|
||||
* An interceptor that makes the configuration bits available, both to the application and the webapp
|
||||
@ -45,41 +39,18 @@ public class ConfigurationInterceptor
|
||||
implements Interceptor
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement role-hint="jdo"
|
||||
*/
|
||||
private ArchivaDAO dao;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="default"
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
/**
|
||||
* @param actionInvocation
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public String intercept( ActionInvocation actionInvocation )
|
||||
throws Exception
|
||||
{
|
||||
// populate webapp configuration bits into the session
|
||||
HttpSession session = ServletActionContext.getRequest().getSession();
|
||||
if ( session != null )
|
||||
{
|
||||
session.setAttribute( "uiOptions", configuration.getConfiguration().getWebapp().getUi() );
|
||||
}
|
||||
|
||||
List repos = dao.getRepositoryDAO().getRepositories();
|
||||
ServletContext applicationScope = ServletActionContext.getServletContext();
|
||||
applicationScope.setAttribute( "uiOptions", configuration.getConfiguration().getWebapp().getUi() );
|
||||
|
||||
if ( !hasManagedRepository( repos ) )
|
||||
{
|
||||
getLogger().info( "No repositories exist - forwarding to repository configuration page" );
|
||||
return "config-repository-needed";
|
||||
}
|
||||
else
|
||||
{
|
||||
return actionInvocation.invoke();
|
||||
}
|
||||
return actionInvocation.invoke();
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
@ -92,28 +63,4 @@ public void init()
|
||||
// This space left intentionally blank
|
||||
}
|
||||
|
||||
public boolean hasManagedRepository( List repos )
|
||||
{
|
||||
if ( repos == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( repos.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator it = repos.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ArchivaRepository repo = (ArchivaRepository) it.next();
|
||||
if ( repo.isManaged() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaRepository;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.ProjectReference;
|
||||
@ -78,7 +78,7 @@ public class ProxiedDavServer
|
||||
|
||||
private BidirectionalRepositoryLayout layout;
|
||||
|
||||
private RepositoryConfiguration repositoryConfiguration;
|
||||
private ManagedRepositoryConfiguration repositoryConfiguration;
|
||||
|
||||
private ArchivaRepository managedRepository;
|
||||
|
||||
@ -109,7 +109,7 @@ public void init( ServletConfig servletConfig )
|
||||
|
||||
Configuration config = archivaConfiguration.getConfiguration();
|
||||
|
||||
repositoryConfiguration = config.findRepositoryById( getPrefix() );
|
||||
repositoryConfiguration = config.findManagedRepositoryById( getPrefix() );
|
||||
|
||||
managedRepository = ArchivaConfigurationAdaptor.toArchivaRepository( repositoryConfiguration );
|
||||
|
||||
@ -214,7 +214,6 @@ private void fetchContentFromProxies( DavServerRequest request )
|
||||
{
|
||||
connectors.fetchFromProxies( managedRepository, project );
|
||||
request.getRequest().setPathInfo( layout.toPath( project ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
@ -228,7 +227,7 @@ private void fetchContentFromProxies( DavServerRequest request )
|
||||
}
|
||||
}
|
||||
|
||||
public RepositoryConfiguration getRepositoryConfiguration()
|
||||
public ManagedRepositoryConfiguration getRepositoryConfiguration()
|
||||
{
|
||||
return repositoryConfiguration;
|
||||
}
|
||||
|
@ -19,15 +19,9 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.collections.Closure;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.functors.IfClosure;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.functors.LocalRepositoryPredicate;
|
||||
import org.apache.maven.archiva.configuration.functors.RepositoryConfigurationToMapClosure;
|
||||
import org.apache.maven.archiva.model.RepositoryURL;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||
import org.codehaus.plexus.redback.authentication.AuthenticationException;
|
||||
import org.codehaus.plexus.redback.authentication.AuthenticationResult;
|
||||
@ -46,6 +40,10 @@
|
||||
import org.codehaus.plexus.webdav.servlet.multiplexed.MultiplexedWebDavServlet;
|
||||
import org.codehaus.plexus.webdav.util.WebdavMethodUtil;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@ -53,11 +51,6 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* RepositoryServlet
|
||||
*
|
||||
@ -88,7 +81,8 @@ public class RepositoryServlet
|
||||
*/
|
||||
private ArchivaConfiguration configuration;
|
||||
|
||||
private Map repositoryMap = new HashMap();
|
||||
private Map<String, ManagedRepositoryConfiguration> repositoryMap =
|
||||
new HashMap<String, ManagedRepositoryConfiguration>();
|
||||
|
||||
public void initComponents()
|
||||
throws ServletException
|
||||
@ -108,26 +102,20 @@ public void initComponents()
|
||||
public void initServers( ServletConfig servletConfig )
|
||||
throws DavServerException
|
||||
{
|
||||
List repositories = configuration.getConfiguration().getRepositories();
|
||||
List repositories = configuration.getConfiguration().getManagedRepositories();
|
||||
Iterator itrepos = repositories.iterator();
|
||||
while ( itrepos.hasNext() )
|
||||
{
|
||||
RepositoryConfiguration repo = (RepositoryConfiguration) itrepos.next();
|
||||
if ( !repo.isManaged() )
|
||||
{
|
||||
// Skip non-managed.
|
||||
continue;
|
||||
}
|
||||
ManagedRepositoryConfiguration repo = (ManagedRepositoryConfiguration) itrepos.next();
|
||||
|
||||
RepositoryURL url = new RepositoryURL( repo.getUrl() );
|
||||
File repoDir = new File( url.getPath() );
|
||||
File repoDir = new File( repo.getLocation() );
|
||||
|
||||
if ( !repoDir.exists() )
|
||||
{
|
||||
if ( !repoDir.mkdirs() )
|
||||
{
|
||||
// Skip invalid directories.
|
||||
log( "Unable to create missing directory for " + url.getPath() );
|
||||
log( "Unable to create missing directory for " + repo.getLocation() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -138,17 +126,18 @@ public void initServers( ServletConfig servletConfig )
|
||||
}
|
||||
}
|
||||
|
||||
public RepositoryConfiguration getRepository( DavServerRequest request )
|
||||
public ManagedRepositoryConfiguration getRepository( DavServerRequest request )
|
||||
{
|
||||
// TODO: use sync wrapper instead?
|
||||
synchronized ( this.repositoryMap )
|
||||
{
|
||||
return (RepositoryConfiguration) repositoryMap.get( request.getPrefix() );
|
||||
return repositoryMap.get( request.getPrefix() );
|
||||
}
|
||||
}
|
||||
|
||||
public String getRepositoryName( DavServerRequest request )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = getRepository( request );
|
||||
ManagedRepositoryConfiguration repoConfig = getRepository( request );
|
||||
if ( repoConfig == null )
|
||||
{
|
||||
return "Unknown";
|
||||
@ -159,14 +148,10 @@ public String getRepositoryName( DavServerRequest request )
|
||||
|
||||
private void updateRepositoryMap()
|
||||
{
|
||||
RepositoryConfigurationToMapClosure repoMapClosure = new RepositoryConfigurationToMapClosure();
|
||||
Closure localRepoMap = IfClosure.getInstance( LocalRepositoryPredicate.getInstance(), repoMapClosure );
|
||||
CollectionUtils.forAllDo( configuration.getConfiguration().getRepositories(), localRepoMap );
|
||||
|
||||
synchronized ( this.repositoryMap )
|
||||
{
|
||||
this.repositoryMap.clear();
|
||||
this.repositoryMap.putAll( repoMapClosure.getMap() );
|
||||
this.repositoryMap.putAll( configuration.getConfiguration().getManagedRepositoriesAsMap() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +165,7 @@ public boolean isAuthenticated( DavServerRequest davRequest, HttpServletResponse
|
||||
{
|
||||
AuthenticationResult result = httpAuth.getAuthenticationResult( request, response );
|
||||
|
||||
if ( ( result != null ) && !result.isAuthenticated() )
|
||||
if ( result != null && !result.isAuthenticated() )
|
||||
{
|
||||
// Must Authenticate.
|
||||
httpAuth.challenge( request, response, "Repository " + getRepositoryName( davRequest ),
|
||||
@ -232,9 +217,9 @@ public boolean isAuthorized( DavServerRequest davRequest, HttpServletResponse re
|
||||
{
|
||||
if ( authzResult.getException() != null )
|
||||
{
|
||||
log( "Authorization Denied [ip=" + request.getRemoteAddr() + ",isWriteRequest=" + isWriteRequest
|
||||
+ ",permission=" + permission + ",repo=" + davRequest.getPrefix() + "] : "
|
||||
+ authzResult.getException().getMessage() );
|
||||
log( "Authorization Denied [ip=" + request.getRemoteAddr() + ",isWriteRequest=" + isWriteRequest +
|
||||
",permission=" + permission + ",repo=" + davRequest.getPrefix() + "] : " +
|
||||
authzResult.getException().getMessage() );
|
||||
}
|
||||
|
||||
// Issue HTTP Challenge.
|
||||
@ -258,7 +243,7 @@ public void beforeConfigurationChange( Registry registry, String propertyName, O
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isRepositories( propertyName ) )
|
||||
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
|
||||
{
|
||||
// Attempt to reduce the number of times we refresh the repository map.
|
||||
if ( propertyName.endsWith( ".id" ) || propertyName.endsWith( ".url" ) )
|
||||
@ -275,8 +260,8 @@ public void afterConfigurationChange( Registry registry, String propertyName, Ob
|
||||
}
|
||||
catch ( DavServerException e )
|
||||
{
|
||||
log( "Error restarting WebDAV server after configuration change - service disabled: "
|
||||
+ e.getMessage(), e );
|
||||
log( "Error restarting WebDAV server after configuration change - service disabled: " +
|
||||
e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,10 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.archiva.common.utils.PathUtil;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
||||
@ -39,14 +40,12 @@
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ConfigurationSynchronization
|
||||
* ConfigurationSynchronization
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component
|
||||
* role="org.apache.maven.archiva.web.startup.ConfigurationSynchronization"
|
||||
* role-hint="default"
|
||||
* @plexus.component role="org.apache.maven.archiva.web.startup.ConfigurationSynchronization"
|
||||
* role-hint="default"
|
||||
*/
|
||||
public class ConfigurationSynchronization
|
||||
extends AbstractLogEnabled
|
||||
@ -69,9 +68,10 @@ public class ConfigurationSynchronization
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isRepositories( propertyName ) )
|
||||
// TODO! this used to store both types, but do we even need it?
|
||||
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
|
||||
{
|
||||
synchConfiguration();
|
||||
synchConfiguration( archivaConfiguration.getConfiguration().getManagedRepositories() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,13 +80,12 @@ public void beforeConfigurationChange( Registry registry, String propertyName, O
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
private void synchConfiguration()
|
||||
private void synchConfiguration( List repos )
|
||||
{
|
||||
List repos = archivaConfiguration.getConfiguration().getRepositories();
|
||||
Iterator it = repos.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
RepositoryConfiguration repoConfig = (RepositoryConfiguration) it.next();
|
||||
ManagedRepositoryConfiguration repoConfig = (ManagedRepositoryConfiguration) it.next();
|
||||
try
|
||||
{
|
||||
try
|
||||
@ -95,7 +94,7 @@ private void synchConfiguration()
|
||||
// Found repository. Update it.
|
||||
|
||||
repository.getModel().setName( repoConfig.getName() );
|
||||
repository.getModel().setUrl( repoConfig.getUrl() );
|
||||
repository.getModel().setUrl( PathUtil.toUrl( repoConfig.getLocation() ) );
|
||||
repository.getModel().setLayoutName( repoConfig.getLayout() );
|
||||
repository.getModel().setCreationSource( "configuration" );
|
||||
repository.getModel().setReleasePolicy( repoConfig.isReleases() );
|
||||
@ -143,7 +142,7 @@ private void synchConfiguration()
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
synchConfiguration();
|
||||
synchConfiguration( archivaConfiguration.getConfiguration().getManagedRepositories() );
|
||||
archivaConfiguration.addChangeListener( this );
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,39 @@
|
||||
package org.apache.maven.archiva.web.tags;
|
||||
|
||||
/*
|
||||
* 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.lang.StringEscapeUtils;
|
||||
import org.apache.maven.archiva.configuration.RepositoryConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.web.util.ContextUtils;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* CopyPasteSnippet
|
||||
* CopyPasteSnippet
|
||||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component role="org.apache.maven.archiva.web.tags.CopyPasteSnippet"
|
||||
*/
|
||||
public class CopyPasteSnippet
|
||||
@ -32,9 +49,9 @@ public void write( Object o, PageContext pageContext )
|
||||
buf.append( "Error generating snippet." );
|
||||
getLogger().error( "Unable to generate snippet for null object." );
|
||||
}
|
||||
else if ( o instanceof RepositoryConfiguration )
|
||||
else if ( o instanceof ManagedRepositoryConfiguration )
|
||||
{
|
||||
createSnippet( buf, (RepositoryConfiguration) o, pageContext );
|
||||
createSnippet( buf, (ManagedRepositoryConfiguration) o, pageContext );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -53,7 +70,7 @@ else if ( o instanceof RepositoryConfiguration )
|
||||
}
|
||||
}
|
||||
|
||||
private void createSnippet( StringBuffer snippet, RepositoryConfiguration repo, PageContext pageContext )
|
||||
private void createSnippet( StringBuffer snippet, ManagedRepositoryConfiguration repo, PageContext pageContext )
|
||||
{
|
||||
snippet.append( "<project>\n" );
|
||||
snippet.append( " ...\n" );
|
||||
@ -83,15 +100,8 @@ private void createSnippet( StringBuffer snippet, RepositoryConfiguration repo,
|
||||
snippet.append( " <name>" ).append( repo.getName() ).append( "</name>\n" );
|
||||
|
||||
snippet.append( " <url>" );
|
||||
if ( repo.isManaged() )
|
||||
{
|
||||
snippet.append( ContextUtils.getBaseURL( pageContext, "repository" ) );
|
||||
snippet.append( "/" ).append( repo.getId() ).append( "/" );
|
||||
}
|
||||
else
|
||||
{
|
||||
snippet.append( repo.getUrl() );
|
||||
}
|
||||
snippet.append( ContextUtils.getBaseURL( pageContext, "repository" ) );
|
||||
snippet.append( "/" ).append( repo.getId() ).append( "/" );
|
||||
|
||||
snippet.append( "</url>\n" );
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
<package name="base" extends="webwork-default">
|
||||
<interceptors>
|
||||
<!-- TODO! eh? -->
|
||||
<interceptor name="strange" class="webwork-is-doing-strange-things"/>
|
||||
<interceptor name="configuration" class="configurationInterceptor"/>
|
||||
<interceptor name="redbackForceAdminUser" class="redbackForceAdminUserInterceptor"/>
|
||||
@ -91,13 +92,6 @@
|
||||
<param name="actionName">repositories</param>
|
||||
</result>
|
||||
|
||||
<!-- This redirect is triggered by the configuration interceptor -->
|
||||
<result name="config-repository-needed" type="redirect-action">
|
||||
<param name="namespace">/admin</param>
|
||||
<param name="actionName">addRepository</param>
|
||||
<param name="method">input</param>
|
||||
</result>
|
||||
|
||||
<!-- The following security-* result names arrive from the plexus-security package -->
|
||||
<result name="security-login-success" type="redirect-action">index</result>
|
||||
<result name="security-login-cancel" type="redirect-action">index</result>
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<%@ taglib prefix="ww" uri="/webwork" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %>
|
||||
<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %>
|
||||
<%@ taglib prefix="archiva" uri="http://maven.apache.org/archiva" %>
|
||||
|
||||
<html>
|
||||
@ -34,197 +34,202 @@
|
||||
|
||||
<div id="contentArea">
|
||||
|
||||
<ww:actionerror />
|
||||
<ww:actionmessage />
|
||||
<ww:actionerror/>
|
||||
<ww:actionmessage/>
|
||||
|
||||
<div class="admin">
|
||||
<div class="controls">
|
||||
<redback:ifAuthorized permission="archiva-manage-configuration">
|
||||
<ww:url id="addRepositoryUrl" action="addRepository"/>
|
||||
<ww:a href="%{addRepositoryUrl}">
|
||||
<img src="<c:url value="/images/icons/create.png" />" />
|
||||
Add Repository</ww:a>
|
||||
</redback:ifAuthorized>
|
||||
</div>
|
||||
<h2>Managed Repositories</h2>
|
||||
<div class="controls">
|
||||
<redback:ifAuthorized permission="archiva-manage-configuration">
|
||||
<ww:url id="addRepositoryUrl" action="addRepository"/>
|
||||
<ww:a href="%{addRepositoryUrl}">
|
||||
<img src="<c:url value="/images/icons/create.png" />"/>
|
||||
Add Repository
|
||||
</ww:a>
|
||||
</redback:ifAuthorized>
|
||||
</div>
|
||||
<h2>Managed Repositories</h2>
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${empty(managedRepositories)}">
|
||||
<%-- No Managed Repositories. --%>
|
||||
<strong>There are no managed repositories configured yet.</strong>
|
||||
<c:when test="${empty(managedRepositories)}">
|
||||
<%-- No Managed Repositories. --%>
|
||||
<strong>There are no managed repositories configured yet.</strong>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<%-- Display the repositories. --%>
|
||||
|
||||
<c:forEach items="${managedRepositories}" var="repository" varStatus="i">
|
||||
<c:choose>
|
||||
<c:when test='${(i.index)%2 eq 0}'>
|
||||
<c:set var="rowColor" value="dark" scope="page"/>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<%-- Display the repositories. --%>
|
||||
|
||||
<c:forEach items="${managedRepositories}" var="repository" varStatus="i">
|
||||
<c:choose>
|
||||
<c:when test='${(i.index)%2 eq 0}'>
|
||||
<c:set var="rowColor" value="dark" scope="page" />
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<c:set var="rowColor" value="lite" scope="page" />
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
<div class="repository ${rowColor}">
|
||||
|
||||
<div class="controls">
|
||||
<%-- TODO: make some icons --%>
|
||||
<redback:ifAnyAuthorized permissions="archiva-manage-configuration">
|
||||
<ww:url id="editRepositoryUrl" action="editRepository">
|
||||
<ww:param name="repoid" value="%{'${repository.id}'}" />
|
||||
</ww:url>
|
||||
<ww:url id="deleteRepositoryUrl" action="deleteRepository" method="confirm">
|
||||
<ww:param name="repoid" value="%{'${repository.id}'}" />
|
||||
</ww:url>
|
||||
<ww:a href="%{editRepositoryUrl}">
|
||||
<img src="<c:url value="/images/icons/edit.png" />" />
|
||||
Edit Repository</ww:a>
|
||||
<ww:a href="%{deleteRepositoryUrl}">
|
||||
<img src="<c:url value="/images/icons/delete.gif" />" />
|
||||
Delete Repository</ww:a>
|
||||
</redback:ifAnyAuthorized>
|
||||
</div>
|
||||
|
||||
<div style="float: left">
|
||||
<img src="<c:url value="/images/archiva-splat-32.gif"/>" />
|
||||
</div>
|
||||
|
||||
<h3 class="repository">${repository.name}</h3>
|
||||
|
||||
<table class="infoTable">
|
||||
<tr>
|
||||
<th>Identifier</th>
|
||||
<td>
|
||||
<code>${repository.id}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>
|
||||
<code>${repository.name}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Directory</th>
|
||||
<td>${repository.directory}
|
||||
<c:if test="${not(repository.directoryExists)}">
|
||||
<span class="missing">Directory Does Not Exist</span>
|
||||
</c:if>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>WebDAV URL</th>
|
||||
<td><a href="${baseUrl}/${repository.id}/">${baseUrl}/${repository.id}/</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${repository.layout == 'default'}">
|
||||
Maven 2.x Repository
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
Maven 1.x Repository
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Repository Purge By Days Older Than</th>
|
||||
<td>${repository.daysOlder}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Repository Purge By Retention Count</th>
|
||||
<td>${repository.retentionCount}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Releases Included</th>
|
||||
<td class="${repository.releases ? 'donemark' : 'errormark'} booleanIcon"> ${repository.releases}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Snapshots Included</th>
|
||||
<td class="${repository.snapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.snapshots}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Scanned</th>
|
||||
<td class="${repository.indexed ? 'donemark' : 'errormark'} booleanIcon"> ${repository.indexed}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Delete Released Snapshots</th>
|
||||
<td class="${repository.deleteReleasedSnapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.deleteReleasedSnapshots}</td>
|
||||
</tr>
|
||||
<c:if test="${repository.indexed}">
|
||||
<tr>
|
||||
<th>Scanning Cron</th>
|
||||
<td>${repository.refreshCronExpression}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Actions
|
||||
</th>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<redback:ifAuthorized permission="archiva-run-indexer">
|
||||
<ww:form action="indexRepository" theme="simple">
|
||||
<ww:hidden name="repoid" value="%{'${repository.id}'}"/>
|
||||
<ww:submit value="Scan Repository Now"/>
|
||||
</ww:form>
|
||||
</redback:ifAuthorized>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Stats</th>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${empty(repository.stats)}">
|
||||
No Statistics Available.
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Last Scanned</th>
|
||||
<td>${repository.stats.whenGathered}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Duration</th>
|
||||
<td>${repository.stats.duration} ms</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total File Count</th>
|
||||
<td>${repository.stats.totalFileCount}
|
||||
</tr>
|
||||
<tr>
|
||||
<th>New Files Found</th>
|
||||
<td>${repository.stats.newFileCount}
|
||||
</tr>
|
||||
</table>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
<tr>
|
||||
<th>POM Snippet</th>
|
||||
<td><a href="#" onclick="Effect.toggle('repoPom${repository.id}','slide'); return false;">Show POM Snippet</a><br/>
|
||||
<pre class="pom" style="display: none;" id="repoPom${repository.id}"><code><archiva:copy-paste-snippet object="${repository}" /></code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</c:forEach>
|
||||
|
||||
<c:set var="rowColor" value="lite" scope="page"/>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
<h2>Remote Repositories</h2>
|
||||
<div class="repository ${rowColor}">
|
||||
|
||||
<div class="controls">
|
||||
<%-- TODO: make some icons --%>
|
||||
<redback:ifAnyAuthorized permissions="archiva-manage-configuration">
|
||||
<ww:url id="editRepositoryUrl" action="editRepository">
|
||||
<ww:param name="repoid" value="%{'${repository.id}'}"/>
|
||||
</ww:url>
|
||||
<ww:url id="deleteRepositoryUrl" action="deleteRepository" method="confirm">
|
||||
<ww:param name="repoid" value="%{'${repository.id}'}"/>
|
||||
</ww:url>
|
||||
<ww:a href="%{editRepositoryUrl}">
|
||||
<img src="<c:url value="/images/icons/edit.png" />"/>
|
||||
Edit Repository
|
||||
</ww:a>
|
||||
<ww:a href="%{deleteRepositoryUrl}">
|
||||
<img src="<c:url value="/images/icons/delete.gif" />"/>
|
||||
Delete Repository
|
||||
</ww:a>
|
||||
</redback:ifAnyAuthorized>
|
||||
</div>
|
||||
|
||||
<div style="float: left">
|
||||
<img src="<c:url value="/images/archiva-splat-32.gif"/>"/>
|
||||
</div>
|
||||
|
||||
<h3 class="repository">${repository.name}</h3>
|
||||
|
||||
<table class="infoTable">
|
||||
<tr>
|
||||
<th>Identifier</th>
|
||||
<td>
|
||||
<code>${repository.id}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>
|
||||
<code>${repository.name}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Directory</th>
|
||||
<td>${repository.location}
|
||||
<c:if test="${not(repository.directoryExists)}">
|
||||
<span class="missing">Directory Does Not Exist</span>
|
||||
</c:if>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>WebDAV URL</th>
|
||||
<td><a href="${baseUrl}/${repository.id}/">${baseUrl}/${repository.id}/</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${repository.layout == 'default'}">
|
||||
Maven 2.x Repository
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
Maven 1.x Repository
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Repository Purge By Days Older Than</th>
|
||||
<td>${repository.daysOlder}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Repository Purge By Retention Count</th>
|
||||
<td>${repository.retentionCount}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Releases Included</th>
|
||||
<td class="${repository.releases ? 'donemark' : 'errormark'} booleanIcon"> ${repository.releases}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Snapshots Included</th>
|
||||
<td class="${repository.snapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.snapshots}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Scanned</th>
|
||||
<td class="${repository.indexed ? 'donemark' : 'errormark'} booleanIcon"> ${repository.indexed}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Delete Released Snapshots</th>
|
||||
<td class="${repository.deleteReleasedSnapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.deleteReleasedSnapshots}</td>
|
||||
</tr>
|
||||
<c:if test="${repository.indexed}">
|
||||
<tr>
|
||||
<th>Scanning Cron</th>
|
||||
<td>${repository.refreshCronExpression}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Actions
|
||||
</th>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<redback:ifAuthorized permission="archiva-run-indexer">
|
||||
<ww:form action="indexRepository" theme="simple">
|
||||
<ww:hidden name="repoid" value="%{'${repository.id}'}"/>
|
||||
<ww:submit value="Scan Repository Now"/>
|
||||
</ww:form>
|
||||
</redback:ifAuthorized>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Stats</th>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${empty(repository.stats)}">
|
||||
No Statistics Available.
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Last Scanned</th>
|
||||
<td>${repository.stats.whenGathered}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Duration</th>
|
||||
<td>${repository.stats.duration} ms</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total File Count</th>
|
||||
<td>${repository.stats.totalFileCount}
|
||||
</tr>
|
||||
<tr>
|
||||
<th>New Files Found</th>
|
||||
<td>${repository.stats.newFileCount}
|
||||
</tr>
|
||||
</table>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
</c:if>
|
||||
<tr>
|
||||
<th>POM Snippet</th>
|
||||
<td><a href="#" onclick="Effect.toggle('repoPom${repository.id}','slide'); return false;">Show POM Snippet</a><br/>
|
||||
<pre class="pom" style="display: none;" id="repoPom${repository.id}"><code>
|
||||
<archiva:copy-paste-snippet object="${repository}"/>
|
||||
</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</c:forEach>
|
||||
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
<h2>Remote Repositories</h2>
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${empty(remoteRepositories)}">
|
||||
@ -233,43 +238,45 @@
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<%-- Display the repositories. --%>
|
||||
|
||||
|
||||
<c:forEach items="${remoteRepositories}" var="repository" varStatus="i">
|
||||
<c:choose>
|
||||
<c:when test='${(i.index)%2 eq 0}'>
|
||||
<c:set var="rowColor" value="dark" scope="page" />
|
||||
<c:set var="rowColor" value="dark" scope="page"/>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<c:set var="rowColor" value="lite" scope="page" />
|
||||
<c:set var="rowColor" value="lite" scope="page"/>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
|
||||
<div class="repository ${rowColor}">
|
||||
|
||||
<div class="controls">
|
||||
<%-- TODO: make some icons --%>
|
||||
<%-- TODO: make some icons --%>
|
||||
<redback:ifAnyAuthorized permissions="archiva-manage-configuration">
|
||||
<ww:url id="editRepositoryUrl" action="editRepository">
|
||||
<ww:param name="repoid" value="%{'${repository.id}'}" />
|
||||
<ww:param name="repoid" value="%{'${repository.id}'}"/>
|
||||
</ww:url>
|
||||
<ww:url id="deleteRepositoryUrl" action="deleteRepository" method="confirm">
|
||||
<ww:param name="repoid" value="%{'${repository.id}'}" />
|
||||
<ww:param name="repoid" value="%{'${repository.id}'}"/>
|
||||
</ww:url>
|
||||
<ww:a href="%{editRepositoryUrl}">
|
||||
<img src="<c:url value="/images/icons/edit.png" />" />
|
||||
Edit Repository</ww:a>
|
||||
<img src="<c:url value="/images/icons/edit.png" />"/>
|
||||
Edit Repository
|
||||
</ww:a>
|
||||
<ww:a href="%{deleteRepositoryUrl}">
|
||||
<img src="<c:url value="/images/icons/delete.gif" />" />
|
||||
Delete Repository</ww:a>
|
||||
<img src="<c:url value="/images/icons/delete.gif" />"/>
|
||||
Delete Repository
|
||||
</ww:a>
|
||||
</redback:ifAnyAuthorized>
|
||||
</div>
|
||||
|
||||
|
||||
<div style="float: left">
|
||||
<img src="<c:url value="/images/archiva-world.png"/>" />
|
||||
<img src="<c:url value="/images/archiva-world.png"/>"/>
|
||||
</div>
|
||||
|
||||
|
||||
<h3 class="repository">${repository.name}</h3>
|
||||
|
||||
|
||||
<table class="infoTable">
|
||||
<tr>
|
||||
<th>Identifier</th>
|
||||
@ -310,7 +317,7 @@
|
||||
<td class="${repository.snapshots ? 'donemark' : 'errormark'} booleanIcon"> ${repository.snapshots}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</c:forEach>
|
||||
</c:otherwise>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<%@ taglib uri="/webwork" prefix="ww" %>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %>
|
||||
<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %>
|
||||
<%@ page import="java.util.Calendar" %>
|
||||
<html>
|
||||
<head>
|
||||
@ -36,7 +36,7 @@
|
||||
<link rel="stylesheet" href="<c:url value="/css/redback/table.css"/>" type="text/css" media="all"/>
|
||||
<link rel="stylesheet" href="<c:url value="/css/site.css"/>" type="text/css" media="all"/>
|
||||
<link rel="stylesheet" href="<c:url value="/css/print.css"/>" type="text/css" media="print"/>
|
||||
<link rel="shortcut icon" href="<c:url value="/favicon.ico" />" />
|
||||
<link rel="shortcut icon" href="<c:url value="/favicon.ico" />"/>
|
||||
<script type="text/javascript" src="<c:url value="/js/scriptaculous/prototype.js"/>"></script>
|
||||
<script type="text/javascript" src="<c:url value="/js/scriptaculous/scriptaculous.js"/>"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
|
||||
@ -83,8 +83,8 @@
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="index" namespace="/">Search</my:currentWWUrl>
|
||||
</li>
|
||||
|
||||
<ww:if test="${sessionScope.uiOptions.showFindArtifacts}">
|
||||
|
||||
<ww:if test="${applicationScope.uiOptions.showFindArtifacts}">
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="findArtifact" namespace="/">Find Artifact</my:currentWWUrl>
|
||||
</li>
|
||||
@ -118,7 +118,7 @@
|
||||
<my:currentWWUrl action="configureAppearance" namespace="/admin">Appearance</my:currentWWUrl>
|
||||
</li>
|
||||
</redback:ifAuthorized>
|
||||
<%-- TODO: future options here.
|
||||
<%-- TODO: future options here.
|
||||
* Repository Statistics.
|
||||
* Web Services Statistics.
|
||||
--%>
|
||||
@ -128,21 +128,21 @@
|
||||
<redback:ifAuthorized permission="archiva-manage-configuration">
|
||||
<h5>Administration</h5>
|
||||
<ul>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="repositories" namespace="/admin">Repositories</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="proxyConnectors" namespace="/admin">Proxy Connectors</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="networkProxies" namespace="/admin">Network Proxies</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="repositoryScanning" namespace="/admin">Repository Scanning</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="database" namespace="/admin">Database</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="repositories" namespace="/admin">Repositories</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="proxyConnectors" namespace="/admin">Proxy Connectors</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="networkProxies" namespace="/admin">Network Proxies</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="repositoryScanning" namespace="/admin">Repository Scanning</my:currentWWUrl>
|
||||
</li>
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="database" namespace="/admin">Database</my:currentWWUrl>
|
||||
</li>
|
||||
<%-- TODO: future options here.
|
||||
* Repository Syncing Connectors. (rsync, ftp, scp, etc...)
|
||||
* Web Services (enable / disable), role based?
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
<div id="contentArea">
|
||||
<div id="searchBox">
|
||||
<ww:if test="${sessionScope.uiOptions.appletFindEnabled}">
|
||||
<ww:if test="${applicationScope.uiOptions.appletFindEnabled}">
|
||||
<script type="text/javascript">
|
||||
function generateMd5( file, defVal )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user