@Test public void deleteArchiveTest() throws Exception { this.versionStore.saveArchive(this.archive, null, false); Assert.assertTrue(this.provider.getAttachmentVersioningMetaFile().exists()); Assert.assertTrue(this.provider.getAttachmentVersionContentFile("1.1").exists()); Assert.assertTrue(this.provider.getAttachmentVersionContentFile("1.2").exists()); Assert.assertTrue(this.provider.getAttachmentVersionContentFile("1.3").exists()); this.versionStore.deleteArchive(this.archive.getAttachment(), null, false); Assert.assertFalse(this.provider.getAttachmentVersioningMetaFile().exists()); Assert.assertFalse(this.provider.getAttachmentVersionContentFile("1.1").exists()); Assert.assertFalse(this.provider.getAttachmentVersionContentFile("1.2").exists()); Assert.assertFalse(this.provider.getAttachmentVersionContentFile("1.3").exists()); }
@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); } }
FilesystemAttachmentVersioningStore implements AttachmentVersioningStore { @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); } } }
FilesystemAttachmentVersioningStore implements AttachmentVersioningStore { @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); } }  }
FilesystemAttachmentVersioningStore implements AttachmentVersioningStore { @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); } }  @Override String getHint(); @Override XWikiAttachmentArchive loadArchive(final XWikiAttachment attachment, final XWikiContext context,
        final boolean bTransaction); @Override void saveArchive(final XWikiAttachmentArchive archive, final XWikiContext context,
        final boolean bTransaction); StartableTransactionRunnable getArchiveSaveRunnable(final XWikiAttachmentArchive archive,
        final XWikiContext context); @Override void deleteArchive(final XWikiAttachment attachment, final XWikiContext context, final boolean bTransaction); StartableTransactionRunnable getArchiveDeleteRunnable(final XWikiAttachmentArchive archive); }
FilesystemAttachmentVersioningStore implements AttachmentVersioningStore { @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); } }  @Override String getHint(); @Override XWikiAttachmentArchive loadArchive(final XWikiAttachment attachment, final XWikiContext context,
        final boolean bTransaction); @Override void saveArchive(final XWikiAttachmentArchive archive, final XWikiContext context,
        final boolean bTransaction); StartableTransactionRunnable getArchiveSaveRunnable(final XWikiAttachmentArchive archive,
        final XWikiContext context); @Override void deleteArchive(final XWikiAttachment attachment, final XWikiContext context, final boolean bTransaction); StartableTransactionRunnable getArchiveDeleteRunnable(final XWikiAttachmentArchive archive);  }