Search in sources :

Example 1 with AttachmentEntry

use of de.metas.attachments.AttachmentEntry in project metasfresh-webui-api by metasfresh.

the class DocumentAttachments method getEntry.

public IDocumentAttachmentEntry getEntry(final DocumentId id) {
    final IPair<String, Integer> prefixAndId = toPrefixAndEntryId(id);
    final String idPrefix = prefixAndId.getLeft();
    final int entryId = prefixAndId.getRight();
    if (ID_PREFIX_Attachment.equals(idPrefix)) {
        final AttachmentEntry entry = attachmentsBL.getEntryById(recordRef, entryId);
        if (entry == null) {
            throw new EntityNotFoundException(id.toJson());
        }
        return DocumentAttachmentEntry.of(id, entry);
    } else if (ID_PREFIX_Archive.equals(idPrefix)) {
        final I_AD_Archive archive = Services.get(IArchiveDAO.class).retrieveArchiveOrNull(Env.getCtx(), recordRef, entryId);
        if (archive == null) {
            throw new EntityNotFoundException(id.toJson());
        }
        return DocumentArchiveEntry.of(id, archive);
    } else {
        throw new EntityNotFoundException(id.toJson());
    }
}
Also used : I_AD_Archive(org.compiere.model.I_AD_Archive) AttachmentEntry(de.metas.attachments.AttachmentEntry) I_AD_AttachmentEntry(org.compiere.model.I_AD_AttachmentEntry) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException)

Aggregations

AttachmentEntry (de.metas.attachments.AttachmentEntry)1 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)1 I_AD_Archive (org.compiere.model.I_AD_Archive)1 I_AD_AttachmentEntry (org.compiere.model.I_AD_AttachmentEntry)1