mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-1101: Add parameters upon insertion of new connection.
This commit is contained in:
@@ -163,16 +163,22 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void updateObject(AuthenticatedUser user, MySQLConnection object)
|
* Given an arbitrary Guacamole connection, produces a collection of
|
||||||
throws GuacamoleException {
|
* parameter model objects containing the name/value pairs of that
|
||||||
|
* connection's parameters.
|
||||||
|
*
|
||||||
|
* @param connection
|
||||||
|
* The connection whose configuration should be used to produce the
|
||||||
|
* collection of parameter models.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A collection of parameter models containing the name/value pairs
|
||||||
|
* of the given connection's parameters.
|
||||||
|
*/
|
||||||
|
private Collection<ParameterModel> getParameterModels(MySQLConnection connection) {
|
||||||
|
|
||||||
// Update connection
|
Map<String, String> parameters = connection.getConfiguration().getParameters();
|
||||||
super.updateObject(user, object);
|
|
||||||
|
|
||||||
// Get identifier and connection parameters
|
|
||||||
String identifier = object.getIdentifier();
|
|
||||||
Map<String, String> parameters = object.getConfiguration().getParameters();
|
|
||||||
|
|
||||||
// Convert parameters to model objects
|
// Convert parameters to model objects
|
||||||
Collection<ParameterModel> parameterModels = new ArrayList(parameters.size());
|
Collection<ParameterModel> parameterModels = new ArrayList(parameters.size());
|
||||||
@@ -188,7 +194,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
|||||||
|
|
||||||
// Produce model object from parameter
|
// Produce model object from parameter
|
||||||
ParameterModel model = new ParameterModel();
|
ParameterModel model = new ParameterModel();
|
||||||
model.setConnectionIdentifier(identifier);
|
model.setConnectionIdentifier(connection.getIdentifier());
|
||||||
model.setName(name);
|
model.setName(name);
|
||||||
model.setValue(value);
|
model.setValue(value);
|
||||||
|
|
||||||
@@ -197,8 +203,37 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parameterModels;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MySQLConnection createObject(AuthenticatedUser user, Connection object)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
// Create connection
|
||||||
|
MySQLConnection connection = super.createObject(user, object);
|
||||||
|
connection.setConfiguration(object.getConfiguration());
|
||||||
|
|
||||||
|
// Insert new parameters, if any
|
||||||
|
Collection<ParameterModel> parameterModels = getParameterModels(connection);
|
||||||
|
if (!parameterModels.isEmpty())
|
||||||
|
parameterMapper.insert(parameterModels);
|
||||||
|
|
||||||
|
return connection;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateObject(AuthenticatedUser user, MySQLConnection object)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
// Update connection
|
||||||
|
super.updateObject(user, object);
|
||||||
|
|
||||||
// Replace existing parameters with new parameters
|
// Replace existing parameters with new parameters
|
||||||
parameterMapper.delete(identifier);
|
Collection<ParameterModel> parameterModels = getParameterModels(object);
|
||||||
|
parameterMapper.delete(object.getIdentifier());
|
||||||
parameterMapper.insert(parameterModels);
|
parameterMapper.insert(parameterModels);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -327,11 +327,14 @@ public abstract class DirectoryObjectService<InternalType extends DirectoryObjec
|
|||||||
* @param object
|
* @param object
|
||||||
* The object to create.
|
* The object to create.
|
||||||
*
|
*
|
||||||
|
* @return
|
||||||
|
* The newly-created object.
|
||||||
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If the user lacks permission to create the object, or an error
|
* If the user lacks permission to create the object, or an error
|
||||||
* occurs while creating the object.
|
* occurs while creating the object.
|
||||||
*/
|
*/
|
||||||
public void createObject(AuthenticatedUser user, ExternalType object)
|
public InternalType createObject(AuthenticatedUser user, ExternalType object)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Only create object if user has permission to do so
|
// Only create object if user has permission to do so
|
||||||
@@ -341,10 +344,11 @@ public abstract class DirectoryObjectService<InternalType extends DirectoryObjec
|
|||||||
validateNewObject(user, object);
|
validateNewObject(user, object);
|
||||||
|
|
||||||
// Create object
|
// Create object
|
||||||
getObjectMapper().insert(getModelInstance(user, object));
|
ModelType model = getModelInstance(user, object);
|
||||||
|
getObjectMapper().insert(model);
|
||||||
|
|
||||||
// FIXME: Insert implicit object permissions, too.
|
// FIXME: Insert implicit object permissions, too.
|
||||||
return;
|
return getObjectInstance(user, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
// User lacks permission to create
|
// User lacks permission to create
|
||||||
|
Reference in New Issue
Block a user