fixed a misbehaviour in isCached in LDCache: it will now also return false in 
case there are no cached triples


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

Branch: refs/heads/develop
Commit: c7cb76dfce4395e1afe09e5e3fbab57155f20bdb
Parents: f2513c2
Author: Sebastian Schaffert <[email protected]>
Authored: Thu May 23 10:55:48 2013 +0200
Committer: Sebastian Schaffert <[email protected]>
Committed: Thu May 23 10:55:48 2013 +0200

----------------------------------------------------------------------
 .../apache/marmotta/ldcache/services/LDCache.java  |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c7cb76df/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
 
b/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
index c137f2a..8d78aa6 100644
--- 
a/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
+++ 
b/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
@@ -136,7 +136,20 @@ public class LDCache implements LDCachingService {
      * @throws RepositoryException
      */
     public boolean isCached(String resourceUri) throws RepositoryException {
-        return backend.isCached(resourceUri);
+        // if there is no cache entry, then return false in any case
+        if(!backend.isCached(resourceUri)) {
+            return false;
+        } else {
+            // else list all cached triples - if there are none, the resource 
is not cached (e.g. blacklist or no LD resource)
+            RepositoryConnection con = backend.getCacheConnection(resourceUri);
+            try {
+                con.begin();
+                return 
con.hasStatement(con.getValueFactory().createURI(resourceUri), null, null, 
false);
+            } finally {
+                con.commit();
+                con.close();
+            }
+        }
     }
 
     /**

Reply via email to