From ed23ae3a2577ff3f2471ff0256ed4ef8b4f2edb5 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 12 Dec 2014 09:55:07 -0800 Subject: [PATCH] GUAC-932: Update protocol service to use Protocol class. Remove single permission add/remove from REST service. --- .../permission/PermissionRESTService.java | 59 ------------------- .../app/rest/services/protocolService.js | 10 +++- 2 files changed, 7 insertions(+), 62 deletions(-) diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/permission/PermissionRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/permission/PermissionRESTService.java index 08e49812b..573763437 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/permission/PermissionRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/permission/PermissionRESTService.java @@ -101,65 +101,6 @@ public class PermissionRESTService { } - /** - * Adds a permissions for a user with the given userID. - * - * @param authToken The authentication token that is used to authenticate - * the user performing the operation. - * @param userID The user ID to add the permission for. - * @param permission The permission to add for the user with the given userID. - * @throws GuacamoleException If a problem is encountered while adding the permission. - */ - @POST - @Path("/{userID}") - @AuthProviderRESTExposure - public void addPermission(@QueryParam("token") String authToken, - @PathParam("userID") String userID, APIPermission permission) - throws GuacamoleException { - - UserContext userContext = authenticationService.getUserContext(authToken); - - // Get the user - User user = userContext.getUserDirectory().get(userID); - if (user == null) - throw new HTTPException(Status.NOT_FOUND, "User not found with the provided userID."); - - // Add the new permission - user.addPermission(permission.toPermission()); - userContext.getUserDirectory().update(user); - - } - - /** - * Removes a permissions for a user with the given userID. - * - * @param authToken The authentication token that is used to authenticate - * the user performing the operation. - * @param userID The user ID to remove the permission for. - * @param permission The permission to remove for the user with the given userID. - * @throws GuacamoleException If a problem is encountered while removing the permission. - */ - @POST - @Path("/remove/{userID}/") - @AuthProviderRESTExposure - public void removePermission(@QueryParam("token") String authToken, - @PathParam("userID") String userID, APIPermission permission) - throws GuacamoleException { - - UserContext userContext = authenticationService.getUserContext(authToken); - - // Get the user - User user = userContext.getUserDirectory().get(userID); - if (user == null) - throw new HTTPException(Status.NOT_FOUND, "User not found with the provided userID."); - - // Remove the permission - user.removePermission(permission.toPermission()); - userContext.getUserDirectory().update(user); - - } - - /** * Applies a given list of permission patches. * diff --git a/guacamole/src/main/webapp/app/rest/services/protocolService.js b/guacamole/src/main/webapp/app/rest/services/protocolService.js index a2a4a5d51..3a3180750 100644 --- a/guacamole/src/main/webapp/app/rest/services/protocolService.js +++ b/guacamole/src/main/webapp/app/rest/services/protocolService.js @@ -28,14 +28,18 @@ angular.module('rest').factory('protocolService', ['$http', function protocolSer var service = {}; /** - * Makes a request to the REST API to get the list of protocols, - * returning a promise that can be used for processing the results of the call. + * Makes a request to the REST API to get the list of protocols, returning + * a promise that provides an array of @link{Protocol} objects if + * successful. * - * @returns {promise} A promise for the HTTP call. + * @returns {Promise.} + * A promise which will resolve with an array of @link{Protocol} + * objects upon success. */ service.getProtocols = function getProtocols() { return $http.get("api/protocol"); }; return service; + }]);