GUAC-932: Send individual patch operations for permission types.

This commit is contained in:
Michael Jumper
2014-12-18 21:08:30 -08:00
parent b517354cea
commit e16ba11899
2 changed files with 22 additions and 16 deletions

View File

@@ -104,6 +104,10 @@ angular.module('rest').factory('permissionService', ['$http', 'authenticationSer
* @param {String} operation
* The operation to specify within each of the patches. Valid values
* for this are defined within PermissionPatch.Operation.
*
* @param {String} path
* The path of the permissions being patched. The path is a JSON path
* describing the position of the permissions within a PermissionSet.
*
* @param {Object.<String, String[]>} permissions
* A map of object identifiers to arrays of permission type strings,
@@ -114,10 +118,12 @@ angular.module('rest').factory('permissionService', ['$http', 'authenticationSer
// Add object permission operations to patch
for (var identifier in permissions) {
patch.push({
op : operation,
path : path + "/" + identifier,
value : permissions[identifier]
permissions[identifier].forEach(function addObjectPatch(type) {
patch.push({
op : operation,
path : path + "/" + identifier,
value : type
});
});
}
@@ -152,13 +158,13 @@ angular.module('rest').factory('permissionService', ['$http', 'authenticationSer
permissions.userPermissions);
// Add system operations to patch
if (permissions.systemPermissions.length) {
permissions.systemPermissions.forEach(function addSystemPatch(type) {
patch.push({
op : operation,
path : "/systemPermissions",
value : permissions.systemPermissions
value : type
});
}
});
};

View File

@@ -59,15 +59,15 @@ angular.module('rest').factory('PermissionPatch', [function definePermissionPatc
this.path = template.path;
/**
* The array of permissions. If the permission applies to an object,
* such as a connection or connection group, these will be values from
* PermissionSet.ObjectPermissionType. If the permission applies to
* the system as a whole (the path is "/systemPermissions"), these will
* be values from PermissionSet.SystemPermissionType.
* The permissions being added or removed. If the permission applies to
* an object, such as a connection or connection group, this will be a
* value from PermissionSet.ObjectPermissionType. If the permission
* applies to the system as a whole (the path is "/systemPermissions"),
* this will be a value from PermissionSet.SystemPermissionType.
*
* @type String[]
* @type String
*/
this.value = template.value || [];
this.value = template.value;
};
@@ -78,12 +78,12 @@ angular.module('rest').factory('PermissionPatch', [function definePermissionPatc
PermissionPatch.Operation = {
/**
* Adds (grants) the specified permissions.
* Adds (grants) the specified permission.
*/
ADD : "add",
/**
* Removes (revokes) the specified permissions.
* Removes (revokes) the specified permission.
*/
REMOVE : "remove"