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;
}
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;
}
Aggregations