use of org.suigeneris.jrcs.rcs.impl.Node in project xwiki-platform by xwiki.
the class ListAttachmentArchive method fromRCS.
/**
* @param rcsArchive the RCS archive to import.
* @throws Exception if getting a revision from the RCS archive or deserializing an attachment from XML fails
*/
private void fromRCS(final Archive rcsArchive) throws Exception {
if (rcsArchive == null) {
return;
}
final Node[] nodes = rcsArchive.changeLog();
for (int i = nodes.length - 1; i > -1; i--) {
final Object[] lines = rcsArchive.getRevision(nodes[i].getVersion());
final StringBuilder content = new StringBuilder();
for (int j = 0; j < lines.length; j++) {
String line = lines[j].toString();
content.append(line);
if (j != lines.length - 1) {
content.append("\n");
}
}
final XWikiAttachment rev = new XWikiAttachment();
rev.fromXML(content.toString());
rev.setDoc(getAttachment().getDoc());
rev.setAttachment_archive(this);
// this should not be necessary, keeping to maintain behavior.
rev.setVersion(nodes[i].getVersion().toString());
revisions.add(rev);
}
}
use of org.suigeneris.jrcs.rcs.impl.Node in project xwiki-platform by xwiki.
the class XWikiAttachmentArchive method getVersions.
/**
* @return an array of versions which are available for this attachment, ordered by version number descending.
*/
public Version[] getVersions() {
final Archive rcsArchive = getRCSArchive();
Version[] versions;
if (rcsArchive != null) {
final Node[] nodes = rcsArchive.changeLog();
versions = new Version[nodes.length];
for (int i = 0; i < nodes.length; i++) {
versions[i] = nodes[i].getVersion();
}
} else {
// No archive means there is no history and only the current version
versions = new Version[] { this.attachment.getRCSVersion() };
}
return versions;
}
Aggregations