You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:26:15 UTC

[sling-org-apache-sling-nosql-mongodb-resourceprovider] branch master created (now 186f90e)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git.


      at 186f90e  SLING-7167 Adjust READMEs

This branch includes the following new commits:

     new 07f1572  SLING-5024 Sling NoSQL Resource Provider for MongoDB (based on nosql.generic)
     new da9cdca  SLING-5024 Sling NoSQL Resource Provider for MongoDB (based on nosql.generic)
     new 4c53655  SLING-5024 add/update readme
     new 362e7b4  SLING-5024 remove obsolete files
     new eea5f49  SLING-4381/SLING-5024 fix root node child listing
     new 7f484fd  SLING-4381/SLING-5024 add missing dependency
     new 521d883  SLING-4381/SLING-5024 for query efficiency on listChildren store parentPath as separate attribute
     new 5b7eaad  update dependencies
     new a5e611a  [maven-release-plugin] prepare release org.apache.sling.nosql.mongodb-resourceprovider-1.0.0
     new a371caa  [maven-release-plugin] prepare for next development iteration
     new 955b81a  update to next snapshot version until releases are available in maven central
     new bfa4caa  switch back to released versions
     new 1992dce  Update the contrib reactor to parent 25
     new a147a8e  SLING-5078 Missing indexes on MongoDBResourceProvider (patch supplied by Norberto Leite) update path to ignore error when index already exists - log error if it could not be created do some refactoring on provided integration test to make sure the mongodb connection parameters passed via command line are used update to latest table mongodb java driver
     new a090df7  SLING-5078 some cosmetic changes This closes #113
     new c1291af  Switch to parent pom 26
     new a6c3139  SLING-5078 fix invalid index attribute names
     new 211eef4  SLING-5437 The NoSQL providers should throw LoginException if the connection to the NoSQL database can't be established (patch provided by Robert Munteanu)
     new 0925670  SLING-5437 add connection check for couchbase resource provider define separate NoSqlAdapter methods for creating index definitions, to ensure they are only executed after connection test succeeds set versions to 1.1.0
     new f5994d5  fix version number for generic test dependencies
     new c1ca345  exclude README.md in rat report
     new 2c06eed  update dependencies
     new d5fef3a  [maven-release-plugin] prepare release org.apache.sling.nosql.mongodb-resourceprovider-1.1.0
     new 3858d2a  [maven-release-plugin] prepare for next development iteration
     new 2891897  update version to next development snapshot until releases available on maven central
     new d600a99  update to release versions
     new 186f90e  SLING-7167 Adjust READMEs

The 27 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 14/27: SLING-5078 Missing indexes on MongoDBResourceProvider (patch supplied by Norberto Leite) update path to ignore error when index already exists - log error if it could not be created do some refactoring on provided integration test to make sure the mongodb connection parameters passed via command line are used update to latest table mongodb java driver

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit a147a8ead56a974966ce9a5df9dd33791203b238
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Nov 24 22:39:37 2015 +0000

    SLING-5078 Missing indexes on MongoDBResourceProvider (patch supplied by Norberto Leite)
    update path to ignore error when index already exists - log error if it could not be created
    do some refactoring on provided integration test to make sure the mongodb connection parameters passed via command line are used
    update to latest table mongodb java driver
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1716273 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  2 +-
 .../resourceprovider/impl/MongoDBNoSqlAdapter.java | 32 ++++++++++
 .../integration/IndexCreationIT.java               | 73 ++++++++++++++++++++++
 3 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index eef1c26..d3fa27f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,7 +56,7 @@
         <dependency>
             <groupId>org.mongodb</groupId>
             <artifactId>mongo-java-driver</artifactId>
-            <version>3.0.4</version>
+            <version>3.1.1</version>
             <scope>provided</scope>
         </dependency>
 
diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
index a25abd5..782021e 100644
--- a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
@@ -28,13 +28,17 @@ import org.apache.sling.nosql.generic.adapter.AbstractNoSqlAdapter;
 import org.apache.sling.nosql.generic.adapter.MultiValueMode;
 import org.apache.sling.nosql.generic.adapter.NoSqlData;
 import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+import com.mongodb.DuplicateKeyException;
 import com.mongodb.MongoClient;
 import com.mongodb.client.FindIterable;
 import com.mongodb.client.MongoCollection;
 import com.mongodb.client.MongoCursor;
 import com.mongodb.client.MongoDatabase;
 import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.IndexOptions;
 import com.mongodb.client.model.UpdateOptions;
 import com.mongodb.client.result.DeleteResult;
 import com.mongodb.client.result.UpdateResult;
@@ -50,6 +54,8 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
     
     private final MongoCollection<Document> collection;
     
+    private static final Logger log = LoggerFactory.getLogger(MongoDBNoSqlAdapter.class);
+    
     /**
      * @param mongoClient MongoDB client
      * @param database MongoDB database
@@ -58,6 +64,32 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
     public MongoDBNoSqlAdapter(MongoClient mongoClient, String database, String collection) {
         MongoDatabase db = mongoClient.getDatabase(database);
         this.collection = db.getCollection(collection);
+        
+        // create index on parent path field (if it does not exist yet)
+        try {
+            Document parenPathtIndex = new Document("_parentPath", 1);
+            this.collection.createIndex(parenPathtIndex);
+        }
+        catch (DuplicateKeyException ex) {
+            // index already exists, ignore
+        }
+        catch (Throwable ex) {
+            log.error("Unable to create index on _parentPath: " + ex.getMessage(), ex);
+        }
+        
+        // create unique index on path field (if it does not exist yet)
+        try {
+            Document pathIndex = new Document("_path", 1);
+            IndexOptions idxOptions = new IndexOptions();
+            idxOptions.unique(true);
+            this.collection.createIndex(pathIndex, idxOptions);
+        }
+        catch (DuplicateKeyException ex) {
+            // index already exists, ignore
+        }
+        catch (Throwable ex) {
+            log.error("Unable to create unique index on _path: " + ex.getMessage(), ex);
+        }
     }
 
     @Override
diff --git a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
new file mode 100644
index 0000000..3ec88fe
--- /dev/null
+++ b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.nosql.mongodb.resourceprovider.integration;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Arrays;
+
+import org.apache.sling.nosql.mongodb.resourceprovider.impl.MongoDBNoSqlAdapter;
+import org.bson.Document;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.mongodb.MongoClient;
+
+public class IndexCreationIT {
+
+	private MongoDBNoSqlAdapter obj;
+	
+	private MongoClient mongoClient;
+	private String database;
+	private String collection;
+		
+	@Before
+	public void setUp() throws Exception {
+	    String connectionString = System.getProperty("connectionString", "localhost:27017");
+        database =  System.getProperty("database", "sling") + "_indextest";
+        collection = System.getProperty("collection", "resources");
+		mongoClient = new MongoClient(connectionString);
+		obj = new MongoDBNoSqlAdapter(mongoClient, database, collection);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		mongoClient.dropDatabase(database);
+		mongoClient.close();
+	}
+
+	@Test
+	public void testIndexesPresent() {
+		assertNotNull(obj);
+		
+		//expecting at least 3 indexes (_id, _path, _parentPath)
+		int expected = 3;
+		int actual = 0;
+		
+		final String[] expectedIndexesNames=  {"_id_", "_path_1", "_parentPath_1"};
+		
+		for( Document d : mongoClient.getDatabase(database).getCollection(collection).listIndexes()){
+			assert Arrays.asList(expectedIndexesNames).contains( d.get("name") );
+			actual++;
+		}
+		assert expected == actual;
+	}
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 25/27: update version to next development snapshot until releases available on maven central

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 2891897a198c2f00130389face0e62429b94212b
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Feb 24 12:27:43 2016 +0000

    update version to next development snapshot until releases available on maven central
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732128 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 096d479..d2015fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
     
@@ -84,7 +84,7 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
             <classifier>tests</classifier>
-            <version>1.1.0</version>
+            <version>1.1.1-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
       

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 24/27: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 3858d2a616266a47ffc39bb17b5ce9acaa7a8a15
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Feb 24 12:23:02 2016 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732126 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 95f0481..096d479 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.nosql.mongodb-resourceprovider</artifactId>
-    <version>1.1.0</version>
+    <version>1.1.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
   
     <name>Apache Sling NoSQL MongoDB Resource Provider</name>
     <description>Resource Provider with MongoDB Persistence for Apache Sling.</description>
   
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.1.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.1.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.1.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/nosql/mongodb-resourceprovider</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 06/27: SLING-4381/SLING-5024 add missing dependency

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 7f484fd1f85d1a94a6aa59d638b1d8297197fb07
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 16 20:33:13 2015 +0000

    SLING-4381/SLING-5024 add missing dependency
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703461 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/pom.xml b/pom.xml
index 26adc53..1498704 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,6 +69,13 @@
         </dependency>
   
         <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.2</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.sling-mock</artifactId>
             <version>1.5.0</version>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 18/27: SLING-5437 The NoSQL providers should throw LoginException if the connection to the NoSQL database can't be established (patch provided by Robert Munteanu)

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 211eef4d7551d6d77d95a0d599f680b8d11db313
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Jan 19 16:42:12 2016 +0000

    SLING-5437 The NoSQL providers should throw LoginException if the connection to the NoSQL database can't be established (patch provided by Robert Munteanu)
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1725565 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                       |  4 ++--
 .../mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java    | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 486bae1..ab83eae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
     
@@ -84,7 +84,7 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
             <classifier>tests</classifier>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
       
diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
index 5239c5f..ab66fc1 100644
--- a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Pattern;
 
+import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.nosql.generic.adapter.AbstractNoSqlAdapter;
 import org.apache.sling.nosql.generic.adapter.MultiValueMode;
@@ -33,6 +34,7 @@ import org.slf4j.LoggerFactory;
 
 import com.mongodb.DuplicateKeyException;
 import com.mongodb.MongoClient;
+import com.mongodb.MongoException;
 import com.mongodb.client.FindIterable;
 import com.mongodb.client.MongoCollection;
 import com.mongodb.client.MongoCursor;
@@ -145,4 +147,13 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
         return result.getDeletedCount() > 0;
     }
 
+    @Override
+    public void checkConnection() throws LoginException {
+        // the query is not relevant, just the successful round-trip
+        try {
+            collection.find(Filters.eq(PN_PATH, "/")).first();
+        } catch (MongoException e) {
+            throw new LoginException(e);
+        }
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 13/27: Update the contrib reactor to parent 25

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 1992dce6b3d47076e163fa35a8bd850e4164dc1e
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Mon Oct 5 10:04:15 2015 +0000

    Update the contrib reactor to parent 25
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1706781 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 219303a..eef1c26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>24</version>
+        <version>25</version>
         <relativePath />
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 26/27: update to release versions

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit d600a9901e0d2097093a91149cb5ef3aa45be44d
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sat Feb 27 14:00:41 2016 +0000

    update to release versions
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732646 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index d2015fe..096d479 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
-            <version>1.1.1-SNAPSHOT</version>
+            <version>1.1.0</version>
             <scope>provided</scope>
         </dependency>
     
@@ -84,7 +84,7 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
             <classifier>tests</classifier>
-            <version>1.1.1-SNAPSHOT</version>
+            <version>1.1.0</version>
             <scope>test</scope>
         </dependency>
       

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 27/27: SLING-7167 Adjust READMEs

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 186f90e5086057be5afdda019df00dc68d23d4ad
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Oct 3 10:06:29 2017 +0000

    SLING-7167 Adjust READMEs
    
    add uniform header linking to Sling project
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810917 13f79535-47bb-0310-9956-ffa450edef68
---
 README.md | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/README.md b/README.md
index eb9f53d..5910107 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,25 @@
-Apache Sling NoSQL MongoDB Resource Provider
-============================================
-
-Sling ResourceProvider implementation that uses [MongoDB](https://www.mongodb.org/) NoSQL database as persistence.
-
-Based on the "Apache Sling NoSQL Generic Resource Provider".
-
-All resource data is stored in one MongoDB database and one collection, using the path of the resource as "_id" property.
-
-
-Configuration on deployment
----------------------------
-
-* Create a factory configuration for "Apache Sling NoSQL MongoDB Resource Provider Factory" to define the root of the resource tree that should be stored in MongoDB, and MongoDB connection string, database name and collection name.
-
-
-Run integration tests
----------------------
-
-To run the integration tests you have to set up a real MongoDB server and run the tests with this command line (inserting the correct parameters):
-
-```
-mvn -Pmongodb-integration-test -DconnectionString=localhost:27017 -Ddatabase=sling -Dcollection=resources integration-test
-```
+# Apache Sling NoSQL MongoDB Resource Provider
+
+This module is part of the [Apache Sling](https://sling.apache.org) project.
+
+Sling ResourceProvider implementation that uses [MongoDB](https://www.mongodb.org/) NoSQL database as persistence.
+
+Based on the "Apache Sling NoSQL Generic Resource Provider".
+
+All resource data is stored in one MongoDB database and one collection, using the path of the resource as "_id" property.
+
+
+Configuration on deployment
+---------------------------
+
+* Create a factory configuration for "Apache Sling NoSQL MongoDB Resource Provider Factory" to define the root of the resource tree that should be stored in MongoDB, and MongoDB connection string, database name and collection name.
+
+
+Run integration tests
+---------------------
+
+To run the integration tests you have to set up a real MongoDB server and run the tests with this command line (inserting the correct parameters):
+
+```
+mvn -Pmongodb-integration-test -DconnectionString=localhost:27017 -Ddatabase=sling -Dcollection=resources integration-test
+```

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 19/27: SLING-5437 add connection check for couchbase resource provider define separate NoSqlAdapter methods for creating index definitions, to ensure they are only executed after connection test succeeds set versions to 1.1.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 09256704ad416e785e95a72247a01ef6445ce31a
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Jan 19 17:47:07 2016 +0000

    SLING-5437 add connection check for couchbase resource provider
    define separate NoSqlAdapter methods for creating index definitions, to ensure they are only executed after connection test succeeds
    set versions to 1.1.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1725576 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  4 +-
 .../resourceprovider/impl/MongoDBNoSqlAdapter.java | 56 ++++++++++++----------
 .../integration/IndexCreationIT.java               | 23 ++++-----
 3 files changed, 44 insertions(+), 39 deletions(-)

diff --git a/pom.xml b/pom.xml
index ab83eae..1750693 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.nosql.mongodb-resourceprovider</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.1.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
   
     <name>Apache Sling NoSQL MongoDB Resource Provider</name>
@@ -49,7 +49,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>1.1.0-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
     
diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
index ab66fc1..9b993e4 100644
--- a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
@@ -66,32 +66,6 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
     public MongoDBNoSqlAdapter(MongoClient mongoClient, String database, String collection) {
         MongoDatabase db = mongoClient.getDatabase(database);
         this.collection = db.getCollection(collection);
-        
-        // create index on parent path field (if it does not exist yet)
-        try {
-            Document parenPathtIndex = new Document(PN_PARENT_PATH, 1);
-            this.collection.createIndex(parenPathtIndex);
-        }
-        catch (DuplicateKeyException ex) {
-            // index already exists, ignore
-        }
-        catch (Throwable ex) {
-            log.error("Unable to create index on " + PN_PARENT_PATH + ": " + ex.getMessage(), ex);
-        }
-        
-        // create unique index on path field (if it does not exist yet)
-        try {
-            Document pathIndex = new Document(PN_PATH, 1);
-            IndexOptions idxOptions = new IndexOptions();
-            idxOptions.unique(true);
-            this.collection.createIndex(pathIndex, idxOptions);
-        }
-        catch (DuplicateKeyException ex) {
-            // index already exists, ignore
-        }
-        catch (Throwable ex) {
-            log.error("Unable to create unique index on " + PN_PATH + ": " + ex.getMessage(), ex);
-        }
     }
 
     @Override
@@ -156,4 +130,34 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
             throw new LoginException(e);
         }
     }
+
+    @Override
+    public void createIndexDefinitions() {
+        // create index on parent path field (if it does not exist yet)
+        try {
+            Document parenPathtIndex = new Document(PN_PARENT_PATH, 1);
+            this.collection.createIndex(parenPathtIndex);
+        }
+        catch (DuplicateKeyException ex) {
+            // index already exists, ignore
+        }
+        catch (Throwable ex) {
+            log.error("Unable to create index on " + PN_PARENT_PATH + ": " + ex.getMessage(), ex);
+        }
+        
+        // create unique index on path field (if it does not exist yet)
+        try {
+            Document pathIndex = new Document(PN_PATH, 1);
+            IndexOptions idxOptions = new IndexOptions();
+            idxOptions.unique(true);
+            this.collection.createIndex(pathIndex, idxOptions);
+        }
+        catch (DuplicateKeyException ex) {
+            // index already exists, ignore
+        }
+        catch (Throwable ex) {
+            log.error("Unable to create unique index on " + PN_PATH + ": " + ex.getMessage(), ex);
+        }
+    }
+
 }
diff --git a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
index e99ec8f..28f1256 100644
--- a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
+++ b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
@@ -21,7 +21,8 @@ package org.apache.sling.nosql.mongodb.resourceprovider.integration;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.sling.nosql.mongodb.resourceprovider.impl.MongoDBNoSqlAdapter;
 import org.bson.Document;
@@ -29,6 +30,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.collect.ImmutableList;
 import com.mongodb.MongoClient;
 
 /**
@@ -43,12 +45,14 @@ public class IndexCreationIT {
 	private String collection;
 		
 	@Before
-	public void setUp() {
+	public void setUp() throws Exception {
 	    String connectionString = System.getProperty("connectionString", "localhost:27017");
         database =  System.getProperty("database", "sling") + "_indextest";
         collection = System.getProperty("collection", "resources");
 		mongoClient = new MongoClient(connectionString);
 		underTest = new MongoDBNoSqlAdapter(mongoClient, database, collection);
+		underTest.checkConnection();
+		underTest.createIndexDefinitions();
 	}
 
 	@After
@@ -61,17 +65,14 @@ public class IndexCreationIT {
 	public void testIndexesPresent() {
 		assertNotNull(underTest);
 		
-		//expecting 2 indexes (_id, parentPath)
-		int expected = 2;
-		int actual = 0;
+		final List<String> expectedIndexNames= ImmutableList.<String>of("_id_", "parentPath_1");
 		
-		final String[] expectedIndexesNames=  {"_id_", "parentPath_1"};
-		
-		for (Document d : mongoClient.getDatabase(database).getCollection(collection).listIndexes()){
-			assert Arrays.asList(expectedIndexesNames).contains( d.get("name") );
-			actual++;
+		List<String> actualIndexNames = new ArrayList<String>();
+		for (Document d : mongoClient.getDatabase(database).getCollection(collection).listIndexes()) {
+		    actualIndexNames.add(d.get("name").toString());
 		}
-		assertEquals(expected, actual);
+		
+		assertEquals(expectedIndexNames, actualIndexNames);
 	}
 
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 10/27: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit a371caa7dcdc08199c30ea1a961f6c5551cd4142
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 17 21:39:25 2015 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703712 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5f5bf59..219303a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.nosql.mongodb-resourceprovider</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
   
     <name>Apache Sling NoSQL MongoDB Resource Provider</name>
     <description>Resource Provider with MongoDB Persistence for Apache Sling.</description>
   
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/nosql/mongodb-resourceprovider</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 01/27: SLING-5024 Sling NoSQL Resource Provider for MongoDB (based on nosql.generic)

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 07f157268ea6eb93271b6e0f4d9178e048357b52
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 14 21:19:29 2015 +0000

    SLING-5024 Sling NoSQL Resource Provider for MongoDB (based on nosql.generic)
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703061 13f79535-47bb-0310-9956-ffa450edef68
---
 README.md                                        |  22 +++
 pom.xml                                          | 171 +++++++++++++++++++++++
 src/main/couchbase-views/ancestorPath.js         |  40 ++++++
 src/main/couchbase-views/ancestorPathTester.html |  84 +++++++++++
 src/main/couchbase-views/parentPath.js           |  37 +++++
 src/main/couchbase-views/parentPathTester.html   |  82 +++++++++++
 6 files changed, 436 insertions(+)

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fc6f114
--- /dev/null
+++ b/README.md
@@ -0,0 +1,22 @@
+Apache Sling NoSQL MongoDB Resource Provider
+============================================
+
+Sling ResourceProvider implementation that uses [MongoDB](https://www.mongodb.org/) NoSQL database as persistence.
+
+Based on the "Apache Sling NoSQL Generic Resource Provider".
+
+
+Configuration on deployment
+---------------------------
+
+* Create a factory configuration for "Apache Sling NoSQL MongoDB Resource Provider Factory" to define the root of the resource tree that should be stored in MongoDB, and MongoDB connection string, database name and collection name.
+
+
+Run integration tests
+---------------------
+
+To run the integration tests you have to set up a real MongoDB server and run the tests with this command line (inserting the correct parameters):
+
+```
+mvn -Pmongodb-integration-test -DconnectionString=localhost:27017 -Ddatabase=sling -Dcollection=resources integration-test
+```
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..26adc53
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>24</version>
+        <relativePath/>
+    </parent>
+
+    <artifactId>org.apache.sling.nosql.mongodb-resourceprovider</artifactId>
+    <version>0.5.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+  
+    <name>Apache Sling NoSQL MongoDB Resource Provider</name>
+    <description>Resource Provider with MongoDB Persistence for Apache Sling.</description>
+  
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/nosql/mongodb-resourceprovider</url>
+    </scm>
+
+    <properties>
+        <sling.java.version>7</sling.java.version>
+    </properties>
+  
+    <dependencies>
+  
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.nosql.generic</artifactId>
+            <version>0.5.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+    
+        <dependency>
+            <groupId>org.mongodb</groupId>
+            <artifactId>mongo-java-driver</artifactId>
+            <version>3.0.4</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.osgi</artifactId>
+            <version>2.2.2</version>
+            <scope>provided</scope>
+        </dependency>
+  
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+            <version>1.5.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.testing.logging-mock</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.nosql.generic</artifactId>
+            <classifier>tests</classifier>
+            <version>0.5.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+      
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>2.0</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+  
+    <build>
+        <plugins>
+    
+          <plugin>
+              <groupId>org.apache.felix</groupId>
+              <artifactId>maven-bundle-plugin</artifactId>
+              <extensions>true</extensions>
+          </plugin>
+    
+          <plugin>
+              <groupId>org.apache.felix</groupId>
+              <artifactId>maven-scr-plugin</artifactId>
+          </plugin>
+    
+          <plugin>
+              <groupId>org.apache.maven.plugins</groupId>
+              <artifactId>maven-surefire-plugin</artifactId>
+              <configuration>
+                  <testFailureIgnore>false</testFailureIgnore>
+                  <includes>
+                      <include>**/*Test.java</include>
+                  </includes>
+                  <excludes>
+                      <exclude>**/*IT.java</exclude>
+                  </excludes>
+              </configuration>
+          </plugin>
+    
+        </plugins>
+    </build>
+    
+    <profiles>
+    
+      <!-- 
+          Profile for Integration tests with a real MongoDB server running.
+          You have to set JVM parameters for MongoDB host and bucket name, e.g.
+          mvn -Pmongodb-integration-test -DmongodbHosts=localhost:8091 -DbucketName=test integration-test
+      -->
+      <profile>
+        <id>mongodb-integration-test</id>
+        <build>
+          <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <includes>
+                        <include>**/*IT.java</include>
+                    </includes>
+                    <excludes>
+                        <exclude>**/*Test.java</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+    
+          </plugins>
+        </build>
+      </profile>
+
+    </profiles>
+  
+</project>
diff --git a/src/main/couchbase-views/ancestorPath.js b/src/main/couchbase-views/ancestorPath.js
new file mode 100644
index 0000000..f8cd94b
--- /dev/null
+++ b/src/main/couchbase-views/ancestorPath.js
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Emits for each document the all parent paths - allowing to fetch children and their decendants by path.
+ * Includes the path of the item itself.
+ */
+function(doc, meta) {
+  
+  // handle only sling resource documents with a valid path
+  if (!(meta.id.indexOf("sling-resource:")==0 && doc.path && doc.data)) {
+    return;
+  }
+  var pathParts = doc.path.split("/");
+  if (pathParts.length < 3) {
+    return;
+  }
+  
+  while (pathParts.length >= 2) {
+    // remove last element to get parent path
+    var parentPath = pathParts.join("/");
+    emit(parentPath, null);
+    pathParts.pop();
+  }
+}
diff --git a/src/main/couchbase-views/ancestorPathTester.html b/src/main/couchbase-views/ancestorPathTester.html
new file mode 100644
index 0000000..9933e6f
--- /dev/null
+++ b/src/main/couchbase-views/ancestorPathTester.html
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+  <head>
+    <title>Couchbase View Tester</title>
+    <style>body { font-family: Courier }</style>
+  </head>
+  <body>
+  
+<script>
+
+var emit = function(key, value) {
+  document.write("[" + key + "]" + "<br/>");
+}
+
+var testFunction = function(doc, meta) {
+  
+  // handle only sling resource documents with a valid path
+  if (!(meta.id.indexOf("sling-resource:")==0 && doc.path && doc.data)) {
+    return;
+  }
+  var pathParts = doc.path.split("/");
+  if (pathParts.length < 3) {
+    return;
+  }
+  
+  while (pathParts.length >= 2) {
+    // remove last element to get parent path
+    var parentPath = pathParts.join("/");
+    emit(parentPath, null);
+    pathParts.pop();
+  }
+};
+
+var testInput = [
+	  null,
+    "",
+    "abc",
+    "/",
+    "/content",
+    "/content/node1",
+    "/content/node1/node2",
+    "/content/node1/node2/node3",
+    "/content/node1/node2/node3/node4"
+];
+  
+</script>
+    
+    <table border="1">
+      <tr>
+	      <th>Input</th>
+	      <th>Output</th>
+	    </tr>
+<script>
+for (var i=0; i < testInput.length; i++) {
+  document.write("<tr>")
+  document.write("<td>" + testInput[i] + "</td>")
+  document.write("<td>")
+  testFunction({path: testInput[i], data: {}}, {id: "sling-resource:doc" + i});
+  document.write("</td>")
+  document.write("</tr>")
+}
+</script>
+    </table>
+  
+  </body>
+</html>
diff --git a/src/main/couchbase-views/parentPath.js b/src/main/couchbase-views/parentPath.js
new file mode 100644
index 0000000..54c4c1f
--- /dev/null
+++ b/src/main/couchbase-views/parentPath.js
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Emits for each document the direct parent path - allowing to fetch direct children by path.
+ */
+function(doc, meta) {
+  
+  // handle only sling resource documents with a valid path
+  if (!(meta.id.indexOf("sling-resource:")==0 && doc.path && doc.data)) {
+    return;
+  }
+  var pathParts = doc.path.split("/");
+  if (pathParts.length < 3) {
+    return;
+  }
+  
+  // remove last element to get parent path
+  pathParts.pop();
+  var parentPath = pathParts.join("/");
+  emit(parentPath, null);
+}
diff --git a/src/main/couchbase-views/parentPathTester.html b/src/main/couchbase-views/parentPathTester.html
new file mode 100644
index 0000000..efcc2d1
--- /dev/null
+++ b/src/main/couchbase-views/parentPathTester.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+  <head>
+    <title>Couchbase View Tester</title>
+    <style>body { font-family: Courier }</style>
+  </head>
+  <body>
+  
+<script>
+
+var emit = function(key, value) {
+  document.write("[" + key + "]" + "<br/>");
+}
+
+var testFunction = function(doc, meta) {
+  
+  // handle only sling resource documents with a valid path
+  if (!(meta.id.indexOf("sling-resource:")==0 && doc.path && doc.data)) {
+    return;
+  }
+  var pathParts = doc.path.split("/");
+  if (pathParts.length < 3) {
+    return;
+  }
+  
+  // remove last element to get parent path
+  pathParts.pop();
+  var parentPath = pathParts.join("/");
+  emit(parentPath, null);
+};
+
+var testInput = [
+	  null,
+    "",
+    "abc",
+    "/",
+    "/content",
+    "/content/node1",
+    "/content/node1/node2",
+    "/content/node1/node2/node3",
+    "/content/node1/node2/node3/node4"
+];
+  
+</script>
+    
+    <table border="1">
+      <tr>
+	      <th>Input</th>
+	      <th>Output</th>
+	    </tr>
+<script>
+for (var i=0; i < testInput.length; i++) {
+  document.write("<tr>")
+  document.write("<td>" + testInput[i] + "</td>")
+  document.write("<td>")
+  testFunction({path: testInput[i], data: {}}, {id: "sling-resource:doc" + i});
+  document.write("</td>")
+  document.write("</tr>")
+}
+</script>
+    </table>
+  
+  </body>
+</html>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 12/27: switch back to released versions

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit bfa4caabbb14f24ff904517fbfc9705a35bf936d
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Sep 29 20:52:02 2015 +0000

    switch back to released versions
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1705925 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index a058e6f..219303a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>1.0.0</version>
             <scope>provided</scope>
         </dependency>
     
@@ -84,7 +84,7 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
             <classifier>tests</classifier>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>1.0.0</version>
             <scope>test</scope>
         </dependency>
       

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 07/27: SLING-4381/SLING-5024 for query efficiency on listChildren store parentPath as separate attribute

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 521d883bd834981ffe3913642f86203eb58ad4e4
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 17 06:00:21 2015 +0000

    SLING-4381/SLING-5024 for query efficiency on listChildren store parentPath as separate attribute
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703494 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  7 ----
 .../resourceprovider/impl/MongoDBNoSqlAdapter.java | 42 ++++++++++++----------
 2 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1498704..26adc53 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,13 +69,6 @@
         </dependency>
   
         <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.3.2</version>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.testing.sling-mock</artifactId>
             <version>1.5.0</version>
diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
index e1931d3..a25abd5 100644
--- a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
@@ -23,7 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.nosql.generic.adapter.AbstractNoSqlAdapter;
 import org.apache.sling.nosql.generic.adapter.MultiValueMode;
 import org.apache.sling.nosql.generic.adapter.NoSqlData;
@@ -44,8 +44,9 @@ import com.mongodb.client.result.UpdateResult;
  */
 public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
     
-    private static final String ID_PROPERTY = "_id";
-    private static final String DATA_PROPERTY = "_data";
+    private static final String PN_PATH = "_id";
+    private static final String PN_PARENT_PATH = "parentPath";
+    private static final String PN_DATA = "data";
     
     private final MongoCollection<Document> collection;
     
@@ -61,25 +62,24 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
 
     @Override
     public NoSqlData get(String path) {
-        Document wrapper = collection.find(Filters.eq(ID_PROPERTY, path)).first();
-        if (wrapper == null) {
+        Document envelope = collection.find(Filters.eq(PN_PATH, path)).first();
+        if (envelope == null) {
             return null;
         }
         else {
-            return new NoSqlData(path, wrapper.get(DATA_PROPERTY, Document.class), MultiValueMode.LISTS);
+            return new NoSqlData(path, envelope.get(PN_DATA, Document.class), MultiValueMode.LISTS);
         }
     }
 
     @Override
     public Iterator<NoSqlData> getChildren(String parentPath) {
         List<NoSqlData> children = new ArrayList<>();
-        Pattern directChildren = Pattern.compile("^" + Pattern.quote(StringUtils.removeEnd(parentPath, "/")) + "/[^/]+$");
-        FindIterable<Document> result = collection.find(Filters.regex(ID_PROPERTY, directChildren));
-        try (MongoCursor<Document> wrappers = result.iterator()) {
-            while (wrappers.hasNext()) {
-                Document wrapper = wrappers.next();
-                String path = wrapper.get(ID_PROPERTY, String.class);
-                Document data = wrapper.get(DATA_PROPERTY, Document.class);
+        FindIterable<Document> result = collection.find(Filters.eq(PN_PARENT_PATH, parentPath));
+        try (MongoCursor<Document> envelopes = result.iterator()) {
+            while (envelopes.hasNext()) {
+                Document envelope = envelopes.next();
+                String path = envelope.get(PN_PATH, String.class);
+                Document data = envelope.get(PN_DATA, Document.class);
                 children.add(new NoSqlData(path, data, MultiValueMode.LISTS));
             }
         }
@@ -88,11 +88,17 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
 
     @Override
     public boolean store(NoSqlData data) {
-        Document wrapper = new Document();
-        wrapper.put(ID_PROPERTY, data.getPath());
-        wrapper.put(DATA_PROPERTY, new Document(data.getProperties(MultiValueMode.LISTS)));
+        Document envelope = new Document();
+        envelope.put(PN_PATH, data.getPath());
+        envelope.put(PN_DATA, new Document(data.getProperties(MultiValueMode.LISTS)));
         
-        UpdateResult result = collection.replaceOne(Filters.eq(ID_PROPERTY, data.getPath()), wrapper, new UpdateOptions().upsert(true));
+        // for list-children query efficiency store parent path as well
+        String parentPath = ResourceUtil.getParent(data.getPath());
+        if (parentPath != null) {
+            envelope.put(PN_PARENT_PATH, parentPath);
+        }
+                
+        UpdateResult result = collection.replaceOne(Filters.eq(PN_PATH, data.getPath()), envelope, new UpdateOptions().upsert(true));
         
         // return true if a new entry was inserted, false if an existing was replaced
         return (result.getMatchedCount() == 0);
@@ -101,7 +107,7 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
     @Override
     public boolean deleteRecursive(String path) {        
         Pattern descendantsAndSelf = Pattern.compile("^" + Pattern.quote(path) + "(/.+)?$");
-        DeleteResult result = collection.deleteMany(Filters.regex(ID_PROPERTY, descendantsAndSelf));
+        DeleteResult result = collection.deleteMany(Filters.regex(PN_PATH, descendantsAndSelf));
         
         // return true if any document was deleted
         return result.getDeletedCount() > 0;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 11/27: update to next snapshot version until releases are available in maven central

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 955b81ad59509907c06515fe5cb334c16a094463
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 17 21:44:36 2015 +0000

    update to next snapshot version until releases are available in maven central
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703715 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 219303a..a058e6f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
     
@@ -84,7 +84,7 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
             <classifier>tests</classifier>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
       

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 04/27: SLING-5024 remove obsolete files

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 362e7b4bbee93dd7e09693573f697882fd650b34
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 14 23:08:23 2015 +0000

    SLING-5024 remove obsolete files
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703075 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/couchbase-views/ancestorPath.js           | 40 -----------
 src/main/couchbase-views/ancestorPathTester.html   | 84 ----------------------
 src/main/couchbase-views/parentPath.js             | 37 ----------
 src/main/couchbase-views/parentPathTester.html     | 82 ---------------------
 .../resourceprovider/impl/MongoDBNoSqlAdapter.java |  4 +-
 5 files changed, 2 insertions(+), 245 deletions(-)

diff --git a/src/main/couchbase-views/ancestorPath.js b/src/main/couchbase-views/ancestorPath.js
deleted file mode 100644
index f8cd94b..0000000
--- a/src/main/couchbase-views/ancestorPath.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/*
- * Emits for each document the all parent paths - allowing to fetch children and their decendants by path.
- * Includes the path of the item itself.
- */
-function(doc, meta) {
-  
-  // handle only sling resource documents with a valid path
-  if (!(meta.id.indexOf("sling-resource:")==0 && doc.path && doc.data)) {
-    return;
-  }
-  var pathParts = doc.path.split("/");
-  if (pathParts.length < 3) {
-    return;
-  }
-  
-  while (pathParts.length >= 2) {
-    // remove last element to get parent path
-    var parentPath = pathParts.join("/");
-    emit(parentPath, null);
-    pathParts.pop();
-  }
-}
diff --git a/src/main/couchbase-views/ancestorPathTester.html b/src/main/couchbase-views/ancestorPathTester.html
deleted file mode 100644
index 9933e6f..0000000
--- a/src/main/couchbase-views/ancestorPathTester.html
+++ /dev/null
@@ -1,84 +0,0 @@
-<!DOCTYPE html>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<html>
-  <head>
-    <title>Couchbase View Tester</title>
-    <style>body { font-family: Courier }</style>
-  </head>
-  <body>
-  
-<script>
-
-var emit = function(key, value) {
-  document.write("[" + key + "]" + "<br/>");
-}
-
-var testFunction = function(doc, meta) {
-  
-  // handle only sling resource documents with a valid path
-  if (!(meta.id.indexOf("sling-resource:")==0 && doc.path && doc.data)) {
-    return;
-  }
-  var pathParts = doc.path.split("/");
-  if (pathParts.length < 3) {
-    return;
-  }
-  
-  while (pathParts.length >= 2) {
-    // remove last element to get parent path
-    var parentPath = pathParts.join("/");
-    emit(parentPath, null);
-    pathParts.pop();
-  }
-};
-
-var testInput = [
-	  null,
-    "",
-    "abc",
-    "/",
-    "/content",
-    "/content/node1",
-    "/content/node1/node2",
-    "/content/node1/node2/node3",
-    "/content/node1/node2/node3/node4"
-];
-  
-</script>
-    
-    <table border="1">
-      <tr>
-	      <th>Input</th>
-	      <th>Output</th>
-	    </tr>
-<script>
-for (var i=0; i < testInput.length; i++) {
-  document.write("<tr>")
-  document.write("<td>" + testInput[i] + "</td>")
-  document.write("<td>")
-  testFunction({path: testInput[i], data: {}}, {id: "sling-resource:doc" + i});
-  document.write("</td>")
-  document.write("</tr>")
-}
-</script>
-    </table>
-  
-  </body>
-</html>
diff --git a/src/main/couchbase-views/parentPath.js b/src/main/couchbase-views/parentPath.js
deleted file mode 100644
index 54c4c1f..0000000
--- a/src/main/couchbase-views/parentPath.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/*
- * Emits for each document the direct parent path - allowing to fetch direct children by path.
- */
-function(doc, meta) {
-  
-  // handle only sling resource documents with a valid path
-  if (!(meta.id.indexOf("sling-resource:")==0 && doc.path && doc.data)) {
-    return;
-  }
-  var pathParts = doc.path.split("/");
-  if (pathParts.length < 3) {
-    return;
-  }
-  
-  // remove last element to get parent path
-  pathParts.pop();
-  var parentPath = pathParts.join("/");
-  emit(parentPath, null);
-}
diff --git a/src/main/couchbase-views/parentPathTester.html b/src/main/couchbase-views/parentPathTester.html
deleted file mode 100644
index efcc2d1..0000000
--- a/src/main/couchbase-views/parentPathTester.html
+++ /dev/null
@@ -1,82 +0,0 @@
-<!DOCTYPE html>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<html>
-  <head>
-    <title>Couchbase View Tester</title>
-    <style>body { font-family: Courier }</style>
-  </head>
-  <body>
-  
-<script>
-
-var emit = function(key, value) {
-  document.write("[" + key + "]" + "<br/>");
-}
-
-var testFunction = function(doc, meta) {
-  
-  // handle only sling resource documents with a valid path
-  if (!(meta.id.indexOf("sling-resource:")==0 && doc.path && doc.data)) {
-    return;
-  }
-  var pathParts = doc.path.split("/");
-  if (pathParts.length < 3) {
-    return;
-  }
-  
-  // remove last element to get parent path
-  pathParts.pop();
-  var parentPath = pathParts.join("/");
-  emit(parentPath, null);
-};
-
-var testInput = [
-	  null,
-    "",
-    "abc",
-    "/",
-    "/content",
-    "/content/node1",
-    "/content/node1/node2",
-    "/content/node1/node2/node3",
-    "/content/node1/node2/node3/node4"
-];
-  
-</script>
-    
-    <table border="1">
-      <tr>
-	      <th>Input</th>
-	      <th>Output</th>
-	    </tr>
-<script>
-for (var i=0; i < testInput.length; i++) {
-  document.write("<tr>")
-  document.write("<td>" + testInput[i] + "</td>")
-  document.write("<td>")
-  testFunction({path: testInput[i], data: {}}, {id: "sling-resource:doc" + i});
-  document.write("</td>")
-  document.write("</tr>")
-}
-</script>
-    </table>
-  
-  </body>
-</html>
diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
index fe509f2..8e034fc 100644
--- a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
@@ -99,8 +99,8 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
 
     @Override
     public boolean deleteRecursive(String path) {        
-        Pattern decendantsAndSelf = Pattern.compile("^" + Pattern.quote(path) + "(/.+)?$");
-        DeleteResult result = collection.deleteMany(Filters.regex(ID_PROPERTY, decendantsAndSelf));
+        Pattern descendantsAndSelf = Pattern.compile("^" + Pattern.quote(path) + "(/.+)?$");
+        DeleteResult result = collection.deleteMany(Filters.regex(ID_PROPERTY, descendantsAndSelf));
         
         // return true if any document was deleted
         return result.getDeletedCount() > 0;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 20/27: fix version number for generic test dependencies

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit f5994d51f4af2bdd29986025163f7f68a3a0e1b5
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Feb 24 10:33:05 2016 +0000

    fix version number for generic test dependencies
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732056 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 1750693..2f9a9d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,7 +84,7 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
             <classifier>tests</classifier>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>1.1.0-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
       

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 21/27: exclude README.md in rat report

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit c1ca345fc23c6b54114e847487f84968c1ad162c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Feb 24 12:02:10 2016 +0000

    exclude README.md in rat report
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732095 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/pom.xml b/pom.xml
index 2f9a9d2..1c9f9c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -126,6 +126,20 @@
           </plugin>
     
         </plugins>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <!-- Extend RAT configuration from parent pom -->
+                    <groupId>org.apache.rat</groupId>
+                    <artifactId>apache-rat-plugin</artifactId>
+                    <configuration>
+                        <excludes combine.children="append">
+                            <exclude>README.md</exclude>
+                        </excludes>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
     </build>
     
     <profiles>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 15/27: SLING-5078 some cosmetic changes This closes #113

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit a090df7dfe695eae2e0d39ce699c964d615a2a43
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Nov 24 22:56:51 2015 +0000

    SLING-5078 some cosmetic changes
    This closes #113
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1716275 13f79535-47bb-0310-9956-ffa450edef68
---
 .../resourceprovider/integration/IndexCreationIT.java       | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
index 3ec88fe..a159514 100644
--- a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
+++ b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
@@ -30,32 +30,35 @@ import org.junit.Test;
 
 import com.mongodb.MongoClient;
 
+/**
+ * Test creation of indexes in MongoDB
+ */
 public class IndexCreationIT {
 
-	private MongoDBNoSqlAdapter obj;
+	private MongoDBNoSqlAdapter underTest;
 	
 	private MongoClient mongoClient;
 	private String database;
 	private String collection;
 		
 	@Before
-	public void setUp() throws Exception {
+	public void setUp() {
 	    String connectionString = System.getProperty("connectionString", "localhost:27017");
         database =  System.getProperty("database", "sling") + "_indextest";
         collection = System.getProperty("collection", "resources");
 		mongoClient = new MongoClient(connectionString);
-		obj = new MongoDBNoSqlAdapter(mongoClient, database, collection);
+		underTest = new MongoDBNoSqlAdapter(mongoClient, database, collection);
 	}
 
 	@After
-	public void tearDown() throws Exception {
+	public void tearDown() {
 		mongoClient.dropDatabase(database);
 		mongoClient.close();
 	}
 
 	@Test
 	public void testIndexesPresent() {
-		assertNotNull(obj);
+		assertNotNull(underTest);
 		
 		//expecting at least 3 indexes (_id, _path, _parentPath)
 		int expected = 3;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 22/27: update dependencies

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 2c06eed755afba0eac5e8cf1d2412c494b1042e8
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Feb 24 12:07:22 2016 +0000

    update dependencies
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732103 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1c9f9c8..22f4403 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
-            <version>1.1.0-SNAPSHOT</version>
+            <version>1.1.0</version>
             <scope>provided</scope>
         </dependency>
     
@@ -84,7 +84,7 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
             <classifier>tests</classifier>
-            <version>1.1.0-SNAPSHOT</version>
+            <version>1.1.0</version>
             <scope>test</scope>
         </dependency>
       

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 02/27: SLING-5024 Sling NoSQL Resource Provider for MongoDB (based on nosql.generic)

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit da9cdca3a5dba06c88f77425e9488ca1cbdebe37
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 14 21:22:00 2015 +0000

    SLING-5024 Sling NoSQL Resource Provider for MongoDB (based on nosql.generic)
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703063 13f79535-47bb-0310-9956-ffa450edef68
---
 .../resourceprovider/impl/MongoDBNoSqlAdapter.java | 109 ++++++++++++++++++++
 .../impl/MongoDBNoSqlResourceProviderFactory.java  | 113 +++++++++++++++++++++
 .../MongoDBNoSqlResourceProviderIT.java            |  69 +++++++++++++
 .../MongoDBNoSqlResourceProviderRootIT.java        |  42 ++++++++
 ...ongoDBNoSqlResourceProviderTransactionalIT.java |  69 +++++++++++++
 5 files changed, 402 insertions(+)

diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
new file mode 100644
index 0000000..fe509f2
--- /dev/null
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.nosql.mongodb.resourceprovider.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.apache.sling.nosql.generic.adapter.AbstractNoSqlAdapter;
+import org.apache.sling.nosql.generic.adapter.MultiValueMode;
+import org.apache.sling.nosql.generic.adapter.NoSqlData;
+import org.bson.Document;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.UpdateOptions;
+import com.mongodb.client.result.DeleteResult;
+import com.mongodb.client.result.UpdateResult;
+
+/**
+ * {@link org.apache.sling.nosql.generic.adapter.NoSqlAdapter} implementation for MongoDB.
+ */
+public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
+    
+    private static final String ID_PROPERTY = "_id";
+    private static final String DATA_PROPERTY = "_data";
+    
+    private final MongoCollection<Document> collection;
+    
+    /**
+     * @param mongoClient MongoDB client
+     * @param database MongoDB database
+     * @param collection MongoDB collection
+     */
+    public MongoDBNoSqlAdapter(MongoClient mongoClient, String database, String collection) {
+        MongoDatabase db = mongoClient.getDatabase(database);
+        this.collection = db.getCollection(collection);
+    }
+
+    @Override
+    public NoSqlData get(String path) {
+        Document wrapper = collection.find(Filters.eq(ID_PROPERTY, path)).first();
+        if (wrapper == null) {
+            return null;
+        }
+        else {
+            return new NoSqlData(path, wrapper.get(DATA_PROPERTY, Document.class), MultiValueMode.LISTS);
+        }
+    }
+
+    @Override
+    public Iterator<NoSqlData> getChildren(String parentPath) {
+        List<NoSqlData> children = new ArrayList<>();
+        Pattern directChildren = Pattern.compile("^" + Pattern.quote(parentPath) + "/[^/]+$");
+        FindIterable<Document> result = collection.find(Filters.regex(ID_PROPERTY, directChildren));
+        try (MongoCursor<Document> wrappers = result.iterator()) {
+            while (wrappers.hasNext()) {
+                Document wrapper = wrappers.next();
+                String path = wrapper.get(ID_PROPERTY, String.class);
+                Document data = wrapper.get(DATA_PROPERTY, Document.class);
+                children.add(new NoSqlData(path, data, MultiValueMode.LISTS));
+            }
+        }
+        return children.iterator();
+    }
+
+    @Override
+    public boolean store(NoSqlData data) {
+        Document wrapper = new Document();
+        wrapper.put(ID_PROPERTY, data.getPath());
+        wrapper.put(DATA_PROPERTY, new Document(data.getProperties(MultiValueMode.LISTS)));
+        
+        UpdateResult result = collection.replaceOne(Filters.eq(ID_PROPERTY, data.getPath()), wrapper, new UpdateOptions().upsert(true));
+        
+        // return true if a new entry was inserted, false if an existing was replaced
+        return (result.getMatchedCount() == 0);
+    }
+
+    @Override
+    public boolean deleteRecursive(String path) {        
+        Pattern decendantsAndSelf = Pattern.compile("^" + Pattern.quote(path) + "(/.+)?$");
+        DeleteResult result = collection.deleteMany(Filters.regex(ID_PROPERTY, decendantsAndSelf));
+        
+        // return true if any document was deleted
+        return result.getDeletedCount() > 0;
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlResourceProviderFactory.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlResourceProviderFactory.java
new file mode 100644
index 0000000..cf697f0
--- /dev/null
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlResourceProviderFactory.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.nosql.mongodb.resourceprovider.impl;
+
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.ResourceProvider;
+import org.apache.sling.api.resource.ResourceProviderFactory;
+import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.apache.sling.nosql.generic.adapter.MetricsNoSqlAdapterWrapper;
+import org.apache.sling.nosql.generic.adapter.NoSqlAdapter;
+import org.apache.sling.nosql.generic.resource.AbstractNoSqlResourceProviderFactory;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.event.EventAdmin;
+import org.slf4j.LoggerFactory;
+
+import com.mongodb.MongoClient;
+
+import aQute.bnd.annotation.component.Deactivate;
+
+/**
+ * {@link ResourceProviderFactory} implementation that uses MongoDB as persistence.
+ */
+@Component(immediate = true, metatype = true,
+    name="org.apache.sling.nosql.mongodb.resourceprovider.MongoDBNoSqlResourceProviderFactory.factory.config",
+    label = "Apache Sling NoSQL MongoDB Resource Provider Factory", 
+    description = "Defines a resource provider factory with MongoDB persistence.", 
+    configurationFactory = true, policy = ConfigurationPolicy.REQUIRE)
+@Service(value = ResourceProviderFactory.class)
+@Property(name = "webconsole.configurationFactory.nameHint", 
+    value = "Root paths: {" + MongoDBNoSqlResourceProviderFactory.PROVIDER_ROOTS_PROPERTY + "}")
+public final class MongoDBNoSqlResourceProviderFactory extends AbstractNoSqlResourceProviderFactory {
+
+    @Property(label = "Root paths", description = "Root paths for resource provider.", cardinality = Integer.MAX_VALUE)
+    static final String PROVIDER_ROOTS_PROPERTY = ResourceProvider.ROOTS;
+    
+    @Property(label = "Connection String",
+            description = "MongoDB connection String. Example: 'localhost:27017,localhost:27018,localhost:27019'",
+            value = MongoDBNoSqlResourceProviderFactory.CONNECTION_STRING_DEFAULT)
+    static final String CONNECTION_STRING_PROPERTY = "connectionString";
+    private static final String CONNECTION_STRING_DEFAULT = "localhost:27017";
+    
+    @Property(label = "Database",
+            description = "MongoDB database to store resource data in.",
+            value = MongoDBNoSqlResourceProviderFactory.DATABASE_DEFAULT)
+    static final String DATABASE_PROPERTY = "database";
+    private static final String DATABASE_DEFAULT = "sling";
+    
+    @Property(label = "Collection",
+            description = "MongoDB collection to store resource data in.",
+            value = MongoDBNoSqlResourceProviderFactory.COLLECTION_DEFAULT)
+    static final String COLLECTION_PROPERTY = "collection";
+    private static final String COLLECTION_DEFAULT = "resources";
+    
+    @Reference
+    private EventAdmin eventAdmin;
+
+    private MongoClient mongoClient;
+    private NoSqlAdapter noSqlAdapter;
+
+    @Activate
+    private void activate(ComponentContext componentContext, Map<String, Object> config) {
+        String connectionString = PropertiesUtil.toString(config.get(CONNECTION_STRING_PROPERTY), CONNECTION_STRING_DEFAULT);
+        String database = PropertiesUtil.toString(config.get(DATABASE_PROPERTY), DATABASE_DEFAULT);
+        String collection = PropertiesUtil.toString(config.get(COLLECTION_PROPERTY), COLLECTION_DEFAULT);
+        
+        mongoClient = new MongoClient(connectionString);
+        NoSqlAdapter mongodbAdapter = new MongoDBNoSqlAdapter(mongoClient, database, collection);
+        
+        // enable call logging and metrics for {@link MongoDBNoSqlAdapter}
+        noSqlAdapter = new MetricsNoSqlAdapterWrapper(mongodbAdapter, LoggerFactory.getLogger(MongoDBNoSqlAdapter.class));
+    }
+    
+    @Deactivate
+    private void deactivate() {
+        if (mongoClient != null) {
+            mongoClient.close();
+        }
+    }
+
+    @Override
+    protected NoSqlAdapter getNoSqlAdapter() {
+        return noSqlAdapter;
+    }
+
+    @Override
+    protected EventAdmin getEventAdmin() {
+        return eventAdmin;
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderIT.java b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderIT.java
new file mode 100644
index 0000000..4126f54
--- /dev/null
+++ b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderIT.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.nosql.mongodb.resourceprovider.integration;
+
+import java.util.UUID;
+
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceProvider;
+import org.apache.sling.nosql.generic.resource.impl.AbstractNoSqlResourceProviderTest;
+import org.apache.sling.nosql.mongodb.resourceprovider.impl.MongoDBNoSqlResourceProviderFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Test basic ResourceResolver and ValueMap with different data types.
+ */
+public class MongoDBNoSqlResourceProviderIT extends AbstractNoSqlResourceProviderTest {
+
+    private Resource testRoot;
+
+    @Override
+    protected void registerResourceProviderFactory() {
+        context.registerInjectActivateService(new MongoDBNoSqlResourceProviderFactory(), ImmutableMap.<String, Object>builder()
+                .put(ResourceProvider.ROOTS, "/test")
+                .put("connectionString", System.getProperty("connectionString", "localhost:27017"))
+                .put("database", System.getProperty("database", "sling"))
+                .put("collection", System.getProperty("collection", "resources"))
+                .build());
+    }
+
+    @Override
+    protected Resource testRoot() {
+        if (this.testRoot == null) {
+            try {
+                Resource root = context.resourceResolver().getResource("/");
+                Resource providerRoot = root.getChild("test");
+                if (providerRoot == null) {
+                    providerRoot = context.resourceResolver().create(root, "test",
+                            ImmutableMap.<String, Object>of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED));
+                }
+                this.testRoot = context.resourceResolver().create(providerRoot, UUID.randomUUID().toString(),
+                        ImmutableMap.<String, Object>of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED));
+            }
+            catch (PersistenceException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+        return this.testRoot;
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderRootIT.java b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderRootIT.java
new file mode 100644
index 0000000..4a28224
--- /dev/null
+++ b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderRootIT.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.nosql.mongodb.resourceprovider.integration;
+
+import org.apache.sling.api.resource.ResourceProvider;
+import org.apache.sling.nosql.generic.resource.impl.AbstractNoSqlResourceProviderRootTest;
+import org.apache.sling.nosql.mongodb.resourceprovider.impl.MongoDBNoSqlResourceProviderFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Test basic ResourceResolver and ValueMap with different data types.
+ */
+public class MongoDBNoSqlResourceProviderRootIT extends AbstractNoSqlResourceProviderRootTest {
+    
+    @Override
+    protected void registerResourceProviderFactoryAsRoot() {
+        context.registerInjectActivateService(new MongoDBNoSqlResourceProviderFactory(), ImmutableMap.<String, Object>builder()
+                .put(ResourceProvider.ROOTS, "/")
+                .put("connectionString", System.getProperty("connectionString", "localhost:27017"))
+                .put("database", System.getProperty("database", "sling"))
+                .put("collection", System.getProperty("collection", "resources"))
+                .build());
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderTransactionalIT.java b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderTransactionalIT.java
new file mode 100644
index 0000000..9325496
--- /dev/null
+++ b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/MongoDBNoSqlResourceProviderTransactionalIT.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.nosql.mongodb.resourceprovider.integration;
+
+import java.util.UUID;
+
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceProvider;
+import org.apache.sling.nosql.generic.resource.impl.AbstractNoSqlResourceProviderTransactionalTest;
+import org.apache.sling.nosql.mongodb.resourceprovider.impl.MongoDBNoSqlResourceProviderFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Test basic ResourceResolver and ValueMap with different data types.
+ */
+public class MongoDBNoSqlResourceProviderTransactionalIT extends AbstractNoSqlResourceProviderTransactionalTest {
+
+    private Resource testRoot;
+
+    @Override
+    protected void registerResourceProviderFactory() {
+        context.registerInjectActivateService(new MongoDBNoSqlResourceProviderFactory(), ImmutableMap.<String, Object>builder()
+                .put(ResourceProvider.ROOTS, "/test")
+                .put("connectionString", System.getProperty("connectionString", "localhost:27017"))
+                .put("database", System.getProperty("database", "sling"))
+                .put("collection", System.getProperty("collection", "resources"))
+                .build());
+    }
+
+    @Override
+    protected Resource testRoot() {
+        if (this.testRoot == null) {
+            try {
+                Resource root = context.resourceResolver().getResource("/");
+                Resource providerRoot = root.getChild("test");
+                if (providerRoot == null) {
+                    providerRoot = context.resourceResolver().create(root,"test",
+                            ImmutableMap.<String, Object>of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED));
+                }
+                this.testRoot = context.resourceResolver().create(providerRoot, UUID.randomUUID().toString(),
+                        ImmutableMap.<String, Object>of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED));
+            }
+            catch (PersistenceException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
+        return this.testRoot;
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 08/27: update dependencies

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 5b7eaad7fde566bcf3ba39a2b94657d02e8f383b
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 17 21:31:07 2015 +0000

    update dependencies
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703701 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 26adc53..979e2d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
-            <version>0.5.0-SNAPSHOT</version>
+            <version>1.0.0</version>
             <scope>provided</scope>
         </dependency>
     
@@ -85,7 +85,7 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.nosql.generic</artifactId>
             <classifier>tests</classifier>
-            <version>0.5.0-SNAPSHOT</version>
+            <version>1.0.0</version>
             <scope>test</scope>
         </dependency>
       

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 05/27: SLING-4381/SLING-5024 fix root node child listing

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit eea5f492d6787002c61068e74e116b36fa59f9ea
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Sep 16 19:25:11 2015 +0000

    SLING-4381/SLING-5024 fix root node child listing
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703453 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
index 8e034fc..e1931d3 100644
--- a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Pattern;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.nosql.generic.adapter.AbstractNoSqlAdapter;
 import org.apache.sling.nosql.generic.adapter.MultiValueMode;
 import org.apache.sling.nosql.generic.adapter.NoSqlData;
@@ -72,7 +73,7 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
     @Override
     public Iterator<NoSqlData> getChildren(String parentPath) {
         List<NoSqlData> children = new ArrayList<>();
-        Pattern directChildren = Pattern.compile("^" + Pattern.quote(parentPath) + "/[^/]+$");
+        Pattern directChildren = Pattern.compile("^" + Pattern.quote(StringUtils.removeEnd(parentPath, "/")) + "/[^/]+$");
         FindIterable<Document> result = collection.find(Filters.regex(ID_PROPERTY, directChildren));
         try (MongoCursor<Document> wrappers = result.iterator()) {
             while (wrappers.hasNext()) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 17/27: SLING-5078 fix invalid index attribute names

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit a6c3139af84b4ed15ddbdf02ea0061c54e87ef4f
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Jan 19 15:57:39 2016 +0000

    SLING-5078 fix invalid index attribute names
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1725553 13f79535-47bb-0310-9956-ffa450edef68
---
 .../mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java    |  8 ++++----
 .../mongodb/resourceprovider/integration/IndexCreationIT.java | 11 ++++++-----
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
index 782021e..5239c5f 100644
--- a/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/mongodb/resourceprovider/impl/MongoDBNoSqlAdapter.java
@@ -67,19 +67,19 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
         
         // create index on parent path field (if it does not exist yet)
         try {
-            Document parenPathtIndex = new Document("_parentPath", 1);
+            Document parenPathtIndex = new Document(PN_PARENT_PATH, 1);
             this.collection.createIndex(parenPathtIndex);
         }
         catch (DuplicateKeyException ex) {
             // index already exists, ignore
         }
         catch (Throwable ex) {
-            log.error("Unable to create index on _parentPath: " + ex.getMessage(), ex);
+            log.error("Unable to create index on " + PN_PARENT_PATH + ": " + ex.getMessage(), ex);
         }
         
         // create unique index on path field (if it does not exist yet)
         try {
-            Document pathIndex = new Document("_path", 1);
+            Document pathIndex = new Document(PN_PATH, 1);
             IndexOptions idxOptions = new IndexOptions();
             idxOptions.unique(true);
             this.collection.createIndex(pathIndex, idxOptions);
@@ -88,7 +88,7 @@ public final class MongoDBNoSqlAdapter extends AbstractNoSqlAdapter {
             // index already exists, ignore
         }
         catch (Throwable ex) {
-            log.error("Unable to create unique index on _path: " + ex.getMessage(), ex);
+            log.error("Unable to create unique index on " + PN_PATH + ": " + ex.getMessage(), ex);
         }
     }
 
diff --git a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
index a159514..e99ec8f 100644
--- a/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
+++ b/src/test/java/org/apache/sling/nosql/mongodb/resourceprovider/integration/IndexCreationIT.java
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.nosql.mongodb.resourceprovider.integration;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import java.util.Arrays;
@@ -60,17 +61,17 @@ public class IndexCreationIT {
 	public void testIndexesPresent() {
 		assertNotNull(underTest);
 		
-		//expecting at least 3 indexes (_id, _path, _parentPath)
-		int expected = 3;
+		//expecting 2 indexes (_id, parentPath)
+		int expected = 2;
 		int actual = 0;
 		
-		final String[] expectedIndexesNames=  {"_id_", "_path_1", "_parentPath_1"};
+		final String[] expectedIndexesNames=  {"_id_", "parentPath_1"};
 		
-		for( Document d : mongoClient.getDatabase(database).getCollection(collection).listIndexes()){
+		for (Document d : mongoClient.getDatabase(database).getCollection(collection).listIndexes()){
 			assert Arrays.asList(expectedIndexesNames).contains( d.get("name") );
 			actual++;
 		}
-		assert expected == actual;
+		assertEquals(expected, actual);
 	}
 
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 23/27: [maven-release-plugin] prepare release org.apache.sling.nosql.mongodb-resourceprovider-1.1.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit d5fef3a1bacac1325ea97498bb868af35cdd4dd9
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Wed Feb 24 12:22:47 2016 +0000

    [maven-release-plugin] prepare release org.apache.sling.nosql.mongodb-resourceprovider-1.1.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732124 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 22f4403..95f0481 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.nosql.mongodb-resourceprovider</artifactId>
-    <version>1.1.0-SNAPSHOT</version>
+    <version>1.1.0</version>
     <packaging>bundle</packaging>
   
     <name>Apache Sling NoSQL MongoDB Resource Provider</name>
     <description>Resource Provider with MongoDB Persistence for Apache Sling.</description>
   
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/nosql/mongodb-resourceprovider</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.1.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.1.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.1.0</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 16/27: Switch to parent pom 26

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit c1291af2bc71ed5050282e84eea1a9f02cf94e32
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Jan 3 14:07:46 2016 +0000

    Switch to parent pom 26
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1722720 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index d3fa27f..486bae1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>25</version>
+        <version>26</version>
         <relativePath />
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 03/27: SLING-5024 add/update readme

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit 4c53655e67b5b05dd0d5aa77f8dd95c10d30345a
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Sep 14 21:31:48 2015 +0000

    SLING-5024 add/update readme
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703067 13f79535-47bb-0310-9956-ffa450edef68
---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index fc6f114..eb9f53d 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,8 @@ Sling ResourceProvider implementation that uses [MongoDB](https://www.mongodb.or
 
 Based on the "Apache Sling NoSQL Generic Resource Provider".
 
+All resource data is stored in one MongoDB database and one collection, using the path of the resource as "_id" property.
+
 
 Configuration on deployment
 ---------------------------

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-nosql-mongodb-resourceprovider] 09/27: [maven-release-plugin] prepare release org.apache.sling.nosql.mongodb-resourceprovider-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-nosql-mongodb-resourceprovider.git

commit a5e611ad82d0ace9aebcd4df909eede4c2a9c64c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Thu Sep 17 21:39:07 2015 +0000

    [maven-release-plugin] prepare release org.apache.sling.nosql.mongodb-resourceprovider-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1703710 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/pom.xml b/pom.xml
index 979e2d2..5f5bf59 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,28 +17,27 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
         <version>24</version>
-        <relativePath/>
+        <relativePath />
     </parent>
 
     <artifactId>org.apache.sling.nosql.mongodb-resourceprovider</artifactId>
-    <version>0.5.0-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>bundle</packaging>
   
     <name>Apache Sling NoSQL MongoDB Resource Provider</name>
     <description>Resource Provider with MongoDB Persistence for Apache Sling.</description>
   
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/nosql/mongodb-resourceprovider</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/nosql/mongodb-resourceprovider</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.nosql.mongodb-resourceprovider-1.0.0</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.