public Object doInHibernate(Session session) throws HibernateException, XWikiException { XWikiAttachmentArchive archive = new XWikiAttachmentArchive(); archive.setAttachment(attachment); session.delete(archive); return null; } });
/** * @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); }
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()); }
/** * {@inheritDoc} * * @see java.lang.Object#clone() */ @Override public Object clone() { XWikiAttachmentArchive attachmentarchive = null; try { attachmentarchive = (XWikiAttachmentArchive) getClass().newInstance(); } catch (Exception e) { // This should not happen LOG.error("Error while attachmentArchive.clone()", e); } attachmentarchive.setAttachment(getAttachment()); attachmentarchive.setRCSArchive(getRCSArchive()); return attachmentarchive; }
/** * {@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); } }
restoredAttachmentRevision.getAttachment_archive().setAttachment(restoredAttachmentRevision); restoredAttachmentRevision.setVersion(restoredAttachment.getVersion()); restoredAttachmentRevision.setMetaDataDirty(true);
attachment.getAttachment_archive().setAttachment(attachment);
@Override public XWikiAttachment restoreAttachment(final XWikiAttachment attachment, final XWikiContext context) throws XWikiException { XWikiAttachment result = attachment; if (result != null) { // TODO Add XWikiAttachment#clone(XWikiAttachment) // this toXML does not copy content. result.fromXML(this.attachment.toXML(context)); if (this.attachment.getAttachment_content() != null) { attachment.setAttachment_content((XWikiAttachmentContent) this.attachment.getAttachment_content() .clone()); attachment.getAttachment_content().setAttachment(attachment); } if (this.attachment.getAttachment_archive() != null) { result.setAttachment_archive((XWikiAttachmentArchive) this.attachment.getAttachment_archive().clone()); result.getAttachment_archive().setAttachment(result); } } else { result = (XWikiAttachment) this.attachment.clone(); } result.setDoc(context.getWiki().getDocument(this.attachment.getReference().getDocumentReference(), context)); return result; }