GUACAMOLE-5: Add sharing profile properties to connection record model.

This commit is contained in:
Michael Jumper
2016-07-19 16:03:11 -07:00
parent cfac865807
commit 53a856b285
4 changed files with 105 additions and 15 deletions

View File

@@ -23,7 +23,8 @@ import java.util.Date;
/**
* A single connection record representing a past usage of a particular
* connection.
* connection. If the connection was being shared, the sharing profile used to
* join the connection is included in the record.
*
* @author Michael Jumper
*/
@@ -39,6 +40,21 @@ public class ConnectionRecordModel {
*/
private String connectionName;
/**
* The identifier of the sharing profile associated with this connection
* record. If no sharing profile was used, or the sharing profile that was
* used was deleted, this will be null.
*/
private String sharingProfileIdentifier;
/**
* The name of the sharing profile associated with this connection record.
* If no sharing profile was used, this will be null. If the sharing profile
* that was used was deleted, this will still contain the name of the
* sharing profile at the time that the connection was used.
*/
private String sharingProfileName;
/**
* The database ID of the user associated with this connection record.
*/
@@ -110,6 +126,56 @@ public class ConnectionRecordModel {
this.connectionName = connectionName;
}
/**
* Returns the identifier of the sharing profile associated with this
* connection record. If no sharing profile was used, or the sharing profile
* that was used was deleted, this will be null.
*
* @return
* The identifier of the sharing profile associated with this connection
* record, or null if no sharing profile was used or if the sharing
* profile that was used was deleted.
*/
public String getSharingProfileIdentifier() {
return sharingProfileIdentifier;
}
/**
* Sets the identifier of the sharing profile associated with this
* connection record. If no sharing profile was used, this should be null.
*
* @param sharingProfileIdentifier
* The identifier of the sharing profile associated with this
* connection record, or null if no sharing profile was used.
*/
public void setSharingProfileIdentifier(String sharingProfileIdentifier) {
this.sharingProfileIdentifier = sharingProfileIdentifier;
}
/**
* Returns the human-readable name of the sharing profile associated with this
* connection record. If no sharing profile was used, this will be null.
*
* @return
* The human-readable name of the sharing profile associated with this
* connection record, or null if no sharing profile was used.
*/
public String getSharingProfileName() {
return sharingProfileName;
}
/**
* Sets the human-readable name of the sharing profile associated with this
* connection record. If no sharing profile was used, this should be null.
*
* @param sharingProfileName
* The human-readable name of the sharing profile associated with this
* connection record, or null if no sharing profile was used.
*/
public void setSharingProfileName(String sharingProfileName) {
this.sharingProfileName = sharingProfileName;
}
/**
* Returns the database ID of the user associated with this connection
* record.

View File

@@ -60,12 +60,12 @@ public class ModeledConnectionRecord implements ConnectionRecord {
@Override
public String getSharingProfileIdentifier() {
return null;
return model.getSharingProfileIdentifier();
}
@Override
public String getSharingProfileName() {
return null;
return model.getSharingProfileName();
}
@Override

View File

@@ -27,6 +27,8 @@
<resultMap id="ConnectionRecordResultMap" type="org.apache.guacamole.auth.jdbc.connection.ConnectionRecordModel">
<result column="connection_id" property="connectionIdentifier" jdbcType="INTEGER"/>
<result column="connection_name" property="connectionName" jdbcType="VARCHAR"/>
<result column="sharing_profile_id" property="sharingProfileIdentifier" jdbcType="INTEGER"/>
<result column="sharing_profile_name" property="sharingProfileName" jdbcType="VARCHAR"/>
<result column="user_id" property="userID" jdbcType="INTEGER"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="start_date" property="startDate" jdbcType="TIMESTAMP"/>
@@ -39,6 +41,8 @@
SELECT
guacamole_connection_history.connection_id,
guacamole_connection_history.connection_name,
guacamole_connection_history.sharing_profile_id,
guacamole_connection_history.sharing_profile_name,
guacamole_connection_history.user_id,
guacamole_connection_history.username,
guacamole_connection_history.start_date,
@@ -58,6 +62,8 @@
INSERT INTO guacamole_connection_history (
connection_id,
connection_name,
sharing_profile_id,
sharing_profile_name,
user_id,
username,
start_date,
@@ -66,6 +72,8 @@
VALUES (
#{record.connectionIdentifier,jdbcType=VARCHAR},
#{record.connectionName,jdbcType=VARCHAR},
#{record.sharingProfileIdentifier,jdbcType=VARCHAR},
#{record.sharingProfileName,jdbcType=VARCHAR},
(SELECT user_id FROM guacamole_user
WHERE username = #{record.username,jdbcType=VARCHAR}),
#{record.username,jdbcType=VARCHAR},
@@ -81,6 +89,8 @@
SELECT
guacamole_connection_history.connection_id,
guacamole_connection_history.connection_name,
guacamole_connection_history.sharing_profile_id,
guacamole_connection_history.sharing_profile_name,
guacamole_connection_history.user_id,
guacamole_connection_history.username,
guacamole_connection_history.start_date,
@@ -136,6 +146,8 @@
SELECT
guacamole_connection_history.connection_id,
guacamole_connection_history.connection_name,
guacamole_connection_history.sharing_profile_id,
guacamole_connection_history.sharing_profile_name,
guacamole_connection_history.user_id,
guacamole_connection_history.username,
guacamole_connection_history.start_date,

View File

@@ -27,6 +27,8 @@
<resultMap id="ConnectionRecordResultMap" type="org.apache.guacamole.auth.jdbc.connection.ConnectionRecordModel">
<result column="connection_id" property="connectionIdentifier" jdbcType="INTEGER"/>
<result column="connection_name" property="connectionName" jdbcType="VARCHAR"/>
<result column="sharing_profile_id" property="sharingProfileIdentifier" jdbcType="INTEGER"/>
<result column="sharing_profile_name" property="sharingProfileName" jdbcType="VARCHAR"/>
<result column="user_id" property="userID" jdbcType="INTEGER"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="start_date" property="startDate" jdbcType="TIMESTAMP"/>
@@ -39,6 +41,8 @@
SELECT
guacamole_connection_history.connection_id,
guacamole_connection_history.connection_name,
guacamole_connection_history.sharing_profile_id,
guacamole_connection_history.sharing_profile_name,
guacamole_connection_history.user_id,
guacamole_connection_history.username,
guacamole_connection_history.start_date,
@@ -58,6 +62,8 @@
INSERT INTO guacamole_connection_history (
connection_id,
connection_name,
sharing_profile_id,
sharing_profile_name,
user_id,
username,
start_date,
@@ -66,6 +72,8 @@
VALUES (
#{record.connectionIdentifier,jdbcType=INTEGER}::integer,
#{record.connectionName,jdbcType=VARCHAR},
#{record.sharingProfileIdentifier,jdbcType=INTEGER}::integer,
#{record.sharingProfileName,jdbcType=VARCHAR},
(SELECT user_id FROM guacamole_user
WHERE username = #{record.username,jdbcType=VARCHAR}),
#{record.username,jdbcType=VARCHAR},
@@ -81,6 +89,8 @@
SELECT
guacamole_connection_history.connection_id,
guacamole_connection_history.connection_name,
guacamole_connection_history.sharing_profile_id,
guacamole_connection_history.sharing_profile_name,
guacamole_connection_history.user_id,
guacamole_connection_history.username,
guacamole_connection_history.start_date,
@@ -134,6 +144,8 @@
SELECT
guacamole_connection_history.connection_id,
guacamole_connection_history.connection_name,
guacamole_connection_history.sharing_profile_id,
guacamole_connection_history.sharing_profile_name,
guacamole_connection_history.user_id,
guacamole_connection_history.username,
guacamole_connection_history.start_date,