aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java2
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/ReadMetadataRequest.java36
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java2
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java53
4 files changed, 70 insertions, 23 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
index d43bed6a6..6d505f13d 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
@@ -101,7 +101,7 @@ public class DefaultMetadataResolver
{
ReadMetadataRequest readMetadataRequest =
new ReadMetadataRequest().repositoryId( repoId ).namespace( namespace ).projectId(
- projectId ).projectVersion( projectVersion );
+ projectId ).projectVersion( projectVersion ).browsingRequest( true );
metadata = repositoryStorage.readProjectVersionMetadata( readMetadataRequest );
log.debug( "Resolved project version metadata from storage: {}", metadata );
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/ReadMetadataRequest.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/ReadMetadataRequest.java
index 6ee552151..56e9f02d2 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/ReadMetadataRequest.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/ReadMetadataRequest.java
@@ -36,6 +36,12 @@ public class ReadMetadataRequest
private Filter<String> filter;
+ /**
+ * define this request as a ui request to remove some constraints added for optimisations
+ * @since 2.0.0
+ */
+ private boolean browsingRequest;
+
public ReadMetadataRequest()
{
// no op
@@ -135,4 +141,34 @@ public class ReadMetadataRequest
this.filter = filter;
return this;
}
+
+ public boolean isBrowsingRequest()
+ {
+ return browsingRequest;
+ }
+
+ public void setBrowsingRequest( boolean browsingRequest )
+ {
+ this.browsingRequest = browsingRequest;
+ }
+
+ public ReadMetadataRequest browsingRequest( boolean browsingRequest )
+ {
+ this.browsingRequest = browsingRequest;
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder( "ReadMetadataRequest{" );
+ sb.append( "repositoryId='" ).append( repositoryId ).append( '\'' );
+ sb.append( ", namespace='" ).append( namespace ).append( '\'' );
+ sb.append( ", projectId='" ).append( projectId ).append( '\'' );
+ sb.append( ", projectVersion='" ).append( projectVersion ).append( '\'' );
+ sb.append( ", filter=" ).append( filter );
+ sb.append( ", browsingRequest=" ).append( browsingRequest );
+ sb.append( '}' );
+ return sb.toString();
+ }
}
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
index 30dcd3dff..197fc9712 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
@@ -213,7 +213,7 @@ public class Maven3DependencyTreeBuilder
collectRequest.setRoot( new Dependency( artifact, "" ) );
// add remote repositories ?
- //collectRequest.addRepository( )
+ collectRequest.addRepository( new org.sonatype.aether.repository.RemoteRepository( "fake", "default", "http://maven.apache.org" ) );
collectRequest.setRequestContext( "project" );
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 8dab2bfef..46602ac97 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
@@ -169,31 +169,35 @@ public class Maven2RepositoryStorage
{
ManagedRepository managedRepository =
managedRepositoryAdmin.getManagedRepository( readMetadataRequest.getRepositoryId() );
-
String artifactVersion = readMetadataRequest.getProjectVersion();
- if ( VersionUtil.isSnapshot(
- readMetadataRequest.getProjectVersion() ) ) // skygo trying to improve speed by honoring managed configuration MRM-1658
+ // olamy: in case of browsing via the ui we can mix repos (parent of a SNAPSHOT can come from release repo)
+ if ( !readMetadataRequest.isBrowsingRequest() )
{
- if ( managedRepository.isReleases() && !managedRepository.isSnapshots() )
+
+ if ( VersionUtil.isSnapshot(
+ artifactVersion ) ) // skygo trying to improve speed by honoring managed configuration MRM-1658
{
- throw new RepositoryStorageRuntimeException( "lookforsnaponreleaseonly",
- "managed repo is configured for release only" );
+ if ( managedRepository.isReleases() && !managedRepository.isSnapshots() )
+ {
+ throw new RepositoryStorageRuntimeException( "lookforsnaponreleaseonly",
+ "managed repo is configured for release only" );
+ }
}
- }
- else
- {
- if ( !managedRepository.isReleases() && managedRepository.isSnapshots() )
+ else
{
- throw new RepositoryStorageRuntimeException( "lookforsreleaseonsneponly",
- "managed repo is configured for snapshot only" );
+ if ( !managedRepository.isReleases() && managedRepository.isSnapshots() )
+ {
+ throw new RepositoryStorageRuntimeException( "lookforsreleaseonsneponly",
+ "managed repo is configured for snapshot only" );
+ }
}
}
File basedir = new File( managedRepository.getLocation() );
- if ( VersionUtil.isSnapshot( readMetadataRequest.getProjectVersion() ) )
+ if ( VersionUtil.isSnapshot( artifactVersion ) )
{
File metadataFile = pathTranslator.toFile( basedir, readMetadataRequest.getNamespace(),
- readMetadataRequest.getProjectId(),
- readMetadataRequest.getProjectVersion(), METADATA_FILENAME );
+ readMetadataRequest.getProjectId(), artifactVersion,
+ METADATA_FILENAME );
try
{
ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
@@ -219,7 +223,7 @@ public class Maven2RepositoryStorage
String id = readMetadataRequest.getProjectId() + "-" + artifactVersion + ".pom";
File file =
pathTranslator.toFile( basedir, readMetadataRequest.getNamespace(), readMetadataRequest.getProjectId(),
- readMetadataRequest.getProjectVersion(), id );
+ artifactVersion, id );
if ( !file.exists() )
{
@@ -258,6 +262,13 @@ public class Maven2RepositoryStorage
}
}
+ // That's a browsing request so we can a mix of SNAPSHOT and release artifacts (especially with snapshots which
+ // can have released parent pom
+ if ( readMetadataRequest.isBrowsingRequest() )
+ {
+ remoteRepositories.addAll( remoteRepositoryAdmin.getRemoteRepositories() );
+ }
+
ModelBuildingRequest req =
new DefaultModelBuildingRequest().setProcessPlugins( false ).setPomFile( file ).setTwoPhaseBuilding(
false ).setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
@@ -809,12 +820,12 @@ public class Maven2RepositoryStorage
filePath =
StringUtils.replace( filePath, artifactReference.getArtifactId() + "-" + artifactReference.getVersion(),
artifactReference.getArtifactId() + "-" + StringUtils.remove(
- artifactReference.getVersion(), "-" + VersionUtil.SNAPSHOT ) + "-" + timestamp + "-"
- + buildNumber );
+ artifactReference.getVersion(), "-" + VersionUtil.SNAPSHOT ) + "-" + timestamp
+ + "-" + buildNumber );
- throw new RelocationException(
- "/repository/" + managedRepositoryContent.getRepository().getId() +
- ( StringUtils.startsWith( filePath, "/" ) ? "" : "/" ) + filePath, RelocationException.RelocationType.TEMPORARY );
+ throw new RelocationException( "/repository/" + managedRepositoryContent.getRepository().getId() +
+ ( StringUtils.startsWith( filePath, "/" ) ? "" : "/" ) + filePath,
+ RelocationException.RelocationType.TEMPORARY );
}