sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-nosql-generic] 04/18: SLING-5437 The NoSQL providers should throw LoginException if the connection to the NoSQL database can't be established (patch provided by Robert Munteanu)
Date Tue, 07 Nov 2017 09:56:31 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 2c43a9f46db4fc5c893bbe31c39c023b2fea8be5
Author: Stefan Seifert <sseifert@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/generic@1725565
13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/nosql/generic/adapter/AbstractNoSqlAdapter.java     |  7 +++++++
 .../nosql/generic/adapter/MetricsNoSqlAdapterWrapper.java     |  6 ++++++
 .../org/apache/sling/nosql/generic/adapter/NoSqlAdapter.java  | 11 ++++++++++-
 .../org/apache/sling/nosql/generic/adapter/package-info.java  |  2 +-
 .../resource/AbstractNoSqlResourceProviderFactory.java        |  4 +++-
 .../generic/resource/impl/ValueMapConvertingNoSqlAdapter.java |  6 ++++++
 .../nosql/generic/simple/provider/SimpleNoSqlAdapter.java     |  6 ++++++
 7 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/sling/nosql/generic/adapter/AbstractNoSqlAdapter.java
b/src/main/java/org/apache/sling/nosql/generic/adapter/AbstractNoSqlAdapter.java
index 38eff2b..d8672e6 100644
--- a/src/main/java/org/apache/sling/nosql/generic/adapter/AbstractNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/generic/adapter/AbstractNoSqlAdapter.java
@@ -20,6 +20,8 @@ package org.apache.sling.nosql.generic.adapter;
 
 import java.util.Iterator;
 
+import org.apache.sling.api.resource.LoginException;
+
 import aQute.bnd.annotation.ConsumerType;
 
 /**
@@ -40,4 +42,9 @@ public abstract class AbstractNoSqlAdapter implements NoSqlAdapter {
         return null;
     }
     
+    @Override
+    public void checkConnection() throws LoginException {
+        // not supported unless it is overwritten explicitly
+    }
+
 }
diff --git a/src/main/java/org/apache/sling/nosql/generic/adapter/MetricsNoSqlAdapterWrapper.java
b/src/main/java/org/apache/sling/nosql/generic/adapter/MetricsNoSqlAdapterWrapper.java
index dfcf7a7..68a8381 100644
--- a/src/main/java/org/apache/sling/nosql/generic/adapter/MetricsNoSqlAdapterWrapper.java
+++ b/src/main/java/org/apache/sling/nosql/generic/adapter/MetricsNoSqlAdapterWrapper.java
@@ -20,6 +20,7 @@ package org.apache.sling.nosql.generic.adapter;
 
 import java.util.Iterator;
 
+import org.apache.sling.api.resource.LoginException;
 import org.slf4j.Logger;
 
 /**
@@ -89,6 +90,11 @@ public final class MetricsNoSqlAdapterWrapper implements NoSqlAdapter {
         }
     }
     
+    @Override
+    public void checkConnection() throws LoginException {
+        delegate.checkConnection();
+    }
+
     private class Metrics {
         
         private long startTime;
diff --git a/src/main/java/org/apache/sling/nosql/generic/adapter/NoSqlAdapter.java b/src/main/java/org/apache/sling/nosql/generic/adapter/NoSqlAdapter.java
index ab3d823..d86cd29 100644
--- a/src/main/java/org/apache/sling/nosql/generic/adapter/NoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/generic/adapter/NoSqlAdapter.java
@@ -20,6 +20,8 @@ package org.apache.sling.nosql.generic.adapter;
 
 import java.util.Iterator;
 
+import org.apache.sling.api.resource.LoginException;
+
 import aQute.bnd.annotation.ConsumerType;
 
 /**
@@ -73,5 +75,12 @@ public interface NoSqlAdapter {
      * @return Query result or null if query not supported
      */
     Iterator<NoSqlData> query(String query, String language);
-        
+
+    /**
+     * Checks whether the connection to the NoSQL database is possible
+     *
+     * @throws LoginException in case of any errors
+     */
+    void checkConnection() throws LoginException;
+
 }
diff --git a/src/main/java/org/apache/sling/nosql/generic/adapter/package-info.java b/src/main/java/org/apache/sling/nosql/generic/adapter/package-info.java
index aed682e..88474a2 100644
--- a/src/main/java/org/apache/sling/nosql/generic/adapter/package-info.java
+++ b/src/main/java/org/apache/sling/nosql/generic/adapter/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Adapter for NoSQL resource provider implementation.
  */
-@aQute.bnd.annotation.Version("1.0.0")
+@aQute.bnd.annotation.Version("2.0.0")
 package org.apache.sling.nosql.generic.adapter;
diff --git a/src/main/java/org/apache/sling/nosql/generic/resource/AbstractNoSqlResourceProviderFactory.java
b/src/main/java/org/apache/sling/nosql/generic/resource/AbstractNoSqlResourceProviderFactory.java
index 2e56b2b..c1e7811 100644
--- a/src/main/java/org/apache/sling/nosql/generic/resource/AbstractNoSqlResourceProviderFactory.java
+++ b/src/main/java/org/apache/sling/nosql/generic/resource/AbstractNoSqlResourceProviderFactory.java
@@ -37,7 +37,9 @@ import aQute.bnd.annotation.ConsumerType;
 public abstract class AbstractNoSqlResourceProviderFactory implements ResourceProviderFactory
{
 
     public final ResourceProvider getResourceProvider(Map<String, Object> authenticationInfo)
throws LoginException {
-        return new NoSqlResourceProvider(getNoSqlAdapter(), getEventAdmin());
+        NoSqlAdapter adapter = getNoSqlAdapter();
+        adapter.checkConnection();
+        return new NoSqlResourceProvider(adapter, getEventAdmin());
     }
 
     public final ResourceProvider getAdministrativeResourceProvider(Map<String, Object>
authenticationInfo) throws LoginException {
diff --git a/src/main/java/org/apache/sling/nosql/generic/resource/impl/ValueMapConvertingNoSqlAdapter.java
b/src/main/java/org/apache/sling/nosql/generic/resource/impl/ValueMapConvertingNoSqlAdapter.java
index 62974f0..52ef419 100644
--- a/src/main/java/org/apache/sling/nosql/generic/resource/impl/ValueMapConvertingNoSqlAdapter.java
+++ b/src/main/java/org/apache/sling/nosql/generic/resource/impl/ValueMapConvertingNoSqlAdapter.java
@@ -30,6 +30,7 @@ import java.util.Map;
 
 import javax.xml.bind.DatatypeConverter;
 
+import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.nosql.generic.adapter.NoSqlAdapter;
 import org.apache.sling.nosql.generic.adapter.NoSqlData;
 import org.slf4j.Logger;
@@ -163,6 +164,11 @@ class ValueMapConvertingNoSqlAdapter implements NoSqlAdapter {
         return new NoSqlData(data.getPath(), deserializedMap);
     }
     
+    @Override
+    public void checkConnection() throws LoginException {
+        delegate.checkConnection();
+    }
+
     private static DateFormat getISO8601Format() {
         return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US);
     }
diff --git a/src/test/java/org/apache/sling/nosql/generic/simple/provider/SimpleNoSqlAdapter.java
b/src/test/java/org/apache/sling/nosql/generic/simple/provider/SimpleNoSqlAdapter.java
index f1743ff..6702e1a 100644
--- a/src/test/java/org/apache/sling/nosql/generic/simple/provider/SimpleNoSqlAdapter.java
+++ b/src/test/java/org/apache/sling/nosql/generic/simple/provider/SimpleNoSqlAdapter.java
@@ -28,6 +28,7 @@ import java.util.TreeMap;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.nosql.generic.adapter.NoSqlAdapter;
 import org.apache.sling.nosql.generic.adapter.NoSqlData;
 import org.apache.sling.nosql.generic.resource.impl.PathUtil;
@@ -114,4 +115,9 @@ public class SimpleNoSqlAdapter implements NoSqlAdapter {
         return Collections.<NoSqlData>emptyList().iterator();
     }
 
+    @Override
+    public void checkConnection() throws LoginException {
+
+    }
+
 }

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

Mime
View raw message