change method to be able to retrieve artifacts

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1388175 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-09-20 19:42:46 +00:00
parent 8f64c48ccf
commit c747a1ffe8
3 changed files with 8 additions and 6 deletions

View File

@ -21,6 +21,7 @@ package org.apache.archiva.rest.api.services;
import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.maven2.model.Artifact;
import org.apache.archiva.maven2.model.TreeEntry; import org.apache.archiva.maven2.model.TreeEntry;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.redback.authorization.RedbackAuthorization; import org.apache.archiva.redback.authorization.RedbackAuthorization;
import org.apache.archiva.rest.api.model.ArtifactContent; import org.apache.archiva.rest.api.model.ArtifactContent;
@ -192,18 +193,18 @@ public interface BrowseService
@PathParam ("v") String version, @QueryParam ("repositoryId") String repositoryId ) @PathParam ("v") String version, @QueryParam ("repositoryId") String repositoryId )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ("artifactsNumber/{r}") @Path ("artifacts/{r}")
@GET @GET
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@RedbackAuthorization (noPermission = true, noRestriction = true) @RedbackAuthorization (noPermission = true, noRestriction = true)
/** /**
* *
* return artifacts number in a repository * return List of all artifacts from this repository
* @param repositoryId * @param repositoryId
* @return * @return
* @throws ArchivaRestServiceException * @throws ArchivaRestServiceException
* @since 1.4-M3 * @since 1.4-M3
*/ */
Integer getArtifactsNumber( @PathParam ( "r" ) String repositoryId ) List<Artifact> getArtifacts( @PathParam ( "r" ) String repositoryId )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
} }

View File

@ -830,13 +830,14 @@ public class DefaultBrowseService
return false; return false;
} }
public Integer getArtifactsNumber( String repositoryId ) public List<Artifact> getArtifacts( String repositoryId )
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {
RepositorySession repositorySession = repositorySessionFactory.createSession(); RepositorySession repositorySession = repositorySessionFactory.createSession();
try try
{ {
return repositorySession.getRepository().getArtifacts( repositoryId ).size(); List<ArtifactMetadata> artifactMetadatas = repositorySession.getRepository().getArtifacts( repositoryId );
return buildArtifacts( artifactMetadatas, repositoryId );
} }
catch ( MetadataRepositoryException e ) catch ( MetadataRepositoryException e )
{ {

View File

@ -447,7 +447,7 @@ public class BrowseServiceTest
try try
{ {
int number = browseService.getArtifactsNumber( testRepoId ); int number = browseService.getArtifacts( testRepoId ).size();
log.info( "getArtifactsNumber: {}", number ); log.info( "getArtifactsNumber: {}", number );