aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2013-12-09 02:47:18 +0000
committerOlivier Lamy <olamy@apache.org>2013-12-09 02:47:18 +0000
commit449de093e2e3293f308ee0f88012bd7662231ce8 (patch)
tree62bfee6d8dfd77fbc7cad5a3b63e6a4c8d5165f3
parent74e63f4bbb4a859944102e0815db03a177032c73 (diff)
downloadarchiva-449de093e2e3293f308ee0f88012bd7662231ce8.tar.gz
archiva-449de093e2e3293f308ee0f88012bd7662231ce8.zip
fix unit tests
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1549370 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java6
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java63
2 files changed, 47 insertions, 22 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
index 7bd7fc360..20b1ad8e3 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
@@ -524,9 +524,9 @@ public class ArchivaDavResourceFactoryTest
expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo );
- expect( request.getMethod() ).andReturn( "GET" ).times( 2 );
+ expect( request.getMethod() ).andReturn( "GET" ).times( 3 );
- expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 );
+ expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 3 );
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
@@ -575,7 +575,7 @@ public class ArchivaDavResourceFactoryTest
expect( request.getMethod() ).andReturn( "GET" ).times( 2 );
- expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 );
+ expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 3 );
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
index 30cc56958..6763e8b9b 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
@@ -106,7 +106,7 @@ import java.util.Map;
* within the session in the context of a single managed repository's resolution needs.
* <p/>
*/
-@Service ( "repositoryStorage#maven2" )
+@Service( "repositoryStorage#maven2" )
public class Maven2RepositoryStorage
implements RepositoryStorage
{
@@ -125,7 +125,7 @@ public class Maven2RepositoryStorage
private NetworkProxyAdmin networkProxyAdmin;
@Inject
- @Named ( value = "repositoryPathTranslator#maven2" )
+ @Named( value = "repositoryPathTranslator#maven2" )
private RepositoryPathTranslator pathTranslator;
@Inject
@@ -135,7 +135,7 @@ public class Maven2RepositoryStorage
private ApplicationContext applicationContext;
@Inject
- @Named ( value = "pathParser#default")
+ @Named( value = "pathParser#default" )
private PathParser pathParser;
private static final Logger log = LoggerFactory.getLogger( Maven2RepositoryStorage.class );
@@ -289,8 +289,8 @@ public class Maven2RepositoryStorage
if ( ( problem.getException() instanceof FileNotFoundException && e.getModelId() != null &&
!e.getModelId().equals( problem.getModelId() ) ) )
{
- log.warn( "The artifact's parent POM file '{}' cannot be resolved. " +
- "Using defaults for project version metadata..", file );
+ log.warn( "The artifact's parent POM file '{}' cannot be resolved. "
+ + "Using defaults for project version metadata..", file );
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId( readMetadataRequest.getProjectVersion() );
@@ -377,7 +377,7 @@ public class Maven2RepositoryStorage
}
catch ( RepositoryAdminException e )
{
- throw new RepositoryStorageRuntimeException( "repo-admin", e.getMessage(), e);
+ throw new RepositoryStorageRuntimeException( "repo-admin", e.getMessage(), e );
}
}
@@ -523,7 +523,7 @@ public class Maven2RepositoryStorage
}
catch ( RepositoryAdminException e )
{
- throw new RepositoryStorageRuntimeException( "repo-admin", e.getMessage(), e);
+ throw new RepositoryStorageRuntimeException( "repo-admin", e.getMessage(), e );
}
}
@@ -765,41 +765,67 @@ public class Maven2RepositoryStorage
}
public String getFilePathWithVersion( final String requestPath, ManagedRepositoryContent managedRepositoryContent )
- throws LayoutException, XMLException
+ throws XMLException
{
- String requestPathNoRepository = removePrefix( requestPath );
- ArtifactReference artifactReference = pathParser.toArtifactReference( requestPathNoRepository );
+
+ if (StringUtils.endsWith( requestPath, METADATA_FILENAME ))
+ {
+ return getFilePath( requestPath, managedRepositoryContent.getRepository() );
+ }
+
String filePath = getFilePath( requestPath, managedRepositoryContent.getRepository() );
- if (StringUtils.endsWith( artifactReference.getVersion(), "SNAPSHOT" ))
+ String requestPathNoRepository = removePrefix( requestPath );
+
+ ArtifactReference artifactReference = null;
+ try
+ {
+ artifactReference = pathParser.toArtifactReference( filePath );
+ }
+ catch ( LayoutException e )
+ {
+ return filePath;
+ }
+
+ if ( StringUtils.endsWith( artifactReference.getVersion(), "SNAPSHOT" ) )
{
// read maven metadata to get last timestamp
- File metadataDir = new File( managedRepositoryContent.getRepoRoot(), filePath).getParentFile();
- ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( new File(metadataDir, METADATA_FILENAME ) );
+ File metadataDir = new File( managedRepositoryContent.getRepoRoot(), filePath ).getParentFile();
+ if ( !metadataDir.exists() )
+ {
+ return filePath;
+ }
+ File metadataFile = new File( metadataDir, METADATA_FILENAME );
+ if ( !metadataFile.exists() )
+ {
+ return filePath;
+ }
+ ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( metadataFile );
int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
String timestamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();
// org/apache/archiva/archiva-checksum/1.4-M4-SNAPSHOT/archiva-checksum-1.4-M4-SNAPSHOT.jar
// -> archiva-checksum-1.4-M4-20130425.081822-1.jar
- filePath = StringUtils.replace( filePath, artifactReference.getArtifactId() + "-" + artifactReference.getVersion(),
- artifactReference.getArtifactId() + "-" + StringUtils.remove( artifactReference.getVersion(), "-SNAPSHOT")
- + "-" + timestamp + "-" + buildNumber );
+ filePath =
+ StringUtils.replace( filePath, artifactReference.getArtifactId() + "-" + artifactReference.getVersion(),
+ artifactReference.getArtifactId() + "-" + StringUtils.remove(
+ artifactReference.getVersion(), "-SNAPSHOT" ) + "-" + timestamp + "-"
+ + buildNumber );
}
return filePath;
}
-
-
//-----------------------------
// internal
//-----------------------------
/**
* FIXME remove
+ *
* @param href
* @return
*/
@@ -992,7 +1018,6 @@ public class Maven2RepositoryStorage
}
-
private static final class PomFilenameFilter
implements FilenameFilter
{