Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
GUAC-1100: Add getActiveConnections() function to Connectable.
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-jumper committed Feb 26, 2015
1 parent 6f61300 commit 79130e9
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 44 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ public interface Connectable {
public GuacamoleSocket connect(GuacamoleClientInformation info) public GuacamoleSocket connect(GuacamoleClientInformation info)
throws GuacamoleException; throws GuacamoleException;


/**
* Returns the number of active connections associated with this object.
* Implementations may simply return 0 if this value is not tracked.
*
* @return
* The number of active connections associated with this object.
*/
public int getActiveConnections();

} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public SimpleConnection(String name, String identifier,


} }


@Override
public int getActiveConnections() {
return 0;
}

@Override @Override
public GuacamoleSocket connect(GuacamoleClientInformation info) public GuacamoleSocket connect(GuacamoleClientInformation info)
throws GuacamoleException { throws GuacamoleException {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public SimpleConnectionGroup(String name, String identifier,


} }


@Override
public int getActiveConnections() {
return 0;
}

@Override @Override
public Set<String> getConnectionIdentifiers() { public Set<String> getConnectionIdentifiers() {
return connectionIdentifiers; return connectionIdentifiers;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@


package org.glyptodon.guacamole.net.basic.rest.connection; package org.glyptodon.guacamole.net.basic.rest.connection;


import java.util.List;
import java.util.Map; import java.util.Map;
import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonIgnoreProperties;
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.ConnectionRecord;
import org.glyptodon.guacamole.net.basic.rest.connectiongroup.APIConnectionGroup;
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;


/** /**
Expand Down Expand Up @@ -65,9 +62,9 @@ public class APIConnection {
private Map<String, String> parameters; private Map<String, String> parameters;


/** /**
* The count of currently active users for this connection. * The count of currently active connections using this connection.
*/ */
private int activeUsers; private int activeConnections;


/** /**
* Create an empty APIConnection. * Create an empty APIConnection.
Expand All @@ -85,23 +82,12 @@ public APIConnection() {}
public APIConnection(Connection connection) public APIConnection(Connection connection)
throws GuacamoleException { throws GuacamoleException {


// Set identifying information // Set connection information
this.name = connection.getName(); this.name = connection.getName();
this.identifier = connection.getIdentifier(); this.identifier = connection.getIdentifier();

// Set proper parent identifier, using root identifier if needed
this.parentIdentifier = connection.getParentIdentifier(); this.parentIdentifier = connection.getParentIdentifier();
if (this.parentIdentifier == null) this.activeConnections = connection.getActiveConnections();
this.parentIdentifier = APIConnectionGroup.ROOT_IDENTIFIER;

// Set the number of currently active users
this.activeUsers = 0;


for (ConnectionRecord history : connection.getHistory()) {
if (history.isActive())
this.activeUsers++;
}

// Set protocol from configuration // Set protocol from configuration
GuacamoleConfiguration configuration = connection.getConfiguration(); GuacamoleConfiguration configuration = connection.getConfiguration();
this.protocol = configuration.getProtocol(); this.protocol = configuration.getProtocol();
Expand Down Expand Up @@ -190,19 +176,24 @@ public void setProtocol(String protocol) {
} }


/** /**
* Returns the number of currently active users for this connection. * Returns the number of currently active connections using this
* @return The number of currently active users for this connection. * connection.
*
* @return
* The number of currently active usages of this connection.
*/ */
public int getActiveUsers() { public int getActiveConnections() {
return activeUsers; return activeConnections;
} }


/** /**
* Set the number of currently active users for this connection. * Set the number of currently active connections using this connection.
* @param activeUsers The number of currently active users for this connection. *
* @param activeConnections
* The number of currently active usages of this connection.
*/ */
public void setActiveUsers(int activeUsers) { public void setActiveUsers(int activeConnections) {
this.activeUsers = activeUsers; this.activeConnections = activeConnections;
} }


} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,8 +40,18 @@
*/ */
public class APIConnectionWrapper implements Connection { public class APIConnectionWrapper implements Connection {


/**
* The wrapped APIConnection.
*/
private final APIConnection apiConnection; private final APIConnection apiConnection;


/**
* Creates a new APIConnectionWrapper which wraps the given APIConnection
* as a Connection.
*
* @param apiConnection
* The APIConnection to wrap.
*/
public APIConnectionWrapper(APIConnection apiConnection) { public APIConnectionWrapper(APIConnection apiConnection) {
this.apiConnection = apiConnection; this.apiConnection = apiConnection;
} }
Expand Down Expand Up @@ -76,6 +86,11 @@ public void setParentIdentifier(String parentIdentifier) {
apiConnection.setParentIdentifier(parentIdentifier); apiConnection.setParentIdentifier(parentIdentifier);
} }


@Override
public int getActiveConnections() {
return apiConnection.getActiveConnections();
}

@Override @Override
public GuacamoleConfiguration getConfiguration() { public GuacamoleConfiguration getConfiguration() {


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public class APIConnectionGroup {
*/ */
private Type type; private Type type;


/**
* The count of currently active connections using this connection group.
*/
private int activeConnections;

/** /**
* All child connection groups. If children are not being queried, this may * All child connection groups. If children are not being queried, this may
* be omitted. * be omitted.
Expand Down Expand Up @@ -91,6 +96,7 @@ public APIConnectionGroup(ConnectionGroup connectionGroup) {


this.name = connectionGroup.getName(); this.name = connectionGroup.getName();
this.type = connectionGroup.getType(); this.type = connectionGroup.getType();
this.activeConnections = connectionGroup.getActiveConnections();


} }


Expand Down Expand Up @@ -206,4 +212,26 @@ public void setChildConnections(Collection<APIConnection> childConnections) {
this.childConnections = childConnections; this.childConnections = childConnections;
} }


/**
* Returns the number of currently active connections using this
* connection group.
*
* @return
* The number of currently active usages of this connection group.
*/
public int getActiveConnections() {
return activeConnections;
}

/**
* Set the number of currently active connections using this connection
* group.
*
* @param activeConnections
* The number of currently active usages of this connection group.
*/
public void setActiveUsers(int activeConnections) {
this.activeConnections = activeConnections;
}

} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import java.util.Set; import java.util.Set;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.net.GuacamoleSocket; import org.glyptodon.guacamole.net.GuacamoleSocket;
import org.glyptodon.guacamole.net.auth.Connection;
import org.glyptodon.guacamole.net.auth.ConnectionGroup; import org.glyptodon.guacamole.net.auth.ConnectionGroup;
import org.glyptodon.guacamole.net.auth.Directory;
import org.glyptodon.guacamole.protocol.GuacamoleClientInformation; import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;


/** /**
Expand Down Expand Up @@ -92,6 +90,11 @@ public Type getType() {
return apiConnectionGroup.getType(); return apiConnectionGroup.getType();
} }


@Override
public int getActiveConnections() {
return apiConnectionGroup.getActiveConnections();
}

@Override @Override
public Set<String> getConnectionIdentifiers() { public Set<String> getConnectionIdentifiers() {
throw new UnsupportedOperationException("Operation not supported."); throw new UnsupportedOperationException("Operation not supported.");
Expand Down
13 changes: 8 additions & 5 deletions guacamole/src/main/webapp/app/groupList/types/GroupListItem.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
this.isExpanded = template.isExpanded; this.isExpanded = template.isExpanded;


/** /**
* The number of currently active users for this connection. This field * The number of currently active users for this connection or
* has no meaning for a connection group, and may be null or undefined. * connection group, if known.
* *
* @type Number * @type Number
*/ */
this.activeUsers = template.activeUsers; this.activeConnections = template.activeConnections;


/** /**
* The connection or connection group whose data is exposed within * The connection or connection group whose data is exposed within
Expand Down Expand Up @@ -143,8 +143,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
isConnection : true, isConnection : true,
isConnectionGroup : false, isConnectionGroup : false,


// Count of currently active users // Count of currently active connections using this connection
activeUsers : connection.activeUsers, activeConnections : connection.activeConnections,


// Wrapped item // Wrapped item
wrappedItem : connection wrappedItem : connection
Expand Down Expand Up @@ -198,6 +198,9 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
// Already-converted children // Already-converted children
children : children, children : children,


// Count of currently active connection groups using this connection
activeConnections : connectionGroup.activeConnections,

// Wrapped item // Wrapped item
wrappedItem : connectionGroup wrappedItem : connectionGroup


Expand Down
6 changes: 3 additions & 3 deletions guacamole/src/main/webapp/app/home/templates/connection.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
THE SOFTWARE. THE SOFTWARE.
--> -->


<div class="caption" ng-class="{active: item.activeUsers}"> <div class="caption" ng-class="{active: item.activeConnections}">


<!-- Connection icon --> <!-- Connection icon -->
<div class="protocol"> <div class="protocol">
Expand All @@ -32,8 +32,8 @@
<span class="name">{{item.name}}</span> <span class="name">{{item.name}}</span>


<!-- Active user count --> <!-- Active user count -->
<span class="activeUserCount" ng-show="item.activeUsers"> <span class="activeUserCount" ng-show="item.activeConnections">
{{'HOME.INFO_ACTIVE_USER_COUNT' | translate:'{USERS: item.activeUsers}'}} {{'HOME.INFO_ACTIVE_USER_COUNT' | translate:'{USERS: item.activeConnections}'}}
</span> </span>


</div> </div>
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
THE SOFTWARE. THE SOFTWARE.
--> -->


<div class="caption" ng-class="{active: item.activeUsers}"> <div class="caption" ng-class="{active: item.activeConnections}">


<!-- Connection icon --> <!-- Connection icon -->
<div class="protocol"> <div class="protocol">
Expand All @@ -32,8 +32,8 @@
<span class="name">{{item.name}}</span> <span class="name">{{item.name}}</span>


<!-- Active user count --> <!-- Active user count -->
<span class="activeUserCount" ng-show="item.activeUsers"> <span class="activeUserCount" ng-show="item.activeConnections">
{{'MANAGE.INFO_ACTIVE_USER_COUNT' | translate:'{USERS: item.activeUsers}'}} {{'MANAGE.INFO_ACTIVE_USER_COUNT' | translate:'{USERS: item.activeConnections}'}}
</span> </span>


</div> </div>
Expand Down
8 changes: 4 additions & 4 deletions guacamole/src/main/webapp/app/rest/types/Connection.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ angular.module('rest').factory('Connection', [function defineConnection() {
this.parameters = template.parameters; this.parameters = template.parameters;


/** /**
* The count of currently active users for this connection. This field * The count of currently active connections using this connection.
* will be returned from the REST API during a get operation, * This field will be returned from the REST API during a get
* but may not be set when doing an update or create operation. * operation, but manually setting this field will have no effect.
* *
* @type Number * @type Number
*/ */
this.activeUsers = template.activeUsers; this.activeConnections = template.activeConnections;


}; };


Expand Down
9 changes: 9 additions & 0 deletions guacamole/src/main/webapp/app/rest/types/ConnectionGroup.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ angular.module('rest').factory('ConnectionGroup', [function defineConnectionGrou
*/ */
this.childConnectionGroups = template.childConnectionGroups; this.childConnectionGroups = template.childConnectionGroups;


/**
* The count of currently active connections using this connection
* group. This field will be returned from the REST API during a get
* operation, but manually setting this field will have no effect.
*
* @type Number
*/
this.activeConnections = template.activeConnections;

}; };


/** /**
Expand Down

0 comments on commit 79130e9

Please sign in to comment.