From 4443868b35fb5311e75395cc9589db9ab4c53532 Mon Sep 17 00:00:00 2001 From: Alin Dreghiciu Date: Tue, 24 Jul 2012 13:00:15 +0300 Subject: [PATCH 1/2] Add new methods that allows creation of repositories with specified artifact/metadata max age Still, keep the old behavior that was not setting this values to not break existing ITs Signed-off-by: Alin Dreghiciu --- .../utils/RepositoriesNexusRestClient.java | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/nexus/nexus-test-harness/nexus-test-utils/src/main/java/org/sonatype/nexus/test/utils/RepositoriesNexusRestClient.java b/nexus/nexus-test-harness/nexus-test-utils/src/main/java/org/sonatype/nexus/test/utils/RepositoriesNexusRestClient.java index 2c43168e87..2b834bf4cb 100644 --- a/nexus/nexus-test-harness/nexus-test-utils/src/main/java/org/sonatype/nexus/test/utils/RepositoriesNexusRestClient.java +++ b/nexus/nexus-test-harness/nexus-test-utils/src/main/java/org/sonatype/nexus/test/utils/RepositoriesNexusRestClient.java @@ -59,6 +59,8 @@ public class RepositoriesNexusRestClient public static final String SERVICE_PART = NexusRestClient.SERVICE_LOCAL + "repositories"; + private static final Integer USE_DEFAULT = null; + private final NexusRestClient nexusRestClient; private final TasksNexusRestClient taskNRC; @@ -522,16 +524,38 @@ public void createMavenHostedRepository( final String id, final RepositoryPolicy public void createMavenProxyReleaseRepository( final String id, final String url ) throws IOException { - createMavenProxyRepository( id, url, RepositoryPolicy.RELEASE ); + createMavenProxyReleaseRepository( id, url, USE_DEFAULT, USE_DEFAULT ); + } + + public void createMavenProxyReleaseRepository( final String id, + final String url, + final Integer artifactMaxAge, + final Integer metadataMaxAge ) + throws IOException + { + createMavenProxyRepository( id, url, RepositoryPolicy.RELEASE, artifactMaxAge, metadataMaxAge ); } public void createMavenProxySnapshotRepository( final String id, final String url ) throws IOException { - createMavenProxyRepository( id, url, RepositoryPolicy.SNAPSHOT ); + createMavenProxySnapshotRepository( id, url, USE_DEFAULT, USE_DEFAULT ); } - public void createMavenProxyRepository( final String id, final String url, final RepositoryPolicy repositoryPolicy ) + public void createMavenProxySnapshotRepository( final String id, + final String url, + final Integer artifactMaxAge, + final Integer metadataMaxAge ) + throws IOException + { + createMavenProxyRepository( id, url, RepositoryPolicy.SNAPSHOT, artifactMaxAge, metadataMaxAge ); + } + + public void createMavenProxyRepository( final String id, + final String url, + final RepositoryPolicy repositoryPolicy, + final Integer artifactMaxAge, + final Integer metadataMaxAge ) throws IOException { final RepositoryProxyResource repository = new RepositoryProxyResource(); @@ -548,6 +572,14 @@ public void createMavenProxyRepository( final String id, final String url, final repository.setBrowseable( true ); repository.setIndexable( true ); repository.setExposed( true ); + if ( artifactMaxAge != null ) + { + repository.setArtifactMaxAge( artifactMaxAge ); + } + if ( metadataMaxAge != null ) + { + repository.setMetadataMaxAge( metadataMaxAge ); + } RepositoryResourceRemoteStorage remoteStorage = new RepositoryResourceRemoteStorage(); remoteStorage.setRemoteStorageUrl( url ); From 2af2a880de621b3a8058aeba7eeef6bffb1591ac Mon Sep 17 00:00:00 2001 From: Alin Dreghiciu Date: Tue, 24 Jul 2012 13:12:49 +0300 Subject: [PATCH 2/2] Rename constant used when artifact/metadata max age is not set (old behavior) Signed-off-by: Alin Dreghiciu --- .../nexus/test/utils/RepositoriesNexusRestClient.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nexus/nexus-test-harness/nexus-test-utils/src/main/java/org/sonatype/nexus/test/utils/RepositoriesNexusRestClient.java b/nexus/nexus-test-harness/nexus-test-utils/src/main/java/org/sonatype/nexus/test/utils/RepositoriesNexusRestClient.java index 2b834bf4cb..6743f5e35f 100644 --- a/nexus/nexus-test-harness/nexus-test-utils/src/main/java/org/sonatype/nexus/test/utils/RepositoriesNexusRestClient.java +++ b/nexus/nexus-test-harness/nexus-test-utils/src/main/java/org/sonatype/nexus/test/utils/RepositoriesNexusRestClient.java @@ -59,7 +59,7 @@ public class RepositoriesNexusRestClient public static final String SERVICE_PART = NexusRestClient.SERVICE_LOCAL + "repositories"; - private static final Integer USE_DEFAULT = null; + private static final Integer DO_NOT_SET = null; private final NexusRestClient nexusRestClient; @@ -524,7 +524,7 @@ public void createMavenHostedRepository( final String id, final RepositoryPolicy public void createMavenProxyReleaseRepository( final String id, final String url ) throws IOException { - createMavenProxyReleaseRepository( id, url, USE_DEFAULT, USE_DEFAULT ); + createMavenProxyReleaseRepository( id, url, DO_NOT_SET, DO_NOT_SET ); } public void createMavenProxyReleaseRepository( final String id, @@ -539,7 +539,7 @@ public void createMavenProxyReleaseRepository( final String id, public void createMavenProxySnapshotRepository( final String id, final String url ) throws IOException { - createMavenProxySnapshotRepository( id, url, USE_DEFAULT, USE_DEFAULT ); + createMavenProxySnapshotRepository( id, url, DO_NOT_SET, DO_NOT_SET ); } public void createMavenProxySnapshotRepository( final String id,