diff --git a/nexus-clients/nexus-restlight-clients/nexus-restlight-stage-client/src/main/java/org/sonatype/nexus/restlight/stage/StageClient.java b/nexus-clients/nexus-restlight-clients/nexus-restlight-stage-client/src/main/java/org/sonatype/nexus/restlight/stage/StageClient.java index 33e8bf8ed8..749d51b326 100644 --- a/nexus-clients/nexus-restlight-clients/nexus-restlight-stage-client/src/main/java/org/sonatype/nexus/restlight/stage/StageClient.java +++ b/nexus-clients/nexus-restlight-clients/nexus-restlight-stage-client/src/main/java/org/sonatype/nexus/restlight/stage/StageClient.java @@ -61,6 +61,8 @@ public class StageClient private static final String PROFILE_NAME_ELEMENT = "name"; + private static final String PROFILE_MODE_ELEMENT = "mode"; + private static final String REPO_ID_ELEMENT = "repositoryId"; private static final String REPO_URI_ELEMENT = "repositoryURI"; @@ -545,4 +547,46 @@ public List getClosedStageRepositories() return parseStageRepositories( doc, STAGE_REPO_LIST_XPATH, false, false ); } + + /** + * Returns a list of all the staging profile Ids. + * + * @return + * @throws RESTLightClientException + */ + @SuppressWarnings( "unchecked" ) + public List getStageProfiles() + throws RESTLightClientException + { + Document doc = get( PROFILES_PATH ); + + // heavy lifting is done with xpath + XPath profileXp = newXPath( STAGE_REPO_XPATH ); + + List profiles; + try + { + profiles = profileXp.selectNodes( doc.getRootElement() ); + } + catch ( JDOMException e ) + { + throw new RESTLightClientException( "XPath selection failed: '" + STAGE_REPO_XPATH + "' (Root node: " + + doc.getRootElement().getName() + ").", e ); + } + + List result = new ArrayList(); + if ( profiles != null ) + { + for ( Element profile : profiles ) + { + // just pull out the id and name. + String profileId = profile.getChild( PROFILE_ID_ELEMENT ).getText(); + String name = profile.getChild( PROFILE_NAME_ELEMENT ).getText(); + String mode = profile.getChild( PROFILE_MODE_ELEMENT ).getText(); + + result.add( new StageProfile( profileId, name, mode ) ); + } + } + return result; + } } diff --git a/nexus-clients/nexus-restlight-clients/nexus-restlight-stage-client/src/main/java/org/sonatype/nexus/restlight/stage/StageProfile.java b/nexus-clients/nexus-restlight-clients/nexus-restlight-stage-client/src/main/java/org/sonatype/nexus/restlight/stage/StageProfile.java index 243a2129d7..0f49379ab3 100644 --- a/nexus-clients/nexus-restlight-clients/nexus-restlight-stage-client/src/main/java/org/sonatype/nexus/restlight/stage/StageProfile.java +++ b/nexus-clients/nexus-restlight-clients/nexus-restlight-stage-client/src/main/java/org/sonatype/nexus/restlight/stage/StageProfile.java @@ -17,11 +17,22 @@ public class StageProfile */ private String name; + /** + * The profile mode + */ + private String mode; + public StageProfile( String profileId, String name ) + { + this( profileId, name, null ); + } + + public StageProfile( String profileId, String name, String mode ) { super(); this.profileId = profileId; this.name = name; + this.mode = mode; } public String getProfileId() @@ -34,4 +45,9 @@ public String getName() return name; } + public String getMode() + { + return mode; + } + }