mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-932: Add getParameters() and setParameters() to GuacamoleConfiguration. Use where reasonable.
This commit is contained in:
@@ -162,4 +162,31 @@ public class GuacamoleConfiguration implements Serializable {
|
||||
return Collections.unmodifiableSet(parameters.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map which contains parameter name/value pairs as key/value
|
||||
* pairs. Changes to this map will affect the parameters stored within
|
||||
* this configuration.
|
||||
*
|
||||
* @return
|
||||
* A map which contains all parameter name/value pairs as key/value
|
||||
* pairs.
|
||||
*/
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all current parameters with the parameters defined within the
|
||||
* given map. Key/value pairs within the map represent parameter name/value
|
||||
* pairs.
|
||||
*
|
||||
* @param parameters
|
||||
* A map which contains all parameter name/value pairs as key/value
|
||||
* pairs.
|
||||
*/
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters.clear();
|
||||
this.parameters.putAll(parameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@
|
||||
package org.glyptodon.guacamole.net.basic.rest.connection;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
@@ -86,10 +85,8 @@ public class APIConnectionWrapper implements Connection {
|
||||
|
||||
// Add parameters, if available
|
||||
Map<String, String> parameters = apiConnection.getParameters();
|
||||
if (parameters != null) {
|
||||
for (Map.Entry<String, String> entry : parameters.entrySet())
|
||||
configuration.setParameter(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (parameters != null)
|
||||
configuration.setParameters(parameters);
|
||||
|
||||
return configuration;
|
||||
}
|
||||
@@ -97,14 +94,9 @@ public class APIConnectionWrapper implements Connection {
|
||||
@Override
|
||||
public void setConfiguration(GuacamoleConfiguration config) {
|
||||
|
||||
// Create a parameter map from the GuacamoleConfiguration
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
for (String key : config.getParameterNames())
|
||||
parameters.put(key, config.getParameter(key));
|
||||
|
||||
// Set protocol and parameters
|
||||
apiConnection.setProtocol(config.getProtocol());
|
||||
apiConnection.setParameters(parameters);
|
||||
apiConnection.setParameters(config.getParameters());
|
||||
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,6 @@
|
||||
package org.glyptodon.guacamole.net.basic.rest.connection;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.Consumes;
|
||||
@@ -147,12 +146,8 @@ public class ConnectionRESTService {
|
||||
// Retrieve connection configuration
|
||||
GuacamoleConfiguration config = connection.getConfiguration();
|
||||
|
||||
// Convert parameters to map
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
for (String key : config.getParameterNames())
|
||||
parameters.put(key, config.getParameter(key));
|
||||
|
||||
return parameters;
|
||||
// Return parameter map
|
||||
return config.getParameters();
|
||||
|
||||
}
|
||||
|
||||
@@ -350,11 +345,14 @@ public class ConnectionRESTService {
|
||||
if (existingConnection == null)
|
||||
throw new GuacamoleResourceNotFoundException("No such connection: \"" + connectionID + "\"");
|
||||
|
||||
Connection wrappedConnection = new APIConnectionWrapper(connection);
|
||||
// Retrieve connection configuration
|
||||
GuacamoleConfiguration config = new GuacamoleConfiguration();
|
||||
config.setProtocol(connection.getProtocol());
|
||||
config.setParameters(connection.getParameters());
|
||||
|
||||
// Update the connection
|
||||
existingConnection.setConfiguration(wrappedConnection.getConfiguration());
|
||||
existingConnection.setName(wrappedConnection.getName());
|
||||
existingConnection.setConfiguration(config);
|
||||
existingConnection.setName(connection.getName());
|
||||
connectionDirectory.update(existingConnection);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user