mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-932: Add getParameters() and setParameters() to GuacamoleConfiguration. Use where reasonable.
This commit is contained in:
		| @@ -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