jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1412058 - in /jackrabbit/oak/trunk/oak-mongomk/src: main/java/org/apache/jackrabbit/mongomk/impl/action/ main/java/org/apache/jackrabbit/mongomk/impl/command/ test/java/org/apache/jackrabbit/mongomk/impl/
Date Wed, 21 Nov 2012 11:12:06 GMT
Author: chetanm
Date: Wed Nov 21 11:12:05 2012
New Revision: 1412058

URL: http://svn.apache.org/viewvc?rev=1412058&view=rev
Log:
OAK-459 -  Handle paths with parenthesis 

Quoting the paths before they are passed for RegEx handling. Also switching to slf4j parameterized
logging from String.format to reduce the cost incurred in logging (on behalf of Mete Atamel)

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitAction.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesAction.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitAddTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitAction.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitAction.java?rev=1412058&r1=1412057&r2=1412058&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitAction.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitAction.java
Wed Nov 21 11:12:05 2012
@@ -53,7 +53,7 @@ public class FetchCommitAction extends B
                 .and(MongoCommit.KEY_REVISION_ID).is(revisionId)
                 .get();
 
-        LOG.debug(String.format("Executing query: %s", query));
+        LOG.debug("Executing query: {}", query);
 
         DBObject dbObject = commitCollection.findOne(query);
         if (dbObject == null) {

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java?rev=1412058&r1=1412057&r2=1412058&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchCommitsAction.java
Wed Nov 21 11:12:05 2012
@@ -122,7 +122,7 @@ public class FetchCommitsAction extends 
 
         DBObject query = queryBuilder.get();
 
-        LOG.debug(String.format("Executing query: %s", query));
+        LOG.debug("Executing query: {}", query);
 
         return maxEntries > 0? commitCollection.find(query).limit(maxEntries) : commitCollection.find(query);
     }
@@ -156,8 +156,8 @@ public class FetchCommitsAction extends 
             currentRevision = baseRevision;
         }
 
-        LOG.debug(String.format("Found list of valid revisions for max revision %s: %s",
-                toRevisionId, validCommits));
+        LOG.debug("Found list of valid revisions for max revision {}: {}",
+                toRevisionId, validCommits);
 
         return validCommits;
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesAction.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesAction.java?rev=1412058&r1=1412057&r2=1412058&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesAction.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/action/FetchNodesAction.java
Wed Nov 21 11:12:05 2012
@@ -75,7 +75,7 @@ public class FetchNodesAction extends Ba
      * specified paths.
      *
      * @param nodeStore Node store.
-     * @param path The exact paths to fetch nodes for.
+     * @param paths The exact paths to fetch nodes for.
      * @param revisionId The revision id.
      */
     public FetchNodesAction(MongoNodeStore nodeStore,  Set<String> paths,
@@ -148,13 +148,14 @@ public class FetchNodesAction extends Ba
         }
 
         DBObject query = queryBuilder.get();
-        LOG.debug(String.format("Executing query: %s", query));
+        LOG.debug("Executing query: {}", query);
 
         return nodeStore.getNodeCollection().find(query);
     }
 
     private Pattern createPrefixRegExp(String path) {
         StringBuilder sb = new StringBuilder();
+        path = Pattern.quote(path);
 
         if (depth < 0) {
             sb.append("^");
@@ -188,11 +189,11 @@ public class FetchNodesAction extends Ba
             String path = nodeMongo.getPath();
             long revisionId = nodeMongo.getRevisionId();
 
-            LOG.debug(String.format("Converting node %s (%d)", path, revisionId));
+            LOG.debug("Converting node {} ({})", path, revisionId);
 
             if (!validRevisions.contains(revisionId)) {
-                LOG.debug(String.format("Node will not be converted as it is not a valid
commit %s (%d)",
-                        path, revisionId));
+                LOG.debug("Node will not be converted as it is not a valid commit {} ({})",
+                        path, revisionId);
                 continue;
             }
 
@@ -202,10 +203,10 @@ public class FetchNodesAction extends Ba
 
                 if (revisionId > existingRevId) {
                     nodeMongos.put(path, nodeMongo);
-                    LOG.debug(String.format("Converted nodes was put into map and replaced
%s (%d)", path, revisionId));
+                    LOG.debug("Converted nodes was put into map and replaced {} ({})", path,
revisionId);
                 } else {
-                    LOG.debug(String.format("Converted nodes was not put into map because
a newer version"
-                            + " is available %s (%d)", path, revisionId));
+                    LOG.debug("Converted nodes was not put into map because a newer version"
+                            + " is available {} ({})", path, revisionId);
                 }
             } else {
                 nodeMongos.put(path, nodeMongo);

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java?rev=1412058&r1=1412057&r2=1412058&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/CommitCommand.java
Wed Nov 21 11:12:05 2012
@@ -75,7 +75,7 @@ public class CommitCommand extends BaseC
 
     @Override
     public Long execute() throws Exception {
-        logger.debug(String.format("Trying to commit: %s", commit.getDiff()));
+        logger.debug("Trying to commit: {}", commit.getDiff());
 
         boolean success = false;
         do {
@@ -158,28 +158,29 @@ public class CommitCommand extends BaseC
         for (MongoNode existingNode : existingNodes) {
             for (MongoNode committingNode : nodes) {
                 if (existingNode.getPath().equals(committingNode.getPath())) {
-                    logger.debug(String.format("Found existing node to merge: %s", existingNode.getPath()));
-                    logger.debug(String.format("Existing node: %s", existingNode));
-                    logger.debug(String.format("Committing node: %s", committingNode));
-
+                    if(logger.isDebugEnabled()){
+                        logger.debug("Found existing node to merge: {}", existingNode.getPath());
+                        logger.debug("Existing node: {}", existingNode);
+                        logger.debug("Committing node: {}", committingNode);
+                    }
                     Map<String, Object> existingProperties = existingNode.getProperties();
                     if (!existingProperties.isEmpty()) {
                         committingNode.setProperties(existingProperties);
 
-                        logger.debug(String.format("Merged properties for %s: %s", existingNode.getPath(),
-                                existingProperties));
+                        logger.debug("Merged properties for {}: {}", existingNode.getPath(),
+                                existingProperties);
                     }
 
                     List<String> existingChildren = existingNode.getChildren();
                     if (existingChildren != null) {
                         committingNode.setChildren(existingChildren);
 
-                        logger.debug(String.format("Merged children for %s: %s", existingNode.getPath(),
existingChildren));
+                        logger.debug("Merged children for {}: {}", existingNode.getPath(),
existingChildren);
                     }
 
                     committingNode.setBaseRevisionId(existingNode.getRevisionId());
 
-                    logger.debug(String.format("Merged node for %s: %s", existingNode.getPath(),
committingNode));
+                    logger.debug("Merged node for {}: {}", existingNode.getPath(), committingNode);
 
                     break;
                 }
@@ -189,8 +190,8 @@ public class CommitCommand extends BaseC
 
     private void prepareMongoNodes() {
         for (MongoNode committingNode : nodes) {
-            logger.debug(String.format("Preparing children (added and removed) of %s", committingNode.getPath()));
-            logger.debug(String.format("Committing node: %s", committingNode));
+            logger.debug("Preparing children (added and removed) of {}", committingNode.getPath());
+            logger.debug("Committing node: {}", committingNode);
 
             List<String> children = committingNode.getChildren();
             if (children == null) {
@@ -239,7 +240,7 @@ public class CommitCommand extends BaseC
                 committingNode.setBranchId(branchId);
             }
 
-            logger.debug(String.format("Prepared committing node: %s", committingNode));
+            logger.debug("Prepared committing node: {}", committingNode);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitAddTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitAddTest.java?rev=1412058&r1=1412057&r2=1412058&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitAddTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKCommitAddTest.java
Wed Nov 21 11:12:05 2012
@@ -47,6 +47,14 @@ public class MongoMKCommitAddTest extend
         assertTrue(mk.nodeExists("/a/b/c/d",null));
     }
 
+    @Test
+    public void addNodeWithParanthesis() throws Exception {
+        mk.commit("/", "+\"Test({0})\" : {}", null, null);
+        String nodes = mk.getNodes("/Test({0})", null, 1, 0, -1, null);
+        JSONObject obj = parseJSONObject(nodes);
+        assertPropertyValue(obj, ":childNodeCount", 0L);
+    }
+
 
     @Test
     public void addIntermediataryNodes() throws Exception {



Mime
View raw message