mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1123: Implement new methods for retrieving user and connection history.
This commit is contained in:
@@ -25,7 +25,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||
import org.apache.guacamole.net.auth.Connection;
|
||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||
@@ -123,14 +125,14 @@ public class APIConnectionWrapper implements Connection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSharingProfileIdentifiers() {
|
||||
throw new UnsupportedOperationException("Operation not supported.");
|
||||
public Set<String> getSharingProfileIdentifiers() throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("Operation not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException {
|
||||
throw new UnsupportedOperationException("Operation not supported.");
|
||||
throw new GuacamoleUnsupportedException("Operation not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,4 +145,11 @@ public class APIConnectionWrapper implements Connection {
|
||||
return Collections.<ConnectionRecord>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("APIConnectionWrapper does not "
|
||||
+ "support retrieving connection history.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,8 +22,6 @@ package org.apache.guacamole.rest.connection;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
@@ -33,7 +31,6 @@ import javax.ws.rs.core.MediaType;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleSecurityException;
|
||||
import org.apache.guacamole.net.auth.Connection;
|
||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.apache.guacamole.net.auth.Permissions;
|
||||
import org.apache.guacamole.rest.directory.DirectoryView;
|
||||
@@ -43,12 +40,12 @@ import org.apache.guacamole.net.auth.permission.ObjectPermission;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermission;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
import org.apache.guacamole.rest.history.APIConnectionRecord;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
import org.apache.guacamole.rest.directory.DirectoryObjectResource;
|
||||
import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
|
||||
import org.apache.guacamole.rest.directory.DirectoryResource;
|
||||
import org.apache.guacamole.rest.directory.DirectoryResourceFactory;
|
||||
import org.apache.guacamole.rest.history.ConnectionHistoryResource;
|
||||
import org.apache.guacamole.rest.sharingprofile.APISharingProfile;
|
||||
|
||||
/**
|
||||
@@ -150,18 +147,11 @@ public class ConnectionResource extends DirectoryObjectResource<Connection, APIC
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the connection history.
|
||||
*/
|
||||
@GET
|
||||
@Path("history")
|
||||
public List<APIConnectionRecord> getConnectionHistory()
|
||||
public ConnectionHistoryResource getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
|
||||
// Retrieve the requested connection's history
|
||||
List<APIConnectionRecord> apiRecords = new ArrayList<>();
|
||||
for (ConnectionRecord record : connection.getHistory())
|
||||
apiRecords.add(new APIConnectionRecord(record));
|
||||
|
||||
// Return the converted history
|
||||
return apiRecords;
|
||||
return new ConnectionHistoryResource(connection.getConnectionHistory());
|
||||
|
||||
}
|
||||
|
||||
|
@@ -84,7 +84,7 @@ public abstract class ActivityRecordSetResource<InternalRecordType extends Activ
|
||||
* A new record object containing the same data as the given internal
|
||||
* record, but intended for use in interchange.
|
||||
*/
|
||||
protected abstract ExternalRecordType toExternalRecord(InternalRecordType record);
|
||||
public abstract ExternalRecordType toExternalRecord(InternalRecordType record);
|
||||
|
||||
/**
|
||||
* Retrieves the list of activity records stored within the underlying
|
||||
|
@@ -42,7 +42,7 @@ public class ConnectionHistoryResource extends ActivityRecordSetResource<Connect
|
||||
}
|
||||
|
||||
@Override
|
||||
protected APIConnectionRecord toExternalRecord(ConnectionRecord record) {
|
||||
public APIConnectionRecord toExternalRecord(ConnectionRecord record) {
|
||||
return new APIConnectionRecord(record);
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,7 @@ public class UserHistoryResource extends ActivityRecordSetResource<ActivityRecor
|
||||
}
|
||||
|
||||
@Override
|
||||
protected APIActivityRecord toExternalRecord(ActivityRecord record) {
|
||||
public APIActivityRecord toExternalRecord(ActivityRecord record) {
|
||||
return new APIActivityRecord(record);
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@ import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.net.auth.ActivityRecord;
|
||||
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||
import org.apache.guacamole.net.auth.Permissions;
|
||||
import org.apache.guacamole.net.auth.RelatedObjectSet;
|
||||
import org.apache.guacamole.net.auth.User;
|
||||
@@ -143,5 +144,11 @@ public class APIUserWrapper implements User {
|
||||
public List<? extends ActivityRecord> getHistory() throws GuacamoleException {
|
||||
return Collections.<ActivityRecord>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("APIUserWrapper does not provide login history.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -33,7 +33,6 @@ import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleSecurityException;
|
||||
import org.apache.guacamole.net.auth.ActivityRecord;
|
||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||
import org.apache.guacamole.net.auth.Credentials;
|
||||
import org.apache.guacamole.net.auth.User;
|
||||
@@ -42,7 +41,7 @@ import org.apache.guacamole.net.auth.UserContext;
|
||||
import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException;
|
||||
import org.apache.guacamole.rest.directory.DirectoryObjectResource;
|
||||
import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
|
||||
import org.apache.guacamole.rest.history.APIActivityRecord;
|
||||
import org.apache.guacamole.rest.history.UserHistoryResource;
|
||||
import org.apache.guacamole.rest.identifier.RelatedObjectSetResource;
|
||||
import org.apache.guacamole.rest.permission.APIPermissionSet;
|
||||
import org.apache.guacamole.rest.permission.PermissionSetResource;
|
||||
@@ -110,18 +109,11 @@ public class UserResource
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the user history.
|
||||
*/
|
||||
@GET
|
||||
@Path("history")
|
||||
public List<APIActivityRecord> getUserHistory()
|
||||
public UserHistoryResource getUserHistory()
|
||||
throws GuacamoleException {
|
||||
|
||||
// Retrieve the requested user's history
|
||||
List<APIActivityRecord> apiRecords = new ArrayList<APIActivityRecord>();
|
||||
for (ActivityRecord record : user.getHistory())
|
||||
apiRecords.add(new APIActivityRecord(record));
|
||||
|
||||
// Return the converted history
|
||||
return apiRecords;
|
||||
return new UserHistoryResource(user.getUserHistory());
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user