Skip to content

Commit

Permalink
bigbluebutton-web: Extended filterRecordingsByMetadata in order to su…
Browse files Browse the repository at this point in the history
…pport wildcards
  • Loading branch information
jfederico committed Feb 1, 2016
1 parent f6453e3 commit 84e4221
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1702,17 +1702,17 @@ class ApiController {
return
}

ArrayList<String> externalMeetingIds = new ArrayList<String>();
List<String> externalMeetingIds = new ArrayList<String>();
if (!StringUtils.isEmpty(params.meetingID)) {
externalMeetingIds=paramsProcessorUtil.decodeIds(params.meetingID);
}

ArrayList<String> internalRecordIds = new ArrayList<String>()
List<String> internalRecordIds = new ArrayList<String>()
if (!StringUtils.isEmpty(params.recordID)) {
internalRecordIds = paramsProcessorUtil.decodeIds(params.recordID)
}

ArrayList<String> states = new ArrayList<String>()
List<String> states = new ArrayList<String>()
if (!StringUtils.isEmpty(params.state)) {
states = paramsProcessorUtil.decodeIds(params.state)
}
Expand All @@ -1725,7 +1725,7 @@ class ApiController {
}


HashMap<String,Recording> recs = meetingService.getRecordings(internalRecordIds, states);
Map<String,Recording> recs = meetingService.getRecordings(internalRecordIds, states);
recs = meetingService.filterRecordingsByMetadata(recs, ParamsProcessorUtil.processMetaParam(params));

if (recs.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,32 @@ public List<Recording> getRecordings(List<String> recordIDs, List<String> states
}

public boolean recordingMatchesMetadata(Recording recording, Map<String, String> metadataFilters) {
boolean matchesMetadata = true;
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
if ( metadataValue == null ) {
// The recording doesn't have metadata specified
matchesMetadata = false;
} else {
return false;
String filterValue = filter.getValue();
if( filterValue.charAt(0) == '%' && filterValue.charAt(filterValue.length()-1) == '%' && metadataValue.contains(filterValue.substring(1, filterValue.length()-1)) ){
// Filter value embraced by two wild cards
// AND the filter value is part of the metadata value
} else if( filterValue.charAt(0) == '%' && metadataValue.endsWith(filterValue.substring(1, filterValue.length())) ) {
// Filter value starts with a wild cards
// AND the filter value ends with the metadata value
} else if( filterValue.charAt(filterValue.length()-1) == '%' && metadataValue.startsWith(filterValue.substring(0, filterValue.length()-1)) ) {
// Filter value ends with a wild cards
// AND the filter value starts with the metadata value
} else if( metadataValue.equals(filterValue) ) {
// Filter value doesnt have wildcards
// AND the filter value is the same as metadata value
} else {
matchesMetadata = false;
}
}
}
return true;
return matchesMetadata;
}

public Map<String, Recording> filterRecordingsByMetadata(Map<String, Recording> recordings, Map<String, String> metadataFilters) {
Expand Down

0 comments on commit 84e4221

Please sign in to comment.