From 7a0dd884f3fd2b39004210b051c7fe8cc99fadfb Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 7 Aug 2016 19:22:17 -0700 Subject: [PATCH] GUACAMOLE-5: Add sharing profile attributes to schema resource. --- .../guacamole/rest/schema/SchemaResource.java | 20 +++++++++++ .../webapp/app/rest/services/schemaService.js | 34 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/schema/SchemaResource.java b/guacamole/src/main/java/org/apache/guacamole/rest/schema/SchemaResource.java index f0fcc8694..ed443b15c 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/schema/SchemaResource.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/schema/SchemaResource.java @@ -99,6 +99,26 @@ public class SchemaResource { } + /** + * Retrieves the possible attributes of a sharing profile object. + * + * @return + * A collection of forms which describe the possible attributes of a + * sharing profile object. + * + * @throws GuacamoleException + * If an error occurs while retrieving the possible attributes. + */ + @GET + @Path("sharingProfileAttributes") + public Collection
getSharingProfileAttributes() + throws GuacamoleException { + + // Retrieve all possible sharing profile attributes + return userContext.getSharingProfileAttributes(); + + } + /** * Retrieves the possible attributes of a connection group object. * diff --git a/guacamole/src/main/webapp/app/rest/services/schemaService.js b/guacamole/src/main/webapp/app/rest/services/schemaService.js index f0db23fe0..851bffed6 100644 --- a/guacamole/src/main/webapp/app/rest/services/schemaService.js +++ b/guacamole/src/main/webapp/app/rest/services/schemaService.js @@ -98,6 +98,40 @@ angular.module('rest').factory('schemaService', ['$injector', }; + /** + * Makes a request to the REST API to get the list of available attributes + * for sharing profile objects, returning a promise that provides an array + * of @link{Form} objects if successful. Each element of the array describes + * a logical grouping of possible attributes. + * + * @param {String} dataSource + * The unique identifier of the data source containing the sharing + * profiles whose available attributes are to be retrieved. This + * identifier corresponds to an AuthenticationProvider within the + * Guacamole web application. + * + * @returns {Promise.} + * A promise which will resolve with an array of @link{Form} + * objects, where each @link{Form} describes a logical grouping of + * possible attributes. + */ + service.getSharingProfileAttributes = function getSharingProfileAttributes(dataSource) { + + // Build HTTP parameters set + var httpParameters = { + token : authenticationService.getCurrentToken() + }; + + // Retrieve available sharing profile attributes + return $http({ + cache : cacheService.schema, + method : 'GET', + url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/sharingProfileAttributes', + params : httpParameters + }); + + }; + /** * Makes a request to the REST API to get the list of available attributes * for connection group objects, returning a promise that provides an array