mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
Merge pull request #302 from glyptodon/GUAC-1429
GUAC-1429: Return whole objects instead of identifiers to fix text/plain conversion error.
This commit is contained in:
@@ -32,6 +32,7 @@ import org.glyptodon.guacamole.GuacamoleSecurityException;
|
|||||||
import org.glyptodon.guacamole.auth.jdbc.permission.ObjectPermissionMapper;
|
import org.glyptodon.guacamole.auth.jdbc.permission.ObjectPermissionMapper;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.permission.ObjectPermissionModel;
|
import org.glyptodon.guacamole.auth.jdbc.permission.ObjectPermissionModel;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.user.UserModel;
|
import org.glyptodon.guacamole.auth.jdbc.user.UserModel;
|
||||||
|
import org.glyptodon.guacamole.net.auth.Identifiable;
|
||||||
import org.glyptodon.guacamole.net.auth.permission.ObjectPermission;
|
import org.glyptodon.guacamole.net.auth.permission.ObjectPermission;
|
||||||
import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
|||||||
* database.
|
* database.
|
||||||
*/
|
*/
|
||||||
public abstract class ModeledDirectoryObjectService<InternalType extends ModeledDirectoryObject<ModelType>,
|
public abstract class ModeledDirectoryObjectService<InternalType extends ModeledDirectoryObject<ModelType>,
|
||||||
ExternalType, ModelType extends ObjectModel>
|
ExternalType extends Identifiable, ModelType extends ObjectModel>
|
||||||
implements DirectoryObjectService<InternalType, ExternalType> {
|
implements DirectoryObjectService<InternalType, ExternalType> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -384,6 +385,9 @@ public abstract class ModeledDirectoryObjectService<InternalType extends Modeled
|
|||||||
// Create object
|
// Create object
|
||||||
getObjectMapper().insert(model);
|
getObjectMapper().insert(model);
|
||||||
|
|
||||||
|
// Set identifier on original object
|
||||||
|
object.setIdentifier(model.getIdentifier());
|
||||||
|
|
||||||
// Add implicit permissions
|
// Add implicit permissions
|
||||||
getPermissionMapper().insert(getImplicitPermissions(user, model));
|
getPermissionMapper().insert(getImplicitPermissions(user, model));
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ import java.util.Collections;
|
|||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.GuacamoleSecurityException;
|
import org.glyptodon.guacamole.GuacamoleSecurityException;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
|
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
|
||||||
|
import org.glyptodon.guacamole.net.auth.Identifiable;
|
||||||
import org.glyptodon.guacamole.net.auth.permission.ObjectPermission;
|
import org.glyptodon.guacamole.net.auth.permission.ObjectPermission;
|
||||||
import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
|||||||
* database.
|
* database.
|
||||||
*/
|
*/
|
||||||
public abstract class ModeledGroupedDirectoryObjectService<InternalType extends ModeledGroupedDirectoryObject<ModelType>,
|
public abstract class ModeledGroupedDirectoryObjectService<InternalType extends ModeledGroupedDirectoryObject<ModelType>,
|
||||||
ExternalType, ModelType extends GroupedObjectModel>
|
ExternalType extends Identifiable, ModelType extends GroupedObjectModel>
|
||||||
extends ModeledDirectoryObjectService<InternalType, ExternalType, ModelType> {
|
extends ModeledDirectoryObjectService<InternalType, ExternalType, ModelType> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -28,16 +28,15 @@ import org.glyptodon.guacamole.GuacamoleException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to a collection of all objects with associated identifiers,
|
* Provides access to a collection of all objects with associated identifiers,
|
||||||
* and allows user manipulation and removal. Objects stored within a
|
* and allows user manipulation and removal. Objects returned by a Directory
|
||||||
* Directory are not necessarily returned to the use as references to
|
* are not necessarily backed by the stored objects, thus updating an object
|
||||||
* the stored objects, thus updating an object requires calling an update
|
* always requires calling the update() function.
|
||||||
* function.
|
|
||||||
*
|
*
|
||||||
* @author Michael Jumper
|
* @author Michael Jumper
|
||||||
* @param <ObjectType>
|
* @param <ObjectType>
|
||||||
* The type of objects stored within this Directory.
|
* The type of objects stored within this Directory.
|
||||||
*/
|
*/
|
||||||
public interface Directory<ObjectType> {
|
public interface Directory<ObjectType extends Identifiable> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the object having the given identifier. Note that changes to
|
* Returns the object having the given identifier. Note that changes to
|
||||||
@@ -91,12 +90,16 @@ public interface Directory<ObjectType> {
|
|||||||
Set<String> getIdentifiers() throws GuacamoleException;
|
Set<String> getIdentifiers() throws GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given object to the overall set.
|
* Adds the given object to the overall set. If a new identifier is
|
||||||
|
* created for the added object, that identifier will be automatically
|
||||||
|
* assigned via setIdentifier().
|
||||||
*
|
*
|
||||||
* @param object The object to add.
|
* @param object
|
||||||
|
* The object to add.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException If an error occurs while adding the object , or
|
* @throws GuacamoleException
|
||||||
* if adding the object is not allowed.
|
* If an error occurs while adding the object, or if adding the object
|
||||||
|
* is not allowed.
|
||||||
*/
|
*/
|
||||||
void add(ObjectType object)
|
void add(ObjectType object)
|
||||||
throws GuacamoleException;
|
throws GuacamoleException;
|
||||||
|
@@ -30,6 +30,7 @@ import java.util.Set;
|
|||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.GuacamoleSecurityException;
|
import org.glyptodon.guacamole.GuacamoleSecurityException;
|
||||||
import org.glyptodon.guacamole.net.auth.Directory;
|
import org.glyptodon.guacamole.net.auth.Directory;
|
||||||
|
import org.glyptodon.guacamole.net.auth.Identifiable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extremely simple read-only implementation of a Directory which provides
|
* An extremely simple read-only implementation of a Directory which provides
|
||||||
@@ -40,7 +41,8 @@ import org.glyptodon.guacamole.net.auth.Directory;
|
|||||||
* @param <ObjectType>
|
* @param <ObjectType>
|
||||||
* The type of objects stored within this SimpleDirectory.
|
* The type of objects stored within this SimpleDirectory.
|
||||||
*/
|
*/
|
||||||
public class SimpleDirectory<ObjectType> implements Directory<ObjectType> {
|
public class SimpleDirectory<ObjectType extends Identifiable>
|
||||||
|
implements Directory<ObjectType> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Map of objects to provide access to.
|
* The Map of objects to provide access to.
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -145,8 +145,8 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Set the identifier on the new connection group and clear the cache
|
// Set the identifier on the new connection group and clear the cache
|
||||||
.success(function connectionGroupCreated(identifier){
|
.success(function connectionGroupCreated(newConnectionGroup){
|
||||||
connectionGroup.identifier = identifier;
|
connectionGroup.identifier = newConnectionGroup.identifier;
|
||||||
cacheService.connections.removeAll();
|
cacheService.connections.removeAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -152,8 +152,8 @@ angular.module('rest').factory('connectionService', ['$injector',
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Set the identifier on the new connection and clear the cache
|
// Set the identifier on the new connection and clear the cache
|
||||||
.success(function connectionCreated(identifier){
|
.success(function connectionCreated(newConnection){
|
||||||
connection.identifier = identifier;
|
connection.identifier = newConnection.identifier;
|
||||||
cacheService.connections.removeAll();
|
cacheService.connections.removeAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user