mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
Ticket #263: Switched to enum for connection group type.
This commit is contained in:
@@ -64,11 +64,6 @@ public class MySQLConnectionGroup extends AbstractConnectionGroup {
|
||||
* The ID of the parent connection group for this connection group.
|
||||
*/
|
||||
private Integer parentID;
|
||||
|
||||
/**
|
||||
* The type of this connection group.
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* The ID of the user who queried or created this connection group.
|
||||
@@ -160,7 +155,6 @@ public class MySQLConnectionGroup extends AbstractConnectionGroup {
|
||||
this.parentID = parentID;
|
||||
setName(name);
|
||||
setIdentifier(identifier);
|
||||
this.type = type;
|
||||
this.userID = userID;
|
||||
|
||||
connectionDirectory = connectionDirectoryProvider.get();
|
||||
@@ -194,34 +188,5 @@ public class MySQLConnectionGroup extends AbstractConnectionGroup {
|
||||
public Directory<String, ConnectionGroup> getConnectionGroupDirectory() throws GuacamoleException {
|
||||
return connectionGroupDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connection group type.
|
||||
* @return the connection group type.
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the connection group type.
|
||||
* @param type the connection group type.
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBalancing(boolean balancing) {
|
||||
if(balancing)
|
||||
this.type = MySQLConstants.CONNECTION_GROUP_BALANCING;
|
||||
else
|
||||
this.type = MySQLConstants.CONNECTION_GROUP_ORGANIZATIONAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBalancing() {
|
||||
return MySQLConstants.CONNECTION_GROUP_BALANCING.equals(this.type);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import net.sourceforge.guacamole.net.GuacamoleSocket;
|
||||
import net.sourceforge.guacamole.net.auth.mysql.MySQLConnectionGroup;
|
||||
import net.sourceforge.guacamole.net.auth.mysql.MySQLConstants;
|
||||
import net.sourceforge.guacamole.net.auth.mysql.dao.ConnectionGroupMapper;
|
||||
import net.sourceforge.guacamole.net.auth.mysql.model.ConnectionGroup;
|
||||
import net.sourceforge.guacamole.net.auth.mysql.model.ConnectionGroupExample;
|
||||
@@ -353,7 +354,15 @@ public class ConnectionGroupService {
|
||||
connectionGroup.setConnection_group_id(mySQLConnectionGroup.getConnectionGroupID());
|
||||
connectionGroup.setParent_id(mySQLConnectionGroup.getParentID());
|
||||
connectionGroup.setConnection_group_name(mySQLConnectionGroup.getName());
|
||||
connectionGroup.setType(mySQLConnectionGroup.getType());
|
||||
|
||||
switch(mySQLConnectionGroup.getType()) {
|
||||
case BALANCING :
|
||||
connectionGroup.setType(MySQLConstants.CONNECTION_GROUP_BALANCING);
|
||||
break;
|
||||
case ORGANIZATIONAL:
|
||||
connectionGroup.setType(MySQLConstants.CONNECTION_GROUP_ORGANIZATIONAL);
|
||||
break;
|
||||
}
|
||||
|
||||
// Update the connection in the database
|
||||
connectionGroupDAO.updateByPrimaryKeySelective(connectionGroup);
|
||||
|
@@ -55,6 +55,11 @@ public abstract class AbstractConnectionGroup implements ConnectionGroup {
|
||||
*/
|
||||
private String identifier;
|
||||
|
||||
/**
|
||||
* The type of this connection group.
|
||||
*/
|
||||
private ConnectionGroup.Type type;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -74,6 +79,16 @@ public abstract class AbstractConnectionGroup implements ConnectionGroup {
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionGroup.Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(ConnectionGroup.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@@ -49,6 +49,10 @@ import net.sourceforge.guacamole.protocol.GuacamoleClientInformation;
|
||||
* @author James Muehlner
|
||||
*/
|
||||
public interface ConnectionGroup {
|
||||
|
||||
public enum Type {
|
||||
ORGANIZATIONAL, BALANCING
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the name assigned to this ConnectionGroup.
|
||||
@@ -77,17 +81,17 @@ public interface ConnectionGroup {
|
||||
public void setIdentifier(String identifier);
|
||||
|
||||
/**
|
||||
* Sets whether this is a balancing ConnectionGroup.
|
||||
* Set the type of this ConnectionGroup.
|
||||
*
|
||||
* @param balancing whether this is a balancing ConnectionGroup.
|
||||
* @param type The type of this ConnectionGroup.
|
||||
*/
|
||||
public void setBalancing(boolean balancing);
|
||||
public void setType(Type type);
|
||||
|
||||
/**
|
||||
* Returns true if this is a balancing ConnectionGroup, false otherwise.
|
||||
* @return true if this is a balancing ConnectionGroup, false otherwise.
|
||||
* Returns the type of this connection.
|
||||
* @return the type of this connection.
|
||||
*/
|
||||
public boolean isBalancing();
|
||||
public Type getType();
|
||||
|
||||
/**
|
||||
* Retrieves a Directory which can be used to view and manipulate
|
||||
|
@@ -64,6 +64,7 @@ public class SimpleConnectionGroup extends AbstractConnectionGroup {
|
||||
Directory<String, ConnectionGroup> connectionGroupDirectory) {
|
||||
this.connectionDirectory = connectionDirectory;
|
||||
this.connectionGroupDirectory = connectionGroupDirectory;
|
||||
this.setType(ConnectionGroup.Type.ORGANIZATIONAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,15 +85,4 @@ public class SimpleConnectionGroup extends AbstractConnectionGroup {
|
||||
throw new GuacamoleSecurityException("Permission denied.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBalancing(boolean balancing) {
|
||||
// All SimpleConnectionGroups are organizational only
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBalancing() {
|
||||
// All SimpleConnectionGroups are organizational only
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user