use selected repository to get versionList and projectMetadata

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1301615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-16 16:08:52 +00:00
parent 0f37a939f8
commit 8e08552d4c
3 changed files with 37 additions and 6 deletions

View File

@ -58,7 +58,8 @@ public interface BrowseService
@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 )
VersionsList getVersionsList( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId ) VersionsList getVersionsList( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId,
@QueryParam( "repositoryId" ) String repositoryId )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path( "projectVersionMetadata/{g}/{a}" ) @Path( "projectVersionMetadata/{g}/{a}" )
@ -66,7 +67,8 @@ public interface BrowseService
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( noPermission = true, noRestriction = true ) @RedbackAuthorization( noPermission = true, noRestriction = true )
ProjectVersionMetadata getProjectVersionMetadata( @PathParam( "g" ) String groupId, ProjectVersionMetadata getProjectVersionMetadata( @PathParam( "g" ) String groupId,
@PathParam( "a" ) String artifactId ) @PathParam( "a" ) String artifactId,
@QueryParam( "repositoryId" ) String repositoryId )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path( "userRepositories" ) @Path( "userRepositories" )

View File

@ -189,7 +189,7 @@ public class DefaultBrowseService
} }
public VersionsList getVersionsList( String groupId, String artifactId ) public VersionsList getVersionsList( String groupId, String artifactId, String repositoryId )
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {
List<String> selectedRepos = getObservableRepos(); List<String> selectedRepos = getObservableRepos();
@ -199,6 +199,17 @@ public class DefaultBrowseService
return new VersionsList(); return new VersionsList();
} }
if ( StringUtils.isNotEmpty( repositoryId ) )
{
// check user has karma on the repository
if ( !selectedRepos.contains( repositoryId ) )
{
throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
Response.Status.FORBIDDEN.getStatusCode() );
}
selectedRepos = Collections.singletonList( repositoryId );
}
try try
{ {
return new VersionsList( new ArrayList<String>( getVersions( selectedRepos, groupId, artifactId ) ) ); return new VersionsList( new ArrayList<String>( getVersions( selectedRepos, groupId, artifactId ) ) );
@ -240,7 +251,7 @@ public class DefaultBrowseService
} }
} }
public ProjectVersionMetadata getProjectVersionMetadata( String groupId, String artifactId ) public ProjectVersionMetadata getProjectVersionMetadata( String groupId, String artifactId, String repositoryId )
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {
@ -252,6 +263,17 @@ public class DefaultBrowseService
return null; return null;
} }
if ( StringUtils.isNotEmpty( repositoryId ) )
{
// check user has karma on the repository
if ( !selectedRepos.contains( repositoryId ) )
{
throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied",
Response.Status.FORBIDDEN.getStatusCode() );
}
selectedRepos = Collections.singletonList( repositoryId );
}
RepositorySession repositorySession = null; RepositorySession repositorySession = null;
try try
{ {

View File

@ -148,12 +148,19 @@ $(function() {
mainContent.find("#browse_artifact").show(); mainContent.find("#browse_artifact").show();
mainContent.find("#browse_artifact").html(mediumSpinnerImg()); mainContent.find("#browse_artifact").html(mediumSpinnerImg());
mainContent.find("#main_browse_result_content").show(); mainContent.find("#main_browse_result_content").show();
$.ajax("restServices/archivaServices/browseService/projectVersionMetadata/"+encodeURIComponent(groupId)+"/"+encodeURIComponent(artifactId), { var metadataUrl="restServices/archivaServices/browseService/projectVersionMetadata/"+encodeURIComponent(groupId)+"/"+encodeURIComponent(artifactId);
var versionsListUrl="restServices/archivaServices/browseService/versionsList/"+encodeURIComponent(groupId)+"/"+encodeURIComponent(artifactId);
var selectedRepo=getSelectedBrowsingRepository();
if (selectedRepo){
metadataUrl+="?repositoryId="+encodeURIComponent(selectedRepo);
versionsListUrl+="?repositoryId="+encodeURIComponent(selectedRepo);
}
$.ajax(metadataUrl, {
type: "GET", type: "GET",
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
artifactDetailViewModel.projectVersionMetadata=mapProjectVersionMetadata(data); artifactDetailViewModel.projectVersionMetadata=mapProjectVersionMetadata(data);
$.ajax("restServices/archivaServices/browseService/versionsList/"+encodeURIComponent(groupId)+"/"+encodeURIComponent(artifactId), { $.ajax(versionsListUrl, {
type: "GET", type: "GET",
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {