Browse Source

jdk 7 (multicatch) for-loop

remove unused package, reduce annotations (value= or locations=)
move javadoc from Maven2RepsotirotyStorage to RepositoryStorage
tags/archiva-2.1.0
Eric Barboni 10 years ago
parent
commit
a7c6ebb10e

+ 12
- 1
archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java View File

@@ -58,7 +58,18 @@ public interface RepositoryStorage
// FIXME: reconsider this API, do we want to expose storage format in the form of a path?
ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path )
throws RepositoryStorageRuntimeException;

/**
* 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 &lt;relocation&gt; element in
* metadatas and serving the expected artifact.
* @param managedRepository the used managed repository
* @param artifact the artifact reference
* @throws org.apache.archiva.policies.ProxyDownloadException
*/
void applyServerSideRelocation( ManagedRepositoryContent managedRepository, ArtifactReference artifact )
throws ProxyDownloadException;


+ 1
- 1
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java View File

@@ -92,7 +92,7 @@ public class Maven3DependencyTreeBuilder
private PlexusSisuBridge plexusSisuBridge;

@Inject
@Named(value = "repositoryPathTranslator#maven2")
@Named( "repositoryPathTranslator#maven2" )
private RepositoryPathTranslator pathTranslator;

@Inject

+ 2
- 11
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java View File

@@ -84,7 +84,6 @@ import javax.inject.Inject;
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;
@@ -130,7 +129,7 @@ public class Maven2RepositoryStorage
private NetworkProxyAdmin networkProxyAdmin;

@Inject
@Named( value = "repositoryPathTranslator#maven2" )
@Named( "repositoryPathTranslator#maven2" )
private RepositoryPathTranslator pathTranslator;

@Inject
@@ -140,7 +139,7 @@ public class Maven2RepositoryStorage
private ApplicationContext applicationContext;

@Inject
@Named( value = "pathParser#default" )
@Named( "pathParser#default" )
private PathParser pathParser;

private static final String METADATA_FILENAME_START = "maven-metadata";
@@ -649,14 +648,6 @@ public class Maven2RepositoryStorage
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 &lt;relocation&gt; element in
* metadatas and serving the expected artifact.
*/
@Override
public void applyServerSideRelocation( ManagedRepositoryContent managedRepository, ArtifactReference artifact )
throws ProxyDownloadException

+ 1
- 6
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java View File

@@ -403,12 +403,7 @@ public class RepositoryModelResolver
}
connected = true;
}
catch ( ConnectionException e )
{
log.error( "Could not connect to {}:{} ", remoteRepository.getName(), e.getMessage() );
connected = false;
}
catch ( AuthenticationException e )
catch ( ConnectionException | AuthenticationException e )
{
log.error( "Could not connect to {}:{} ", remoteRepository.getName(), e.getMessage() );
connected = false;

+ 1
- 1
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/AbstractLegacyRepositoryContent.java View File

@@ -56,7 +56,7 @@ public abstract class AbstractLegacyRepositoryContent
*
*/
@Inject
@Named( value = "pathParser#legacy" )
@Named( "pathParser#legacy" )
private PathParser legacyPathParser;

public ArtifactReference toArtifactReference( String path )

+ 19
- 40
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java View File

@@ -54,7 +54,7 @@ public class ManagedDefaultRepositoryContent
implements ManagedRepositoryContent
{
@Inject
@Named (value = "fileTypes")
@Named ( "fileTypes" )
private FileTypes filetypes;

private ManagedRepository repository;
@@ -182,20 +182,17 @@ public class ManagedDefaultRepositoryContent
"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
@@ -204,7 +201,7 @@ public class ManagedDefaultRepositoryContent

// 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 );
}
@@ -265,24 +262,21 @@ public class ManagedDefaultRepositoryContent
"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.
@@ -319,26 +313,22 @@ public class ManagedDefaultRepositoryContent
"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
@@ -372,11 +362,7 @@ public class ManagedDefaultRepositoryContent
Set<String> versions = getVersions( reference );
return !versions.isEmpty();
}
catch ( ContentNotFoundException e )
{
return false;
}
catch ( LayoutException e )
catch ( ContentNotFoundException | LayoutException e )
{
return false;
}
@@ -389,11 +375,7 @@ public class ManagedDefaultRepositoryContent
{
return ( getFirstArtifact( reference ) != null );
}
catch ( IOException e )
{
return false;
}
catch ( LayoutException e )
catch ( IOException | LayoutException e )
{
return false;
}
@@ -470,16 +452,13 @@ public class ManagedDefaultRepositoryContent
}

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 );

Loading…
Cancel
Save