import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List;
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( noPermission = true, noRestriction = true )
- BrowseResult getRootGroups()
+ BrowseResult getRootGroups( @QueryParam( "repositoryId" ) String repositoryId )
throws ArchivaRestServiceException;
@Path( "browseGroupId/{groupId}" )
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( noPermission = true, noRestriction = true )
- BrowseResult browseGroupId( @PathParam( "groupId" ) String groupId )
+ BrowseResult browseGroupId( @PathParam( "groupId" ) String groupId,
+ @QueryParam( "repositoryId" ) String repositoryId )
throws ArchivaRestServiceException;
@Path( "versionsList/{g}/{a}" )
implements BrowseService
{
- public BrowseResult getRootGroups()
+ public BrowseResult getRootGroups( String repositoryId )
throws ArchivaRestServiceException
{
List<String> selectedRepos = getObservableRepos();
return new BrowseResult();
}
+ 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 );
+ }
+
Set<String> namespaces = new LinkedHashSet<String>();
// TODO: this logic should be optional, particularly remembering we want to keep this code simple
{
MetadataResolver metadataResolver = repositorySession.getResolver();
namespacesToCollapse = new LinkedHashSet<String>();
+
for ( String repoId : selectedRepos )
{
namespacesToCollapse.addAll( metadataResolver.resolveRootNamespaces( repositorySession, repoId ) );
return new BrowseResult( browseGroupResultEntries );
}
- public BrowseResult browseGroupId( String groupId )
+ public BrowseResult browseGroupId( String groupId, String repositoryId )
throws ArchivaRestServiceException
{
return new BrowseResult();
}
+ 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 );
+ }
+
Set<String> projects = new LinkedHashSet<String>();
RepositorySession repositorySession = repositorySessionFactory.createSession();
*/
require( ["order!jquery" ,"order!redback/redback"],
function($) {
- "use strict"
+
$(function() {
// define a container object with various datas
* reccord a cookie for session with the logged user
* @param user see user.js
*/
- function reccordLoginCookie(user) {
+ reccordLoginCookie=function(user) {
$.cookie('redback_login', ko.toJSON(user));
}
- function getUserFromLoginCookie(){
+ getUserFromLoginCookie=function(){
return $.parseJSON($.cookie('redback_login'));
}
- function deleteLoginCookie(){
+ deleteLoginCookie=function(){
$.cookie('redback_login', null);
}
- function logout(screenChange){
+ logout=function(doScreenChange){
deleteLoginCookie();
$("#login-link").show();
$("#register-link").show();
$("#logout-link").hide();
$("#change-password-link").hide();
hideElementWithKarma();
- if (screenChange) screenChange();
+ if (doScreenChange) screenChange();
$("#main-content").html("");
$.ajax({
url: 'restServices/redbackServices/loginService/logout'
}
// handle url with registration link
- function checkUrlParams() {
+ checkUrlParams=function(){
var validateMeId = $.urlParam('validateMe');
if (validateMeId) {
validateKey(validateMeId);
return;
}
if (screen=="browse"){
- displayBrowse();
+ displayBrowse(true);
return;
}
}
displaySearch();
}
- function hasKarma(karmaName){
+ hasKarma=function(karmaName){
return $.inArray(karmaName,window.redbackModel.operatioNames)>=0;
}
- function decorateMenuWithKarma(user) {
+ decorateMenuWithKarma=function(user) {
var username = user.username;
$.log("decorateMenuWithKarma");
// we can receive an observable user so take if it's a function or not
});
}
- function checkElementKarma(element){
+ checkElementKarma=function(element){
var bindingValue = $(element).attr("redback-permissions");
$(element).hide();
var neededKarmas = $(eval(bindingValue)).toArray();
}
}
- function hideElementWithKarma(){
+ hideElementWithKarma=function(){
$("#topbar-menu-container [redback-permissions]").each(function(element){
$(this).hide();
});
$.log("hideElementWithKarma");
}
- function userLoggedCallbackFn(user){
+ userLoggedCallbackFn=function(user){
$.log("userLoggedCallbackFn:"+ (user?user.username:null));
if (!user) {
}
}
- function checkSecurityLinks(){
+ checkSecurityLinks=function(){
userLogged(userLoggedCallbackFn);
}
- function checkCreateAdminLink(){
+ checkCreateAdminLink=function(){
$.ajax("restServices/redbackServices/userService/isAdminUserExists", {
type: "GET",
dataType: 'json',
- function startArchivaApplication(){
+ startArchivaApplication=function(){
$.log("startArchivaApplication");
$('#topbar-menu-container').html($("#topbar-menu"));
$('#sidebar-content').html($("#main-menu"));
};;
}
-
-
startArchivaApplication();
-
-
})
});
/**
* call from menu entry to display root level
*/
- displayBrowse=function(){
+ displayBrowse=function(freshView){
screenChange()
var mainContent = $("#main-content");
- mainContent.html($("#browse-tmpl" ).tmpl());
+ if(freshView){
+ mainContent.html($("#browse-tmpl" ).tmpl());
+ }
mainContent.find("#browse_result").html(mediumSpinnerImg());
$.ajax("restServices/archivaServices/browseService/userRepositories", {
type: "GET",
dataType: 'json',
success: function(data) {
- mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data}));// selected_repository_tmpl
- $.ajax("restServices/archivaServices/browseService/rootGroups", {
+ mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data}));
+ var url="restServices/archivaServices/browseService/rootGroups"
+ $.ajax(url, {
type: "GET",
dataType: 'json',
success: function(data) {
}
});
+ }
+ changeBrowseRepository=function(){
+ var selectedRepository=getSelectedBrowsingRepository();
+ //displayBrowse(false,selectedRepository);
+ displayGroupDetail(null,null,"restServices/archivaServices/browseService/rootGroups?repositoryId="+encodeURIComponent(selectedRepository));
+ }
+ getSelectedBrowsingRepository=function(){
+ var selectedOption=$("#main-content #select_browse_repository option:selected" );
+ if (selectedOption.length>0){
+ var repoId=selectedOption.val();
+ $.log("getSelectedBrowsingRepository:"+repoId);
+ return repoId;
+ }
+ $.log("getSelectedBrowsingRepository:none");
}
enableAutocompleBrowse=function(groupId){
displayBrowseGroupIdFromAutoComplete=function(groupId){
clearUserMessages();
var mainContent = $("#main-content");
- //mainContent.html($("#browse-tmpl" ).tmpl());
mainContent.find("#browse_result").html(mediumSpinnerImg());
var parentBrowseViewModel=new BrowseViewModel(null,null,null);
displayGroupDetail(groupId,parentBrowseViewModel,null);
<a href="#" id="menu-find-search-a" onclick="displaySearch(this)">${$.i18n.prop('menu.artifacts.search')}</a>
</li>
<li>
- <a href="#" id="menu-find-browse-a" onclick="displayBrowse()">${$.i18n.prop('menu.artifacts.browse')}</a>
+ <a href="#" id="menu-find-browse-a" onclick="displayBrowse(true)">${$.i18n.prop('menu.artifacts.browse')}</a>
</li>
</ul>
<script id="selected_repository_tmpl" type="text/html">
- <select id="repository">
+ <select id="select_browse_repository" onchange="changeBrowseRepository()">
<option value="">All</option>
{{each(i,repository) repositories}}
<option value="${repository.id}">${repository.name}</option>