marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [1/3] marmotta git commit: MARMOTTA-666: extended prefix provider interface to allow pinging
Date Wed, 07 Jun 2017 09:59:59 GMT
Repository: marmotta
Updated Branches:
  refs/heads/develop 3f7588a49 -> 56981f5db


MARMOTTA-666: extended prefix provider interface to allow pinging


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/7f691913
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/7f691913
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/7f691913

Branch: refs/heads/develop
Commit: 7f691913264d03b5540314d643748baa5f7e0408
Parents: 3f7588a
Author: Sergio Fernández <wikier@apache.org>
Authored: Wed Jun 7 11:28:46 2017 +0200
Committer: Sergio Fernández <wikier@apache.org>
Committed: Wed Jun 7 11:28:46 2017 +0200

----------------------------------------------------------------------
 .../core/api/prefix/PrefixProvider.java         |  7 +++++++
 .../platform/core/services/prefix/PrefixCC.java | 21 +++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/7f691913/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/prefix/PrefixProvider.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/prefix/PrefixProvider.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/prefix/PrefixProvider.java
index d0bd578..338ede0 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/prefix/PrefixProvider.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/prefix/PrefixProvider.java
@@ -26,6 +26,13 @@ package org.apache.marmotta.platform.core.api.prefix;
 public interface PrefixProvider {
 
     /**
+     * Ccheck the connectivity with the prefix provider
+     *
+     * @return connectivity state
+     */
+    boolean ping();
+
+    /**
      * Get namespace identified by this prefix
      * 
      * @param prefix prefix

http://git-wip-us.apache.org/repos/asf/marmotta/blob/7f691913/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java
index 523c3bb..8dd0ae8 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/prefix/PrefixCC.java
@@ -17,6 +17,7 @@
  */
 package org.apache.marmotta.platform.core.services.prefix;
 
+import com.sun.org.apache.xpath.internal.operations.Bool;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.LineIterator;
 import org.apache.http.HttpEntity;
@@ -54,7 +55,25 @@ public class PrefixCC implements PrefixProvider {
     private Logger log;
 
     @Inject
-    private HttpClientService   httpClientService;
+    private HttpClientService httpClientService;
+
+    @Override
+    public boolean ping() {
+        HttpGet head = new HttpGet(URI);
+        HttpRequestUtil.setUserAgentString(head, USER_AGENT);
+        try {
+            return httpClientService.execute(head, new ResponseHandler<Boolean>() {
+
+                @Override
+                public Boolean handleResponse(HttpResponse response) {
+                    return (200 == response.getStatusLine().getStatusCode());
+                }
+            });
+        } catch (IOException e) {
+            log.error("Error pinging {}: {}", URI, e.getMessage());
+            return false;
+        }
+    }
 
     @Override
     public String getNamespace(final String prefix) {


Mime
View raw message