@Test public void saveArchiveTest() throws Exception { final XWikiAttachmentContent content = this.archive.getAttachment().getAttachment_content(); final XWikiAttachment attach = this.archive.getAttachment(); 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()); this.versionStore.saveArchive(this.archive, null, false); Assert.assertTrue(this.provider.getAttachmentVersioningMetaFile().exists()); Assert.assertTrue(this.provider.getAttachmentVersioningMetaFile().length() > 120); Assert.assertTrue(this.provider.getAttachmentVersionContentFile("1.1").exists()); Assert.assertTrue(this.provider.getAttachmentVersionContentFile("1.2").exists()); Assert.assertTrue(this.provider.getAttachmentVersionContentFile("1.3").exists()); Assert.assertSame(attach, this.archive.getAttachment()); Assert.assertSame(content, this.archive.getAttachment().getAttachment_content()); }
@Override public void saveArchive(final XWikiAttachmentArchive archive, final XWikiContext context, final boolean bTransaction) throws XWikiException { try { this.getArchiveSaveRunnable(archive, context).start(); } catch (Exception e) { if (e instanceof XWikiException) { throw (XWikiException) e; } final Object[] args = { UNKNOWN_NAME, UNKNOWN_NAME }; if (archive.getAttachment() != null) { args[0] = archive.getAttachment().getFilename(); if (archive.getAttachment().getDoc() != null) { args[1] = archive.getAttachment().getDoc().getFullName(); } } throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Exception while saving attachment archive {0} of document {1}", e, args); } }
FilesystemAttachmentVersioningStore implements AttachmentVersioningStore { @Override public void saveArchive(final XWikiAttachmentArchive archive, final XWikiContext context, final boolean bTransaction) throws XWikiException { try { this.getArchiveSaveRunnable(archive, context).start(); } catch (Exception e) { if (e instanceof XWikiException) { throw (XWikiException) e; } final Object[] args = { UNKNOWN_NAME, UNKNOWN_NAME }; if (archive.getAttachment() != null) { args[0] = archive.getAttachment().getFilename(); if (archive.getAttachment().getDoc() != null) { args[1] = archive.getAttachment().getDoc().getFullName(); } } throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Exception while saving attachment archive {0} of document {1}", e, args); } } }
FilesystemAttachmentVersioningStore implements AttachmentVersioningStore { @Override public void saveArchive(final XWikiAttachmentArchive archive, final XWikiContext context, final boolean bTransaction) throws XWikiException { try { this.getArchiveSaveRunnable(archive, context).start(); } catch (Exception e) { if (e instanceof XWikiException) { throw (XWikiException) e; } final Object[] args = { UNKNOWN_NAME, UNKNOWN_NAME }; if (archive.getAttachment() != null) { args[0] = archive.getAttachment().getFilename(); if (archive.getAttachment().getDoc() != null) { args[1] = archive.getAttachment().getDoc().getFullName(); } } throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Exception while saving attachment archive {0} of document {1}", e, args); } }  }
FilesystemAttachmentVersioningStore implements AttachmentVersioningStore { @Override public void saveArchive(final XWikiAttachmentArchive archive, final XWikiContext context, final boolean bTransaction) throws XWikiException { try { this.getArchiveSaveRunnable(archive, context).start(); } catch (Exception e) { if (e instanceof XWikiException) { throw (XWikiException) e; } final Object[] args = { UNKNOWN_NAME, UNKNOWN_NAME }; if (archive.getAttachment() != null) { args[0] = archive.getAttachment().getFilename(); if (archive.getAttachment().getDoc() != null) { args[1] = archive.getAttachment().getDoc().getFullName(); } } throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Exception while saving attachment archive {0} of 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 saveArchive(final XWikiAttachmentArchive archive, final XWikiContext context, final boolean bTransaction) throws XWikiException { try { this.getArchiveSaveRunnable(archive, context).start(); } catch (Exception e) { if (e instanceof XWikiException) { throw (XWikiException) e; } final Object[] args = { UNKNOWN_NAME, UNKNOWN_NAME }; if (archive.getAttachment() != null) { args[0] = archive.getAttachment().getFilename(); if (archive.getAttachment().getDoc() != null) { args[1] = archive.getAttachment().getDoc().getFullName(); } } throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Exception while saving attachment archive {0} of 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);  }