mirror of https://github.com/apache/archiva.git
Multicatch and override
This commit is contained in:
parent
4444ed0e1d
commit
d44d957734
|
@ -87,7 +87,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -136,7 +135,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
|
||||
private Map<String, List<ProxyConnector>> proxyConnectorMap = new HashMap<>();
|
||||
|
||||
private Map<String, ProxyInfo> networkProxyMap = new ConcurrentHashMap<String, ProxyInfo>();
|
||||
private Map<String, ProxyInfo> networkProxyMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Inject
|
||||
private WagonFactory wagonFactory;
|
||||
|
@ -302,6 +301,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
return proxyConnectorRuleConfigurations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File fetchFromProxies( ManagedRepositoryContent repository, ArtifactReference artifact )
|
||||
throws ProxyDownloadException
|
||||
{
|
||||
|
@ -313,7 +313,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
requestProperties.setProperty( "managedRepositoryId", repository.getId() );
|
||||
|
||||
List<ProxyConnector> connectors = getProxyConnectors( repository );
|
||||
Map<String, Exception> previousExceptions = new LinkedHashMap<String, Exception>();
|
||||
Map<String, Exception> previousExceptions = new LinkedHashMap<>();
|
||||
for ( ProxyConnector connector : connectors )
|
||||
{
|
||||
if ( connector.isDisabled() )
|
||||
|
@ -354,12 +354,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
log.debug( "Artifact {} not updated on repository \"{}\".", Keys.toKey( artifact ),
|
||||
targetRepository.getRepository().getId() );
|
||||
}
|
||||
catch ( ProxyException e )
|
||||
{
|
||||
validatePolicies( this.downloadErrorPolicies, connector.getPolicies(), requestProperties, artifact,
|
||||
targetRepository, localFile, e, previousExceptions );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
catch ( ProxyException | RepositoryAdminException e )
|
||||
{
|
||||
validatePolicies( this.downloadErrorPolicies, connector.getPolicies(), requestProperties, artifact,
|
||||
targetRepository, localFile, e, previousExceptions );
|
||||
|
@ -377,6 +372,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File fetchFromProxies( ManagedRepositoryContent repository, String path )
|
||||
{
|
||||
File localFile = new File( repository.getRepoRoot(), path );
|
||||
|
@ -450,6 +446,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File fetchMetatadaFromProxies( ManagedRepositoryContent repository, String logicalPath )
|
||||
{
|
||||
File localFile = new File( repository.getRepoRoot(), logicalPath );
|
||||
|
@ -496,14 +493,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
targetRepository.getRepository().getId(), e );
|
||||
|
||||
}
|
||||
catch ( ProxyException e )
|
||||
{
|
||||
log.warn(
|
||||
"Transfer error from repository {} for versioned Metadata {}, continuing to next repository. Error message: {}",
|
||||
targetRepository.getRepository().getId(), logicalPath, e.getMessage() );
|
||||
log.debug( "Full stack trace", e );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
catch ( ProxyException | RepositoryAdminException e )
|
||||
{
|
||||
log.warn(
|
||||
"Transfer error from repository {} for versioned Metadata {}, continuing to next repository. Error message: {}",
|
||||
|
@ -550,6 +540,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
* @param repository
|
||||
* @throws ProxyException
|
||||
* @throws NotModifiedException
|
||||
* @throws org.apache.archiva.admin.model.RepositoryAdminException
|
||||
*/
|
||||
protected void transferResources( ProxyConnector connector, RemoteRepositoryContent remoteRepository, File tmpMd5,
|
||||
File tmpSha1, File tmpResource, String url, String remotePath, File resource,
|
||||
|
@ -669,6 +660,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
/**
|
||||
* Test if the provided ManagedRepositoryContent has any proxies configured for it.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasProxies( ManagedRepositoryContent repository )
|
||||
{
|
||||
synchronized ( this.proxyConnectorMap )
|
||||
|
@ -700,12 +692,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( !file.isFile() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return file.isFile();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1204,12 +1191,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
wagon.connect( wagonRepository, authInfo, networkProxy );
|
||||
connected = true;
|
||||
}
|
||||
catch ( ConnectionException e )
|
||||
{
|
||||
log.warn( "Could not connect to {}: {}", remoteRepository.getRepository().getName(), e.getMessage() );
|
||||
connected = false;
|
||||
}
|
||||
catch ( AuthenticationException e )
|
||||
catch ( ConnectionException | AuthenticationException e )
|
||||
{
|
||||
log.warn( "Could not connect to {}: {}", remoteRepository.getRepository().getName(), e.getMessage() );
|
||||
connected = false;
|
||||
|
@ -1256,6 +1238,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
/**
|
||||
* TODO: Ensure that list is correctly ordered based on configuration. See MRM-477
|
||||
*/
|
||||
@Override
|
||||
public List<ProxyConnector> getProxyConnectors( ManagedRepositoryContent repository )
|
||||
{
|
||||
synchronized ( this.proxyConnectorMap )
|
||||
|
@ -1271,6 +1254,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isNetworkProxy( propertyName ) || ConfigurationNames.isManagedRepositories(
|
||||
|
@ -1304,6 +1288,7 @@ public class DefaultRepositoryProxyConnectors
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
/* do nothing */
|
||||
|
|
|
@ -38,6 +38,7 @@ public class ProxyConnectorOrderComparator
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare( ProxyConnector o1, ProxyConnector o2 )
|
||||
{
|
||||
if ( o1 == null && o2 == null )
|
||||
|
|
|
@ -30,22 +30,26 @@ import org.springframework.stereotype.Service;
|
|||
public class MockRepositoryArchivaTaskScheduler
|
||||
implements RepositoryArchivaTaskScheduler
|
||||
{
|
||||
@Override
|
||||
public boolean isProcessingRepositoryTask( String repositoryId )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProcessingRepositoryTask( RepositoryTask task )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queueTask( RepositoryTask task )
|
||||
throws TaskQueueException
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unQueueTask( RepositoryTask task )
|
||||
throws TaskQueueException
|
||||
{
|
||||
|
|
|
@ -37,157 +37,187 @@ import java.util.List;
|
|||
public class TestMetadataRepository
|
||||
implements MetadataRepository
|
||||
{
|
||||
@Override
|
||||
public ProjectMetadata getProject( String repoId, String namespace, String projectId )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
|
||||
String projectVersion )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
|
||||
String projectVersion )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
|
||||
String projectVersion )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getRootNamespaces( String repoId )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getNamespaces( String repoId, String namespace )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getProjects( String repoId, String namespace )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProject( String repoId, ProjectMetadata project )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
|
||||
ArtifactMetadata artifactMeta )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProjectVersion( String repoId, String namespace, String projectId,
|
||||
ProjectVersionMetadata versionMetadata )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNamespace( String repoId, String namespace )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMetadataFacets( String repodId, String facetId )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadataFacets( String repositoryId, String facetId )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadataFacet( String repoId, String facetId, String name )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getRepositories()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtifactMetadata> getArtifactsByChecksum( String repoId, String checksum )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRepository( String repoId )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
|
||||
String projectVersion )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revert()
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canObtainAccess( Class<?> aClass )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T>T obtainAccess( Class<T> aClass )
|
||||
{
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtifactMetadata> getArtifacts( String repositoryId )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeArtifact( String repositoryId, String namespace, String project, String version,
|
||||
MetadataFacet metadataFacet )
|
||||
throws MetadataRepositoryException
|
||||
|
@ -195,30 +225,35 @@ public class TestMetadataRepository
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNamespace( String repositoryId, String namespace )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeProject( String repositoryId, String namespace, String projectId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadataFacet( String repositoryId, String facetId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.apache.archiva.metadata.repository;
|
||||
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Configurable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -29,6 +28,7 @@ public class TestRepositorySessionFactory
|
|||
{
|
||||
private MetadataResolver resolver;
|
||||
|
||||
@Override
|
||||
public RepositorySession createSession()
|
||||
{
|
||||
return new RepositorySession( new TestMetadataRepository(), resolver );
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
|
|||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.maven.index.NexusIndexer;
|
||||
import org.apache.maven.index.context.IndexingContext;
|
||||
import org.apache.maven.wagon.Wagon;
|
||||
|
|
|
@ -138,6 +138,7 @@ public class HttpProxyTransferTest
|
|||
|
||||
Handler handler = new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle( String s, Request request, HttpServletRequest httpServletRequest,
|
||||
HttpServletResponse response )
|
||||
throws IOException, ServletException
|
||||
|
|
|
@ -82,16 +82,19 @@ public class MockConfiguration
|
|||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChangeListener( org.apache.archiva.redback.components.registry.RegistryListener listener )
|
||||
{
|
||||
registryListeners.add( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration()
|
||||
{
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save( Configuration configuration )
|
||||
throws RegistryException
|
||||
{
|
||||
|
@ -113,21 +116,25 @@ public class MockConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( ConfigurationListener listener )
|
||||
{
|
||||
configListeners.add( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( ConfigurationListener listener )
|
||||
{
|
||||
configListeners.remove( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaulted()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload()
|
||||
{
|
||||
// no op
|
||||
|
|
|
@ -54,6 +54,7 @@ public class WagonDelegate
|
|||
|
||||
private String contentToGet;
|
||||
|
||||
@Override
|
||||
public void get( String resourceName, File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||
{
|
||||
|
@ -62,6 +63,7 @@ public class WagonDelegate
|
|||
create( destination );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIfNewer( String resourceName, File destination, long timestamp )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||
{
|
||||
|
@ -72,18 +74,21 @@ public class WagonDelegate
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put( File source, String destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||
{
|
||||
delegate.put( source, destination );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putDirectory( File sourceDirectory, String destinationDirectory )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||
{
|
||||
delegate.putDirectory( sourceDirectory, destinationDirectory );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resourceExists( String resourceName )
|
||||
throws TransferFailedException, AuthorizationException
|
||||
{
|
||||
|
@ -91,72 +96,85 @@ public class WagonDelegate
|
|||
}
|
||||
|
||||
@SuppressWarnings ("unchecked")
|
||||
@Override
|
||||
public List<String> getFileList( String destinationDirectory )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
|
||||
{
|
||||
return delegate.getFileList( destinationDirectory );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsDirectoryCopy()
|
||||
{
|
||||
return delegate.supportsDirectoryCopy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeout( int val )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimeout()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadTimeout( int timeoutValue )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReadTimeout()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repository getRepository()
|
||||
{
|
||||
return delegate.getRepository();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect( Repository source )
|
||||
throws ConnectionException, AuthenticationException
|
||||
{
|
||||
delegate.connect( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect( Repository source, ProxyInfo proxyInfo )
|
||||
throws ConnectionException, AuthenticationException
|
||||
{
|
||||
delegate.connect( source, proxyInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect( Repository source, ProxyInfoProvider proxyInfoProvider )
|
||||
throws ConnectionException, AuthenticationException
|
||||
{
|
||||
delegate.connect( source, proxyInfoProvider );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect( Repository source, AuthenticationInfo authenticationInfo )
|
||||
throws ConnectionException, AuthenticationException
|
||||
{
|
||||
delegate.connect( source, authenticationInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
|
||||
throws ConnectionException, AuthenticationException
|
||||
{
|
||||
delegate.connect( source, authenticationInfo, proxyInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider )
|
||||
throws ConnectionException, AuthenticationException
|
||||
{
|
||||
|
@ -164,53 +182,63 @@ public class WagonDelegate
|
|||
}
|
||||
|
||||
@SuppressWarnings ("deprecation")
|
||||
@Override
|
||||
public void openConnection()
|
||||
throws ConnectionException, AuthenticationException
|
||||
{
|
||||
delegate.openConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect()
|
||||
throws ConnectionException
|
||||
{
|
||||
delegate.disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSessionListener( SessionListener listener )
|
||||
{
|
||||
delegate.addSessionListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSessionListener( SessionListener listener )
|
||||
{
|
||||
delegate.removeSessionListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSessionListener( SessionListener listener )
|
||||
{
|
||||
return delegate.hasSessionListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTransferListener( TransferListener listener )
|
||||
{
|
||||
delegate.addTransferListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTransferListener( TransferListener listener )
|
||||
{
|
||||
delegate.removeTransferListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTransferListener( TransferListener listener )
|
||||
{
|
||||
return delegate.hasTransferListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInteractive()
|
||||
{
|
||||
return delegate.isInteractive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteractive( boolean interactive )
|
||||
{
|
||||
delegate.setInteractive( interactive );
|
||||
|
|
Loading…
Reference in New Issue