Package org.apache.jackrabbit.mongomk.impl.model

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


            return;
        }
        DBCollection nodeCollection = mongoConnection.getDB().getCollection(
                COLLECTION_NODES);
        nodeCollection.remove(new BasicDBObject());
        MongoNode root = new MongoNode();
        root.setRevisionId(0L);
        root.setPath("/");
        nodeCollection.insert(root);
    }
View Full Code Here


     * @param revisionId Revision id
     * @return
     */
    public MongoNode getFromCache(String path, String branchId, long revisionId) {
        String key = path + "*" + branchId + "*" + revisionId;
        MongoNode node = nodeCache.get(key);
        if (node == null) {
            return null;
        }
        LOG.debug("Returning node from cache: {}", key);
        return node.copy();
    }
View Full Code Here

        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);

        nodeCollection.ensureIndex(index, options);

        MongoNode root = new MongoNode();
        root.setRevisionId(0L);
        root.setPath("/");
        nodeCollection.insert(root);
    }
View Full Code Here

        }

        // FIXME - Should deal with multiple paths as long as depth = 0
        if (paths.size() == 1 && depth == 0) {
            String path = paths.toArray(new String[0])[0];
            MongoNode node = nodeStore.getFromCache(path, branchId, revisionId);
            if (node != null) {
                Map<String, MongoNode> nodes = new HashMap<String, MongoNode>();
                nodes.put(node.getPath(), node);
                return nodes;
            }
        }

        DBCursor dbCursor = performQuery();
View Full Code Here

        Map<String, MongoNode> nodes = new HashMap<String, MongoNode>();
        Map<Long, MongoCommit> commits = new HashMap<Long, MongoCommit>();

        while (dbCursor.hasNext() && (numberOfNodesToFetch == -1 || nodes.size() < numberOfNodesToFetch)) {
            MongoNode node = (MongoNode)dbCursor.next();
            String path = node.getPath();
            // Assuming that revision ids are ordered and nodes are fetched in
            // sorted order, first check if the path is already in the map.
            if (nodes.containsKey(path)) {
                LOG.debug("Converted node @{} with path {} was not put into map"
                        + " because a newer version is available", node.getRevisionId(), path);
                continue;
            } else {
                long revisionId = node.getRevisionId();
                LOG.debug("Converting node {} (@{})", path, revisionId);

                if (!commits.containsKey(revisionId) && nodeStore.getFromCache(revisionId) == null) {
                    LOG.debug("Fetching commit @{}", revisionId);
                    FetchCommitAction action = new FetchCommitAction(nodeStore, revisionId);
View Full Code Here

            getStagedNode(nodePath);
            return;
        }

        String parentNodePath = PathUtils.getParentPath(nodePath);
        MongoNode parent = getStoredNode(parentNodePath);
        if (parent.childExists(nodeName)) {
            throw new RuntimeException("There's already a child node with name '" + nodeName + "'");
        }
        getStagedNode(nodePath);
        parent.addChild(nodeName);
    }
View Full Code Here

    @Override
    public void visit(SetPropertyInstruction instruction) {
        String key = instruction.getKey();
        Object value = instruction.getValue();
        MongoNode node = getStoredNode(instruction.getPath());
        if (value == null) {
            node.removeProp(key);
        } else {
            node.addProperty(key, value);
        }
    }
View Full Code Here

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

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

        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

        if (pathAndNodeMap.isEmpty()) {
            return true;
        }

        MongoNode nodeMongo = pathAndNodeMap.get(path);
        if (nodeMongo != null) {
            verified = true;
            if ((depth == -1) || (currentDepth < depth)) {
                List<String> childNames = nodeMongo.getChildren();
                if (childNames != null) {
                    for (String childName : childNames) {
                        String childPath = PathUtils.concat(path, childName);
                        verified = verifyNodeHierarchyRec(childPath, ++currentDepth);
                        if (!verified) {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mongomk.impl.model.MongoNode

Copyright © 2018 www.massapicom. 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.