very first implementation of the getRecordings call filtering by metadata; the idea is the same as on create, the user will specify some parameters as meta_*, and the call will return just the recordings that match all the metadata specified; it continues working with the meetingID filter, and both can be used together
This commit is contained in:
parent
17bba97d40
commit
f8180d3cee
@ -828,6 +828,7 @@ class ApiController {
|
||||
// Everything is good so far. Translate the external meeting ids to an internal meeting ids.
|
||||
ArrayList<String> internalMeetingIds = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingIds);
|
||||
HashMap<String,Recording> recs = meetingService.getRecordings(internalMeetingIds);
|
||||
recs = meetingService.filterRecordingsByMetadata(recs, paramsProcessorUtil.getMetadataFromParams(params));
|
||||
|
||||
if (recs.isEmpty()) {
|
||||
response.addHeader("Cache-Control", "no-cache")
|
||||
|
@ -113,6 +113,10 @@ public class MeetingService {
|
||||
return recs;
|
||||
}
|
||||
|
||||
public Map<String, Recording> filterRecordingsByMetadata(Map<String, Recording> recordings, Map<String, String> metadataFilters) {
|
||||
return recordingService.filterRecordingsByMetadata(recordings, metadataFilters);
|
||||
}
|
||||
|
||||
public HashMap<String,Recording> reorderRecordings(ArrayList<Recording> olds){
|
||||
HashMap<String,Recording> map= new HashMap<String, Recording>();
|
||||
for(Recording r:olds){
|
||||
|
@ -265,16 +265,7 @@ public class ParamsProcessorUtil {
|
||||
}
|
||||
|
||||
// Collect metadata for this meeting that the third-party app wants to store if meeting is recorded.
|
||||
Map<String, String> meetingInfo = new HashMap<String, String>();
|
||||
for (String key: params.keySet()) {
|
||||
if (key.contains("meta")&&key.indexOf("meta")==0){
|
||||
String[] meta = key.split("_");
|
||||
if(meta.length == 2){
|
||||
log.debug("Got metadata {} = {}", key, params.get(key));
|
||||
meetingInfo.put(meta[1].toLowerCase(), params.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> meetingInfo = getMetadataFromParams(params);
|
||||
|
||||
// Create a unique internal id by appending the current time. This way, the 3rd-party
|
||||
// app can reuse the external meeting id.
|
||||
@ -290,7 +281,21 @@ public class ParamsProcessorUtil {
|
||||
|
||||
return meeting;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, String> getMetadataFromParams(Map<String, String> params) {
|
||||
// Collect metadata for this meeting that the third-party app wants to store if meeting is recorded.
|
||||
Map<String, String> meetingInfo = new HashMap<String, String>();
|
||||
for (String key: params.keySet()) {
|
||||
if (key.contains("meta")&&key.indexOf("meta")==0){
|
||||
String[] meta = key.split("_");
|
||||
if(meta.length == 2){
|
||||
log.debug("Got metadata {} = {}", key, params.get(key));
|
||||
meetingInfo.put(meta[1].toLowerCase(), params.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
return meetingInfo;
|
||||
}
|
||||
|
||||
public String getApiVersion() {
|
||||
return apiVersion;
|
||||
|
@ -4,6 +4,8 @@ import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bigbluebutton.api.domain.Recording;
|
||||
import org.slf4j.Logger;
|
||||
@ -57,6 +59,28 @@ public class RecordingService {
|
||||
return recs;
|
||||
}
|
||||
|
||||
public boolean recordingMatchesMetadata(Recording recording, Map<String, String> metadataFilters) {
|
||||
for (Map.Entry<String, String> filter : metadataFilters.entrySet()) {
|
||||
String metadataValue = recording.getMetadata().get(filter.getKey());
|
||||
if (metadataValue != null && metadataValue.equals(filter.getValue())) {
|
||||
// the recording has the metadata specified
|
||||
// AND the value is the same as the filter
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<String, Recording> filterRecordingsByMetadata(Map<String, Recording> recordings, Map<String, String> metadataFilters) {
|
||||
Map<String, Recording> resultRecordings = new HashMap<String, Recording>();
|
||||
for (Map.Entry<String, Recording> entry : recordings.entrySet()) {
|
||||
if (recordingMatchesMetadata(entry.getValue(), metadataFilters))
|
||||
resultRecordings.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return resultRecordings;
|
||||
}
|
||||
|
||||
public boolean existAnyRecording(ArrayList<String> idList){
|
||||
ArrayList<String> publishList=getAllRecordingIds(publishedDir);
|
||||
ArrayList<String> unpublishList=getAllRecordingIds(unpublishedDir);
|
||||
|
Loading…
Reference in New Issue
Block a user