mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +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());
|
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;
|
package org.glyptodon.guacamole.net.basic.rest.connection;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
@@ -86,10 +85,8 @@ public class APIConnectionWrapper implements Connection {
|
|||||||
|
|
||||||
// Add parameters, if available
|
// Add parameters, if available
|
||||||
Map<String, String> parameters = apiConnection.getParameters();
|
Map<String, String> parameters = apiConnection.getParameters();
|
||||||
if (parameters != null) {
|
if (parameters != null)
|
||||||
for (Map.Entry<String, String> entry : parameters.entrySet())
|
configuration.setParameters(parameters);
|
||||||
configuration.setParameter(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
@@ -97,14 +94,9 @@ public class APIConnectionWrapper implements Connection {
|
|||||||
@Override
|
@Override
|
||||||
public void setConfiguration(GuacamoleConfiguration config) {
|
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
|
// Set protocol and parameters
|
||||||
apiConnection.setProtocol(config.getProtocol());
|
apiConnection.setProtocol(config.getProtocol());
|
||||||
apiConnection.setParameters(parameters);
|
apiConnection.setParameters(config.getParameters());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
package org.glyptodon.guacamole.net.basic.rest.connection;
|
package org.glyptodon.guacamole.net.basic.rest.connection;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
@@ -147,12 +146,8 @@ public class ConnectionRESTService {
|
|||||||
// Retrieve connection configuration
|
// Retrieve connection configuration
|
||||||
GuacamoleConfiguration config = connection.getConfiguration();
|
GuacamoleConfiguration config = connection.getConfiguration();
|
||||||
|
|
||||||
// Convert parameters to map
|
// Return parameter map
|
||||||
Map<String, String> parameters = new HashMap<String, String>();
|
return config.getParameters();
|
||||||
for (String key : config.getParameterNames())
|
|
||||||
parameters.put(key, config.getParameter(key));
|
|
||||||
|
|
||||||
return parameters;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,11 +345,14 @@ public class ConnectionRESTService {
|
|||||||
if (existingConnection == null)
|
if (existingConnection == null)
|
||||||
throw new GuacamoleResourceNotFoundException("No such connection: \"" + connectionID + "\"");
|
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
|
// Update the connection
|
||||||
existingConnection.setConfiguration(wrappedConnection.getConfiguration());
|
existingConnection.setConfiguration(config);
|
||||||
existingConnection.setName(wrappedConnection.getName());
|
existingConnection.setName(connection.getName());
|
||||||
connectionDirectory.update(existingConnection);
|
connectionDirectory.update(existingConnection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user