Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #491 from sonatype/create-repos-with-max-age-set
Browse files Browse the repository at this point in the history
Add new methods that allows creation of repositories with specified artifact/metadata max age
  • Loading branch information
adreghiciu committed Jul 24, 2012
2 parents ab56707 + 2af2a88 commit 4f5c69a
Showing 1 changed file with 35 additions and 3 deletions.
Expand Up @@ -59,6 +59,8 @@ public class RepositoriesNexusRestClient

public static final String SERVICE_PART = NexusRestClient.SERVICE_LOCAL + "repositories";

private static final Integer DO_NOT_SET = null;

private final NexusRestClient nexusRestClient;

private final TasksNexusRestClient taskNRC;
Expand Down Expand Up @@ -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, DO_NOT_SET, DO_NOT_SET );
}

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, DO_NOT_SET, DO_NOT_SET );
}

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();
Expand All @@ -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 );
Expand Down

0 comments on commit 4f5c69a

Please sign in to comment.