@Override public void loadAttachmentContent(final XWikiAttachment attachment, final XWikiContext context, final boolean bTransaction) throws XWikiException { final File attachFile = this.fileTools.getAttachmentFileProvider(attachment.getReference()).getAttachmentContentFile(); if (!attachFile.exists()) { throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_FILENOTFOUND, String.format("The attachment [%s] could not be found in the filesystem attachment store.", attachFile)); } FilesystemAttachmentContent content = new FilesystemAttachmentContent(attachFile); content.setContentDirty(false); attachment.setAttachment_content(content); attachment.setContentStore(FileSystemStoreUtils.HINT); }
attachment.setAttachment_content(new FilesystemAttachmentContent(contentFile, attachment)); attachment.setContentStore(FileSystemStoreUtils.HINT);
attach.setAttachment_content(new FilesystemAttachmentContent(contentFile, attach));
@Override public void loadAttachmentContent(final XWikiAttachment attachment, final XWikiContext context, final boolean bTransaction) throws XWikiException { final File attachFile = getFilesystemStoreTools().getAttachmentFileProvider(attachment).getAttachmentContentFile(); if (attachFile.exists()) { FilesystemAttachmentContent content = new FilesystemAttachmentContent(attachFile); content.setContentDirty(false); attachment.setAttachment_content(content); return; } throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_FILENOTFOUND, "The attachment could not be found in the filesystem attachment store.\n" + "This can happen if attachment storage is switched from database to " + "filesystem without first moving all of the database attachments over " + "to the filesystem using a script."); }
attach.setAttachment_content(new FilesystemAttachmentContent(contentFile, attach)); attach.setContentStore(FileSystemStoreUtils.HINT);
attachment.setAttachment_content(new FilesystemAttachmentContent(contentFile, attachment));
fakeAvatarAttachment.setAttachment_content(new XWikiAttachmentContent(fakeAvatarAttachment));
attachment.setRCSVersion(getRCSVersion()); if (getAttachment_content() != null) { attachment.setAttachment_content((XWikiAttachmentContent) getAttachment_content().clone()); attachment.getAttachment_content().setAttachment(attachment);
attachment.setAttachment_content(content); session.load(content, new Long(content.getId()));
@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; }