Search in sources :

Example 1 with XWikiPatch

use of com.xpn.xwiki.doc.rcs.XWikiPatch in project xwiki-platform by xwiki.

the class XWikiDocumentArchive method makePatch.

/**
 * Make a patch. It is store only modified nodes(latest). New nodes need be saved after.
 *
 * @param newnode - new node information
 * @param doc - document for that patch created
 * @param context - used for loading node contents and generating xml
 * @return node content for newnode
 * @throws XWikiException if exception while loading content
 */
protected XWikiRCSNodeContent makePatch(XWikiRCSNodeInfo newnode, XWikiDocument doc, XWikiContext context) throws XWikiException {
    XWikiRCSNodeContent result = new XWikiRCSNodeContent();
    result.setPatch(new XWikiPatch().setFullVersion(doc, context));
    newnode.setContent(result);
    XWikiRCSNodeInfo latestNode = getLatestNode();
    if (latestNode != null) {
        int nodesCount = getNodes().size();
        int nodesPerFull = context.getWiki() == null ? 5 : Integer.parseInt(context.getWiki().getConfig().getProperty("xwiki.store.rcs.nodesPerFull", "5"));
        if (nodesPerFull <= 0 || (nodesCount % nodesPerFull) != 0) {
            XWikiRCSNodeContent latestContent = latestNode.getContent(context);
            latestContent.getPatch().setDiffVersion(latestContent.getPatch().getContent(), doc, context);
            latestNode.setContent(latestContent);
            updateNode(latestNode);
            getUpdatedNodeContents().add(latestContent);
        }
    }
    return result;
}
Also used : XWikiRCSNodeContent(com.xpn.xwiki.doc.rcs.XWikiRCSNodeContent) XWikiRCSNodeInfo(com.xpn.xwiki.doc.rcs.XWikiRCSNodeInfo) XWikiPatch(com.xpn.xwiki.doc.rcs.XWikiPatch)

Aggregations

XWikiPatch (com.xpn.xwiki.doc.rcs.XWikiPatch)1 XWikiRCSNodeContent (com.xpn.xwiki.doc.rcs.XWikiRCSNodeContent)1 XWikiRCSNodeInfo (com.xpn.xwiki.doc.rcs.XWikiRCSNodeInfo)1