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

Commit

Permalink
[maven-release-plugin] copy for tag nexus-1.3.2
Browse files Browse the repository at this point in the history
git-svn-id: file:///opt/svn/repositories/sonatype.org/nexus/tags/nexus-1.3.2@3864 2aa8b3fc-8ebb-4439-a84f-95066eaea8ab
  • Loading branch information
mpowers committed Apr 7, 2009
2 parents dce014a + 642b66d commit 7f63caa
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public interface RepositoryTypeRegistry
*/
Set<String> getRepositoryRoles();

/**
* Returns the available content classes.
*
* @return
*/
Set<ContentClass> getContentClasses();

/**
* Returns the set of hints for the given repository role.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ public List<StageRepository> getOpenStageRepositoriesForUser()
return parseStageRepositories( doc, STAGE_REPO_LIST_XPATH, true );
}

/**
* Retrieve the list of all closed (finished) staging repositories that may house artifacts with the specified
* groupId, artifactId, and version for the current user.
*
* @return details about each closed repository
*/
public List<StageRepository> getOpenStageRepositoriesForUser( final String groupId, final String artifactId,
final String version )
throws RESTLightClientException
{
Map<String, String> params = new HashMap<String, String>();
mapCoord( groupId, artifactId, version, params );

Document doc = get( PROFILES_PATH, params );

return parseStageRepositories( doc, STAGE_REPO_XPATH, true );
}

/**
* Retrieve the details for the open staging repository which would be used for an artifact with the specified
* groupId, artifactId, and version if the current user deployed it. In the event Nexus returns multiple open
Expand Down Expand Up @@ -175,9 +193,22 @@ public void finishRepositoryForUser( final String groupId, final String artifact
public void finishRepository( final StageRepository repo, final String description )
throws RESTLightClientException
{
Element desc = new Element( REPO_DESCRIPTION_ELEMENT ).setText( description );
String descElementName =
getVocabulary().getProperty( VocabularyKeys.PROMOTE_STAGE_REPO_DESCRIPTION_ELEMENT,
VocabularyKeys.SUPPRESS_ELEMENT_VALUE );

List<Element> extras;
if ( !VocabularyKeys.SUPPRESS_ELEMENT_VALUE.equals( descElementName ) )
{
Element desc = new Element( REPO_DESCRIPTION_ELEMENT ).setText( description );
extras = Collections.singletonList( desc );
}
else
{
extras = null;
}

performStagingAction( repo, STAGE_REPO_FINISH_ACTION, Collections.singletonList( desc ) );
performStagingAction( repo, STAGE_REPO_FINISH_ACTION, extras );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ public final class VocabularyKeys
* 1.3.2, the element has been simplified to <code>promoteRequest</code>.
*/
public static final String PROMOTE_STAGE_REPO_ROOT_ELEMENT = "promoteRepository.rootElement";

/**
* This is the description element name to use when finishing a staged repository. In Nexus Professional 1.3.1, it
* wasn't used at all, so the value is {@link VocabularyKeys#SUPPRESS_ELEMENT_VALUE}. In Nexus Professional 1.3.2+,
* the element is <code>description</code>.
*/
public static final String PROMOTE_STAGE_REPO_DESCRIPTION_ELEMENT = "promoteRepository.descriptionElement";

/**
* Flag value that tells the REST client to suppress that element.
*/
public static final String SUPPRESS_ELEMENT_VALUE = "NONE";

private VocabularyKeys()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
promoteRepository.rootElement=promoteRequest
promoteRepository.descriptionElement=description
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class AbstractRESTTest

private static final String TEST_NX_API_VERSION_SYSPROP = "test.nexus.api.version";

private static final String DEFAULT_TEST_NX_API_VERSION = "1.3.1";
private static final String DEFAULT_TEST_NX_API_VERSION = "1.3.2";

/**
* <p>
Expand Down
5 changes: 3 additions & 2 deletions nexus-clients/nexus-restlight-clients/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<groupId>org.sonatype.nexus.restlight</groupId>
<artifactId>nexus-restlight-clients</artifactId>
<version>1.3.2</version>
<packaging>pom</packaging>

<name>Nexus Lightweight REST Clients</name>
Expand All @@ -26,7 +27,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nexus-restlight-client-common</artifactId>
<version>${project.version}</version>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId> org.jdom</groupId>
Expand Down Expand Up @@ -83,7 +84,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nexus-restlight-test-harness</artifactId>
<version>${project.version}</version>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.component.repository.ComponentRequirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
import org.sonatype.nexus.proxy.repository.GroupRepository;
Expand All @@ -38,6 +39,9 @@ public class DefaultRepositoryTypeRegistry
@Requirement
private PlexusContainer container;

@Requirement( role = ContentClass.class )
private Map<String, ContentClass> contentClasses;

private Set<RepositoryTypeDescriptor> repositoryRoles;

public Set<RepositoryTypeDescriptor> getRepositoryTypeDescriptors()
Expand Down Expand Up @@ -70,15 +74,20 @@ public Set<String> getRepositoryRoles()
return Collections.unmodifiableSet( result );
}

public Set<ContentClass> getContentClasses()
{
return Collections.unmodifiableSet( new HashSet<ContentClass>( contentClasses.values() ) );
}

public Set<String> getExistingRepositoryHints( String role )
{
if ( !getRepositoryRoles().contains( role ) )
{
return Collections.emptySet();
}

List<ComponentDescriptor<Repository>> components = container
.getComponentDescriptorList( Repository.class, role );
List<ComponentDescriptor<Repository>> components =
container.getComponentDescriptorList( Repository.class, role );

HashSet<String> result = new HashSet<String>( components.size() );

Expand All @@ -99,18 +108,26 @@ public ContentClass getRepositoryContentClass( String role, String hint )

if ( container.hasComponent( Repository.class, role, hint ) )
{
try
ComponentDescriptor<Repository> descriptor = container
.getComponentDescriptor( Repository.class, role, hint );

String contentClassHint = null;

for ( ComponentRequirement req : descriptor.getRequirements() )
{
// Note: this is very heavy to do on every call, we need some better solution.
// but if we think about plugins, and having runtime changes about available repository
// implementations...
Repository repository = container.lookup( Repository.class, role, hint );
if ( StringUtils.equals( ContentClass.class.getName(), req.getRole() ) )
{
// XXX: shadow has two of these!
contentClassHint = req.getRoleHint();
}
}

return repository.getRepositoryContentClass();
if ( contentClassHint != null )
{
return contentClasses.get( contentClassHint );
}
catch ( ComponentLookupException e )
else
{
// should not happen, we checked for it
return null;
}
}
Expand Down

0 comments on commit 7f63caa

Please sign in to comment.