diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/service/XmlService.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/service/XmlService.java index eb4253f6b1..8bc283c644 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/service/XmlService.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/service/XmlService.java @@ -14,7 +14,7 @@ public interface XmlService { String thumbnailToXml(Thumbnail thumbnail); String callbackDataToXml(CallbackData callbackData); String constructResponseFromRecordingsXml(String xml); - String constructPaginatedResponse(Page page, String response); + String constructPaginatedResponse(Page page, int offset, String response); Recording xmlToRecording(String recordId, String xml); String noRecordings(); } diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/RecordingServiceDbImpl.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/RecordingServiceDbImpl.java index 85d2f978ce..7ba86444ad 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/RecordingServiceDbImpl.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/RecordingServiceDbImpl.java @@ -74,61 +74,73 @@ public class RecordingServiceDbImpl implements RecordingService { @Override public String getRecordings2x(List idList, List states, Map metadataFilters, int offset, Pageable pageable) { // If no IDs or limit were provided return no recordings instead of every recording - if(idList.isEmpty() && pageable == null) return xmlService.noRecordings(); + if((idList == null || idList.isEmpty()) && pageable == null) return xmlService.noRecordings(); logger.info("Retrieving all recordings"); - Set recordings = new HashSet<>(); - recordings.addAll(dataStore.findAll(Recording.class)); + Set recordings = new HashSet<>(dataStore.findAll(Recording.class)); + logger.info("{} recordings found", recordings.size()); - Set recordingsById = new HashSet<>(); - for(String id: idList) { - List r = dataStore.findRecordingsByMeetingId(id); + if(idList != null && !idList.isEmpty()) { + Set recordingsById = new HashSet<>(); - if(r == null || r.size() == 0) { - Recording recording = dataStore.findRecordingByRecordId(id); - if(recording != null) { - r = new ArrayList<>(); - r.add(recording); + for(String id: idList) { + logger.info("Finding recordings using meeting ID with value {}", id); + List recordingsByMeetingId = dataStore.findRecordingsByMeetingId(id); + + if(recordingsByMeetingId == null || recordingsByMeetingId.isEmpty()) { + logger.info("Finding recordings using recording ID with value {}", id); + Recording recording = dataStore.findRecordingByRecordId(id); + if(recording != null) { + logger.info("Recording found"); + recordingsById.add(recording); + } + } else { + logger.info("{} recordings found", recordingsByMeetingId.size()); + recordingsById.addAll(recordingsByMeetingId); } } - if(r != null) recordingsById.addAll(r); - } - - logger.info("Filtering recordings by meeting ID"); - if(recordingsById.size() > 0) { + logger.info("Filtering recordings by ID"); recordings.retainAll(recordingsById); - } - logger.info("{} recordings remaining", recordings.size()); - - Set recordingsByState = new HashSet<>(); - for(String state: states) { - List r = dataStore.findRecordingsByState(state); - if(r != null) recordingsByState.addAll(r); + logger.info("{} recordings remain", recordings.size()); } - logger.info("Filtering recordings by state"); - if(recordingsByState.size() > 0) { + if(states != null && !states.isEmpty()) { + Set recordingsByState = new HashSet<>(); + + for(String state: states) { + logger.info("Finding recordings by state {}", state); + List r = dataStore.findRecordingsByState(state); + if(state != null && !state.isEmpty()) { + logger.info("{} recordings found", r.size()); + recordingsByState.addAll(r); + } + } + + logger.info("Filtering recordings by state"); recordings.retainAll(recordingsByState); - } - logger.info("{} recordings remaining", recordings.size()); - - List metadata = new ArrayList<>(); - for(Map.Entry metadataFilter: metadataFilters.entrySet()) { - List m = dataStore.findMetadataByFilter(metadataFilter.getKey(), metadataFilter.getValue()); - if(m != null) metadata.addAll(m); + logger.info("{} recordings remain", recordings.size()); } - Set recordingsByMetadata = new HashSet<>(); - for(Metadata m: metadata) { - recordingsByMetadata.add(m.getRecording()); - } + if(metadataFilters != null && !metadataFilters.isEmpty()) { + List metadata = new ArrayList<>(); - logger.info("Filtering recordings by metadata"); - if(recordingsByMetadata.size() > 0) { + for(Map.Entry filter: metadataFilters.entrySet()) { + logger.info("Finding metadata using filter {} {}", filter.getKey(), filter.getValue()); + List metadataByFilter = dataStore.findMetadataByFilter(filter.getKey(), filter.getValue()); + if(metadataByFilter != null) { + logger.info("{} metadata found", metadataByFilter.size()); + metadata.addAll(metadataByFilter); + } + } + + Set recordingsByMetadata = new HashSet<>(); + for(Metadata m: metadata) recordingsByMetadata.add(m.getRecording()); + + logger.info("Filtering recordings by metadata"); recordings.retainAll(recordingsByMetadata); + logger.info("{} recordings remain", recordings.size()); } - logger.info("{} recordings remaining", recordings.size()); // If no/invalid pagination parameters were given do not paginate the response if(pageable == null) { @@ -140,7 +152,7 @@ public class RecordingServiceDbImpl implements RecordingService { String recordingsXml = xmlService.recordingsToXml(recordingsPage.getContent()); String response = xmlService.constructResponseFromRecordingsXml(recordingsXml); - return xmlService.constructPaginatedResponse(recordingsPage, response); + return xmlService.constructPaginatedResponse(recordingsPage, offset, response); } @Override diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/RecordingServiceFileImpl.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/RecordingServiceFileImpl.java index 4d83e1881a..a8ba25c096 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/RecordingServiceFileImpl.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/RecordingServiceFileImpl.java @@ -213,7 +213,7 @@ public class RecordingServiceFileImpl implements RecordingService { Page recordingsPage = listToPage(recs, offset, pageable); String response = recordingServiceHelper.getRecordings2x(new ArrayList(recordingsPage.getContent())); - return xmlService.constructPaginatedResponse(recordingsPage, response); + return xmlService.constructPaginatedResponse(recordingsPage, offset, response); } private RecordingMetadata getRecordingMetadata(File dir) { diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/XmlServiceImpl.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/XmlServiceImpl.java index 1b2bc03b5a..9ca7ee2406 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/XmlServiceImpl.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/service/impl/XmlServiceImpl.java @@ -72,7 +72,7 @@ public class XmlServiceImpl implements XmlService { @Override public String recordingToXml(Recording recording) { - logger.info("Converting {} to xml", recording); +// logger.info("Converting {} to xml", recording); try { setup(); Document document = builder.newDocument(); @@ -125,7 +125,7 @@ public class XmlServiceImpl implements XmlService { @Override public String metadataToXml(Metadata metadata) { - logger.info("Converting {} to xml", metadata); +// logger.info("Converting {} to xml", metadata); try { setup(); @@ -148,7 +148,7 @@ public class XmlServiceImpl implements XmlService { @Override public String playbackFormatToXml(PlaybackFormat playbackFormat) { - logger.info("Converting {} to xml", playbackFormat); +// logger.info("Converting {} to xml", playbackFormat); try { setup(); @@ -187,7 +187,7 @@ public class XmlServiceImpl implements XmlService { @Override public String thumbnailToXml(Thumbnail thumbnail) { - logger.info("Converting {} to xml", thumbnail); +// logger.info("Converting {} to xml", thumbnail); try { setup(); @@ -211,7 +211,7 @@ public class XmlServiceImpl implements XmlService { @Override public String callbackDataToXml(CallbackData callbackData) { - logger.info("Converting {} to xml", callbackData); +// logger.info("Converting {} to xml", callbackData); try { setup(); @@ -296,7 +296,7 @@ public class XmlServiceImpl implements XmlService { } @Override - public String constructPaginatedResponse(Page page, String response) { + public String constructPaginatedResponse(Page page, int offset, String response) { logger.info("Constructing paginated response"); try { @@ -315,7 +315,7 @@ public class XmlServiceImpl implements XmlService { Document secondDoc; Node node; - xml = pageableToXml(page.getPageable()); + xml = pageableToXml(page.getPageable(), offset); secondDoc = builder.parse(new ByteArrayInputStream(xml.getBytes())); node = document.importNode(secondDoc.getDocumentElement(), true); pagination.appendChild(node); @@ -326,8 +326,8 @@ public class XmlServiceImpl implements XmlService { // Element last = createElement(document, "last", String.valueOf(page.isLast())); // pagination.appendChild(last); - Element totalPages = createElement(document, "totalPages", String.valueOf(page.getTotalPages())); - pagination.appendChild(totalPages); +// Element totalPages = createElement(document, "totalPages", String.valueOf(page.getTotalPages())); +// pagination.appendChild(totalPages); // Element first = createElement(document, "first", String.valueOf(page.isFirst())); // pagination.appendChild(first); @@ -349,7 +349,7 @@ public class XmlServiceImpl implements XmlService { return null; } - private String pageableToXml(Pageable pageable) { + private String pageableToXml(Pageable pageable, int o) { logger.info("Converting {} to xml", pageable); try { @@ -373,7 +373,7 @@ public class XmlServiceImpl implements XmlService { // // rootElement.appendChild(sortElement); - Element offset = createElement(document, "offset", String.valueOf(pageable.getOffset())); + Element offset = createElement(document, "offset", String.valueOf(o)); rootElement.appendChild(offset); Element limit = createElement(document, "limit", String.valueOf(pageable.getPageSize())); diff --git a/bbb-recording-imex/get-recordings.sh b/bbb-recording-imex/get-recordings.sh index 2a0bdb1995..e15fb6e1f2 100755 --- a/bbb-recording-imex/get-recordings.sh +++ b/bbb-recording-imex/get-recordings.sh @@ -1,11 +1,13 @@ #!/bin/bash -while getopts i:r:s:m: flag +while getopts i:r:s:m:o:l: flag do case "${flag}" in i) MEETING_ID=${OPTARG};; r) RECORD_ID=${OPTARG};; s) STATE=${OPTARG};; m) META=${OPTARG};; + o) OFFSET=${OPTARG};; + l) LIMIT=${OPTARG};; esac done @@ -17,7 +19,9 @@ QUERY="" if ! [[ -z ${MEETING_ID+x} ]]; then QUERY+="meetingID=$MEETING_ID&"; fi if ! [[ -z ${RECORD_ID+x} ]]; then QUERY+="recordID=$RECORD_ID&"; fi if ! [[ -z ${STATE+x} ]]; then QUERY+="state=$STATE&"; fi -if ! [[ -z ${META+x} ]]; then QUERY+="meta=$META"; fi +if ! [[ -z ${META+x} ]]; then QUERY+="meta=$META&"; fi +if ! [[ -z ${OFFSET+x} ]]; then QUERY+="offset=$OFFSET&"; fi +if ! [[ -z ${LIMIT+x} ]]; then QUERY+="limit=$LIMIT"; fi echo "query: $QUERY" @@ -26,7 +30,7 @@ if [ "${QUERY:$INDEX:1}" = "&" ]; then QUERY=${QUERY:0:$INDEX}; fi echo "query: $QUERY" -SALT= +SALT="" DATA="$ENDPOINT$QUERY$SALT" echo "data: $DATA"