Search in sources :

Example 1 with AttachmentURLCommand

use of com.celements.web.plugin.cmd.AttachmentURLCommand in project celements-blog by celements.

the class NewsletterAttachmentService method getImageURL.

@Override
public String getImageURL(String imgFullname, boolean embedImage) {
    String imgURL = "";
    AttachmentURLCommand attURL = new AttachmentURLCommand();
    if (embedImage) {
        extendAttachmentList(getAttachmentForFullname(imgFullname), DEFAULT_NL_ATTACHMENT_LIST);
        imgURL = "cid:" + attURL.getAttachmentName(imgFullname);
    } else {
        imgURL = attURL.getAttachmentURL(imgFullname, "download", getContext());
    }
    return imgURL;
}
Also used : AttachmentURLCommand(com.celements.web.plugin.cmd.AttachmentURLCommand)

Example 2 with AttachmentURLCommand

use of com.celements.web.plugin.cmd.AttachmentURLCommand in project celements-blog by celements.

the class NewsletterAttachmentService method getAttachmentForFullname.

Attachment getAttachmentForFullname(String imgFullname) {
    AttachmentURLCommand attURL = new AttachmentURLCommand();
    Attachment att = null;
    try {
        XWikiDocument attDoc = getContext().getWiki().getDocument(webUtils.resolveDocumentReference(attURL.getPageFullName(imgFullname)), getContext());
        XWikiAttachment xatt = attService.getAttachmentNameEqual(attDoc, attURL.getAttachmentName(imgFullname));
        att = attService.getApiAttachment(xatt);
    } catch (XWikiException xwe) {
        LOGGER.error("Exception getting attachment Document.", xwe);
    } catch (AttachmentNotExistsException anee) {
        LOGGER.error("Attachment [{}] not found.", imgFullname, anee);
    } catch (NoAccessRightsException nore) {
        LOGGER.error("No access rights on attachment [{}]", imgFullname, nore);
    }
    return att;
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) AttachmentURLCommand(com.celements.web.plugin.cmd.AttachmentURLCommand) AttachmentNotExistsException(com.celements.model.access.exception.AttachmentNotExistsException) XWikiAttachment(com.xpn.xwiki.doc.XWikiAttachment) Attachment(com.xpn.xwiki.api.Attachment) XWikiAttachment(com.xpn.xwiki.doc.XWikiAttachment) NoAccessRightsException(com.celements.rights.access.exceptions.NoAccessRightsException) XWikiException(com.xpn.xwiki.XWikiException)

Aggregations

AttachmentURLCommand (com.celements.web.plugin.cmd.AttachmentURLCommand)2 AttachmentNotExistsException (com.celements.model.access.exception.AttachmentNotExistsException)1 NoAccessRightsException (com.celements.rights.access.exceptions.NoAccessRightsException)1 XWikiException (com.xpn.xwiki.XWikiException)1 Attachment (com.xpn.xwiki.api.Attachment)1 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1