* 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
{
private NetworkProxyAdmin networkProxyAdmin;
@Inject
- @Named ( value = "repositoryPathTranslator#maven2" )
+ @Named( value = "repositoryPathTranslator#maven2" )
private RepositoryPathTranslator pathTranslator;
@Inject
private ApplicationContext applicationContext;
@Inject
- @Named ( value = "pathParser#default")
+ @Named( value = "pathParser#default" )
private PathParser pathParser;
private static final Logger log = LoggerFactory.getLogger( Maven2RepositoryStorage.class );
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() );
}
catch ( RepositoryAdminException e )
{
- throw new RepositoryStorageRuntimeException( "repo-admin", e.getMessage(), e);
+ throw new RepositoryStorageRuntimeException( "repo-admin", e.getMessage(), e );
}
}
}
catch ( RepositoryAdminException e )
{
- throw new RepositoryStorageRuntimeException( "repo-admin", e.getMessage(), e);
+ throw new RepositoryStorageRuntimeException( "repo-admin", e.getMessage(), e );
}
}
}
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
*/
}
-
private static final class PomFilenameFilter
implements FilenameFilter
{