use of org.suigeneris.jrcs.rcs.Archive in project xwiki-platform by xwiki.
the class ListAttachmentArchive method setArchive.
@Override
public void setArchive(final byte[] data) throws XWikiException {
this.revisions.clear();
if ((data != null) && (data.length == 0)) {
try {
final ByteArrayInputStream is = new ByteArrayInputStream(data);
final Archive rcsArchive = new Archive(getAttachment().getFilename(), is);
this.setRCSArchive(rcsArchive);
} catch (Exception e) {
if (e instanceof XWikiException) {
throw (XWikiException) e;
}
Object[] args = { getAttachment().getFilename() };
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_ATTACHMENT_ARCHIVEFORMAT, GENERIC_EXCEPTION_MESSAGE, e, args);
}
}
}
use of org.suigeneris.jrcs.rcs.Archive in project xwiki-platform by xwiki.
the class ListAttachmentArchive method toRCS.
/**
* 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;
}
Aggregations