GUAC-932: Add permission filtering to recursive connection group query.

This commit is contained in:
Michael Jumper
2014-12-16 21:30:54 -08:00
parent 21ee9073d0
commit ef5a9f9600
2 changed files with 78 additions and 21 deletions

View File

@@ -32,34 +32,55 @@ angular.module('rest').factory('connectionGroupService', ['$http', 'authenticati
* Makes a request to the REST API to get an individual connection group
* and all descendants, returning a promise that provides the corresponding
* @link{ConnectionGroup} if successful. Descendant groups and connections
* will be stored as children of that connection group.
* will be stored as children of that connection group. If a permission
* type is specified, the result will be filtering by that permission.
*
* @param {String} [connectionGroupID=ConnectionGroup.ROOT_IDENTIFIER]
* The ID of the connection group to retrieve. If not provided, the
* root connection group will be retrieved by default.
*
*
* @param {String} [permissionType]
* The permission type string of the permission that the current user
* must have for a given connection or connection group to appear
* within the result. Valid values are listed within
* PermissionSet.ObjectType.
*
* @returns {Promise.ConnectionGroup}
* A promise which will resolve with a @link{ConnectionGroup} upon
* success.
*/
service.getConnectionGroupTree = function getConnectionGroupTree(connectionGroupID) {
service.getConnectionGroupTree = function getConnectionGroupTree(connectionGroupID, permissionType) {
// Use the root connection group ID if no ID is passed in
connectionGroupID = connectionGroupID || ConnectionGroup.ROOT_IDENTIFIER;
return $http.get("api/connectionGroup/" + connectionGroupID + "/tree?token=" + authenticationService.getCurrentToken());
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Add permission filter if specified
if (permissionType)
httpParameters.permission = permissionType;
// Retrieve connection group
return $http({
method : 'GET',
url : 'api/connectionGroup/' + encodeURIComponent(connectionGroupID) + '/tree',
params : httpParameters
});
};
/**
* Makes a request to the REST API to get an individual connection group,
* returning a promise that provides the corresponding
* @link{ConnectionGroup} if successful.
*
*
* @param {String} [connectionGroupID=ConnectionGroup.ROOT_IDENTIFIER]
* The ID of the connection group to retrieve. If not provided, the
* root connection group will be retrieved by default.
*
*
* @returns {Promise.<ConnectionGroup>} A promise for the HTTP call.
* A promise which will resolve with a @link{ConnectionGroup} upon
* success.
@@ -69,7 +90,17 @@ angular.module('rest').factory('connectionGroupService', ['$http', 'authenticati
// Use the root connection group ID if no ID is passed in
connectionGroupID = connectionGroupID || ConnectionGroup.ROOT_IDENTIFIER;
return $http.get("api/connectionGroup/" + connectionGroupID + "?token=" + authenticationService.getCurrentToken());
// Build HTTP parameters set
var httpParameters = {
token : authenticationService.getCurrentToken()
};
// Retrieve connection group
return $http({
method : 'GET',
url : 'api/connectionGroup/' + encodeURIComponent(connectionGroupID),
params : httpParameters
});
};