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/11/07 09:56:34 UTC

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

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

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

commit f41a21e24e2ee607bd3993be9f43055b28e994f3
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/contrib/nosql/mongodb-resourceprovider@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>.