Skip to content

Commit

Permalink
bigbluebuttonbn-web: Implemented filter for recordIDs [id:eq:xxxx,yyy…
Browse files Browse the repository at this point in the history
…y,zzzz]
  • Loading branch information
jfederico committed Jan 22, 2016
1 parent 6b91182 commit 2c214ca
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
Expand Up @@ -1711,11 +1711,10 @@ class ApiController {
internalRecordIds = paramsProcessorUtil.decodeIds(params.recordID) internalRecordIds = paramsProcessorUtil.decodeIds(params.recordID)
} }


Map<String, Object> filters = new LinkedHashMap<String, Object>() Map<String, Map<String, Object>> filters = new LinkedHashMap<String, Map<String, Object>>()
if (!StringUtils.isEmpty(params.filter)) { if (!StringUtils.isEmpty(params.filter)) {
filters = paramsProcessorUtil.decodeFilters(params.filter) filters = paramsProcessorUtil.decodeFilters(params.filter)
} }
log.debug(new groovy.json.JsonBuilder( filters ).toPrettyString())


// Everything is good so far. // Everything is good so far.
if ( internalRecordIds.size() == 0 ) { if ( internalRecordIds.size() == 0 ) {
Expand Down
Expand Up @@ -339,7 +339,7 @@ public Meeting getNotEndedMeetingWithId(String meetingId) {
return null; return null;
} }


public HashMap<String,Recording> getRecordings(ArrayList<String> idList, Map<String, Object> filters) { public HashMap<String,Recording> getRecordings(ArrayList<String> idList, Map<String, Map<String, Object>> filters) {
//TODO: this method shouldn't be used //TODO: this method shouldn't be used
HashMap<String,Recording> recs= reorderRecordings(recordingService.getRecordings(idList, filters)); HashMap<String,Recording> recs= reorderRecordings(recordingService.getRecordings(idList, filters));
return recs; return recs;
Expand Down
Expand Up @@ -740,8 +740,8 @@ public Map<String,String> getUserCustomData(Map<String,String> params) {
return resp; return resp;
} }


public Map<String, Object> decodeFilters(String encodedFilters) { public Map<String, Map<String, Object>> decodeFilters(String encodedFilters) {
Map<String, Object> filters = new LinkedHashMap<String, Object>(); Map<String, Map<String, Object>> filters = new LinkedHashMap<String, Map<String, Object>>();


try { try {
String[] sFilters = encodedFilters.split(URLDECODER_SEPARATOR); String[] sFilters = encodedFilters.split(URLDECODER_SEPARATOR);
Expand Down
Expand Up @@ -57,7 +57,7 @@ public void startIngestAndProcessing(String meetingId) {
} }
} }


private boolean shouldIncludeDir( Map<String, Object> filters, String type ) { private boolean shouldIncludeDir( Map<String, Map<String, Object>> filters, String type ) {
boolean r = false; boolean r = false;


if( filters.containsKey("state") ) { if( filters.containsKey("state") ) {
Expand All @@ -83,7 +83,18 @@ private boolean shouldIncludeDir( Map<String, Object> filters, String type ) {
return r; return r;
} }


public ArrayList<Recording> getRecordings(ArrayList<String> meetingIds, Map<String, Object> filters) { private String[] recordingIdsFromFilters( Map<String, Map<String, Object>> filters ) {
String[] recordingIds = {};

if( filters.containsKey("id") ) {
Map<String, Object> filter = (Map<String, Object>)filters.get("id");
recordingIds = (String[])filter.get("values");
}

return recordingIds;
}

public ArrayList<Recording> getRecordings(ArrayList<String> meetingIds, Map<String, Map<String, Object>> filters) {
ArrayList<Recording> recs = new ArrayList<Recording>(); ArrayList<Recording> recs = new ArrayList<Recording>();


if(meetingIds.isEmpty()){ if(meetingIds.isEmpty()){
Expand All @@ -99,21 +110,21 @@ public ArrayList<Recording> getRecordings(ArrayList<String> meetingIds, Map<Stri


for(String meetingId : meetingIds){ for(String meetingId : meetingIds){
if ( shouldIncludeDir(filters, Recording.STATE_PUBLISHED) ) { if ( shouldIncludeDir(filters, Recording.STATE_PUBLISHED) ) {
ArrayList<Recording> published = getRecordingsForPath(meetingId, publishedDir); ArrayList<Recording> published = getRecordingsForPath(meetingId, recordingIdsFromFilters(filters), publishedDir);
if (!published.isEmpty()) { if (!published.isEmpty()) {
recs.addAll(published); recs.addAll(published);
} }
} }


if ( shouldIncludeDir(filters, Recording.STATE_UNPUBLISHED) ) { if ( shouldIncludeDir(filters, Recording.STATE_UNPUBLISHED) ) {
ArrayList<Recording> unpublished = getRecordingsForPath(meetingId, unpublishedDir); ArrayList<Recording> unpublished = getRecordingsForPath(meetingId, recordingIdsFromFilters(filters), unpublishedDir);
if (!unpublished.isEmpty()) { if (!unpublished.isEmpty()) {
recs.addAll(unpublished); recs.addAll(unpublished);
} }
} }


if ( shouldIncludeDir(filters, Recording.STATE_DELETED) ) { if ( shouldIncludeDir(filters, Recording.STATE_DELETED) ) {
ArrayList<Recording> deleted = getRecordingsForPath(meetingId, deletedDir); ArrayList<Recording> deleted = getRecordingsForPath(meetingId, recordingIdsFromFilters(filters), deletedDir);
if (!deleted.isEmpty()) { if (!deleted.isEmpty()) {
recs.addAll(deleted); recs.addAll(deleted);
} }
Expand Down Expand Up @@ -171,7 +182,7 @@ private ArrayList<String> getAllRecordingIds(String path){
return ids; return ids;
} }


private ArrayList<Recording> getRecordingsForPath(String meetingId, String path) { private ArrayList<Recording> getRecordingsForPath(String meetingId, String[] recordingId, String path) {
ArrayList<Recording> recs = new ArrayList<Recording>(); ArrayList<Recording> recs = new ArrayList<Recording>();


String[] format = getPlaybackFormats(path); String[] format = getPlaybackFormats(path);
Expand All @@ -180,7 +191,9 @@ private ArrayList<Recording> getRecordingsForPath(String meetingId, String path)
for (int f = 0; f < recordings.length; f++) { for (int f = 0; f < recordings.length; f++) {
if (recordings[f].getName().startsWith(meetingId)) { if (recordings[f].getName().startsWith(meetingId)) {
Recording r = getRecordingInfo(path, recordings[f].getName(), format[i]); Recording r = getRecordingInfo(path, recordings[f].getName(), format[i]);
if (r != null) recs.add(r); if (r != null && ( recordingId.length == 0 || Arrays.asList(recordingId).contains("any") || Arrays.asList(recordingId).contains(r.getId())) ) {
recs.add(r);
}
} }
} }
} }
Expand Down

0 comments on commit 2c214ca

Please sign in to comment.