use of de.metas.attachments.AttachmentEntryType in project metasfresh-webui-api by metasfresh.
the class DocumentAttachmentsRestController method getAttachmentById.
@GetMapping("/{id}")
public ResponseEntity<byte[]> getAttachmentById(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentId, @PathVariable("id") final String entryIdStr) {
userSession.assertLoggedIn();
final DocumentId entryId = DocumentId.of(entryIdStr);
final IDocumentAttachmentEntry entry = getDocumentAttachments(windowIdStr, documentId).getEntry(entryId);
final AttachmentEntryType type = entry.getType();
if (type == AttachmentEntryType.Data) {
return extractResponseEntryFromData(entry);
} else if (type == AttachmentEntryType.URL) {
return extractResponseEntryFromURL(entry);
} else {
throw new AdempiereException("Invalid attachment entry").setParameter("reason", "invalid type").setParameter("type", type).setParameter("entry", entry);
}
}
Aggregations