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

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


        }
        DBCollection commitCollection = mongoConnection.getDB().getCollection(
                COLLECTION_COMMITS);
        commitCollection.remove(new BasicDBObject());

        MongoCommit commit = new MongoCommit();
        commit.setAffectedPaths(Collections.singleton("/"));
        commit.setBaseRevisionId(0L);
        commit.setDiff(INITIAL_COMMIT_DIFF);
        commit.setMessage(INITIAL_COMMIT_MESSAGE);
        commit.setRevisionId(0L);
        commit.setPath(INITIAL_COMMIT_PATH);
        commitCollection.insert(commit);
    }
View Full Code Here


     *
     * @param revisionId Commit revision id.
     * @return Commit from cache or null if commit is not in the cache.
     */
    public MongoCommit getFromCache(long revisionId) {
        MongoCommit commit = commitCache.get(revisionId);
        if (commit != null) {
            LOG.debug("Returning commit {} from cache", revisionId);
        }
        return commit;
    }
View Full Code Here

        index.put(MongoCommit.KEY_REVISION_ID, 1L);
        index.put(MongoCommit.KEY_BRANCH_ID, 1L);
        DBObject options = new BasicDBObject();
        options.put("unique", Boolean.TRUE);
        commitCollection.ensureIndex(index, options);
        MongoCommit commit = new MongoCommit();
        commit.setAffectedPaths(Collections.singleton("/"));
        commit.setBaseRevisionId(0L);
        commit.setDiff(INITIAL_COMMIT_DIFF);
        commit.setMessage(INITIAL_COMMIT_MESSAGE);
        commit.setRevisionId(0L);
        commit.setPath(INITIAL_COMMIT_PATH);
        commitCollection.insert(commit);
    }
View Full Code Here

    private String getBranchId(String revisionId) throws Exception {
        if (revisionId == null) {
            return null;
        }

        MongoCommit baseCommit = new FetchCommitAction(this,
                MongoUtil.toMongoRepresentation(revisionId)).execute();
        return baseCommit.getBranchId();
    }
View Full Code Here

                if (!commits.containsKey(revisionId) && nodeStore.getFromCache(revisionId) == null) {
                    LOG.debug("Fetching commit @{}", revisionId);
                    FetchCommitAction action = new FetchCommitAction(nodeStore, revisionId);
                    try {
                        MongoCommit commit = action.execute();
                        commits.put(revisionId, commit);
                    } catch (Exception e) {
                        LOG.debug("Node will not be converted as it is not part of a valid commit {} ({})",
                                path, revisionId);
                        continue;
View Full Code Here

    private void deriveProblematicNodes() {
        problematicNodes = new HashMap<String, Long>();

        for (ListIterator<MongoCommit> iterator = lastCommits.listIterator(); iterator.hasPrevious();) {
            MongoCommit commitMongo = iterator.previous();
            long revisionId = commitMongo.getRevisionId();
            Set<String> affectedPaths = commitMongo.getAffectedPaths();
            for (String path : affectedPaths) {
                problematicNodes.put(path, revisionId);
            }
        }
    }
View Full Code Here

        if (fromRevisionId == toRevisionId) {
            return "";
        }

        if ("/".equals(path)) {
            MongoCommit toCommit = new FetchCommitAction(nodeStore, toRevisionId).execute();
            if (toCommit.getBaseRevisionId() == fromRevisionId) {
                // Specified range spans a single commit:
                // use diff stored in commit instead of building it dynamically
                return toCommit.getDiff();
            }
        }

        NodeState beforeState = MongoUtil.wrap(getNode(path, fromRevisionId));
        NodeState afterState = MongoUtil.wrap(getNode(path, toRevisionId));
View Full Code Here

        this.message = message;
    }

    @Override
    public String execute() throws Exception {
        MongoCommit commit = new FetchCommitAction(nodeStore,
                MongoUtil.toMongoRepresentation(branchRevisionId)).execute();
        String branchId = commit.getBranchId();
        if (branchId == null) {
            throw new Exception("Can only merge a private branch commit");
        }

        long rootNodeId = commit.getRevisionId();

        FetchHeadRevisionIdAction query2 = new FetchHeadRevisionIdAction(nodeStore);
        long currentHead = query2.execute();

        long branchRootId = Long.parseLong(branchId.substring(0, branchId.indexOf("-")));

        Commit newCommit;
        String diff = getNonConflictingCommitsDiff(Math.max(currentHead, commit.getRevisionId()),
                branchRootId, branchId);
        if (diff != null) {
            newCommit = CommitBuilder.build("/", diff.toString(),
                    MongoUtil.fromMongoRepresentation(currentHead), message);
        } else {
View Full Code Here

        this.revisionId = revisionId;
    }

    @Override
    public MongoCommit execute() throws Exception {
        MongoCommit commit = nodeStore.getFromCache(revisionId);
        if (commit != null) {
            return commit;
        }

        DBCollection commitCollection = nodeStore.getCommitCollection();
View Full Code Here

        Set<String> affectedPathsBranch = new HashSet<String>();
        Set<String> affectedPathsTrunk = new HashSet<String>();
        StringBuilder diff = new StringBuilder();

        for (int i = commits.size() - 1; i >= 0; i--) {
            MongoCommit commit = commits.get(i);
            Set<String> affectedPaths = commit.getAffectedPaths();
            for (String affectedPath : affectedPaths) {
                if (branchId.equals(commit.getBranchId())) {
                    if (affectedPathsTrunk.contains(affectedPath)) {
                        return null;
                    }
                    affectedPathsBranch.add(affectedPath);
                } else if (commit.getBranchId() == null){
                    if (affectedPathsBranch.contains(affectedPath)) {
                        return null;
                    }
                    affectedPathsTrunk.add(affectedPath);
                }
            }
            if (branchId.equals(commit.getBranchId())) {
                try {
                    diff.append(normalizeDiff(commit.getPath(), commit.getDiff()));
                } catch (Exception e) {
                    LOG.error("Normalization error", e);
                }
            }
        }
View Full Code Here

TOP

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

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.