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;
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;
return proxyConnectorRuleConfigurations;
}
+ @Override
public File fetchFromProxies( ManagedRepositoryContent repository, ArtifactReference artifact )
throws ProxyDownloadException
{
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() )
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 );
return null;
}
+ @Override
public File fetchFromProxies( ManagedRepositoryContent repository, String path )
{
File localFile = new File( repository.getRepoRoot(), path );
return null;
}
+ @Override
public File fetchMetatadaFromProxies( ManagedRepositoryContent repository, String logicalPath )
{
File localFile = new File( repository.getRepoRoot(), logicalPath );
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: {}",
* @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,
/**
* Test if the provided ManagedRepositoryContent has any proxies configured for it.
*/
+ @Override
public boolean hasProxies( ManagedRepositoryContent repository )
{
synchronized ( this.proxyConnectorMap )
return false;
}
- if ( !file.isFile() )
- {
- return false;
- }
-
- return true;
+ return file.isFile();
}
/**
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;
/**
* TODO: Ensure that list is correctly ordered based on configuration. See MRM-477
*/
+ @Override
public List<ProxyConnector> getProxyConnectors( ManagedRepositoryContent repository )
{
synchronized ( this.proxyConnectorMap )
}
}
+ @Override
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
if ( ConfigurationNames.isNetworkProxy( propertyName ) || ConfigurationNames.isManagedRepositories(
}
+ @Override
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
/* do nothing */
return INSTANCE;
}
+ @Override
public int compare( ProxyConnector o1, ProxyConnector o2 )
{
if ( o1 == null && o2 == null )
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
{
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
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
{
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;
{
private MetadataResolver resolver;
+ @Override
public RepositorySession createSession()
{
return new RepositorySession( new TestMetadataRepository(), resolver );
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;
Handler handler = new AbstractHandler()
{
+ @Override
public void handle( String s, Request request, HttpServletRequest httpServletRequest,
HttpServletResponse response )
throws IOException, ServletException
} );
}
+ @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
{
}
}
+ @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
private String contentToGet;
+ @Override
public void get( String resourceName, File destination )
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
{
create( destination );
}
+ @Override
public boolean getIfNewer( String resourceName, File destination, long timestamp )
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
{
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
{
}
@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
{
}
@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 );