Search in sources :

Example 1 with JSONAttachment

use of de.metas.ui.web.attachments.json.JSONAttachment in project metasfresh-webui-api by metasfresh.

the class DocumentAttachmentsRestController method getAttachments.

@GetMapping
public List<JSONAttachment> getAttachments(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId) {
    userSession.assertLoggedIn();
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), documentId);
    if (documentPath.isComposedKey()) {
        // document with composed keys does not support attachments
        return ImmutableList.of();
    }
    final boolean allowDelete = isAllowDeletingAttachments();
    final List<JSONAttachment> attachments = getDocumentAttachments(documentPath).toJson();
    attachments.forEach(attachment -> attachment.setAllowDelete(allowDelete));
    return attachments;
}
Also used : DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONAttachment(de.metas.ui.web.attachments.json.JSONAttachment) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

JSONAttachment (de.metas.ui.web.attachments.json.JSONAttachment)1 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1