public Object doInHibernate(Session session) throws HibernateException, XWikiException { XWikiAttachmentArchive archive = new XWikiAttachmentArchive(); archive.setAttachment(attachment); session.delete(archive); return null; } });
public void setArchive(String data) throws XWikiException { if (this.attachment_archive == null) { this.attachment_archive = new XWikiAttachmentArchive(); this.attachment_archive.setAttachment(this); } this.attachment_archive.setArchive(data.getBytes()); }
/** * @deprecated since 2.6M1 please do not use this, it is bound to a jrcs based implementation. */ @Deprecated public void setArchive(Archive archive) { if (this.attachment_archive == null) { this.attachment_archive = new XWikiAttachmentArchive(); this.attachment_archive.setAttachment(this); } this.attachment_archive.setRCSArchive(archive); }
/** * {@inheritDoc} */ public void deleteArchive(final XWikiAttachment attachment, final XWikiContext context, boolean bTransaction) throws XWikiException { try { executeWrite(context, bTransaction, new HibernateCallback<Object>() { public Object doInHibernate(Session session) throws HibernateException, XWikiException { XWikiAttachmentArchive archive = new XWikiAttachmentArchive(); archive.setAttachment(attachment); session.delete(archive); return null; } }); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(String.format("Error deleting attachment archive [%s] of doc [%s]", attachment.getFilename(), attachment.getDoc().getFullName()), e); } } } }
/** * {@inheritDoc} */ public XWikiAttachmentArchive loadArchive(final XWikiAttachment attachment, XWikiContext context, boolean bTransaction) throws XWikiException { try { final XWikiAttachmentArchive archive = new XWikiAttachmentArchive(); archive.setAttachment(attachment); executeRead(context, bTransaction, new HibernateCallback<Object>() { public Object doInHibernate(Session session) throws HibernateException { try { session.load(archive, archive.getId()); } catch (ObjectNotFoundException e) { // if none found then return empty created archive } return null; } }); attachment.setAttachment_archive(archive); return archive; } catch (Exception e) { Object[] args = {attachment.getFilename(), attachment.getDoc().getFullName()}; throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_LOADING_ATTACHMENT, "Exception while loading attachment archive {0} of document {1}", e, args); } }