public void fromXML(Element docel) throws XWikiException { setFilename(docel.element("filename").getText()); setFilesize(Integer.parseInt(docel.element("filesize").getText())); setAuthor(docel.element("author").getText()); setVersion(docel.element("version").getText()); setComment(docel.element("comment").getText()); String sdate = docel.element("date").getText(); Date date = new Date(Long.parseLong(sdate)); setDate(date); Element contentel = docel.element("content"); if (contentel != null) { String base64content = contentel.getText(); byte[] content = Base64.decodeBase64(base64content.getBytes()); setContent(content); } Element archiveel = docel.element("versions"); if (archiveel != null) { String archive = archiveel.getText(); setArchive(archive); } }
/** * {@inheritDoc} */ @Override public void updateArchive(byte[] data, XWikiContext context) throws XWikiException { getAttachment().incrementVersion(); getAttachment().setDate(new Date()); }
this.attachment.setAuthorReference(null); this.attachment.setDate(ISO_DATE_FORMAT.parseDateTime(json.getString(JSON_FIELD_DATE)).toDate()); try { this.attachment.setContent(
/** * Update the archive, increment the attachment version, set the date on the attachment and add the attachment to * the list. */ private void update() { final XWikiAttachment attach = this.getAttachment(); attach.incrementVersion(); attach.setDate(new Date()); // Clone the attachment but don't clone this archive. final XWikiAttachment clone = cloneAttachment(attach); clone.setAttachment_archive(this); this.revisions.add(clone); }
@Override public XWikiAttachment parse(final Element docel) throws IOException { if (!ROOT_ELEMENT_NAME.equals(docel.getName())) { throw new IOException("XML not recognizable as attachment metadata, expecting <attachment> tag"); } if (docel.attribute(SERIALIZER_PARAM) == null || !THIS_SERIALIZER.equals(docel.attribute(SERIALIZER_PARAM).getValue())) { throw new IOException("Cannot parse this attachment metadata, it was saved with a different " + "serializer."); } final XWikiAttachment out = new XWikiAttachment(); out.setFilename(docel.element(FILENAME).getText()); out.setFilesize(Integer.parseInt(docel.element(FILESIZE).getText())); out.setAuthor(docel.element(AUTHOR).getText()); out.setVersion(docel.element(VERSION).getText()); out.setComment(docel.element(COMMENT).getText()); final String sdate = docel.element(DATE).getText(); final Date date = new Date(Long.parseLong(sdate)); out.setDate(date); return out; }
@Override public XWikiAttachment parse(final Element docel) throws IOException { if (!ROOT_ELEMENT_NAME.equals(docel.getName())) { throw new IOException("XML not recognizable as attachment metadata, expecting <attachment> tag"); } if (docel.attribute(SERIALIZER_PARAM) == null || !THIS_SERIALIZER.equals(docel.attribute(SERIALIZER_PARAM).getValue())) { throw new IOException("Cannot parse this attachment metadata, it was saved with a different " + "serializer."); } final XWikiAttachment out = new XWikiAttachment(); out.setFilename(docel.element(FILENAME).getText()); out.setLongSize(Long.parseLong(docel.element(FILESIZE).getText())); out.setAuthor(docel.element(AUTHOR).getText()); out.setVersion(docel.element(VERSION).getText()); out.setComment(docel.element(COMMENT).getText()); final String sdate = docel.element(DATE).getText(); final Date date = new Date(Long.parseLong(sdate)); out.setDate(date); return out; }
/** * Update the archive, increment the attachment version, set the date on the attachment and add the attachment to * the list. */ private void update() { final XWikiAttachment attach = this.getAttachment(); attach.incrementVersion(); attach.setDate(new Date()); // Clone the attachment but don't clone this archive. final XWikiAttachment clone = cloneAttachment(attach); clone.setAttachment_archive(this); this.revisions.add(clone); }
newAttachment.setDoc(attachment.getDoc(), false); newAttachment.setAuthorReference(attachment.getAuthorReference()); newAttachment.setDate(attachment.getDate());
newAttachment.setDoc(attachment.getDoc()); newAttachment.setAuthor(attachment.getAuthor()); newAttachment.setDate(attachment.getDate());
xattachment.setDate(report.getDate()); xattachment.setFilesize((int) report.getFilesize()); return report.getFilename();
xattachment.setDate(file.getDate()); xattachment.setFilesize((int) file.getFilesize()); xobject.setStringValue(FILE_FIELD_NAME, file.getFilename());
/** * 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); } }
xattachment.setDate(image.getDate()); xattachment.setFilesize((int) image.getFilesize()); xobject.setStringValue(FILE_FIELD_NAME, image.getFilename());
attachment.setDate(getDate(WikiAttachmentFilter.PARAMETER_REVISION_DATE, parameters, new Date()));
attachment.setDate(getDate()); attachment.setDoc(getDoc()); attachment.setFilename(getFilename());