GUACAMOLE-462: Directly support associating session recordings with history entries at API level.

This commit is contained in:
Michael Jumper
2021-12-11 14:58:30 -08:00
parent 538ac5d934
commit 0cca98d0b2
7 changed files with 402 additions and 2 deletions

View File

@@ -0,0 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.guacamole.rest.history;
import org.apache.guacamole.language.TranslatableMessage;
import org.apache.guacamole.net.auth.ActivityLog;
/**
* A activity log which may be exposed through the REST endpoints.
*/
public class APIActivityLog {
/**
* The type of this ActivityLog.
*/
private final ActivityLog.Type type;
/**
* A human-readable description of this log.
*/
private final TranslatableMessage description;
/**
* Creates a new APIActivityLog, copying the data from the given activity
* log.
*
* @param log
* The log to copy data from.
*/
public APIActivityLog(ActivityLog log) {
this.type = log.getType();
this.description = log.getDescription();
}
/**
* Returns the type of this activity log. The type of an activity log
* dictates how its content should be interpreted or exposed, however the
* content of a log is not directly exposed by this class.
*
* @return
* The type of this activity log.
*/
public ActivityLog.Type getType() {
return type;
}
/**
* Returns a human-readable message that describes this log.
*
* @return
* A human-readable message that describes this log.
*/
public TranslatableMessage getDescription() {
return description;
}
}

View File

@@ -22,6 +22,7 @@ package org.apache.guacamole.rest.history;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.guacamole.net.auth.ActivityRecord;
/**
@@ -74,7 +75,13 @@ public class APIActivityRecord {
* all attributes associated with this record.
*/
private final Map<String, String> attributes;
/**
* A map of all logs associated and accessible via this record, associated
* with their corresponding unique names.
*/
private final Map<String, APIActivityLog> logs;
/**
* Creates a new APIActivityRecord, copying the data from the given activity
* record.
@@ -83,6 +90,7 @@ public class APIActivityRecord {
* The record to copy data from.
*/
public APIActivityRecord(ActivityRecord record) {
this.startDate = record.getStartDate();
this.endDate = record.getEndDate();
this.remoteHost = record.getRemoteHost();
@@ -90,6 +98,12 @@ public class APIActivityRecord {
this.active = record.isActive();
this.uuid = record.getUUID();
this.attributes = record.getAttributes();
this.logs = record.getLogs().entrySet().stream().collect(Collectors.toMap(
Map.Entry::getKey,
(entry) -> new APIActivityLog(entry.getValue())
));
}
/**
@@ -172,5 +186,17 @@ public class APIActivityRecord {
public Map<String, String> getAttributes() {
return attributes;
}
/**
* Returns a Map of logs related to this record and accessible by the
* current user, such as Guacamole session recordings. Each log is
* associated with a corresponding, arbitrary, unique name.
*
* @return
* A Map of logs related to this record.
*/
public Map<String, APIActivityLog> getLogs() {
return logs;
}
}