Skip to content

Commit

Permalink
LPS-155148 Need to do it like this now so it can detect the exception…
Browse files Browse the repository at this point in the history
… thrown
  • Loading branch information
brianchandotcom committed Jun 1, 2022
1 parent ab7c081 commit 4416c97
Showing 1 changed file with 16 additions and 15 deletions.
Expand Up @@ -92,23 +92,10 @@ protected void doServeResource(
private List<DSDocument> _getDSDocuments(ResourceRequest resourceRequest)
throws Exception {

return TransformUtil.unsafeTransformToList(
return TransformUtil.transformToList(
ArrayUtil.toLongArray(
ParamUtil.getLongValues(resourceRequest, "fileEntryIds")),
fileEntryId -> {
FileEntry fileEntry = _dlAppLocalService.getFileEntry(
fileEntryId);

return new DSDocument() {
{
data = Base64.encode(
FileUtil.getBytes(fileEntry.getContentStream()));
dsDocumentId = String.valueOf(fileEntryId);
fileExtension = fileEntry.getExtension();
name = fileEntry.getFileName();
}
};
});
fileEntryId -> _toDSDocument(fileEntryId));
}

private List<DSRecipient> _getDSRecipients(ResourceRequest resourceRequest)
Expand All @@ -128,6 +115,20 @@ private List<DSRecipient> _getDSRecipients(ResourceRequest resourceRequest)
});
}

private DSDocument _toDSDocument(long fileEntryId) throws Exception {
FileEntry fileEntry = _dlAppLocalService.getFileEntry(fileEntryId);

return new DSDocument() {
{
data = Base64.encode(
FileUtil.getBytes(fileEntry.getContentStream()));
dsDocumentId = String.valueOf(fileEntryId);
fileExtension = fileEntry.getExtension();
name = fileEntry.getFileName();
}
};
}

@Reference
private DLAppLocalService _dlAppLocalService;

Expand Down

0 comments on commit 4416c97

Please sign in to comment.