Search in sources :

Example 6 with XWikiAttachmentArchive

use of com.xpn.xwiki.doc.XWikiAttachmentArchive in project xwiki-platform by xwiki.

the class FilesystemAttachmentVersioningStore method deleteArchive.

/**
 * {@inheritDoc}
 * <p>
 * bTransaction is ignored by this implementation. If you need to delete an archive inside of a larger transaction,
 * please use getArchiveDeleteRunnable()
 * </p>
 *
 * @see AttachmentVersioningStore#deleteArchive(XWikiAttachment, XWikiContext, boolean)
 */
@Override
public void deleteArchive(final XWikiAttachment attachment, final XWikiContext context, final boolean bTransaction) throws XWikiException {
    if (attachment == null) {
        throw new NullPointerException("The attachment to delete cannot be null");
    }
    try {
        final XWikiAttachmentArchive archive = this.loadArchive(attachment, context, bTransaction);
        this.getArchiveDeleteRunnable(archive).start();
    } catch (Exception e) {
        if (e instanceof XWikiException) {
            throw (XWikiException) e;
        }
        final Object[] args = { attachment.getFilename(), UNKNOWN_NAME };
        if (attachment.getDoc() != null) {
            args[1] = attachment.getDoc().getFullName();
        }
        throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Exception while deleting attachment archive {0} from document {1}", e, args);
    }
}
Also used : XWikiAttachmentArchive(com.xpn.xwiki.doc.XWikiAttachmentArchive) XWikiException(com.xpn.xwiki.XWikiException) IOException(java.io.IOException) XWikiException(com.xpn.xwiki.XWikiException)

Aggregations

XWikiAttachmentArchive (com.xpn.xwiki.doc.XWikiAttachmentArchive)6 XWikiException (com.xpn.xwiki.XWikiException)3 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HibernateException (org.hibernate.HibernateException)1 ObjectNotFoundException (org.hibernate.ObjectNotFoundException)1 Session (org.hibernate.Session)1 Test (org.junit.Test)1 FilterEventParameters (org.xwiki.filter.FilterEventParameters)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1