mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
Ticket #362: The cleaning never ends.
This commit is contained in:
@@ -102,15 +102,8 @@ public class ConnectionRESTService {
|
|||||||
Directory<String, Connection> connectionDirectory =
|
Directory<String, Connection> connectionDirectory =
|
||||||
parentConnectionGroup.getConnectionDirectory();
|
parentConnectionGroup.getConnectionDirectory();
|
||||||
|
|
||||||
// Get the list of connection names
|
// Return the converted connection directory
|
||||||
List<Connection> connections = new ArrayList<Connection>();
|
return connectionService.convertConnectionList(connectionDirectory);
|
||||||
Iterable<String> identifiers = connectionDirectory.getIdentifiers();
|
|
||||||
|
|
||||||
// Get the connection for each name
|
|
||||||
for(String identifier : identifiers)
|
|
||||||
connections.add(connectionDirectory.get(identifier));
|
|
||||||
|
|
||||||
return connectionService.convertConnectionList(connections);
|
|
||||||
} catch(GuacamoleSecurityException e) {
|
} catch(GuacamoleSecurityException e) {
|
||||||
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
|
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
|
||||||
} catch(GuacamoleClientException e) {
|
} catch(GuacamoleClientException e) {
|
||||||
|
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.net.auth.Connection;
|
import org.glyptodon.guacamole.net.auth.Connection;
|
||||||
|
import org.glyptodon.guacamole.net.auth.Directory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Guacamole - Clientless Remote Desktop
|
* Guacamole - Clientless Remote Desktop
|
||||||
@@ -37,14 +38,14 @@ public class ConnectionService {
|
|||||||
* @param connections The Connection to convert for REST endpoint use.
|
* @param connections The Connection to convert for REST endpoint use.
|
||||||
* @return A List of APIConnection objects for use with the REST endpoint.
|
* @return A List of APIConnection objects for use with the REST endpoint.
|
||||||
* @throws GuacamoleException If an error occurs while converting the
|
* @throws GuacamoleException If an error occurs while converting the
|
||||||
* connections.
|
* connection directory.
|
||||||
*/
|
*/
|
||||||
public List<APIConnection> convertConnectionList(Iterable<? extends Connection> connections)
|
public List<APIConnection> convertConnectionList(Directory<String, Connection> connectionDirectory)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
List<APIConnection> restConnections = new ArrayList<APIConnection>();
|
List<APIConnection> restConnections = new ArrayList<APIConnection>();
|
||||||
|
|
||||||
for(Connection connection : connections) {
|
for(String connectionID : connectionDirectory.getIdentifiers()) {
|
||||||
restConnections.add(new APIConnection(connection));
|
restConnections.add(new APIConnection(connectionDirectory.get(connectionID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return restConnections;
|
return restConnections;
|
||||||
|
@@ -101,15 +101,8 @@ public class ConnectionGroupRESTService {
|
|||||||
Directory<String, ConnectionGroup> connectionGroupDirectory =
|
Directory<String, ConnectionGroup> connectionGroupDirectory =
|
||||||
parentConnectionGroup.getConnectionGroupDirectory();
|
parentConnectionGroup.getConnectionGroupDirectory();
|
||||||
|
|
||||||
// Get the list of connection group names
|
// return the converted connection group list
|
||||||
List<ConnectionGroup> connectionGroups = new ArrayList<ConnectionGroup>();
|
return connectionGroupService.convertConnectionGroupList(connectionGroupDirectory);
|
||||||
Iterable<String> identifiers = connectionGroupDirectory.getIdentifiers();
|
|
||||||
|
|
||||||
// Get the connection group for each name
|
|
||||||
for(String identifier : identifiers)
|
|
||||||
connectionGroups.add(connectionGroupDirectory.get(identifier));
|
|
||||||
|
|
||||||
return connectionGroupService.convertConnectionGroupList(connectionGroups);
|
|
||||||
} catch(GuacamoleSecurityException e) {
|
} catch(GuacamoleSecurityException e) {
|
||||||
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
|
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
|
||||||
} catch(GuacamoleClientException e) {
|
} catch(GuacamoleClientException e) {
|
||||||
@@ -146,6 +139,7 @@ public class ConnectionGroupRESTService {
|
|||||||
if(connectionGroup == null)
|
if(connectionGroup == null)
|
||||||
throw new HTTPException(Status.NOT_FOUND, "No ConnectionGroup found with the provided ID.");
|
throw new HTTPException(Status.NOT_FOUND, "No ConnectionGroup found with the provided ID.");
|
||||||
|
|
||||||
|
// Return the connectiion group
|
||||||
return new APIConnectionGroup(connectionGroup);
|
return new APIConnectionGroup(connectionGroup);
|
||||||
} catch(GuacamoleSecurityException e) {
|
} catch(GuacamoleSecurityException e) {
|
||||||
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
|
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
|
||||||
@@ -311,7 +305,7 @@ public class ConnectionGroupRESTService {
|
|||||||
if(parentConnectionGroup == null)
|
if(parentConnectionGroup == null)
|
||||||
throw new HTTPException(Status.NOT_FOUND, "No ConnectionGroup found with the provided parentID.");
|
throw new HTTPException(Status.NOT_FOUND, "No ConnectionGroup found with the provided parentID.");
|
||||||
|
|
||||||
// Move the connection
|
// Move the connection group
|
||||||
connectionGroupDirectory.move(connectionGroupID, parentConnectionGroup.getConnectionGroupDirectory());
|
connectionGroupDirectory.move(connectionGroupID, parentConnectionGroup.getConnectionGroupDirectory());
|
||||||
} catch(GuacamoleSecurityException e) {
|
} catch(GuacamoleSecurityException e) {
|
||||||
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
|
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
|
||||||
|
@@ -2,7 +2,9 @@ package org.glyptodon.guacamole.net.basic.rest.connectiongroup;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
||||||
|
import org.glyptodon.guacamole.net.auth.Directory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Guacamole - Clientless Remote Desktop
|
* Guacamole - Clientless Remote Desktop
|
||||||
@@ -35,13 +37,15 @@ public class ConnectionGroupService {
|
|||||||
*
|
*
|
||||||
* @param connectionGroups The ConnectionGroup to convert for REST endpoint use.
|
* @param connectionGroups The ConnectionGroup to convert for REST endpoint use.
|
||||||
* @return A List of APIConnectionGroup objects for use with the REST endpoint.
|
* @return A List of APIConnectionGroup objects for use with the REST endpoint.
|
||||||
|
* @throws GuacamoleException If an error occurs while converting the
|
||||||
|
* connection group directory.
|
||||||
*/
|
*/
|
||||||
public List<APIConnectionGroup> convertConnectionGroupList(
|
public List<APIConnectionGroup> convertConnectionGroupList(
|
||||||
Iterable<? extends ConnectionGroup> connectionGroups) {
|
Directory<String, ConnectionGroup> connectionGroupDirectory) throws GuacamoleException {
|
||||||
List<APIConnectionGroup> restConnectionGroups = new ArrayList<APIConnectionGroup>();
|
List<APIConnectionGroup> restConnectionGroups = new ArrayList<APIConnectionGroup>();
|
||||||
|
|
||||||
for(ConnectionGroup connectionGroup : connectionGroups) {
|
for(String connectionGroupID : connectionGroupDirectory.getIdentifiers()) {
|
||||||
restConnectionGroups.add(new APIConnectionGroup(connectionGroup));
|
restConnectionGroups.add(new APIConnectionGroup(connectionGroupDirectory.get(connectionGroupID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return restConnectionGroups;
|
return restConnectionGroups;
|
||||||
|
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
|
||||||
import org.glyptodon.guacamole.net.auth.permission.Permission;
|
import org.glyptodon.guacamole.net.auth.permission.Permission;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user