GUAC-1429: Return whole objects instead of identifiers to fix text/plain conversion error.

This commit is contained in:
James Muehlner
2015-12-09 22:22:34 -08:00
parent 8cf4b61720
commit 86841ebfe3
3 changed files with 17 additions and 21 deletions

View File

@@ -249,8 +249,8 @@ public class ConnectionRESTService {
} }
/** /**
* Creates a new connection and returns the identifier of the new * Creates a new connection and returns the new connection, with identifier
* connection. * field populated.
* *
* @param authToken * @param authToken
* The authentication token that is used to authenticate the user * The authentication token that is used to authenticate the user
@@ -264,14 +264,13 @@ public class ConnectionRESTService {
* The connection to create. * The connection to create.
* *
* @return * @return
* The identifier of the new connection. * The new connection.
* *
* @throws GuacamoleException * @throws GuacamoleException
* If an error occurs while creating the connection. * If an error occurs while creating the connection.
*/ */
@POST @POST
@Produces(MediaType.TEXT_PLAIN) public APIConnection createConnection(@QueryParam("token") String authToken,
public String createConnection(@QueryParam("token") String authToken,
@PathParam("dataSource") String authProviderIdentifier, @PathParam("dataSource") String authProviderIdentifier,
APIConnection connection) throws GuacamoleException { APIConnection connection) throws GuacamoleException {
@@ -286,8 +285,8 @@ public class ConnectionRESTService {
Directory<Connection> connectionDirectory = userContext.getConnectionDirectory(); Directory<Connection> connectionDirectory = userContext.getConnectionDirectory();
connectionDirectory.add(new APIConnectionWrapper(connection)); connectionDirectory.add(new APIConnectionWrapper(connection));
// Return the new connection identifier // Return the new connection
return connection.getIdentifier(); return connection;
} }

View File

@@ -190,10 +190,8 @@ public class ConnectionGroupRESTService {
} }
/** /**
* Creates a new connection group and returns the identifier of the new connection group. * Creates a new connection group and returns the new connection group,
* If a parentID is provided, the connection group will be created in the * with identifier field populated.
* connection group with the parentID. Otherwise, the root connection group
* will be used.
* *
* @param authToken * @param authToken
* The authentication token that is used to authenticate the user * The authentication token that is used to authenticate the user
@@ -207,14 +205,14 @@ public class ConnectionGroupRESTService {
* The connection group to create. * The connection group to create.
* *
* @return * @return
* The identifier of the new connection group. * The new connection group.
* *
* @throws GuacamoleException * @throws GuacamoleException
* If an error occurs while creating the connection group. * If an error occurs while creating the connection group.
*/ */
@POST @POST
@Produces(MediaType.TEXT_PLAIN) public APIConnectionGroup createConnectionGroup(
public String createConnectionGroup(@QueryParam("token") String authToken, @QueryParam("token") String authToken,
@PathParam("dataSource") String authProviderIdentifier, @PathParam("dataSource") String authProviderIdentifier,
APIConnectionGroup connectionGroup) throws GuacamoleException { APIConnectionGroup connectionGroup) throws GuacamoleException {
@@ -229,8 +227,8 @@ public class ConnectionGroupRESTService {
Directory<ConnectionGroup> connectionGroupDirectory = userContext.getConnectionGroupDirectory(); Directory<ConnectionGroup> connectionGroupDirectory = userContext.getConnectionGroupDirectory();
connectionGroupDirectory.add(new APIConnectionGroupWrapper(connectionGroup)); connectionGroupDirectory.add(new APIConnectionGroupWrapper(connectionGroup));
// Return the new connection group identifier // Return the new connection group
return connectionGroup.getIdentifier(); return connectionGroup;
} }

View File

@@ -217,7 +217,7 @@ public class UserRESTService {
} }
/** /**
* Creates a new user and returns the username. * Creates a new user and returns the user that was created.
* *
* @param authToken * @param authToken
* The authentication token that is used to authenticate the user * The authentication token that is used to authenticate the user
@@ -234,11 +234,10 @@ public class UserRESTService {
* If a problem is encountered while creating the user. * If a problem is encountered while creating the user.
* *
* @return * @return
* The username of the newly created user. * The newly created user.
*/ */
@POST @POST
@Produces(MediaType.TEXT_PLAIN) public APIUser createUser(@QueryParam("token") String authToken,
public String createUser(@QueryParam("token") String authToken,
@PathParam("dataSource") String authProviderIdentifier, APIUser user) @PathParam("dataSource") String authProviderIdentifier, APIUser user)
throws GuacamoleException { throws GuacamoleException {
@@ -255,7 +254,7 @@ public class UserRESTService {
// Create the user // Create the user
userDirectory.add(new APIUserWrapper(user)); userDirectory.add(new APIUserWrapper(user));
return user.getUsername(); return user;
} }