Updated Branches:
  refs/heads/develop e030d8805 -> 8941574ce

MARMOTTA-418: switched all modules to new LDCache API


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

Branch: refs/heads/develop
Commit: aa843450b63b029466129afb4c9a5f7eb1ec84e5
Parents: e030d88
Author: Sebastian Schaffert <[email protected]>
Authored: Fri Jan 10 18:01:11 2014 +0100
Committer: Sebastian Schaffert <[email protected]>
Committed: Fri Jan 10 18:01:11 2014 +0100

----------------------------------------------------------------------
 .../commons/sesame/model/ModelCommons.java      |  2 +-
 .../backend/kiwi/LDCachingKiWiBackendNG.java    | 69 +++++++++++++-------
 .../services/test/LDCacheKiWiNGTest.java        |  4 +-
 .../ldcache/sail/GenericLinkedDataSail.java     | 26 ++++----
 .../sail/GenericLinkedDataSailConnection.java   | 51 ++++-----------
 .../test/GenericLinkedDataSailOfflineTest.java  |  6 +-
 .../ldcache/sail/KiWiLinkedDataSail.java        | 16 ++---
 .../sail/KiWiLinkedDataSailConnection.java      | 15 ++---
 .../backend/linkeddata/LDPersistentBackend.java |  6 +-
 .../api/ldcache/LDCacheSailProvider.java        |  6 +-
 .../services/kiwi/FileLDCacheSailProvider.java  | 12 ++--
 .../services/kiwi/KiWiLDCacheSailProvider.java  |  6 +-
 12 files changed, 103 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
----------------------------------------------------------------------
diff --git 
a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
 
b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
index 6a1b338..d4bb143 100644
--- 
a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
+++ 
b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
@@ -126,7 +126,7 @@ public class ModelCommons {
      * @throws IOException
      * @throws RDFParseException
      */
-    public static <X extends Exception> void add(Model model, 
CloseableIteration<Statement,X> triples, Predicate<Statement>... filters) 
throws X {
+    public static <X extends Exception> void add(Model model, 
CloseableIteration<? extends Statement,X> triples, Predicate<Statement>... 
filters) throws X {
         try {
             rloop: while(triples.hasNext()) {
                 Statement st = triples.next();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
 
b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
index 3102caa..dd5082c 100644
--- 
a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
+++ 
b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
@@ -27,14 +27,15 @@ import 
org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersist
 import org.apache.marmotta.ldcache.model.CacheEntry;
 import org.openrdf.model.Model;
 import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
 import org.openrdf.model.URI;
 import org.openrdf.model.impl.TreeModel;
 import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
 import org.openrdf.repository.base.RepositoryWrapper;
 import org.openrdf.repository.sail.SailRepository;
 import org.openrdf.sail.Sail;
+import org.openrdf.sail.SailConnection;
+import org.openrdf.sail.SailException;
 import org.openrdf.sail.helpers.SailWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,7 +65,7 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
     /**
      * Repository API access to the cache data
      */
-    protected Repository repository;
+    protected KiWiStore store;
 
 
     /**
@@ -75,7 +76,19 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
      */
     public LDCachingKiWiBackendNG(Repository repository, String cacheContext) {
         this.cacheContext = cacheContext;
-        this.repository   = repository;
+        this.store   = getStore(repository);
+        this.persistence  = new 
LDCachingKiWiPersistence(getStore(repository).getPersistence());
+    }
+
+    /**
+     * Create a new LDCache KiWi backend using the given store and context for 
caching triples and storing cache
+     * metadata via JDBC in the database.
+     *
+     * @param cacheContext
+     */
+    public LDCachingKiWiBackendNG(Sail repository, String cacheContext) {
+        this.cacheContext = cacheContext;
+        this.store   = getStore(repository);
         this.persistence  = new 
LDCachingKiWiPersistence(getStore(repository).getPersistence());
     }
 
@@ -124,16 +137,16 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
 
                 // if entry exists, load triples for the resource from the 
cache context of the repository
                 if(ce != null) {
-                    RepositoryConnection con = repository.getConnection();
+                    SailConnection con = store.getConnection();
                     try {
                         con.begin();
 
                         Model triples = new TreeModel();
-                        
ModelCommons.add(triples,con.getStatements(resource,null,null,true,con.getValueFactory().createURI(cacheContext)));
+                        
ModelCommons.add(triples,con.getStatements(resource,null,null,true,store.getValueFactory().createURI(cacheContext)));
                         ce.setTriples(triples);
 
                         con.commit();
-                    } catch(RepositoryException ex) {
+                    } catch(SailException ex) {
                         con.rollback();
                     } finally {
                         con.close();
@@ -143,7 +156,7 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
 
             }
 
-        } catch (RepositoryException | SQLException e) {
+        } catch (SailException | SQLException e) {
             log.error("could not retrieve cached triples from repository",e);
         }
 
@@ -165,19 +178,21 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
                 dbcon.removeCacheEntry(resource.stringValue());
 
                 // update triples in cache
-                RepositoryConnection con = repository.getConnection();
+                SailConnection con = store.getConnection();
                 try {
                     con.begin();
 
-                    
con.remove(resource,null,null,con.getValueFactory().createURI(cacheContext));
-                    
con.add(entry.getTriples(),con.getValueFactory().createURI(cacheContext));
+                    con.removeStatements(resource, null, null, 
store.getValueFactory().createURI(cacheContext));
+                    for(Statement stmt : entry.getTriples()) {
+                        con.addStatement(stmt.getSubject(), 
stmt.getPredicate(), stmt.getObject(), 
store.getValueFactory().createURI(cacheContext));
+                    }
 
                     con.commit();
 
-                    
entry.setResource(con.getValueFactory().createURI(resource.stringValue()));
+                    
entry.setResource(store.getValueFactory().createURI(resource.stringValue()));
 
                     dbcon.storeCacheEntry(entry);
-                } catch(RepositoryException ex) {
+                } catch(SailException ex) {
                     con.rollback();
                 } finally {
                     con.close();
@@ -185,7 +200,7 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
 
             }
 
-        } catch (RepositoryException | SQLException e) {
+        } catch (SailException | SQLException e) {
             log.error("could not retrieve cached triples from repository",e);
         }
 
@@ -205,14 +220,14 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
                 dbcon.removeCacheEntry(resource.stringValue());
 
                 // update triples in cache
-                RepositoryConnection con = repository.getConnection();
+                SailConnection con = store.getConnection();
                 try {
                     con.begin();
 
-                    con.remove(resource, null, null, 
con.getValueFactory().createURI(cacheContext));
+                    con.removeStatements(resource, null, null, 
store.getValueFactory().createURI(cacheContext));
 
                     con.commit();
-                } catch(RepositoryException ex) {
+                } catch(SailException ex) {
                     con.rollback();
                 } finally {
                     con.close();
@@ -220,8 +235,8 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
 
             }
 
-        } catch (RepositoryException | SQLException e) {
-            log.error("could not retrieve cached triples from repository",e);
+        } catch (SailException | SQLException e) {
+            log.error("could not remove cached triples from repository",e);
         }
     }
 
@@ -240,14 +255,14 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
                 }
 
                 // update triples in cache
-                RepositoryConnection con = repository.getConnection();
+                SailConnection con = store.getConnection();
                 try {
                     con.begin();
 
-                    
con.remove((Resource)null,null,null,con.getValueFactory().createURI(cacheContext));
+                    con.removeStatements((Resource) null, null, null, 
store.getValueFactory().createURI(cacheContext));
 
                     con.commit();
-                } catch(RepositoryException ex) {
+                } catch(SailException ex) {
                     con.rollback();
                 } finally {
                     con.close();
@@ -255,8 +270,8 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
 
             }
 
-        } catch (RepositoryException | SQLException e) {
-            log.error("could not retrieve cached triples from repository",e);
+        } catch (SailException | SQLException e) {
+            log.error("could not remove cached triples from repository",e);
         }
 
     }
@@ -273,7 +288,7 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
         }
 
         // register cache context in database
-        repository.getValueFactory().createURI(cacheContext);
+        store.getValueFactory().createURI(cacheContext);
 
     }
 
@@ -283,4 +298,8 @@ public class LDCachingKiWiBackendNG implements 
LDCachingBackendNG {
     @Override
     public void shutdown() {
     }
+
+    public LDCachingKiWiPersistence getPersistence() {
+        return persistence;
+    }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
 
b/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
index a67587f..4b822bc 100644
--- 
a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
+++ 
b/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
@@ -129,7 +129,7 @@ public class LDCacheKiWiNGTest extends BaseLDCacheNGTest {
     protected LDCachingBackendNG createBackend() {
         try {
             KiWiStore store = new 
KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, 
"http://localhost/context/default";, "http://localhost/context/inferred";);
-            Repository repository = new SailRepository(store);
+            final Repository repository = new SailRepository(store);
             repository.initialize();
 
             LDCachingKiWiBackendNG backend = new 
LDCachingKiWiBackendNG(repository, CACHE_CONTEXT) {
@@ -141,7 +141,7 @@ public class LDCacheKiWiNGTest extends BaseLDCacheNGTest {
 
                     try {
                         persistence.dropDatabase();
-                        getStore(repository).getPersistence().dropDatabase();
+                        store.getPersistence().dropDatabase();
 
                         super.shutdown();
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
 
b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
index f41879c..c4936bc 100644
--- 
a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
+++ 
b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
@@ -19,9 +19,9 @@ package org.apache.marmotta.ldcache.sail;
 
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.api.LDCachingBackend;
+import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
 import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.openrdf.model.Resource;
 import org.openrdf.sail.NotifyingSail;
@@ -37,32 +37,32 @@ import org.openrdf.sail.helpers.NotifyingSailWrapper;
  */
 public class GenericLinkedDataSail extends NotifyingSailWrapper {
 
-       private final LDCachingBackend cachingBackend;
+       private final LDCachingBackendNG cachingBackend;
        private CacheConfiguration config;
-       private LDCache ldcache;
+       private LDCacheNG ldcache;
        private SesameFilter<Resource> acceptForCaching;
 
-       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend 
cachingBackend) {
+       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG 
cachingBackend) {
                this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), 
createCacheConfiguration(null));
        }
 
-       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend 
cachingBackend, ClientConfiguration clientConfig) {
+       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG 
cachingBackend, ClientConfiguration clientConfig) {
                this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), 
clientConfig);
        }
 
-       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend 
cachingBackend, CacheConfiguration cacheConfig) {
+       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG 
cachingBackend, CacheConfiguration cacheConfig) {
                this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), 
cacheConfig);
        }
        
-       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend 
cachingBackend, SesameFilter<Resource> acceptForCaching) {
+       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG 
cachingBackend, SesameFilter<Resource> acceptForCaching) {
                this(base, cachingBackend, acceptForCaching, 
createCacheConfiguration(null));
        }
 
-       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend 
cachingBackend, SesameFilter<Resource> acceptForCaching, ClientConfiguration 
clientConfig) {
+       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG 
cachingBackend, SesameFilter<Resource> acceptForCaching, ClientConfiguration 
clientConfig) {
                this(base, cachingBackend, acceptForCaching, 
createCacheConfiguration(clientConfig));
        }
 
-       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend 
cachingBackend, SesameFilter<Resource> acceptForCaching, CacheConfiguration 
cacheConfig) {
+       public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG 
cachingBackend, SesameFilter<Resource> acceptForCaching, CacheConfiguration 
cacheConfig) {
                super(base);
                this.cachingBackend = cachingBackend;
                this.acceptForCaching = acceptForCaching;
@@ -88,7 +88,7 @@ public class GenericLinkedDataSail extends 
NotifyingSailWrapper {
                
                cachingBackend.initialize();
                
-               ldcache = new LDCache(this.config,cachingBackend);
+               ldcache = new LDCacheNG(this.config,cachingBackend);
        }
        
        @Override
@@ -102,14 +102,14 @@ public class GenericLinkedDataSail extends 
NotifyingSailWrapper {
        
        public void reinit() {
                ldcache.shutdown();
-               ldcache = new LDCache(this.config,cachingBackend);
+               ldcache = new LDCacheNG(this.config,cachingBackend);
        }
        
        public CacheConfiguration getCacheConfiguration() {
                return config;
        }
 
-    public LDCache getLDCache() {
+    public LDCacheNG getLDCache() {
         return ldcache;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
 
b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
index b67977e..3eb996a 100644
--- 
a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
+++ 
b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
@@ -18,19 +18,13 @@
 package org.apache.marmotta.ldcache.sail;
 
 import info.aduna.iteration.CloseableIteration;
-
-import info.aduna.iteration.ExceptionConvertingIteration;
+import info.aduna.iteration.CloseableIteratorIteration;
 import info.aduna.iteration.UnionIteration;
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.commons.sesame.repository.ResourceUtils;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.services.LDCache;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.repository.RepositoryException;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.openrdf.model.*;
 import org.openrdf.sail.NotifyingSailConnection;
 import org.openrdf.sail.SailException;
 import org.openrdf.sail.helpers.NotifyingSailConnectionWrapper;
@@ -49,15 +43,15 @@ public class GenericLinkedDataSailConnection extends 
NotifyingSailConnectionWrap
 
     private static Logger log = 
LoggerFactory.getLogger(GenericLinkedDataSailConnection.class);
 
-    private final LDCache ldcache;
+    private final LDCacheNG ldcache;
     private final SesameFilter<Resource> acceptForCaching;
 
-    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, 
LDCache ldcache) {
+    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, 
LDCacheNG ldcache) {
         this(connection, ldcache, new AlwaysTrueFilter<Resource>());
     }
 
 
-    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, 
LDCache ldcache, SesameFilter<Resource> acceptForCaching) {
+    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, 
LDCacheNG ldcache, SesameFilter<Resource> acceptForCaching) {
         super(connection);
         this.ldcache = ldcache;
         this.acceptForCaching = acceptForCaching;
@@ -81,34 +75,13 @@ public class GenericLinkedDataSailConnection extends 
NotifyingSailConnectionWrap
 
         if (accept(subj)) {
             log.debug("Refreshing resource: {}", subj.stringValue());
-            ldcache.refreshResource((URI) subj, false);
-
-            try {
-                final LDCachingConnection cachingConnection = 
ldcache.getCacheConnection(subj.stringValue());
-                // join the results of the cache connection and the wrapped 
connection in a single result
-                return new UnionIteration<Statement, SailException>(
-                        new ExceptionConvertingIteration<Statement, 
SailException>(cachingConnection.getStatements(subj,pred,obj,includeInferred, 
contexts)) {
-                            @Override
-                            protected SailException convert(Exception e) {
-                                return new SailException("error while 
accessing cache connection",e);
-                            }
-
-                            @Override
-                            protected void handleClose() throws SailException {
-                                super.handleClose();
+            final Model cached = ldcache.get((URI)subj);
 
-                                try {
-                                    cachingConnection.close();
-                                } catch (RepositoryException e) {
-                                    throw new SailException("error while 
closing cache connection",e);
-                                }
-                            }
-                        },
-                        super.getStatements(subj, pred, obj, includeInferred, 
contexts)
-                );
-            } catch (RepositoryException e) {
-                throw new SailException("error while accessing cache 
connection",e);
-            }
+            // join the results of the cache connection and the wrapped 
connection in a single result
+            return new UnionIteration<Statement, SailException>(
+                    new 
CloseableIteratorIteration<Statement,SailException>(cached.iterator()),
+                    super.getStatements(subj, pred, obj, includeInferred, 
contexts)
+            );
         } else {
             return super.getStatements(subj, pred, obj, includeInferred, 
contexts);
         }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
 
b/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
index 0d4ef57..4bff0ac 100644
--- 
a/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
+++ 
b/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
@@ -21,7 +21,7 @@ import info.aduna.iteration.Iterations;
 import org.apache.commons.io.FileUtils;
 import org.apache.marmotta.commons.sesame.filter.resource.ResourceFilter;
 import org.apache.marmotta.commons.sesame.filter.resource.UriPrefixFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
 import org.apache.marmotta.ldcache.services.test.dummy.DummyEndpoint;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
@@ -60,7 +60,7 @@ public class GenericLinkedDataSailOfflineTest {
 
     private Repository repository;
 
-    private LDCachingFileBackend backend;
+    private LDCachingFileBackendNG backend;
 
     private GenericLinkedDataSail lsail;
 
@@ -76,7 +76,7 @@ public class GenericLinkedDataSailOfflineTest {
 
         tmpDirectory = Files.createTempDir();
 
-        backend = new LDCachingFileBackend(tmpDirectory);
+        backend = new LDCachingFileBackendNG(tmpDirectory);
         lsail = new GenericLinkedDataSail(new MemoryStore(),backend, 
cacheFilter, config);
         repository = new SailRepository(lsail);
         repository.initialize();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
 
b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
index 70a0625..a571234 100644
--- 
a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
+++ 
b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
@@ -19,9 +19,9 @@ package org.apache.marmotta.ldcache.sail;
 
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackend;
+import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackendNG;
 import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.openrdf.model.Resource;
 import org.openrdf.sail.NotifyingSail;
@@ -39,9 +39,9 @@ public class KiWiLinkedDataSail extends NotifyingSailWrapper {
 
     private KiWiStore store;
 
-    private LDCachingKiWiBackend backend;
+    private LDCachingKiWiBackendNG backend;
 
-    private LDCache ldcache;
+    private LDCacheNG ldcache;
 
     private SesameFilter<Resource> acceptor;
 
@@ -88,10 +88,10 @@ public class KiWiLinkedDataSail extends 
NotifyingSailWrapper {
     public void initialize() throws SailException {
         super.initialize();
 
-        backend = new LDCachingKiWiBackend(store, cache_context);
+        backend = new LDCachingKiWiBackendNG(store, cache_context);
         backend.initialize();
 
-        ldcache = new LDCache(config,backend);
+        ldcache = new LDCacheNG(config,backend);
 
     }
 
@@ -126,11 +126,11 @@ public class KiWiLinkedDataSail extends 
NotifyingSailWrapper {
         }
     }
 
-    public LDCachingKiWiBackend getBackend() {
+    public LDCachingKiWiBackendNG getBackend() {
         return backend;
     }
 
-    public LDCache getLDCache() {
+    public LDCacheNG getLDCache() {
         return ldcache;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
 
b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
index d9141b3..36dae58 100644
--- 
a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
+++ 
b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
@@ -18,14 +18,9 @@
 package org.apache.marmotta.ldcache.sail;
 
 import info.aduna.iteration.CloseableIteration;
-
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.services.LDCache;
-import org.openrdf.model.BNode;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.openrdf.model.*;
 import org.openrdf.sail.NotifyingSailConnection;
 import org.openrdf.sail.SailException;
 import org.openrdf.sail.helpers.NotifyingSailConnectionWrapper;
@@ -37,11 +32,11 @@ import 
org.openrdf.sail.helpers.NotifyingSailConnectionWrapper;
  */
 public class KiWiLinkedDataSailConnection extends 
NotifyingSailConnectionWrapper {
 
-    private LDCache ldcache;
+    private LDCacheNG ldcache;
 
     private SesameFilter<Resource> acceptor;
 
-    public KiWiLinkedDataSailConnection(NotifyingSailConnection wrappedCon, 
LDCache ldcache, SesameFilter<Resource> acceptor) {
+    public KiWiLinkedDataSailConnection(NotifyingSailConnection wrappedCon, 
LDCacheNG ldcache, SesameFilter<Resource> acceptor) {
         super(wrappedCon);
 
         this.ldcache = ldcache;
@@ -59,7 +54,7 @@ public class KiWiLinkedDataSailConnection extends 
NotifyingSailConnectionWrapper
     @Override
     public CloseableIteration<? extends Statement, SailException> 
getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, 
Resource... contexts) throws SailException {
         if(subj != null && isAcceptable(subj)) {
-            ldcache.refreshResource((URI)subj,false);
+            ldcache.refresh((URI) subj);
         }
 
         // the refreshed resources will anyways be stored in the same triple 
store, so we can simply delegate the query

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
 
b/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
index 1e56703..a7d2067 100644
--- 
a/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
+++ 
b/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
@@ -19,7 +19,7 @@ package org.apache.marmotta.ldpath.backend.linkeddata;
 
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.apache.marmotta.ldpath.backend.sesame.SesameRepositoryBackend;
@@ -43,7 +43,7 @@ import java.io.IOException;
 public class LDPersistentBackend extends SesameRepositoryBackend {
     private static final Logger log = 
LoggerFactory.getLogger(LDPersistentBackend.class);
 
-    private LDCachingFileBackend backend;
+    private LDCachingFileBackendNG backend;
 
     private GenericLinkedDataSail sail;
 
@@ -72,7 +72,7 @@ public class LDPersistentBackend extends 
SesameRepositoryBackend {
         try {
             ClientConfiguration config = new ClientConfiguration();
 
-            backend = new LDCachingFileBackend(dataDirectory);
+            backend = new LDCachingFileBackendNG(dataDirectory);
             sail = new GenericLinkedDataSail(new MemoryStore(),backend, 
cacheFilter, config);
             Repository repository = new SailRepository(sail);
             repository.initialize();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
----------------------------------------------------------------------
diff --git 
a/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
 
b/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
index 2cc597d..f99a23e 100644
--- 
a/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
+++ 
b/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
@@ -17,7 +17,7 @@
 
 package org.apache.marmotta.platform.ldcache.api.ldcache;
 
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
@@ -79,7 +79,7 @@ public abstract class LDCacheSailProvider implements 
NotifyingSailProvider {
      * @return
      */
     public boolean isCached(URI resource) throws RepositoryException {
-        return getLDCache().isCached(resource.stringValue());
+        return getLDCache().contains(resource);
     }
 
     /**
@@ -155,7 +155,7 @@ public abstract class LDCacheSailProvider implements 
NotifyingSailProvider {
      * Return the caching backend used by the caching system (e.g. for 
debugging)
      * @return
      */
-    public abstract LDCache getLDCache();
+    public abstract LDCacheNG getLDCache();
 
     /**
      * Add a volatile (in-memory) endpoint to the LDClient configuration. Can 
be used by other services for auto-registering

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
----------------------------------------------------------------------
diff --git 
a/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
 
b/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
index 394a4a2..b71ac41 100644
--- 
a/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
+++ 
b/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
@@ -20,9 +20,9 @@ import com.google.common.collect.Lists;
 import org.apache.marmotta.commons.sesame.filter.NotFilter;
 import org.apache.marmotta.commons.sesame.filter.OneOfFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.platform.core.model.filter.MarmottaLocalFilter;
 import org.apache.marmotta.platform.ldcache.api.ldcache.LDCacheSailProvider;
@@ -51,7 +51,7 @@ public class FileLDCacheSailProvider extends 
LDCacheSailProvider {
 
     private static Logger log = 
LoggerFactory.getLogger(FileLDCacheSailProvider.class);
 
-    private LDCachingFileBackend backend;
+    private LDCachingFileBackendNG backend;
 
     private GenericLinkedDataSail sail;
 
@@ -87,7 +87,7 @@ public class FileLDCacheSailProvider extends 
LDCacheSailProvider {
         directory = new File(configurationService.getHome() + File.separator + 
"ldcache");
 
         try {
-            backend = new LDCachingFileBackend(directory);
+            backend = new LDCachingFileBackendNG(directory);
             sail = new GenericLinkedDataSail(parent, backend, new 
NotFilter<Resource>(cacheFilters), ldclientConfig);
             return sail;
         } catch (RepositoryException e) {
@@ -103,7 +103,7 @@ public class FileLDCacheSailProvider extends 
LDCacheSailProvider {
      */
     public LDClientService getLDClient() {
         if(sail != null) {
-            return sail.getLDCache().getLDClient();
+            return sail.getLDCache().getClient();
         } else {
             return null;
         }
@@ -113,7 +113,7 @@ public class FileLDCacheSailProvider extends 
LDCacheSailProvider {
      * Return the caching backend used by the caching system (e.g. for 
debugging)
      * @return
      */
-    public LDCache getLDCache() {
+    public LDCacheNG getLDCache() {
         if(sail != null) {
             return sail.getLDCache();
         } else {

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
----------------------------------------------------------------------
diff --git 
a/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
 
b/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
index e97737d..cb8f328 100644
--- 
a/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
+++ 
b/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
@@ -22,7 +22,7 @@ import org.apache.marmotta.commons.sesame.filter.NotFilter;
 import org.apache.marmotta.commons.sesame.filter.OneOfFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.ldcache.sail.KiWiLinkedDataSail;
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.platform.core.model.filter.MarmottaLocalFilter;
 import org.apache.marmotta.platform.ldcache.api.ldcache.LDCacheSailProvider;
@@ -85,7 +85,7 @@ public class KiWiLDCacheSailProvider extends 
LDCacheSailProvider {
      */
     public LDClientService getLDClient() {
         if(sail != null) {
-            return sail.getLDCache().getLDClient();
+            return sail.getLDCache().getClient();
         } else {
             return null;
         }
@@ -95,7 +95,7 @@ public class KiWiLDCacheSailProvider extends 
LDCacheSailProvider {
      * Return the caching backend used by the caching system (e.g. for 
debugging)
      * @return
      */
-    public LDCache getLDCache() {
+    public LDCacheNG getLDCache() {
         if(sail != null) {
             return sail.getLDCache();
         } else {

Reply via email to