Skip to content
Browse files

Implement a new Repositories getter

Fix JavaDoc

Signed-off-by: Alin Dreghiciu <adreghiciu@gmail.com>
  • Loading branch information...
1 parent 9c9a6ff commit cc3105324661a2ca7a3d9513f447f4c89c41ee95 @adreghiciu adreghiciu committed Oct 31, 2012
Showing with 3,406 additions and 91 deletions.
  1. +40 −0 nexus/nexus-client-core-testsuite/pom.xml
  2. +35 −0 nexus/nexus-client-core-testsuite/src/test/filtered-resources/logback-test.xml
  3. +47 −0 ...client-core-testsuite/src/test/java/org/sonatype/nexus/client/testsuite/NexusClientITSupport.java
  4. +262 −0 ...nexus-client-core-testsuite/src/test/java/org/sonatype/nexus/client/testsuite/RepositoriesIT.java
  5. +6 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/Condition.java
  6. +1 −1 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/NexusClient.java
  7. +3 −2 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/NexusClientException.java
  8. +3 −2 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/NexusErrorMessageException.java
  9. +1 −1 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/NexusStatus.java
  10. +5 −4 ...us-client-core/src/main/java/org/sonatype/nexus/client/core/NexusUnexpectedResponseException.java
  11. +1 −1 ...s/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/condition/EditionConditions.java
  12. +1 −1 ...s/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/condition/LogicalConditions.java
  13. +1 −1 ...xus-client-core/src/main/java/org/sonatype/nexus/client/core/condition/NexusStatusConditions.java
  14. +1 −1 ...s/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/condition/VersionConditions.java
  15. +2 −3 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/spi/SubsystemFactory.java
  16. +3 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/spi/SubsystemSupport.java
  17. +60 −0 ...core/src/main/java/org/sonatype/nexus/client/core/spi/subsystem/repository/RepositoryFactory.java
  18. +2 −3 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/Utilities.java
  19. +2 −4 ...us-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/artifact/ArtifactMaven.java
  20. +5 −0 ...s-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/artifact/ResolveRequest.java
  21. +5 −0 ...-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/artifact/ResolveResponse.java
  22. +0 −2 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/config/Segment.java
  23. +4 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/content/Content.java
  24. +3 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/content/Location.java
  25. +36 −0 ...lient-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/GroupRepository.java
  26. +61 −0 ...ient-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/HostedRepository.java
  27. +81 −0 ...lient-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/ProxyRepository.java
  28. +34 −0 ...core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/ProxyRepositoryStatus.java
  29. +67 −0 ...s-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/Repositories.java
  30. +86 −0 ...xus-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/Repository.java
  31. +28 −0 ...ient-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/RepositoryStatus.java
  32. +37 −0 ...ent-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/VirtualRepository.java
  33. +27 −0 ...src/main/java/org/sonatype/nexus/client/core/subsystem/repository/maven/MavenGroupRepository.java
  34. +41 −0 ...rc/main/java/org/sonatype/nexus/client/core/subsystem/repository/maven/MavenHostedRepository.java
  35. +27 −0 ...main/java/org/sonatype/nexus/client/core/subsystem/repository/maven/MavenM1VirtualRepository.java
  36. +43 −0 ...src/main/java/org/sonatype/nexus/client/core/subsystem/repository/maven/MavenProxyRepository.java
  37. +4 −2 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/msg/ErrorMessage.java
  38. +4 −2 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/msg/ErrorResponse.java
  39. +3 −0 .../nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/rest/AbstractNexusClient.java
  40. +3 −0 ...client-core/src/main/java/org/sonatype/nexus/client/internal/rest/AbstractNexusClientFactory.java
  41. +1 −1 ...client-core/src/main/java/org/sonatype/nexus/client/internal/rest/AbstractXStreamNexusClient.java
  42. +3 −3 .../nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/rest/NexusXStreamFactory.java
  43. +1 −1 ...s/nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/rest/XStreamXmlProvider.java
  44. +3 −0 ...e/src/main/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyArtifactMaven.java
  45. +5 −4 ...nt-core/src/main/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyContent.java
  46. +3 −0 ...main/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyServerConfiguration.java
  47. +3 −0 ...-core/src/main/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyUtilities.java
  48. +142 −0 ...va/org/sonatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyGroupRepository.java
  49. +70 −0 ...sonatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyGroupRepositoryFactory.java
  50. +107 −0 ...a/org/sonatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyHostedRepository.java
  51. +69 −0 ...onatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyHostedRepositoryFactory.java
  52. +159 −0 ...va/org/sonatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyProxyRepository.java
  53. +70 −0 ...sonatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyProxyRepositoryFactory.java
  54. +174 −0 .../java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyRepositories.java
  55. +259 −0 ...in/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyRepository.java
  56. +74 −0 .../org/sonatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyVirtualRepository.java
  57. +70 −0 ...natype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyVirtualRepositoryFactory.java
  58. +52 −0 ...rg/sonatype/nexus/client/internal/rest/jersey/subsystem/repository/ProxyRepositoryStatusImpl.java
  59. +39 −0 ...ava/org/sonatype/nexus/client/internal/rest/jersey/subsystem/repository/RepositoryStatusImpl.java
  60. +52 −0 ...type/nexus/client/internal/rest/jersey/subsystem/repository/maven/JerseyMavenGroupRepository.java
  61. +69 −0 ...xus/client/internal/rest/jersey/subsystem/repository/maven/JerseyMavenGroupRepositoryFactory.java
  62. +68 −0 ...ype/nexus/client/internal/rest/jersey/subsystem/repository/maven/JerseyMavenHostedRepository.java
  63. +68 −0 ...us/client/internal/rest/jersey/subsystem/repository/maven/JerseyMavenHostedRepositoryFactory.java
  64. +53 −0 .../nexus/client/internal/rest/jersey/subsystem/repository/maven/JerseyMavenM1VirtualRepository.java
  65. +69 −0 ...client/internal/rest/jersey/subsystem/repository/maven/JerseyMavenM1VirtualRepositoryFactory.java
  66. +73 −0 ...type/nexus/client/internal/rest/jersey/subsystem/repository/maven/JerseyMavenProxyRepository.java
  67. +69 −0 ...xus/client/internal/rest/jersey/subsystem/repository/maven/JerseyMavenProxyRepositoryFactory.java
  68. +1 −1 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/util/Check.java
  69. +1 −1 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/util/Template.java
  70. +3 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/rest/AuthenticationInfo.java
  71. +3 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/rest/BaseUrl.java
  72. +3 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/rest/ConnectionInfo.java
  73. +4 −10 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/rest/NexusClientFactory.java
  74. +3 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/rest/Protocol.java
  75. +4 −0 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/rest/ProxyInfo.java
  76. +4 −0 ...-client-core/src/main/java/org/sonatype/nexus/client/rest/UsernamePasswordAuthenticationInfo.java
  77. +13 −11 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/rest/jersey/JerseyNexusClient.java
  78. +13 −8 ...xus-client-core/src/main/java/org/sonatype/nexus/client/rest/jersey/JerseyNexusClientFactory.java
  79. +1 −3 ...ain/java/org/sonatype/nexus/client/rest/jersey/subsystem/JerseyArtifactMavenSubsystemFactory.java
  80. +1 −3 .../src/main/java/org/sonatype/nexus/client/rest/jersey/subsystem/JerseyContentSubsystemFactory.java
  81. +63 −0 ...core/src/main/java/org/sonatype/nexus/client/rest/jersey/subsystem/JerseyRepositoriesFactory.java
  82. +0 −2 ...c/main/java/org/sonatype/nexus/client/rest/jersey/subsystem/JerseyServerConfigurationFactory.java
  83. +1 −3 ...rc/main/java/org/sonatype/nexus/client/rest/jersey/subsystem/JerseyUtilitiesSubsystemFactory.java
  84. +26 −0 nexus/nexus-client-core/src/main/java/org/sonatype/plexus/rest/xstream/LookAheadStreamReader.java
  85. +92 −0 nexus/nexus-client-core/src/main/java/org/sonatype/plexus/rest/xstream/xml/LookAheadXppDriver.java
  86. +265 −0 nexus/nexus-client-core/src/main/java/org/sonatype/plexus/rest/xstream/xml/LookAheadXppReader.java
  87. +4 −10 ...client-core/src/test/java/org/sonatype/nexus/client/rest/jersey/JerseyNexusClientFactoryTest.java
  88. +1 −0 nexus/pom.xml
View
40 nexus/nexus-client-core-testsuite/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Sonatype Nexus (TM) Open Source Version
+ Copyright (c) 2007-2012 Sonatype, Inc.
+ All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+
+ This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+
+ Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ Eclipse Foundation. All other trademarks are the property of their respective owners.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus</artifactId>
+ <version>2.3-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.sonatype.nexus.client</groupId>
+ <artifactId>nexus-client-core-testsuite</artifactId>
+ <name>Nexus : Client Testsuite</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus-testsuite-support</artifactId>
+ <version>2.3-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
View
35 nexus/nexus-client-core-testsuite/src/test/filtered-resources/logback-test.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Sonatype Nexus (TM) Open Source Version
+ Copyright (c) 2007-2012 Sonatype, Inc.
+ All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+
+ This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+
+ Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ Eclipse Foundation. All other trademarks are the property of their respective owners.
+
+-->
+<configuration>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <target>System.out</target>
+ <encoder>
+ <pattern>%level [%thread%X{DC}] %logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="Sisu" level="${test.log.level.Sisu:-INFO}"/>
+ <logger name="org.apache.commons.httpclient" level="ERROR"/>
+ <logger name="org.apache.http" level="${test.log.level.org.apache.http:-ERROR}"/>
+
+ <logger name="org.sonatype.nexus.client" level="TRACE"/>
+
+ <root level="${test.log.level:-INFO}">
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</configuration>
View
47 ...ore-testsuite/src/test/java/org/sonatype/nexus/client/testsuite/NexusClientITSupport.java
@@ -0,0 +1,47 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.testsuite;
+
+import static org.sonatype.nexus.testsuite.support.ParametersLoaders.firstAvailableTestParameters;
+import static org.sonatype.nexus.testsuite.support.ParametersLoaders.systemTestParameters;
+import static org.sonatype.nexus.testsuite.support.ParametersLoaders.testParameters;
+import static org.sonatype.sisu.goodies.common.Varargs.$;
+
+import java.util.Collection;
+
+import org.junit.runners.Parameterized;
+import org.sonatype.nexus.testsuite.support.NexusRunningParametrizedITSupport;
+import org.sonatype.nexus.testsuite.support.NexusStartAndStopStrategy;
+
+@NexusStartAndStopStrategy( NexusStartAndStopStrategy.Strategy.EACH_TEST )
+public abstract class NexusClientITSupport
+ extends NexusRunningParametrizedITSupport
+{
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> data()
+ {
+ return firstAvailableTestParameters(
+ systemTestParameters(),
+ testParameters(
+ $( "${it.nexus.bundle.groupId}:${it.nexus.bundle.artifactId}:zip:bundle" )
+ )
+ ).load();
+ }
+
+ public NexusClientITSupport( final String nexusBundleCoordinates )
+ {
+ super( nexusBundleCoordinates );
+ }
+
+}
View
262 ...ient-core-testsuite/src/test/java/org/sonatype/nexus/client/testsuite/RepositoriesIT.java
@@ -0,0 +1,262 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.testsuite;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+
+import java.util.Collection;
+
+import org.junit.Test;
+import org.sonatype.nexus.client.core.subsystem.repository.Repositories;
+import org.sonatype.nexus.client.core.subsystem.repository.Repository;
+import org.sonatype.nexus.client.core.subsystem.repository.maven.MavenGroupRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.maven.MavenHostedRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.maven.MavenM1VirtualRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.maven.MavenProxyRepository;
+
+public class RepositoriesIT
+ extends NexusClientITSupport
+{
+
+ public RepositoriesIT( final String nexusBundleCoordinates )
+ {
+ super( nexusBundleCoordinates );
+ }
+
+ @Test
+ public void getHosted()
+ {
+ final Repository repository = repositories().get( "releases" );
+ assertThat( repository, is( instanceOf( MavenHostedRepository.class ) ) );
+ }
+
+ @Test
+ public void refreshHosted()
+ {
+ final Repository repository = repositories().get( "releases" );
+ final String name = repository.name();
+ repository.withName( "foo" );
+ repository.refresh();
+ assertThat( repository.name(), is( name ) );
+ }
+
+ @Test
+ public void createHosted()
+ {
+ final String id = repositoryIdForTest();
+ repositories().create( MavenHostedRepository.class, id )
+ .save();
+ }
+
+ @Test
+ public void removeHosted()
+ {
+ final String id = repositoryIdForTest();
+ repositories().create( MavenHostedRepository.class, id )
+ .save()
+ .remove();
+ }
+
+ @Test
+ public void statusHosted()
+ {
+ final String id = repositoryIdForTest();
+ final MavenHostedRepository repository = repositories().create( MavenHostedRepository.class, id );
+ assertThat( repository.status().isInService(), is( false ) );
+ repository.save();
+ assertThat( repository.status().isInService(), is( true ) );
+ assertThat( repository.putOutOfService().status().isInService(), is( false ) );
+ assertThat( repository.putInService().status().isInService(), is( true ) );
+ }
+
+ @Test
+ public void getProxy()
+ {
+ final Repository repository = repositories().get( "central" );
+ assertThat( repository, is( instanceOf( MavenProxyRepository.class ) ) );
+ }
+
+ @Test
+ public void refreshProxy()
+ {
+ final Repository repository = repositories().get( "central" );
+ final String name = repository.name();
+ repository.withName( "foo" );
+ repository.refresh();
+ assertThat( repository.name(), is( name ) );
+ }
+
+ @Test
+ public void createProxy()
+ {
+ final String id = repositoryIdForTest();
+ repositories().create( MavenProxyRepository.class, id )
+ .asProxyOf( "http://localhost:8080" )
+ .save();
+ }
+
+ public void removeProxy()
+ {
+ final String id = repositoryIdForTest();
+ repositories().create( MavenProxyRepository.class, id )
+ .asProxyOf( "http://localhost:8080" )
+ .save()
+ .remove();
+ }
+
+ @Test
+ public void statusProxy()
+ {
+ final String id = repositoryIdForTest();
+ final MavenProxyRepository repository = repositories().create( MavenProxyRepository.class, id )
+ .asProxyOf( "http://localhost:8080" );
+ assertThat( repository.status().isInService(), is( false ) );
+ repository.save();
+ assertThat( repository.status().isInService(), is( true ) );
+ assertThat( repository.putOutOfService().status().isInService(), is( false ) );
+ assertThat( repository.putInService().status().isInService(), is( true ) );
+ }
+
+ @Test
+ public void proxyMode()
+ {
+ final String id = repositoryIdForTest();
+ final MavenProxyRepository repository = repositories().create( MavenProxyRepository.class, id )
+ .asProxyOf( "http://localhost:8080" )
+ .doNotAutoBlock();
+ assertThat( repository.status().isBlocked(), is( false ) );
+ assertThat( repository.status().isAutoBlocked(), is( false ) );
+ repository.save();
+ assertThat( repository.status().isBlocked(), is( false ) );
+ assertThat( repository.status().isAutoBlocked(), is( false ) );
+ repository.block();
+ assertThat( repository.status().isBlocked(), is( true ) );
+ assertThat( repository.status().isAutoBlocked(), is( false ) );
+ repository.unblock();
+ assertThat( repository.status().isBlocked(), is( false ) );
+ assertThat( repository.status().isAutoBlocked(), is( false ) );
+ }
+
+ @Test
+ public void getGroup()
+ {
+ final Repository repository = repositories().get( "public" );
+ assertThat( repository, is( instanceOf( MavenGroupRepository.class ) ) );
+ }
+
+ @Test
+ public void refreshGroup()
+ {
+ final Repository repository = repositories().get( "public" );
+ final String name = repository.name();
+ repository.withName( "foo" );
+ repository.refresh();
+ assertThat( repository.name(), is( name ) );
+ }
+
+ @Test
+ public void createGroup()
+ {
+ final String id = repositoryIdForTest();
+ repositories().create( MavenGroupRepository.class, id )
+ .ofRepositories( "central", "releases", "snapshots" )
+ .save();
+ }
+
+ @Test
+ public void removeGroup()
+ {
+ final String id = repositoryIdForTest();
+ repositories().create( MavenGroupRepository.class, id )
+ .ofRepositories( "central", "releases", "snapshots" )
+ .save();
+ }
+
+ @Test
+ public void statusGroup()
+ {
+ final String id = repositoryIdForTest();
+ final MavenGroupRepository repository = repositories().create( MavenGroupRepository.class, id )
+ .ofRepositories( "central", "releases", "snapshots" );
+ assertThat( repository.status().isInService(), is( false ) );
+ repository.save();
+ assertThat( repository.status().isInService(), is( true ) );
+ assertThat( repository.putOutOfService().status().isInService(), is( false ) );
+ assertThat( repository.putInService().status().isInService(), is( true ) );
+ }
+
+ @Test
+ public void getShadow()
+ {
+ final Repository repository = repositories().get( "central-m1" );
+ assertThat( repository, is( instanceOf( MavenM1VirtualRepository.class ) ) );
+ }
+
+ @Test
+ public void refreshShadow()
+ {
+ final Repository repository = repositories().get( "central-m1" );
+ final String name = repository.name();
+ repository.withName( "foo" );
+ repository.refresh();
+ assertThat( repository.name(), is( name ) );
+ }
+
+ @Test
+ public void createShadow()
+ {
+ final String id = repositoryIdForTest();
+ repositories().create( MavenM1VirtualRepository.class, id )
+ .ofRepository( "apache-snapshots" )
+ .save();
+ }
+
+ @Test
+ public void removeShadow()
+ {
+ final String id = repositoryIdForTest();
+ repositories().create( MavenM1VirtualRepository.class, id )
+ .ofRepository( "apache-snapshots" )
+ .save()
+ .remove();
+ }
+
+ @Test
+ public void statusShadow()
+ {
+ final String id = repositoryIdForTest();
+ final MavenM1VirtualRepository repository = repositories().create( MavenM1VirtualRepository.class, id )
+ .ofRepository( "apache-snapshots" );
+ assertThat( repository.status().isInService(), is( false ) );
+ repository.save();
+ assertThat( repository.status().isInService(), is( true ) );
+ assertThat( repository.putOutOfService().status().isInService(), is( false ) );
+ assertThat( repository.putInService().status().isInService(), is( true ) );
+ }
+
+ @Test
+ public void get()
+ {
+ final Collection<Repository> repositories = repositories().get();
+ assertThat( repositories.size(), is( greaterThanOrEqualTo( 7 ) ) );
+ }
+
+ private Repositories repositories()
+ {
+ return client().getSubsystem( Repositories.class );
+ }
+
+}
View
6 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/Condition.java
@@ -12,10 +12,16 @@
*/
package org.sonatype.nexus.client.core;
+/**
+ * A condition to be satisfied by Nexus status in order for Nexus client to connect.
+ *
+ * @since 2.1
+ */
public interface Condition
{
boolean isSatisfiedBy( final NexusStatus status );
String explainNotSatisfied( final NexusStatus status );
+
}
View
2 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/NexusClient.java
@@ -19,7 +19,7 @@
/**
* A simple high level Nexus client.
*
- * @author cstamas
+ * @since 2.1
*/
public interface NexusClient
{
View
5 .../nexus-client-core/src/main/java/org/sonatype/nexus/client/core/NexusClientException.java
@@ -15,13 +15,14 @@
/**
* Generic runtime exception to be thrown by Subsystems, when some error is reported by Nexus. This exception here is
* solely for purpose of not proliferating possible runtime exceptions of underlying implementation.
- *
- * @author cstamas
+ *
+ * @since 2.1
*/
@SuppressWarnings( "serial" )
public abstract class NexusClientException
extends RuntimeException
{
+
public NexusClientException( String message )
{
super( message );
View
5 ...-client-core/src/main/java/org/sonatype/nexus/client/core/NexusErrorMessageException.java
@@ -18,13 +18,14 @@
/**
* Thrown when Nexus responds with an Client Error status code and (optionally) with an error message.
- *
- * @author cstamas
+ *
+ * @since 2.1
*/
@SuppressWarnings( "serial" )
public class NexusErrorMessageException
extends NexusUnexpectedResponseException
{
+
private final Map<String, String> errors;
public NexusErrorMessageException( final int statusCode, final String statusMessage,
View
2 nexus/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/NexusStatus.java
@@ -17,7 +17,7 @@
/**
* Status of the remote Nexus instance.
*
- * @author cstamas
+ * @since 2.1
*/
public class NexusStatus
{
View
9 ...t-core/src/main/java/org/sonatype/nexus/client/core/NexusUnexpectedResponseException.java
@@ -17,21 +17,21 @@
* here is solely for purpose of not proliferating possible runtime exceptions of underlying implementation. Best to use
* some subclass of this exception, but this is the last resort (ie. resource does not send proper response, just HTTP
* code and reason phrase).
- *
- * @author cstamas
+ *
+ * @since 2.1
*/
@SuppressWarnings( "serial" )
public class NexusUnexpectedResponseException
extends NexusClientException
{
+
private final int statusCode;
private final String statusMessage;
public NexusUnexpectedResponseException( final int statusCode, final String statusMessage )
{
- this( statusCode, statusMessage, String.format( "Unexpected response: %s %s", String.valueOf( statusCode ),
- String.valueOf( statusMessage ) ) );
+ this( statusCode, statusMessage, String.format( "Unexpected response: %s %s", statusCode, statusMessage ) );
}
public NexusUnexpectedResponseException( final int statusCode, final String statusMessage, final String message )
@@ -50,4 +50,5 @@ public String getStatusMessage()
{
return statusMessage;
}
+
}
View
2 ...client-core/src/main/java/org/sonatype/nexus/client/core/condition/EditionConditions.java
@@ -22,7 +22,7 @@
/**
* Edition conditions that contains {@link Condition}s to match remote Nexus edition.
*
- * @author cstamas
+ * @since 2.1
*/
public abstract class EditionConditions
{
View
2 ...client-core/src/main/java/org/sonatype/nexus/client/core/condition/LogicalConditions.java
@@ -19,7 +19,7 @@
/**
* Set of basic logical operators that combines multiple {@link org.sonatype.nexus.client.core.Condition}s into one.
*
- * @author cstamas
+ * @since 2.1
*/
public abstract class LogicalConditions
{
View
2 ...nt-core/src/main/java/org/sonatype/nexus/client/core/condition/NexusStatusConditions.java
@@ -18,7 +18,7 @@
/**
* {@link Condition}s matching {@link NexusStatus}.
*
- * @author cstamas
+ * @since 2.1
*/
public abstract class NexusStatusConditions
{
View
2 ...client-core/src/main/java/org/sonatype/nexus/client/core/condition/VersionConditions.java
@@ -24,7 +24,7 @@
/**
* {@link Condition}s that matches remote Nexus version.
*
- * @author cstamas
+ * @since 2.1
*/
public abstract class VersionConditions
implements Condition
View
5 .../nexus-client-core/src/main/java/org/sonatype/nexus/client/core/spi/SubsystemFactory.java
@@ -16,9 +16,7 @@
import org.sonatype.nexus.client.core.NexusClient;
/**
- * TODO
- *
- * @since 1.0
+ * @since 2.1
*/
public interface SubsystemFactory<T, NC extends NexusClient>
{
@@ -28,4 +26,5 @@
Class<T> getType();
T create( NC nexusClient );
+
}
View
3 .../nexus-client-core/src/main/java/org/sonatype/nexus/client/core/spi/SubsystemSupport.java
@@ -15,6 +15,9 @@
import org.sonatype.nexus.client.core.NexusClient;
import org.sonatype.nexus.client.internal.util.Check;
+/**
+ * @since 2.1
+ */
public abstract class SubsystemSupport<NC extends NexusClient>
{
View
60 .../main/java/org/sonatype/nexus/client/core/spi/subsystem/repository/RepositoryFactory.java
@@ -0,0 +1,60 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.spi.subsystem.repository;
+
+import org.sonatype.nexus.client.core.subsystem.repository.Repository;
+import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
+import org.sonatype.nexus.rest.model.RepositoryBaseResource;
+
+/**
+ * A {@link Repository} factory, that can create a new one or from a REST resource.
+ *
+ * @since 2.3
+ */
+public interface RepositoryFactory<R extends Repository>
+{
+
+ /**
+ * @param resource to be converted (never null)
+ * @return a score if this factory can adapt the resource into a {@link Repository}. Factory with higher score
+ * will be used. A value <= 0 will be mean that this factory cannot adapt
+ */
+ int canAdapt( RepositoryBaseResource resource );
+
+ /**
+ * Adapts a resource to a {@link Repository}.
+ *
+ * @param nexusClient current Nexus client
+ * @param resource to be adapted
+ * @return {@link Repository} created from resource
+ */
+ R adapt( JerseyNexusClient nexusClient, RepositoryBaseResource resource );
+
+ /**
+ * Whether or not this factory can create a {@link Repository} of specified type
+ *
+ * @param type to be created
+ * @return true if it can create, false otherwise
+ */
+ boolean canCreate( Class<? extends Repository> type );
+
+ /**
+ * Creates a {@link Repository} with specified id
+ *
+ * @param nexusClient current Nexus client (not null)
+ * @param id of repository to be created (not null / not empty)
+ * @return created {@link Repository}
+ */
+ R create( JerseyNexusClient nexusClient, String id );
+
+}
View
5 ...s/nexus-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/Utilities.java
@@ -15,12 +15,11 @@
import java.util.Date;
/**
- * TODO
- *
- * @since 1.0
+ * @since 2.1
*/
public interface Utilities
{
Date getLastModified( String uri );
+
}
View
6 ...t-core/src/main/java/org/sonatype/nexus/client/core/subsystem/artifact/ArtifactMaven.java
@@ -15,17 +15,15 @@
/**
* The core service at URI of {@code /service/local/artifact/maven}.
*
- * @author cstamas
+ * @since 2.1
*/
public interface ArtifactMaven
{
/**
* Performs a "resolve" operation on Nexus side, using whatever metadata targeted repository uses and returns the
* resolved artifact or {@code null} if resolution failed.
- *
- * @param req
- * @return
*/
ResolveResponse resolve( ResolveRequest req );
+
}
View
5 ...-core/src/main/java/org/sonatype/nexus/client/core/subsystem/artifact/ResolveRequest.java
@@ -14,6 +14,11 @@
import org.sonatype.nexus.client.internal.util.Check;
+/**
+ * Result of resolving a {@link ArtifactMaven}.
+ *
+ * @since 2.1
+ */
public class ResolveRequest
{
View
5 ...core/src/main/java/org/sonatype/nexus/client/core/subsystem/artifact/ResolveResponse.java
@@ -12,6 +12,11 @@
*/
package org.sonatype.nexus.client.core.subsystem.artifact;
+/**
+ * Request for resolving a {@link ArtifactMaven}.
+ *
+ * @since 2.1
+ */
public class ResolveResponse
{
View
2 ...us-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/config/Segment.java
@@ -12,8 +12,6 @@
*/
package org.sonatype.nexus.client.core.subsystem.config;
-import org.sonatype.nexus.rest.model.RemoteHttpProxySettings;
-
/**
* A configuration segment.
*
View
4 ...s-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/content/Content.java
@@ -15,8 +15,12 @@
import java.io.File;
import java.io.IOException;
+/**
+ * @since 2.1
+ */
public interface Content
{
+
void download( Location location, File target )
throws IOException;
View
3 ...-client-core/src/main/java/org/sonatype/nexus/client/core/subsystem/content/Location.java
@@ -14,6 +14,9 @@
import org.sonatype.nexus.client.internal.util.Check;
+/**
+ * @since 2.1
+ */
public class Location
{
View
36 ...re/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/GroupRepository.java
@@ -0,0 +1,36 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository;
+
+import java.util.List;
+
+/**
+ * A Nexus group {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface GroupRepository<T extends GroupRepository>
+ extends Repository<T, RepositoryStatus>
+{
+
+ List<String> memberRepositories();
+
+ /**
+ * Configures member repositories. Provided member repositories will replace exiting members (if any).
+ *
+ * @param memberRepositoryIds id of member repositories to be added (cannot be null)
+ * @return itself, for fluent api usage
+ */
+ T ofRepositories( String... memberRepositoryIds );
+
+}
View
61 ...e/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/HostedRepository.java
@@ -0,0 +1,61 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository;
+
+/**
+ * A Nexus hosted {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface HostedRepository<T extends HostedRepository>
+ extends Repository<T, RepositoryStatus>
+{
+
+ T withRepoPolicy( final String policy );
+
+ /**
+ * Makes repository a read-only repository.
+ *
+ * @return itself, for fluent api usage
+ */
+ T readOnly();
+
+ /**
+ * Allow redeploy of items into repository.
+ *
+ * @return itself, for fluent api usage
+ */
+ T allowRedeploy();
+
+ /**
+ * Do not allow redeployment into repository (items cannot be updated)
+ *
+ * @return itself, for fluent api usage
+ */
+ T disableRedeploy();
+
+ /**
+ * Enable browsing (see content of repository)
+ *
+ * @return itself, for fluent api usage
+ */
+ T enableBrowsing();
+
+ /**
+ * Disable browsing (see content of repository).
+ *
+ * @return itself, for fluent api usage
+ */
+ T disableBrowsing();
+
+}
View
81 ...re/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/ProxyRepository.java
@@ -0,0 +1,81 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository;
+
+/**
+ * A Nexus proxy {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface ProxyRepository<T extends ProxyRepository>
+ extends Repository<T, ProxyRepositoryStatus>
+{
+
+ /**
+ * @return proxied URI
+ */
+ String proxyUri();
+
+ /**
+ * Configures repository policy (RELEASES/SNAPSHOTS/MIXED).
+ *
+ * @param policy repository policy
+ * @return itself, for fluent api usage
+ */
+ T withRepoPolicy( final String policy );
+
+ /**
+ * Sets the URI of proxied repository.
+ *
+ * @param remoteUri of proxied repository
+ * @return itself, for fluent api usage
+ */
+ T asProxyOf( String remoteUri );
+
+ /**
+ * Auto block the repository if proxied repository is unresponsive.
+ *
+ * @return itself, for fluent api usage
+ */
+ T autoBlock();
+
+ /**
+ * Do not auto block the repository if proxied repository is unresponsive.
+ *
+ * @return itself, for fluent api usage
+ */
+ T doNotAutoBlock();
+
+ /**
+ * Directly blocks the repository (no save required).
+ *
+ * @return itself, for fluent api usage
+ */
+ T block();
+
+ /**
+ * Directly unblocks the repository (no save required).
+ *
+ * @return itself, for fluent api usage
+ */
+ T unblock();
+
+ /**
+ * Sets the number of minutes that not found items will be kept in NFC.
+ *
+ * @param minutes not found cache TTL in minutes
+ * @return itself, for fluent api usage
+ */
+ T withNotFoundCacheTTL( int minutes );
+
+}
View
34 .../main/java/org/sonatype/nexus/client/core/subsystem/repository/ProxyRepositoryStatus.java
@@ -0,0 +1,34 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository;
+
+/**
+ * Status of a {@link ProxyRepository}.
+ *
+ * @since 2.3
+ */
+public interface ProxyRepositoryStatus
+ extends RepositoryStatus
+{
+
+ /**
+ * @return if repository is currently blocked (manual or automatic)
+ */
+ boolean isBlocked();
+
+ /**
+ * @return if repository is currently automatically blocked
+ */
+ boolean isAutoBlocked();
+
+}
View
67 ...-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/Repositories.java
@@ -0,0 +1,67 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository;
+
+import java.util.Collection;
+
+/**
+ * Repositories subsystem.
+ *
+ * @since 2.3
+ */
+public interface Repositories
+{
+
+ /**
+ * Retrieves an existing repository by id.
+ *
+ * @param id of repository to be retrieved (cannot be null)
+ * @return repository with specified id
+ */
+ <R extends Repository> R get( String id );
+
+ /**
+ * Retrieves an existing repository by id.
+ *
+ * @param type expected type of retrieved repository (cannot be null)
+ * @param id of repository to be retrieved (cannot be null)
+ * @return repository with specified id
+ * @throws ClassCastException - if repository with specified id is not to expected type
+ */
+ <R extends Repository> R get( Class<R> type, String id );
+
+ /**
+ * Retrieves all existing repositories.
+ *
+ * @return all exiting repositories (never null)
+ */
+ Collection<Repository> get();
+
+ /**
+ * Retrieves all existing repositories of specified type.
+ *
+ * @param type expected type of retrieved repository (cannot be null)
+ * @return all exiting repositories of expected type (never null)
+ */
+ <R extends Repository> Collection<R> get( Class<R> type );
+
+ /**
+ * Creates a new repository of specified type / id.
+ *
+ * @param type of created repository
+ * @param id of new repository
+ * @return created repository (never null)
+ */
+ <R extends Repository> R create( Class<R> type, String id );
+
+}
View
86 ...nt-core/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/Repository.java
@@ -0,0 +1,86 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository;
+
+/**
+ * A Nexus repository.
+ *
+ * @since 2.3
+ */
+public interface Repository<T extends Repository, U extends RepositoryStatus>
+{
+
+ /**
+ * @return repository id (never null)
+ */
+ String id();
+
+ /**
+ * @return repository name
+ */
+ String name();
+
+ /**
+ * @return content URI (null when repository does not publish its URI)
+ */
+ String contentUri();
+
+ /**
+ * @return repository status.
+ */
+ U status();
+
+ /**
+ * Sets repository name.
+ *
+ * @param name repository name
+ * @return itself, for fluent api usage
+ */
+ T withName( String name );
+
+ /**
+ * Directly puts repository out of service (no save required).
+ *
+ * @return itself, for fluent api usage
+ */
+ T putOutOfService();
+
+ /**
+ * Directly puts repository in service (no save required).
+ *
+ * @return itself, for fluent api usage
+ */
+ T putInService();
+
+ /**
+ * Refreshes repository, replacing any current changes.
+ *
+ * @return itself, for fluent api usage
+ */
+ T refresh();
+
+ /**
+ * Saves current changes.
+ *
+ * @return itself, for fluent api usage
+ */
+ T save();
+
+ /**
+ * Removes the repository.
+ *
+ * @return itself, for fluent api usage
+ */
+ T remove();
+
+}
View
28 ...e/src/main/java/org/sonatype/nexus/client/core/subsystem/repository/RepositoryStatus.java
@@ -0,0 +1,28 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository;
+
+/**
+ * Status of a {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface RepositoryStatus
+{
+
+ /**
+ * @return ir repository is in service or not
+ */
+ boolean isInService();
+
+}
View
37 .../src/main/java/org/sonatype/nexus/client/core/subsystem/repository/VirtualRepository.java
@@ -0,0 +1,37 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository;
+
+/**
+ * A Nexus virtual {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface VirtualRepository<T extends VirtualRepository>
+ extends Repository<T, RepositoryStatus>
+{
+
+ /**
+ * @return id of virtualized repository
+ */
+ String virtualizedRepository();
+
+ /**
+ * Specify the id of virtualized repository.
+ *
+ * @param repositoryId of virtualized repository
+ * @return itself, for fluent api usage
+ */
+ T ofRepository( String repositoryId );
+
+}
View
27 .../java/org/sonatype/nexus/client/core/subsystem/repository/maven/MavenGroupRepository.java
@@ -0,0 +1,27 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository.maven;
+
+import org.sonatype.nexus.client.core.subsystem.repository.GroupRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.Repository;
+
+/**
+ * A Nexus Maven group {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface MavenGroupRepository
+ extends GroupRepository<MavenGroupRepository>
+{
+
+}
View
41 ...java/org/sonatype/nexus/client/core/subsystem/repository/maven/MavenHostedRepository.java
@@ -0,0 +1,41 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository.maven;
+
+import org.sonatype.nexus.client.core.subsystem.repository.HostedRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.Repository;
+
+/**
+ * A Nexus Maven hosted {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface MavenHostedRepository
+ extends HostedRepository<MavenHostedRepository>
+{
+
+ /**
+ * Artifact of this repository will be included in search results.
+ *
+ * @return itself, for fluent api usage
+ */
+ MavenHostedRepository includeInSearchResults();
+
+ /**
+ * Artifact of this repository will be excluded from search results.
+ *
+ * @return itself, for fluent api usage
+ */
+ MavenHostedRepository excludeFromSearchResults();
+
+}
View
27 ...a/org/sonatype/nexus/client/core/subsystem/repository/maven/MavenM1VirtualRepository.java
@@ -0,0 +1,27 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository.maven;
+
+import org.sonatype.nexus.client.core.subsystem.repository.Repository;
+import org.sonatype.nexus.client.core.subsystem.repository.VirtualRepository;
+
+/**
+ * A Nexus Maven M2 -> M1 virtual {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface MavenM1VirtualRepository
+ extends VirtualRepository<MavenM1VirtualRepository>
+{
+
+}
View
43 .../java/org/sonatype/nexus/client/core/subsystem/repository/maven/MavenProxyRepository.java
@@ -0,0 +1,43 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.core.subsystem.repository.maven;
+
+import org.sonatype.nexus.client.core.subsystem.repository.ProxyRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.Repository;
+
+/**
+ * A Nexus Maven proxy {@link Repository}.
+ *
+ * @since 2.3
+ */
+public interface MavenProxyRepository
+ extends ProxyRepository<MavenProxyRepository>
+{
+
+ /**
+ * Configures number of minutes artifacts will be cached.
+ *
+ * @param minutes to be cached
+ * @return itself, for fluent api usage
+ */
+ MavenProxyRepository withArtifactMaxAge( int minutes );
+
+ /**
+ * Configures number of minutes artifact metadata will be cached.
+ *
+ * @param minutes to be cached
+ * @return itself, for fluent api usage
+ */
+ MavenProxyRepository withMetadataMaxAge( int minutes );
+
+}
View
6 .../nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/msg/ErrorMessage.java
@@ -21,10 +21,12 @@
//---------------------------------/
/**
- * COPIED FROM plexus-restlet-bridge to cease the dependency on it (as it would pull in Restlet and other shit).
+ * COPIED FROM plexus-restlet-bridge to cease the dependency on it (as it would pull in Restlet and many other
+ * dependencies).
+ * <p/>
* An item describing the error.
*
- * @version $Revision$ $Date$
+ * @since 2.1
*/
public class ErrorMessage
implements java.io.Serializable
View
6 ...nexus-client-core/src/main/java/org/sonatype/nexus/client/internal/msg/ErrorResponse.java
@@ -21,10 +21,12 @@
//---------------------------------/
/**
- * COPIED FROM plexus-restlet-bridge to cease the dependency on it (as it would pull in Restlet and other shit).
+ * COPIED FROM plexus-restlet-bridge to cease the dependency on it (as it would pull in Restlet and many other
+ * dependencies).
+ * <p/>
* Class ErrorResponse.
*
- * @version $Revision$ $Date$
+ * @since 2.1
*/
public class ErrorResponse
implements java.io.Serializable
View
3 ...lient-core/src/main/java/org/sonatype/nexus/client/internal/rest/AbstractNexusClient.java
@@ -25,6 +25,9 @@
import org.sonatype.nexus.client.internal.util.Check;
import org.sonatype.nexus.client.rest.ConnectionInfo;
+/**
+ * @since 2.1
+ */
public abstract class AbstractNexusClient
implements NexusClient
{
View
3 ...ore/src/main/java/org/sonatype/nexus/client/internal/rest/AbstractNexusClientFactory.java
@@ -22,6 +22,9 @@
import org.sonatype.nexus.client.rest.ConnectionInfo;
import org.sonatype.nexus.client.rest.NexusClientFactory;
+/**
+ * @since 2.1
+ */
public abstract class AbstractNexusClientFactory<NC extends NexusClient>
implements NexusClientFactory
{
View
2 ...ore/src/main/java/org/sonatype/nexus/client/internal/rest/AbstractXStreamNexusClient.java
@@ -23,7 +23,7 @@
* of the implementations keeps the fact of XStream use encapsulated, I did not want to proliferate it through all of
* Nexus Client.
*
- * @author cstamas
+ * @since 2.1
*/
public abstract class AbstractXStreamNexusClient
extends AbstractNexusClient
View
6 ...lient-core/src/main/java/org/sonatype/nexus/client/internal/rest/NexusXStreamFactory.java
@@ -15,13 +15,13 @@
import org.sonatype.nexus.client.internal.msg.ErrorMessage;
import org.sonatype.nexus.client.internal.msg.ErrorResponse;
import org.sonatype.nexus.rest.model.XStreamConfiguratorLightweight;
+import org.sonatype.plexus.rest.xstream.xml.LookAheadXppDriver;
import com.thoughtworks.xstream.XStream;
-import com.thoughtworks.xstream.io.xml.XppDriver;
/**
* Creates XStream instances "preconfigured" for Nexus Core DTOs.
*
- * @author cstamas
+ * @since 2.1
*/
public class NexusXStreamFactory
{
@@ -33,7 +33,7 @@
*/
public XStream createForXml()
{
- final XStream xstream = new XStream( new XppDriver() );
+ final XStream xstream = new XStream( new LookAheadXppDriver() );
xstream.setMode( XStream.NO_REFERENCES );
xstream.autodetectAnnotations( false );
return xstream;
View
2 ...client-core/src/main/java/org/sonatype/nexus/client/internal/rest/XStreamXmlProvider.java
@@ -33,7 +33,7 @@
* Jersey provider that uses XStream, as we want to use the same tech (as we have all the config bits already) on client
* side for marshaling as server side does.
*
- * @author cstamas
+ * @since 2.1
*/
@Provider
public class XStreamXmlProvider
View
3 ...in/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyArtifactMaven.java
@@ -24,6 +24,9 @@
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.core.util.MultivaluedMapImpl;
+/**
+ * @since 2.1
+ */
public class JerseyArtifactMaven
extends SubsystemSupport<JerseyNexusClient>
implements ArtifactMaven
View
9 ...src/main/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyContent.java
@@ -13,7 +13,6 @@
package org.sonatype.nexus.client.internal.rest.jersey.subsystem;
import static com.google.common.base.Preconditions.checkState;
-import static java.lang.String.format;
import java.io.File;
import java.io.FileNotFoundException;
@@ -25,14 +24,16 @@
import org.sonatype.nexus.client.core.subsystem.content.Content;
import org.sonatype.nexus.client.core.subsystem.content.Location;
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
-
-import com.google.common.base.Preconditions;
import com.sun.jersey.api.client.ClientResponse;
+/**
+ * @since 2.1
+ */
public class JerseyContent
extends SubsystemSupport<JerseyNexusClient>
implements Content
{
+
private static final String CONTENT_PREFIX = "content/";
public JerseyContent( final JerseyNexusClient nexusClient )
@@ -55,7 +56,7 @@ public void download( final Location location, final File target )
else
{
checkState(
- target.isFile() && target.canWrite(),
+ target.isFile() && target.canWrite(),
"File '%s' is not a file or could not be written", target.getAbsolutePath()
);
}
View
3 ...a/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyServerConfiguration.java
@@ -18,6 +18,9 @@
import org.sonatype.nexus.client.internal.rest.jersey.subsystem.config.JerseyHttpProxy;
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
+/**
+ * @since 2.2
+ */
public class JerseyServerConfiguration
extends SubsystemSupport<JerseyNexusClient>
implements ServerConfiguration
View
3 ...c/main/java/org/sonatype/nexus/client/internal/rest/jersey/subsystem/JerseyUtilities.java
@@ -19,6 +19,9 @@
import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
import com.sun.jersey.api.client.ClientResponse;
+/**
+ * @since 2.1
+ */
public class JerseyUtilities
extends SubsystemSupport<JerseyNexusClient>
implements Utilities
View
142 ...onatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyGroupRepository.java
@@ -0,0 +1,142 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository;
+
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.Nullable;
+
+import org.sonatype.nexus.client.core.subsystem.repository.GroupRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.RepositoryStatus;
+import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
+import org.sonatype.nexus.rest.model.RepositoryGroupMemberRepository;
+import org.sonatype.nexus.rest.model.RepositoryGroupResource;
+import org.sonatype.nexus.rest.model.RepositoryGroupResourceResponse;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+/**
+ * Jersey based {@link GroupRepository} implementation.
+ *
+ * @since 2.3
+ */
+public class JerseyGroupRepository<T extends GroupRepository>
+ extends JerseyRepository<T, RepositoryGroupResource, RepositoryStatus>
+ implements GroupRepository<T>
+{
+
+ static final String REPO_TYPE = "group";
+
+ static final String PROVIDER_ROLE = "org.sonatype.nexus.proxy.repository.GroupRepository";
+
+ public JerseyGroupRepository( final JerseyNexusClient nexusClient, final String id )
+ {
+ super( nexusClient, id );
+ }
+
+ public JerseyGroupRepository( final JerseyNexusClient nexusClient, final RepositoryGroupResource resource )
+ {
+ super( nexusClient, resource );
+ }
+
+ @Override
+ protected RepositoryGroupResource createSettings()
+ {
+ final RepositoryGroupResource settings = new RepositoryGroupResource();
+
+ settings.setRepoType( REPO_TYPE );
+ settings.setProviderRole( PROVIDER_ROLE );
+ settings.setExposed( true );
+
+ return settings;
+ }
+
+ private T me()
+ {
+ return (T) this;
+ }
+
+ @Override
+ String uri()
+ {
+ return "repo_groups";
+ }
+
+ @Override
+ RepositoryGroupResource doGet()
+ {
+ final RepositoryGroupResourceResponse response = getNexusClient()
+ .serviceResource( uri() + "/" + id() )
+ .get( RepositoryGroupResourceResponse.class );
+
+ return response.getData();
+ }
+
+ @Override
+ RepositoryGroupResource doCreate()
+ {
+ final RepositoryGroupResourceResponse request = new RepositoryGroupResourceResponse();
+ request.setData( settings() );
+
+ final RepositoryGroupResourceResponse response = getNexusClient()
+ .serviceResource( uri() )
+ .post( RepositoryGroupResourceResponse.class, request );
+
+ return response.getData();
+ }
+
+ @Override
+ RepositoryGroupResource doUpdate()
+ {
+ final RepositoryGroupResourceResponse request = new RepositoryGroupResourceResponse();
+ request.setData( settings() );
+
+ final RepositoryGroupResourceResponse response = getNexusClient()
+ .serviceResource( uri() + "/" + id() )
+ .put( RepositoryGroupResourceResponse.class, request );
+
+ return response.getData();
+ }
+
+ @Override
+ public List<String> memberRepositories()
+ {
+ final List<RepositoryGroupMemberRepository> memberRepositories = settings().getRepositories();
+ if ( memberRepositories == null )
+ {
+ return Collections.emptyList();
+ }
+ return Collections.unmodifiableList(
+ Lists.transform( memberRepositories, new Function<RepositoryGroupMemberRepository, String>()
+ {
+ @Override
+ public String apply( @Nullable final RepositoryGroupMemberRepository member )
+ {
+ return member == null ? null : member.getId();
+ }
+ } ) );
+ }
+
+ @Override
+ public T ofRepositories( final String... memberRepositoryIds )
+ {
+ for ( final String memberRepositoryId : memberRepositoryIds )
+ {
+ final RepositoryGroupMemberRepository repository = new RepositoryGroupMemberRepository();
+ repository.setId( memberRepositoryId );
+ settings().addRepository( repository );
+ }
+ return me();
+ }
+
+}
View
70 .../nexus/client/internal/rest/jersey/subsystem/repository/JerseyGroupRepositoryFactory.java
@@ -0,0 +1,70 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.sonatype.nexus.client.core.spi.subsystem.repository.RepositoryFactory;
+import org.sonatype.nexus.client.core.subsystem.repository.GroupRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.Repository;
+import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
+import org.sonatype.nexus.rest.model.RepositoryBaseResource;
+import org.sonatype.nexus.rest.model.RepositoryGroupResource;
+
+/**
+ * {@link JerseyGroupRepository} factory.
+ *
+ * @since 2.3
+ */
+@Named
+@Singleton
+public class JerseyGroupRepositoryFactory
+ implements RepositoryFactory<GroupRepository>
+{
+
+ @Override
+ public int canAdapt( final RepositoryBaseResource resource )
+ {
+ int score = 0;
+ if ( resource instanceof RepositoryGroupResource )
+ {
+ score++;
+ }
+ if ( JerseyGroupRepository.REPO_TYPE.equals( resource.getRepoType() ) )
+ {
+ score++;
+ }
+ return score;
+ }
+
+ @Override
+ public JerseyGroupRepository adapt( final JerseyNexusClient nexusClient,
+ final RepositoryBaseResource resource )
+ {
+ return new JerseyGroupRepository( nexusClient, (RepositoryGroupResource) resource );
+ }
+
+ @Override
+ public boolean canCreate( final Class<? extends Repository> type )
+ {
+ return GroupRepository.class.equals( type );
+ }
+
+ @Override
+ public JerseyGroupRepository create( final JerseyNexusClient nexusClient, final String id )
+ {
+ return new JerseyGroupRepository( nexusClient, id );
+ }
+
+}
View
107 ...natype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyHostedRepository.java
@@ -0,0 +1,107 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository;
+
+import org.sonatype.nexus.client.core.subsystem.repository.HostedRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.RepositoryStatus;
+import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
+import org.sonatype.nexus.rest.model.RepositoryResource;
+
+/**
+ * Jersey based {@link HostedRepository} implementation.
+ *
+ * @since 2.3
+ */
+public class JerseyHostedRepository<T extends HostedRepository>
+ extends JerseyRepository<T, RepositoryResource, RepositoryStatus>
+ implements HostedRepository<T>
+{
+
+ static final String REPO_TYPE = "hosted";
+
+ static final String PROVIDER_ROLE = "org.sonatype.nexus.proxy.repository.Repository";
+
+ public JerseyHostedRepository( final JerseyNexusClient nexusClient, final String id )
+ {
+ super( nexusClient, id );
+ }
+
+ public JerseyHostedRepository( final JerseyNexusClient nexusClient, final RepositoryResource resource )
+ {
+ super( nexusClient, resource );
+ }
+
+ @Override
+ protected RepositoryResource createSettings()
+ {
+ final RepositoryResource settings = new RepositoryResource();
+
+ settings.setRepoType( REPO_TYPE );
+ settings.setProviderRole( PROVIDER_ROLE );
+ settings.setExposed( true );
+ settings.setWritePolicy( "ALLOW_WRITE_ONCE" );
+ settings.setBrowseable( true );
+ settings.setIndexable( false );
+ settings.setRepoPolicy( "MIXED" );
+
+ return settings;
+ }
+
+ private T me()
+ {
+ return (T) this;
+ }
+
+ @Override
+ public T withRepoPolicy( final String policy )
+ {
+ settings().setRepoPolicy( policy );
+ return me();
+ }
+
+ @Override
+ public T readOnly()
+ {
+ settings().setWritePolicy( "READ_ONLY" );
+ return me();
+ }
+
+ @Override
+ public T allowRedeploy()
+ {
+ settings().setWritePolicy( "ALLOW_WRITE_ONCE" );
+ return me();
+ }
+
+ @Override
+ public T disableRedeploy()
+ {
+ settings().setWritePolicy( "ALLOW_WRITE" );
+ return me();
+ }
+
+ @Override
+ public T enableBrowsing()
+ {
+ settings().setBrowseable( true );
+ return me();
+ }
+
+ @Override
+ public T disableBrowsing()
+ {
+ settings().setBrowseable( false );
+ return me();
+ }
+
+}
View
69 ...nexus/client/internal/rest/jersey/subsystem/repository/JerseyHostedRepositoryFactory.java
@@ -0,0 +1,69 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.sonatype.nexus.client.core.spi.subsystem.repository.RepositoryFactory;
+import org.sonatype.nexus.client.core.subsystem.repository.HostedRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.Repository;
+import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
+import org.sonatype.nexus.rest.model.RepositoryBaseResource;
+import org.sonatype.nexus.rest.model.RepositoryResource;
+
+/**
+ * {@link JerseyHostedRepository} factory.
+ *
+ * @since 2.3
+ */
+@Named
+@Singleton
+public class JerseyHostedRepositoryFactory
+ implements RepositoryFactory<HostedRepository>
+{
+
+ @Override
+ public int canAdapt( final RepositoryBaseResource resource )
+ {
+ int score = 0;
+ if ( resource instanceof RepositoryResource )
+ {
+ score++;
+ }
+ if ( JerseyHostedRepository.REPO_TYPE.equals( resource.getRepoType() ) )
+ {
+ score++;
+ }
+ return score;
+ }
+
+ @Override
+ public JerseyHostedRepository adapt( final JerseyNexusClient nexusClient,
+ final RepositoryBaseResource resource )
+ {
+ return new JerseyHostedRepository( nexusClient, (RepositoryResource) resource );
+ }
+
+ @Override
+ public boolean canCreate( final Class<? extends Repository> type )
+ {
+ return HostedRepository.class.equals( type );
+ }
+
+ @Override
+ public JerseyHostedRepository create( final JerseyNexusClient nexusClient, final String id )
+ {
+ return new JerseyHostedRepository( nexusClient, id );
+ }
+}
View
159 ...onatype/nexus/client/internal/rest/jersey/subsystem/repository/JerseyProxyRepository.java
@@ -0,0 +1,159 @@
+/**
+ * Sonatype Nexus (TM) Open Source Version
+ * Copyright (c) 2007-2012 Sonatype, Inc.
+ * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
+ *
+ * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
+ * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
+ * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
+ * Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.client.internal.rest.jersey.subsystem.repository;
+
+import org.sonatype.nexus.client.core.subsystem.repository.ProxyRepository;
+import org.sonatype.nexus.client.core.subsystem.repository.ProxyRepositoryStatus;
+import org.sonatype.nexus.client.rest.jersey.JerseyNexusClient;
+import org.sonatype.nexus.rest.model.RepositoryProxyResource;
+import org.sonatype.nexus.rest.model.RepositoryResourceRemoteStorage;
+import org.sonatype.nexus.rest.model.RepositoryStatusResource;
+
+/**
+ * Jersey based {@link ProxyRepository} implementation.
+ *
+ * @since 2.3
+ */
+public class JerseyProxyRepository<T extends ProxyRepository>
+ extends JerseyRepository<T, RepositoryProxyResource, ProxyRepositoryStatus>
+ implements ProxyRepository<T>
+{
+
+ static final String REPO_TYPE = "proxy";
+
+ static final String PROVIDER_ROLE = "org.sonatype.nexus.proxy.repository.Repository";
+
+ public JerseyProxyRepository( final JerseyNexusClient nexusClient, final String id )
+ {
+ super( nexusClient, id );
+ }
+
+ public JerseyProxyRepository( final JerseyNexusClient nexusClient, final RepositoryProxyResource settings )
+ {
+ super( nexusClient, settings );
+ }
+
+ @Override
+ protected RepositoryProxyResource createSettings()
+ {
+ final RepositoryProxyResource settings = new RepositoryProxyResource();
+
+ settings.setRepoType( REPO_TYPE );
+ settings.setProviderRole( PROVIDER_ROLE );
+ settings.setExposed( true );
+ settings.setWritePolicy( "READ_ONLY" );
+ settings.setBrowseable( true );
+ settings.setIndexable( false );
+ settings.setNotFoundCacheTTL( 1440 );
+ settings.setRepoPolicy( "MIXED" );
+ settings.setChecksumPolicy( "WARN" );
+ settings.setDownloadRemoteIndexes( true );
+ settings.setFileTypeValidation( true );
+ settings.setArtifactMaxAge( -1 );
+ settings.setMetadataMaxAge( 1440 );
+ settings.setAutoBlockActive( true );
+
+ return settings;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private T me()
+ {
+ return (T) this;
+ }
+
+ @Override
+ ProxyRepositoryStatus convertStatus( final RepositoryStatusResource status )
+ {
+ if ( status == null )
+ {
+ return new ProxyRepositoryStatusImpl( false, false, false );
+ }
+ return new ProxyRepositoryStatusImpl(
+ "IN_SERVICE".equals( status.getLocalStatus() ),
+ !"ALLOW".equals( status.getProxyMode() ),
+ "BLOCKED_AUTO".equals( status.getProxyMode() )
+ );
+ }
+
+ @Override
+ public String proxyUri()
+ {
+ final RepositoryResourceRemoteStorage remoteStorage = settings().getRemoteStorage();
+ if ( remoteStorage == null )
+ {
+ return null;
+ }
+ return remoteStorage.getRemoteStorageUrl();
+ }
+
+ @Override