/** * @return the last version number of the document */ public String getVersion() { return this.attachment.getVersion(); }
/** * {@inheritDoc} */ @Override public XWikiAttachment getRevision(XWikiAttachment attachment, String rev, XWikiContext context) throws XWikiException { return (attachment.getVersion().equals(rev)) ? attachment : null; }
public XWikiAttachment getAttachmentRevision(String rev, XWikiContext context) throws XWikiException { if (StringUtils.equals(rev, this.getVersion())) { return this; } return loadArchive(context).getRevision(this, rev, context); }
XWikiAttachment newAttach = toDoc.getAttachment(fileName); if (newAttach == null) { difflist.add(new AttachmentDiff(fileName, origAttach.getVersion(), null)); } else { if (!origAttach.getVersion().equals(newAttach.getVersion())) { difflist.add(new AttachmentDiff(fileName, origAttach.getVersion(), newAttach.getVersion())); XWikiAttachment origAttach = fromDoc.getAttachment(fileName); if (origAttach == null) { difflist.add(new AttachmentDiff(fileName, null, newAttach.getVersion()));
public synchronized Version[] getVersions() { try { return getAttachment_archive().getVersions(); } catch (Exception ex) { LOG.warn(String.format("Cannot retrieve versions of attachment [%s@%s]: %s", getFilename(), getDoc() .getFullName(), ex.getMessage())); return new Version[] {new Version(this.getVersion())}; } }
@Override public XWikiAttachment getRevision(final XWikiAttachment attachment, final String rev, final XWikiContext context) { if (rev == null) { return null; } for (XWikiAttachment attach : this.revisions) { if (rev.equals(attach.getVersion())) { final XWikiAttachment out = cloneAttachment(attach); out.setAttachment_archive(this); // This is silly, we set the attachment document and passed value. // Keeping to maintain current behavior. out.setDoc(attachment.getDoc()); return out; } } return null; }
@Override public XWikiAttachment getRevision(final XWikiAttachment attachment, final String rev, final XWikiContext context) { if (rev == null) { return null; } for (XWikiAttachment attach : this.revisions) { if (rev.equals(attach.getVersion())) { final XWikiAttachment out = cloneAttachment(attach); out.setAttachment_archive(this); // This is silly, we set the attachment document and passed value. // Keeping to maintain current behavior. out.setDoc(attachment.getDoc(), false); return out; } } return null; }
final File contentFile = provider.getAttachmentVersionContentFile(attach.getVersion()); attach.setAttachment_content(new FilesystemAttachmentContent(contentFile, attach));
final File contentFile = provider.getAttachmentVersionContentFile(attach.getVersion()); attach.setAttachment_content(new FilesystemAttachmentContent(contentFile, attach)); attach.setContentStore(FileSystemStoreUtils.HINT);
/** * {@inheritDoc} * * @see DocumentAccessBridge#getAttachmentVersion(AttachmentReference) */ public String getAttachmentVersion(AttachmentReference attachmentReference) throws Exception { XWikiContext xcontext = getContext(); XWikiDocument doc = xcontext.getWiki().getDocument(attachmentReference.getDocumentReference(), xcontext); XWikiAttachment attachment = doc.getAttachment(attachmentReference.getName()); return attachment == null ? null : attachment.getVersion(); }
String.format("%s;%s;%s;%s;%s;%s", image.getId(), image.getVersion(), width, height, keepAspectRatio, quality); byte[] data = this.imageCache.get(key);
} else { long arbId = findDeletedAttachmentForDocRevision(context.getDoc(), docRevision, filename, context); return createAttachmentRevisionURL(filename, web, name, attachment.getVersion(), arbId, querystring, xwikidb, context);
/** * Convert this attachment archive into JRCS format. * * @param context the XWikiContext for the request. * @return this archive in JRCS format. * @throws Exception if something goes wrong while serializing the attachment to XML or inserting it into the RCS * archive. */ private Archive toRCS(final XWikiContext context) throws Exception { final Version[] versions = this.getVersions(); Archive rcsArch = null; for (XWikiAttachment rev : this.revisions) { final String sdata = rev.toStringXML(true, false, context); final Object[] lines = ToString.stringToArray(sdata); if (rcsArch == null) { // First cycle. rcsArch = new Archive(lines, rev.getFilename(), rev.getVersion()); } else { rcsArch.addRevision(lines, ""); } } return rcsArch; }
/** * Convert this attachment archive into JRCS format. * * @param context the XWikiContext for the request. * @return this archive in JRCS format. * @throws Exception if something goes wrong while serializing the attachment to XML or inserting it into the RCS * archive. */ private Archive toRCS(final XWikiContext context) throws Exception { final Version[] versions = this.getVersions(); Archive rcsArch = null; for (XWikiAttachment rev : this.revisions) { final String sdata = rev.toStringXML(true, false, context); final Object[] lines = ToString.stringToArray(sdata); if (rcsArch == null) { // First cycle. rcsArch = new Archive(lines, rev.getFilename(), rev.getVersion()); } else { rcsArch.addRevision(lines, ""); } } return rcsArch; }
attachmentParameters.put(WikiAttachmentFilter.PARAMETER_REVISION, attachment.getVersion());
/** * Update the archive. * * @param data not used for anything, the data is loaded from the attachment included * with this archive. * @param context the XWikiContext for the request used to load the correct attachment * content from the database. * @throws XWikiException if anything goes wrong. */ public void updateArchive(final byte[] data, final XWikiContext context) throws XWikiException { try { this.attachment.incrementVersion(); this.attachment.setDate(new Date()); final String sdata = this.attachment.toStringXML(true, false, context); final Object[] lines = ToString.stringToArray(sdata); if (this.archive != null) { this.archive.addRevision(lines, ""); } else { this.archive = new Archive(lines, getAttachment().getFilename(), getAttachment().getVersion()); } } catch (Exception e) { Object[] args = {getAttachment().getFilename()}; throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_ATTACHMENT_ARCHIVEFORMAT, GENERIC_EXCEPTION_MESSAGE, e, args); } }
@Override public void serialize(final XWikiAttachment attach, final XMLWriter writer) throws IOException { final Element docel = new DOMElement(ROOT_ELEMENT_NAME); docel.addAttribute(SERIALIZER_PARAM, THIS_SERIALIZER); writer.writeOpen(docel); writer.write(new DOMElement(FILENAME).addText(attach.getFilename())); writer.write(new DOMElement(FILESIZE).addText(attach.getLongSize() + "")); writer.write(new DOMElement(AUTHOR).addText(attach.getAuthor())); writer.write(new DOMElement(VERSION).addText(attach.getVersion())); writer.write(new DOMElement(COMMENT).addText(attach.getComment())); writer.write(new DOMElement(DATE).addText(attach.getDate().getTime() + "")); writer.writeClose(docel); } }
@Override public void serialize(final XWikiAttachment attach, final XMLWriter writer) throws IOException { final Element docel = new DOMElement(ROOT_ELEMENT_NAME); docel.addAttribute(SERIALIZER_PARAM, THIS_SERIALIZER); writer.writeOpen(docel); writer.write(new DOMElement(FILENAME).addText(attach.getFilename())); writer.write(new DOMElement(FILESIZE).addText(attach.getFilesize() + "")); writer.write(new DOMElement(AUTHOR).addText(attach.getAuthor())); writer.write(new DOMElement(VERSION).addText(attach.getVersion())); writer.write(new DOMElement(COMMENT).addText(attach.getComment())); writer.write(new DOMElement(DATE).addText(attach.getDate().getTime() + "")); writer.writeClose(docel); } }
solrDocument.setField(FieldUtils.ATTACHMENT_VERSION, attachment.getVersion());
el.addText(getVersion()); wr.write(el);