Search in sources :

Example 1 with NoAccessRightsException

use of com.celements.rights.access.exceptions.NoAccessRightsException 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

AttachmentNotExistsException (com.celements.model.access.exception.AttachmentNotExistsException)1 NoAccessRightsException (com.celements.rights.access.exceptions.NoAccessRightsException)1 AttachmentURLCommand (com.celements.web.plugin.cmd.AttachmentURLCommand)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