/** @param versions - collection of XWikiRCSNodeInfo */ public void setNodes(Collection<XWikiRCSNodeInfo> versions) { resetArchive(); for (XWikiRCSNodeInfo node : versions) { updateNode(node); } if (getNodes().size() > 0) { // ensure latest version is full getLatestNode().setDiff(false); updateNode(getLatestNode()); } }
/** * Deserialize class. Used in {@link com.xpn.xwiki.plugin.packaging.PackagePlugin}. * * @param text - archive in JRCS format * @throws XWikiException if parse error */ public void setArchive(String text) throws XWikiException { try { XWikiRCSArchive archive = new XWikiRCSArchive(text); resetArchive(); Collection nodes = archive.getNodes(getId()); for (Iterator it = nodes.iterator(); it.hasNext();) { XWikiRCSNodeInfo nodeInfo = (XWikiRCSNodeInfo) it.next(); XWikiRCSNodeContent nodeContent = (XWikiRCSNodeContent) it.next(); updateNode(nodeInfo); updatedNodeInfos.add(nodeInfo); updatedNodeContents.add(nodeContent); } } catch (Exception e) { Object[] args = {text, new Long(getId())}; throw new XWikiException(XWikiException.MODULE_XWIKI_DIFF, XWikiException.ERROR_XWIKI_DIFF_CONTENT_ERROR, "Exception while constructing archive for JRCS string [{0}] for document [{1}]", e, args); } }
ncBefore.getPatch().setFullVersion(xmlBefore); niBefore.setContent(ncBefore); updateNode(niBefore); getUpdatedNodeContents().add(ncBefore); } else if (firstVersionBefore != null) { ncBefore.getPatch().setDiffVersion(xmlBefore, xmlAfter, ""); niBefore.setContent(ncBefore); updateNode(niBefore); getUpdatedNodeContents().add(ncBefore);
/** * Update history with new document version. * * @param doc - document for this version * @param author - author of version * @param date - date of version * @param comment - version comment * @param version - preferably document version in history * @param context - used for loading nodes content * @throws XWikiException in any error */ public void updateArchive(XWikiDocument doc, String author, Date date, String comment, Version version, XWikiContext context) throws XWikiException { Version oldLatestVer = getLatestVersion(); Version newVer = version; if (newVer == null || oldLatestVer != null && newVer.compareVersions(oldLatestVer) <= 0) { newVer = createNextVersion(oldLatestVer, doc.isMinorEdit()); } XWikiRCSNodeInfo newNode = new XWikiRCSNodeInfo(new XWikiRCSNodeId(getId(), newVer)); newNode.setAuthor(author); newNode.setComment(comment); newNode.setDate(date); XWikiRCSNodeContent newContent = makePatch(newNode, doc, context); updateNode(newNode); updatedNodeInfos.add(newNode); updatedNodeContents.add(newContent); }
doc, context); latestNode.setContent(latestContent); updateNode(latestNode); getUpdatedNodeContents().add(latestContent);