import javax.inject.Named;
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.Reader;
private NetworkProxyAdmin networkProxyAdmin;
@Inject
- @Named( value = "repositoryPathTranslator#maven2" )
+ @Named( "repositoryPathTranslator#maven2" )
private RepositoryPathTranslator pathTranslator;
@Inject
private ApplicationContext applicationContext;
@Inject
- @Named( value = "pathParser#default" )
+ @Named( "pathParser#default" )
private PathParser pathParser;
private static final String METADATA_FILENAME_START = "maven-metadata";
return metadata;
}
- /**
- * A relocation capable client will request the POM prior to the artifact, and will then read meta-data and do
- * client side relocation. A simplier client (like maven 1) will only request the artifact and not use the
- * metadatas.
- * <p>
- * For such clients, archiva does server-side relocation by reading itself the <relocation> element in
- * metadatas and serving the expected artifact.
- */
@Override
public void applyServerSideRelocation( ManagedRepositoryContent managedRepository, ArtifactReference artifact )
throws ProxyDownloadException
implements ManagedRepositoryContent
{
@Inject
- @Named (value = "fileTypes")
+ @Named ( "fileTypes" )
private FileTypes filetypes;
private ManagedRepository repository;
"Unable to get related artifacts using a non-directory: " + repoDir.getAbsolutePath() );
}
- Set<ArtifactReference> foundArtifacts = new HashSet<ArtifactReference>();
+ Set<ArtifactReference> foundArtifacts = new HashSet<>();
// First gather up the versions found as artifacts in the managed repository.
File repoFiles[] = repoDir.listFiles();
- for ( int i = 0; i < repoFiles.length; i++ )
+ for (File repoFile : repoFiles)
{
- if ( repoFiles[i].isDirectory() )
- {
+ if (repoFile.isDirectory()) {
// Skip it. it's a directory.
continue;
}
-
- String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
-
+ String relativePath = PathUtil.getRelative(repository.getLocation(), repoFile);
if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
// Test for related, groupId / artifactId / version must match.
if ( artifact.getGroupId().equals( reference.getGroupId() ) && artifact.getArtifactId().equals(
- reference.getArtifactId() ) && artifact.getVersion().equals( reference.getVersion() ) )
+ reference.getArtifactId() ) && artifact.getVersion().equals( reference.getVersion() ) )
{
foundArtifacts.add( artifact );
}
"Unable to get Versions on a non-directory: " + repoDir.getAbsolutePath() );
}
- Set<String> foundVersions = new HashSet<String>();
+ Set<String> foundVersions = new HashSet<>();
VersionedReference versionRef = new VersionedReference();
versionRef.setGroupId( reference.getGroupId() );
versionRef.setArtifactId( reference.getArtifactId() );
File repoFiles[] = repoDir.listFiles();
- for ( int i = 0; i < repoFiles.length; i++ )
+ for (File repoFile : repoFiles)
{
- if ( !repoFiles[i].isDirectory() )
- {
+ if (!repoFile.isDirectory()) {
// Skip it. not a directory.
continue;
}
-
// Test if dir has an artifact, which proves to us that it is a valid version directory.
- String version = repoFiles[i].getName();
+ String version = repoFile.getName();
versionRef.setVersion( version );
-
if ( hasArtifact( versionRef ) )
{
// Found an artifact, must be a valid version.
"Unable to get versions on a non-directory: " + repoDir.getAbsolutePath() );
}
- Set<String> foundVersions = new HashSet<String>();
+ Set<String> foundVersions = new HashSet<>();
// First gather up the versions found as artifacts in the managed repository.
File repoFiles[] = repoDir.listFiles();
- for ( int i = 0; i < repoFiles.length; i++ )
+ for (File repoFile : repoFiles)
{
- if ( repoFiles[i].isDirectory() )
- {
+ if (repoFile.isDirectory()) {
// Skip it. it's a directory.
continue;
}
-
- String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
-
+ String relativePath = PathUtil.getRelative(repository.getLocation(), repoFile);
if ( filetypes.matchesDefaultExclusions( relativePath ) )
{
// Skip it, it's metadata or similar
continue;
}
-
if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
Set<String> versions = getVersions( reference );
return !versions.isEmpty();
}
- catch ( ContentNotFoundException e )
- {
- return false;
- }
- catch ( LayoutException e )
+ catch ( ContentNotFoundException | LayoutException e )
{
return false;
}
{
return ( getFirstArtifact( reference ) != null );
}
- catch ( IOException e )
- {
- return false;
- }
- catch ( LayoutException e )
+ catch ( IOException | LayoutException e )
{
return false;
}
}
File repoFiles[] = repoDir.listFiles();
- for ( int i = 0; i < repoFiles.length; i++ )
+ for (File repoFile : repoFiles)
{
- if ( repoFiles[i].isDirectory() )
- {
+ if (repoFile.isDirectory()) {
// Skip it. it's a directory.
continue;
}
-
- String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
-
+ String relativePath = PathUtil.getRelative(repository.getLocation(), repoFile);
if ( filetypes.matchesArtifactPattern( relativePath ) )
{
ArtifactReference artifact = toArtifactReference( relativePath );