Examples of MongoNode


Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

        String nodePath = instruction.getPath();
        checkAbsolutePath(nodePath);

        String parentPath = PathUtils.getParentPath(nodePath);
        String nodeName = PathUtils.getName(nodePath);
        MongoNode parent = getStoredNode(parentPath);
        if (!parent.childExists(nodeName)) {
            throw new RuntimeException("Node " + nodeName
                    + " does not exists at parent path: " + parentPath);
        }
        parent.removeChild(nodeName);
        markAsDeleted(nodePath);
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

    private boolean verifyProblematicNodes() {
        for (Map.Entry<String, Long> entry : problematicNodes.entrySet()) {
            String path = entry.getKey();
            Long revisionId = entry.getValue();
            MongoNode nodeMongo = pathAndNodeMap.get(path);
            if (nodeMongo != null) {
                if (!revisionId.equals(nodeMongo.getRevisionId())) {
                    LOG.error("Node could not be verified because revisionIds"
                            + " did not match: {} (expected) vs {} (actual)",
                            revisionId, nodeMongo.getRevisionId());
                    return false;
                }
            }
        }
        return true;
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

        String srcNodeName = PathUtils.getName(srcPath);

        String destParentPath = PathUtils.getParentPath(destPath);
        String destNodeName = PathUtils.getName(destPath);

        MongoNode srcParent = getStoredNode(srcParentPath, false);
        if (!srcParent.childExists(srcNodeName)) {
            throw new NotFoundException(srcPath);
        }
        MongoNode destParent = getStoredNode(destParentPath);
        if (destParent.childExists(destNodeName)) {
            throw new RuntimeException("Node already exists at copy destination path: " + destPath);
        }

        copy(getStoredNode(srcPath, false), destPath);

        // Finally, add to destParent.
        destParent.addChild(destNodeName);
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

            throw new RuntimeException("Absolute path expected: " + srcPath);
        }
    }

    private MongoNode getStagedNode(String path) {
        MongoNode node = pathNodeMap.get(path);
        if (node == null) {
            node = new MongoNode();
            node.setPath(path);
            pathNodeMap.put(path, node);
        }
        return node;
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

    private MongoNode getStoredNode(String path) {
        return getStoredNode(path, true);
    }

    private MongoNode getStoredNode(String path, boolean addToMap) {
        MongoNode node = pathNodeMap.get(path);
        if (node != null) {
            return node;
        }

        // First need to check that the path is indeed valid.
        NodeExistsCommand existCommand = new NodeExistsCommand(nodeStore,
                path, baseRevisionId);
        existCommand.setBranchId(branchId);
        boolean exists = false;
        try {
            exists = existCommand.execute();
        } catch (Exception ignore) {}

        if (!exists) {
            throw new NotFoundException(path + " @rev" + baseRevisionId);
        }
        node = existCommand.getNode();
        node.removeField("_id");
        if (addToMap) {
            pathNodeMap.put(path, node);
        }
        return node;
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

     * staged nodes into account.
     *
     * @param srcNode the source node.
     */
    private void copy(MongoNode srcNode, String destPath) {
        MongoNode destNode = srcNode.copy();
        destNode.setPath(destPath);
        destNode.removeField("_id");
        copyAddedProperties(srcNode, destNode);
        copyRemovedProperties(srcNode, destNode);
        pathNodeMap.put(destPath, destNode);

        List<String> children = new ArrayList<String>();
        if (srcNode.getChildren() != null) {
            children.addAll(srcNode.getChildren());
        }
        if (srcNode.getRemovedChildren() != null) {
            for (String child : srcNode.getRemovedChildren()) {
                destNode.removeChild(child);
                children.remove(child);
            }
        }
        if (srcNode.getAddedChildren() != null) {
            for (String child : srcNode.getAddedChildren()) {
                destNode.addChild(child);
                children.add(child);
            }
        }
        for (String child : children) {
            String srcChildPath = PathUtils.concat(srcNode.getPath(), child);
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

            destNode.removeProp(key);
        }
    }

    private void markAsDeleted(String path) {
        MongoNode node = getStoredNode(path);
        node.setDeleted(true);
        List<String> children = new ArrayList<String>();
        if (node.getChildren() != null) {
            children.addAll(node.getChildren());
        }
        if (node.getAddedChildren() != null) {
            children.addAll(node.getAddedChildren());
        }
        for (String child : children) {
            markAsDeleted(PathUtils.concat(path, child));
        }
        pathNodeMap.put(path, node);
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

        List<Long> validRevisions = extractRevisionIds(validCommits);
        Map<String, MongoNode> nodeMongos = new HashMap<String, MongoNode>();

        while (dbCursor.hasNext()) {
            MongoNode nodeMongo = (MongoNode) dbCursor.next();

            String path = nodeMongo.getPath();
            long revisionId = nodeMongo.getRevisionId();

            LOG.debug("Converting node {} ({})", path, revisionId);

            if (!validRevisions.contains(revisionId)) {
                LOG.debug("Node will not be converted as it is not a valid commit {} ({})",
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

    public boolean needsRetry(Exception e) {
        return e instanceof InconsistentNodeHierarchyException;
    }

    private void buildNodeStructure() {
        MongoNode nodeMongoRootOfPath = pathAndNodeMap.get(path);
        rootNode = buildNodeStructure(nodeMongoRootOfPath);
    }
View Full Code Here

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoNode

        NodeImpl node = MongoNode.toNode(nodeMongo);

        for (Iterator<Node> it = node.getChildNodeEntries(0, -1); it.hasNext(); ) {
            Node child = it.next();
            MongoNode nodeMongoChild = pathAndNodeMap.get(child.getPath());
            if (nodeMongoChild != null) {
                NodeImpl nodeChild = buildNodeStructure(nodeMongoChild);
                node.addChildNodeEntry(nodeChild);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.