Ticket #390: Made changes suggested in code review.

This commit is contained in:
James Muehlner
2013-08-18 21:49:01 -07:00
parent 681a0201ba
commit 7111fec092
2 changed files with 20 additions and 35 deletions

View File

@@ -120,7 +120,7 @@ public class ActiveConnectionMap {
/** /**
* The ID of the connection or connection group that this ConnectionUser refers to. * The ID of the connection or connection group that this ConnectionUser refers to.
*/ */
private int connectionID; private int identifier;
/** /**
* The user that this ConnectionUser refers to. * The user that this ConnectionUser refers to.
@@ -131,8 +131,8 @@ public class ActiveConnectionMap {
* Returns ID of the connection or connection group that this ConnectionUser refers to. * Returns ID of the connection or connection group that this ConnectionUser refers to.
* @return ID of the connection or connection group that this ConnectionUser refers to. * @return ID of the connection or connection group that this ConnectionUser refers to.
*/ */
public int getConnectionGroupID() { public int getIdentifier() {
return connectionID; return identifier;
} }
/** /**
@@ -147,12 +147,12 @@ public class ActiveConnectionMap {
* Create a ConnectionUser with the given connection or connection group * Create a ConnectionUser with the given connection or connection group
* ID and user ID. * ID and user ID.
* *
* @param connectionID The connection or connection group ID that this * @param identifier The connection or connection group ID that this
* ConnectionUser refers to. * ConnectionUser refers to.
* @param userID The user ID that this ConnectionUser refers to. * @param userID The user ID that this ConnectionUser refers to.
*/ */
public ConnectionUser(int connectionID, int userID) { public ConnectionUser(int identifier, int userID) {
this.connectionID = connectionID; this.identifier = identifier;
this.userID = userID; this.userID = userID;
} }
@@ -170,14 +170,14 @@ public class ActiveConnectionMap {
* Two ConnectionGroupUsers are equal iff they represent the exact * Two ConnectionGroupUsers are equal iff they represent the exact
* same pairing of connection or connection group and user. * same pairing of connection or connection group and user.
*/ */
return this.connectionID == otherConnectionGroupUser.connectionID return this.identifier == otherConnectionGroupUser.identifier
&& this.userID == otherConnectionGroupUser.userID; && this.userID == otherConnectionGroupUser.userID;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 3; int hash = 3;
hash = 23 * hash + this.connectionID; hash = 23 * hash + this.identifier;
hash = 23 * hash + this.userID; hash = 23 * hash + this.userID;
return hash; return hash;
} }
@@ -209,10 +209,10 @@ public class ActiveConnectionMap {
new HashMap<ConnectionUser, Integer>(); new HashMap<ConnectionUser, Integer>();
/** /**
* Returns the number of connectionGroups opened by the given user using * Returns the number of connections opened by the given user using
* the given ConnectionGroup. * the given ConnectionGroup.
* *
* @param connectionID The connection group ID that this * @param connectionGroupID The connection group ID that this
* ConnectionUser refers to. * ConnectionUser refers to.
* @param userID The user ID that this ConnectionUser refers to. * @param userID The user ID that this ConnectionUser refers to.
* *
@@ -451,7 +451,7 @@ public class ActiveConnectionMap {
* Set a connection as open. * Set a connection as open.
* @param connectionID The ID of the connection that is being opened. * @param connectionID The ID of the connection that is being opened.
* @param userID The ID of the user who is opening the connection. * @param userID The ID of the user who is opening the connection.
* @param connectionID The ID of the BALANCING connection group that is * @param connectionGroupID The ID of the BALANCING connection group that is
* being connected to; null if not used. * being connected to; null if not used.
* @return The ID of the history record created for this open connection. * @return The ID of the history record created for this open connection.
*/ */
@@ -479,15 +479,13 @@ public class ActiveConnectionMap {
/** /**
* Set a connection as closed. * Set a connection as closed.
* @param connectionID The ID of the connection that is being opened.
* @param userID The ID of the user who is opening the connection.
* @param historyID The ID of the history record about the open connection. * @param historyID The ID of the history record about the open connection.
* @param connectionID The ID of the BALANCING connection group that is * @param connectionGroupID The ID of the BALANCING connection group that is
* being connected to; null if not used. * being connected to; null if not used.
* @throws GuacamoleException If the open connection history is not found. * @throws GuacamoleException If the open connection history is not found.
*/ */
public void closeConnection(int connectionID, int userID, int historyID, public void closeConnection(int historyID, Integer connectionGroupID)
Integer connectionGroupID) throws GuacamoleException { throws GuacamoleException {
// Get the existing history record // Get the existing history record
ConnectionHistory connectionHistory = ConnectionHistory connectionHistory =
@@ -495,6 +493,10 @@ public class ActiveConnectionMap {
if(connectionHistory == null) if(connectionHistory == null)
throw new GuacamoleException("History record not found."); throw new GuacamoleException("History record not found.");
// Get the connection and user IDs
int connectionID = connectionHistory.getConnection_id();
int userID = connectionHistory.getUser_id();
// Update the connection history record to mark that it is now closed // Update the connection history record to mark that it is now closed
connectionHistory.setEnd_date(new Date()); connectionHistory.setEnd_date(new Date());

View File

@@ -60,17 +60,6 @@ public class MySQLGuacamoleSocket implements GuacamoleSocket {
*/ */
private GuacamoleSocket socket; private GuacamoleSocket socket;
/**
* The ID associated with the connection associated with the wrapped
* socket.
*/
private int connectionID;
/**
* The ID of the user who is connecting to the socket.
*/
private int userID;
/** /**
* The ID of the history record associated with this instance of the * The ID of the history record associated with this instance of the
* connection. * connection.
@@ -87,9 +76,6 @@ public class MySQLGuacamoleSocket implements GuacamoleSocket {
* Initialize this MySQLGuacamoleSocket with the provided GuacamoleSocket. * Initialize this MySQLGuacamoleSocket with the provided GuacamoleSocket.
* *
* @param socket The ConfiguredGuacamoleSocket to wrap. * @param socket The ConfiguredGuacamoleSocket to wrap.
* @param connectionID The ID of the connection associated with the given
* socket.
* @param userID The ID of the user who is connecting to the socket.
* @param historyID The ID of the history record associated with this * @param historyID The ID of the history record associated with this
* instance of the connection. * instance of the connection.
* @param connectionGroupID The ID of the balancing connection group that is * @param connectionGroupID The ID of the balancing connection group that is
@@ -98,8 +84,6 @@ public class MySQLGuacamoleSocket implements GuacamoleSocket {
public void init(GuacamoleSocket socket, int connectionID, int userID, public void init(GuacamoleSocket socket, int connectionID, int userID,
int historyID, Integer connectionGroupID) { int historyID, Integer connectionGroupID) {
this.socket = socket; this.socket = socket;
this.connectionID = connectionID;
this.userID = userID;
this.historyID = historyID; this.historyID = historyID;
this.connectionGroupID = connectionGroupID; this.connectionGroupID = connectionGroupID;
} }
@@ -121,8 +105,7 @@ public class MySQLGuacamoleSocket implements GuacamoleSocket {
socket.close(); socket.close();
// Mark this connection as inactive // Mark this connection as inactive
activeConnectionSet.closeConnection(connectionID, userID, activeConnectionSet.closeConnection(historyID, connectionGroupID);
historyID, connectionGroupID);
} }
@Override @Override