You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/10/24 17:09:27 UTC

[06/30] git commit: remove KiWi dependencies from marmotta-core

remove KiWi dependencies from marmotta-core


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

Branch: refs/heads/MARMOTTA-345
Commit: 8fdc14987815c153c40a18794e81862ea64c3bc3
Parents: 8756395
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Mon Oct 21 12:06:02 2013 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Mon Oct 21 12:06:02 2013 +0200

----------------------------------------------------------------------
 .../commons/sesame/model/StatementCommons.java  |   1 +
 .../sesame/repository/ResourceUtils.java        | 120 ++++++++++++++++++-
 platform/marmotta-core/pom.xml                  |  38 +++---
 .../platform/core/api/user/UserToken.java       |  10 +-
 .../platform/core/rio/RDFHtmlWriterImpl.java    |   6 +-
 .../content/FileSystemContentReader.java        |  33 ++---
 .../content/FileSystemContentWriter.java        |  18 +--
 .../services/content/HTTPContentReader.java     |  36 +++---
 .../core/services/sesame/KiWiSesameUtil.java    |  63 ----------
 .../sesame/ResourceSubjectMetadata.java         |   6 +-
 .../resource/InspectionWebService.java          |  44 ++-----
 .../webservices/resource/MetaWebService.java    |   3 +-
 .../resource/ResourceWebService.java            |   3 +-
 .../core/test/base/TestStoreProvider.java       |   9 ++
 14 files changed, 202 insertions(+), 188 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/StatementCommons.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/StatementCommons.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/StatementCommons.java
index 0d9f2b0..194732c 100644
--- a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/StatementCommons.java
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/StatementCommons.java
@@ -187,4 +187,5 @@ public class StatementCommons {
             }
         };
     }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java
index 1484df2..3f79ea4 100644
--- a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java
@@ -21,7 +21,6 @@ import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Iterators;
-
 import org.apache.marmotta.commons.sesame.model.Namespaces;
 import org.openrdf.model.*;
 import org.openrdf.repository.RepositoryConnection;
@@ -33,6 +32,8 @@ import org.openrdf.sail.helpers.SailConnectionWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.*;
 
 /**
@@ -1368,4 +1369,121 @@ public class ResourceUtils {
         }
     }
 
+
+    /**
+     * Return the creation date of the resource if this information is available. Otherwise returns null. At the
+     * moment only supports KiWi resources (through reflection)
+     *
+     * @param resource
+     * @return
+     * @throws RepositoryConnection
+     */
+    public static Date getCreated(RepositoryConnection conn, Resource resource) {
+        try {
+            Method m = resource.getClass().getMethod("getCreated", new Class[0]);
+            return (Date)m.invoke(resource);
+        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassCastException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Get the last modification of the set of triples passed as argument.
+     *
+     * @return date
+     * @throws org.openrdf.repository.RepositoryException
+     */
+    public static Date getLastModified(RepositoryConnection conn, Resource resource) throws RepositoryException {
+        Date last_modified = new Date(0);
+        RepositoryResult<Statement> triples = conn.getStatements(resource, null, null, false);
+        try {
+            while (triples.hasNext()) {
+                Statement triple = triples.next();
+
+                try {
+                    Method m = triple.getClass().getMethod("getCreated", new Class[0]);
+                    Date created = (Date)m.invoke(triple);
+                    if (created.getTime() > last_modified.getTime()) {
+                        last_modified = created;
+                    }
+                } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassCastException e) {
+                    // do nothing
+                }
+            }
+        } finally {
+            triples.close();
+        }
+        return last_modified;
+    }
+
+
+    /**
+     * Return true in case the statement passed as argument is an inferred statement. Since this method does not
+     * have access to the repository it can only use properties of the statement to figure out if it is inferred.
+     * @param stmt
+     * @return
+     * @throws RepositoryConnection
+     */
+    public static boolean isInferred(Statement stmt)  {
+        try {
+            Method m = stmt.getClass().getMethod("isInferred", new Class[0]);
+            return (Boolean)m.invoke(stmt);
+        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassCastException e) {
+            return false;
+        }
+
+    }
+
+
+    /**
+     * Return true in case the statement passed as argument is an inferred statement. Depending on the concrete
+     * implementation of the statement uses different approaches to figure out if it is inferred or not.
+     * @param conn
+     * @param stmt
+     * @return
+     * @throws RepositoryConnection
+     */
+    public static boolean isInferred(RepositoryConnection conn, Statement stmt) throws RepositoryException {
+        try {
+            Method m = stmt.getClass().getMethod("isInferred", new Class[0]);
+            return (Boolean)m.invoke(stmt);
+        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassCastException e) {
+            boolean is_base = conn.hasStatement(stmt,false);
+            boolean exists  = conn.hasStatement(stmt,true);
+
+            return !is_base && exists;
+        }
+
+    }
+
+
+    /**
+     * Return true in case the statement passed as argument is a deleted statement. Depending on the concrete
+     * implementation of the statement uses different approaches to figure out if it is deleted or not.
+     * @param conn
+     * @param stmt
+     * @return
+     * @throws RepositoryConnection
+     */
+    public static boolean isDeleted(RepositoryConnection conn, Statement stmt) throws RepositoryException {
+        try {
+            Method m = stmt.getClass().getMethod("isDeleted", new Class[0]);
+            return (Boolean)m.invoke(stmt);
+        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassCastException e) {
+            boolean exists  = conn.hasStatement(stmt,true);
+
+            return !exists;
+        }
+
+    }
+
+    public static long getId(Statement stmt) {
+        try {
+            Method m = stmt.getClass().getMethod("getId", new Class[0]);
+            return (Long)m.invoke(stmt);
+        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassCastException e) {
+            return 0L;
+        }
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/pom.xml
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/pom.xml b/platform/marmotta-core/pom.xml
index 780359d..d435294 100644
--- a/platform/marmotta-core/pom.xml
+++ b/platform/marmotta-core/pom.xml
@@ -381,14 +381,6 @@
             <artifactId>h2</artifactId>
             <scope>test</scope>
         </dependency>
-        <!-- introduces a cyclic reference ...
-        <dependency>
-            <groupId>org.apache.marmotta</groupId>
-            <artifactId>marmotta-backend-kiwi</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        -->
 
         <dependency>
             <groupId>com.jayway.restassured</groupId>
@@ -416,6 +408,18 @@
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.openrdf.sesame</groupId>
+            <artifactId>sesame-sail-memory</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.openrdf.sesame</groupId>
+            <artifactId>sesame-sail-inferencer</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+
         <!-- CDI/Java EE 6 Environment -->
         <dependency>
             <groupId>javax.enterprise</groupId>
@@ -500,18 +504,8 @@
             <groupId>org.openrdf.sesame</groupId>
             <artifactId>sesame-sail-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-sail-memory</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-sail-nativerdf</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-sail-inferencer</artifactId>
-        </dependency>
+
+
 
         <dependency>
             <groupId>org.apache.marmotta</groupId>
@@ -569,10 +563,6 @@
 
         <dependency>
             <groupId>org.apache.marmotta</groupId>
-            <artifactId>kiwi-triplestore</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.marmotta</groupId>
             <artifactId>kiwi-transactions</artifactId>
         </dependency>
 

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/user/UserToken.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/user/UserToken.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/user/UserToken.java
index a56329a..940c795 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/user/UserToken.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/user/UserToken.java
@@ -18,7 +18,7 @@
 package org.apache.marmotta.platform.core.api.user;
 
 
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.openrdf.model.URI;
 
 import java.util.Date;
 import java.util.UUID;
@@ -34,10 +34,10 @@ public class UserToken {
 
     private UUID uuid;
 
-    private KiWiUriResource user;
+    private URI user;
 
 
-    public UserToken(KiWiUriResource user) {
+    public UserToken(URI user) {
         this.user     = user;
         this.uuid     = UUID.randomUUID();
         this.created  = new Date();
@@ -60,11 +60,11 @@ public class UserToken {
         this.uuid = uuid;
     }
 
-    public KiWiUriResource getUser() {
+    public URI getUser() {
         return user;
     }
 
-    public void setUser(KiWiUriResource user) {
+    public void setUser(URI user) {
         this.user = user;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/rio/RDFHtmlWriterImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/rio/RDFHtmlWriterImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/rio/RDFHtmlWriterImpl.java
index 9c42bc1..4d73a9c 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/rio/RDFHtmlWriterImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/rio/RDFHtmlWriterImpl.java
@@ -20,7 +20,7 @@ package org.apache.marmotta.platform.core.rio;
 import com.google.common.collect.ImmutableMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.commons.http.UriUtil;
-import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
+import org.apache.marmotta.commons.sesame.repository.ResourceUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.io.RDFHtmlWriter;
 import org.apache.marmotta.platform.core.api.io.RDFWriterPriority;
@@ -204,8 +204,8 @@ public class RDFHtmlWriterImpl implements RDFHtmlWriter {
                     triple.put("context", ImmutableMap.of("uri","","curie",""));
                 }
 
-                if (t instanceof KiWiTriple && ((KiWiTriple) t).isInferred()) {
-                    triple.put("info", createInfo(((KiWiTriple) t).getId()));
+                if (ResourceUtils.isInferred(t)) {
+                    triple.put("info", ResourceUtils.getId(t));
                 } else {
                     triple.put("info", "-");
                 }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentReader.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentReader.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentReader.java
index 3c2510e..b0d9e02 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentReader.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentReader.java
@@ -17,21 +17,9 @@
  */
 package org.apache.marmotta.platform.core.services.content;
 
-import static org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-
+import com.google.common.io.ByteStreams;
+import com.google.common.io.Files;
 import org.apache.marmotta.commons.sesame.facading.FacadingFactory;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.content.ContentReader;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
@@ -43,8 +31,13 @@ import org.openrdf.repository.RepositoryConnection;
 import org.openrdf.repository.RepositoryException;
 import org.slf4j.Logger;
 
-import com.google.common.io.ByteStreams;
-import com.google.common.io.Files;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import java.io.*;
+import java.net.URI;
+
+import static org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException;
 
 /**
  * A content reader that reads the content of a resource from the file system.
@@ -138,7 +131,7 @@ public class FileSystemContentReader implements ContentReader {
                 MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);
 
                 String path = mci.getContentPath();
-                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
+                if(path == null && resource instanceof org.openrdf.model.URI && resource.stringValue().startsWith("file:")) {
                     try {
                         URI uri = new URI(resource.stringValue());
                         path = uri.getPath();
@@ -192,7 +185,7 @@ public class FileSystemContentReader implements ContentReader {
                 MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);
 
                 String path = mci.getContentPath();
-                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
+                if(path == null && resource instanceof org.openrdf.model.URI && resource.stringValue().startsWith("file:")) {
                     try {
                         URI uri = new URI(resource.stringValue());
                         path = uri.getPath();
@@ -235,7 +228,7 @@ public class FileSystemContentReader implements ContentReader {
                 MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);
 
                 String path = mci.getContentPath();
-                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
+                if(path == null && resource instanceof org.openrdf.model.URI && resource.stringValue().startsWith("file:")) {
                     try {
                         URI uri = new URI(resource.stringValue());
                         path = uri.getPath();
@@ -292,7 +285,7 @@ public class FileSystemContentReader implements ContentReader {
                 MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);
 
                 String path = mci.getContentPath();
-                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
+                if(path == null && resource instanceof org.openrdf.model.URI && resource.stringValue().startsWith("file:")) {
                     try {
                         URI uri = new URI(resource.stringValue());
                         path = uri.getPath();

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentWriter.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentWriter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentWriter.java
index d26f2cc..5a4af17 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentWriter.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/FileSystemContentWriter.java
@@ -17,17 +17,13 @@
  */
 package org.apache.marmotta.platform.core.services.content;
 
-import static org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException;
-
 import com.google.common.io.ByteStreams;
 import com.google.common.io.Files;
+import org.apache.marmotta.commons.sesame.facading.FacadingFactory;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.content.ContentWriter;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
 import org.apache.marmotta.platform.core.model.content.MediaContentItem;
-
-import org.apache.marmotta.commons.sesame.facading.FacadingFactory;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
 import org.openrdf.model.Resource;
 import org.openrdf.repository.RepositoryConnection;
 import org.openrdf.repository.RepositoryException;
@@ -38,14 +34,12 @@ import sun.net.www.MimeTable;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Inject;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.net.URI;
 import java.util.UUID;
 
+import static org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException;
+
 /**
  * A content writer that writes the content of a resource to the file system.
  * It uses the kiwi:hasContentPath property to determine the destination path of the content to write to.
@@ -171,9 +165,9 @@ public class FileSystemContentWriter implements ContentWriter {
                 String path = mci.getContentPath();
 
                 if(path == null) {
-                    if(resource instanceof KiWiUriResource && ((KiWiUriResource)resource).stringValue().startsWith("file:")) {
+                    if(resource instanceof org.openrdf.model.URI && resource.stringValue().startsWith("file:")) {
                         try {
-                            URI uri = new URI(((KiWiUriResource)resource).stringValue());
+                            URI uri = new URI(resource.stringValue());
                             path = uri.getPath();
                         } catch(Exception ex) {}
                     } else {

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/HTTPContentReader.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/HTTPContentReader.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/HTTPContentReader.java
index b52038e..d74c37f 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/HTTPContentReader.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/HTTPContentReader.java
@@ -17,32 +17,30 @@
  */
 package org.apache.marmotta.platform.core.services.content;
 
-import static org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-
+import com.google.common.io.ByteStreams;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.ResponseHandler;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpHead;
 import org.apache.marmotta.commons.sesame.facading.FacadingFactory;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
 import org.apache.marmotta.platform.core.api.content.ContentReader;
 import org.apache.marmotta.platform.core.api.http.HttpClientService;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
 import org.apache.marmotta.platform.core.model.content.MediaContentItem;
 import org.openrdf.model.Resource;
+import org.openrdf.model.URI;
 import org.openrdf.repository.RepositoryConnection;
 import org.openrdf.repository.RepositoryException;
 import org.slf4j.Logger;
 
-import com.google.common.io.ByteStreams;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException;
 
 /**
  * Add file description here!
@@ -122,8 +120,8 @@ public class HTTPContentReader implements ContentReader {
                 String location = mci.getContentLocation();
 
                 // if no location is explicitly specified, use the resource URI itself
-                if(location == null && resource instanceof KiWiUriResource && ((KiWiUriResource)resource).stringValue().startsWith("http://")) {
-                    location = ((KiWiUriResource)resource).stringValue();
+                if(location == null && resource instanceof URI && resource.stringValue().startsWith("http://")) {
+                    location = resource.stringValue();
                 }
 
                 if(location != null) {
@@ -168,8 +166,8 @@ public class HTTPContentReader implements ContentReader {
                 String location = mci.getContentLocation();
 
                 // if no location is explicitly specified, use the resource URI itself
-                if(location == null && resource instanceof KiWiUriResource && ((KiWiUriResource)resource).stringValue().startsWith("http://")) {
-                    location = ((KiWiUriResource)resource).stringValue();
+                if(location == null && resource instanceof URI && resource.stringValue().startsWith("http://")) {
+                    location = resource.stringValue();
                 }
 
                 try {
@@ -216,8 +214,8 @@ public class HTTPContentReader implements ContentReader {
                 String location = mci.getContentLocation();
 
                 // if no location is explicitly specified, use the resource URI itself
-                if(location == null && resource instanceof KiWiUriResource && ((KiWiUriResource)resource).stringValue().startsWith("http://")) {
-                    location = ((KiWiUriResource)resource).stringValue();
+                if(location == null && resource instanceof URI && resource.stringValue().startsWith("http://")) {
+                    location = resource.stringValue();
                 }
 
                 try {
@@ -265,8 +263,8 @@ public class HTTPContentReader implements ContentReader {
                 String location = mci.getContentLocation();
 
                 // if no location is explicitly specified, use the resource URI itself
-                if(location == null && resource instanceof KiWiUriResource && ((KiWiUriResource)resource).stringValue().startsWith("http://")) {
-                    location = ((KiWiUriResource)resource).stringValue();
+                if(location == null && resource instanceof URI && resource.stringValue().startsWith("http://")) {
+                    location = resource.stringValue();
                 }
 
                 try {

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/KiWiSesameUtil.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/KiWiSesameUtil.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/KiWiSesameUtil.java
deleted file mode 100644
index c7943e7..0000000
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/KiWiSesameUtil.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.platform.core.services.sesame;
-
-import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.RepositoryResult;
-
-import java.util.Date;
-
-/**
- * Some utils to work with KiWi model and Sesame
- * 
- * @author Sebastian Schaffert
- */
-public class KiWiSesameUtil {
-
-
-    /**
-     * Get the last modification of the set of triples passed as argument.
-     *
-     * @deprecated this class will be removed before the 2.6 release, the helper function should be moved elsewhere
-     * @return date
-     * @throws RepositoryException
-     */
-    public static Date lastModified(Resource resource, RepositoryConnection conn) throws RepositoryException {
-        Date last_modified = new Date(0);
-        RepositoryResult<Statement> triples = conn.getStatements(resource, null, null, false);
-        try {
-            while (triples.hasNext()) {
-                Statement triple = triples.next();
-                if (triple instanceof KiWiTriple) {
-                    KiWiTriple t = (KiWiTriple) triple;
-                    if (t.getCreated().getTime() > last_modified.getTime()) {
-                        last_modified = t.getCreated();
-                    }
-                }
-            }
-        } finally {
-            triples.close();
-        }
-        return last_modified;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java
index 1b68337..800ced8 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/sesame/ResourceSubjectMetadata.java
@@ -17,8 +17,6 @@
  */
 package org.apache.marmotta.platform.core.services.sesame;
 
-import org.apache.marmotta.kiwi.model.rdf.KiWiAnonResource;
-import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
 import org.openrdf.model.BNode;
 import org.openrdf.model.Resource;
 import org.openrdf.model.Value;
@@ -45,11 +43,11 @@ public class ResourceSubjectMetadata extends RepositoryConnectionInterceptorAdap
         if (s instanceof org.openrdf.model.URI && subject instanceof org.openrdf.model.URI ) {
             // if s is a URI and subject a KiWiUriResource, return
             // true if they are different
-            denyAdd = !s.stringValue().equals(((KiWiUriResource) subject).toString());
+            denyAdd = !s.stringValue().equals(subject.stringValue());
         } else if (s instanceof BNode && subject instanceof BNode) {
             // if s is a BNode and subject a KiWiAnonResource,
             // return true if they are different
-            denyAdd = !s.stringValue().equals(((KiWiAnonResource) subject).getID());
+            denyAdd = !s.stringValue().equals(subject.stringValue());
         } else {
             // in all other cases, return true to filter out the
             // triple

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java
index 4dd30c3..13ba090 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/InspectionWebService.java
@@ -18,8 +18,7 @@
 package org.apache.marmotta.platform.core.webservices.resource;
 
 import org.apache.marmotta.commons.sesame.model.Namespaces;
-import org.apache.marmotta.kiwi.model.rdf.KiWiResource;
-import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
+import org.apache.marmotta.commons.sesame.repository.ResourceUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
 import org.openrdf.model.*;
@@ -173,11 +172,7 @@ public class InspectionWebService {
         private final String s, p, o, c;
 
         public TriplePoJo(Statement t) {
-            if(t instanceof KiWiTriple) {
-                id = ((KiWiTriple)t).getId();
-            } else {
-                id = 0;
-            }
+            id = ResourceUtils.getId(t);
             s = t.getSubject().toString();
             p = t.getPredicate().toString();
             o = t.getObject().toString();
@@ -300,10 +295,11 @@ public class InspectionWebService {
         ps.println("</head><body>");
 
         ps.printf("<h1>Inspect %s</h1>%n<div>ShortName: %s<span class='%s'>%<s</span></div>%n", rsc.stringValue(), getLabel(conn,rsc), "");
-        if(rsc instanceof KiWiResource) {
-            ps.printf("<div>Created: <span>%tF %<tT</span> by <span>%s</span></div>%n", ((KiWiResource)rsc).getCreated(), createInspectLink(conn, null, null, ""));
+        Date created = ResourceUtils.getCreated(conn, rsc);
+        if(created != null) {
+            ps.printf("<div>Created: <span>%tF %<tT</span> by <span>%s</span></div>%n", created, createInspectLink(conn, null, null, ""));
         }
-        ps.printf("<div>Last Modified: <span>%tF %<tT</span></div>%n", lastModified(conn, rsc));
+        ps.printf("<div>Last Modified: <span>%tF %<tT</span></div>%n", ResourceUtils.getLastModified(conn, rsc));
 
         // Outgoing
         printOutgoing(conn, rsc, ps, subjOffset, limit);
@@ -319,7 +315,7 @@ public class InspectionWebService {
 
         ps.println();
         ps.println("</body></html>");
-        return Response.ok().header("Content-Type", "text/html;charset=" + CHARSET).header("Last-Modified", lastModified(conn, rsc))
+        return Response.ok().header("Content-Type", "text/html;charset=" + CHARSET).header("Last-Modified", ResourceUtils.getLastModified(conn, rsc))
                 .entity(os.toString(CHARSET)).build();
     }
 
@@ -345,7 +341,7 @@ public class InspectionWebService {
             for (Statement t : triples) {
                 ps.printf("    <tr class='%s'><td>%s</td><td>%s</td><td>%s</td><td><span class='reasoned'>%s</span></td><td><span class='deleted %b'></span></td></tr>%n",
                         i++ % 2 == 0 ? "even" : "odd", createInspectLink(conn, t.getSubject()), createInspectLink(conn,t.getObject()), createInspectLink(conn,t.getContext()),
-                                t instanceof KiWiTriple && ((KiWiTriple)t).isInferred() ? createInfo(((KiWiTriple)t).getId()) : "", t instanceof KiWiTriple && ((KiWiTriple)t).isDeleted());
+                                ResourceUtils.isInferred(conn,t) ? createInfo(ResourceUtils.getId(t)) : "", ResourceUtils.isDeleted(conn,t));
             }
             ps.printf("  </tbody>%n</table>");
         } else if (offset > 0) {
@@ -376,7 +372,7 @@ public class InspectionWebService {
                 ps.printf(
                         "    <tr class='%s'><td>%s</td><td>%s</td><td>%s</td><td><span class='reasoned'>%s</span></td><td><span class='deleted %b'></span></td></tr>%n",
                         i++ % 2 == 0 ? "even" : "odd", createInspectLink(conn, t.getSubject()), createInspectLink(conn,t.getObject()), createInspectLink(conn,t.getContext()),
-                                t instanceof KiWiTriple && ((KiWiTriple)t).isInferred() ? createInfo(((KiWiTriple)t).getId()) : "", t instanceof KiWiTriple && ((KiWiTriple)t).isDeleted());
+                        ResourceUtils.isInferred(conn,t) ? createInfo(ResourceUtils.getId(t)) : "", ResourceUtils.isDeleted(conn,t));
             }
             ps.printf("  </tbody>%n</table>");
         } else if (offset > 0) {
@@ -407,7 +403,7 @@ public class InspectionWebService {
                 ps.printf(
                         "    <tr class='%s'><td>%s</td><td>%s</td><td>%s</td><td><span class='reasoned'>%s</span></td><td><span class='deleted %b'></span></td></tr>%n",
                         i++ % 2 == 0 ? "even" : "odd", createInspectLink(conn, t.getSubject()), createInspectLink(conn,t.getObject()), createInspectLink(conn,t.getContext()),
-                                t instanceof KiWiTriple && ((KiWiTriple)t).isInferred() ? createInfo(((KiWiTriple)t).getId()) : "", t instanceof KiWiTriple && ((KiWiTriple)t).isDeleted());
+                        ResourceUtils.isInferred(conn,t) ? createInfo(ResourceUtils.getId(t)) : "", ResourceUtils.isDeleted(conn,t));
             }
             ps.printf("  </tbody>%n</table>");
         } else if (offset > 0) {
@@ -439,7 +435,7 @@ public class InspectionWebService {
                 ps.printf(
                         "    <tr class='%s'><td>%s</td><td>%s</td><td>%s</td><td><span class='reasoned'>%s</span></td><td><span class='deleted %b'></span></td></tr>%n",
                         i++ % 2 == 0 ? "even" : "odd", createInspectLink(conn, t.getSubject()), createInspectLink(conn,t.getObject()), createInspectLink(conn,t.getContext()),
-                                t instanceof KiWiTriple && ((KiWiTriple)t).isInferred() ? createInfo(((KiWiTriple)t).getId()) : "", t instanceof KiWiTriple && ((KiWiTriple)t).isDeleted());
+                        ResourceUtils.isInferred(conn,t) ? createInfo(ResourceUtils.getId(t)) : "", ResourceUtils.isDeleted(conn,t));
             }
             ps.printf("  </tbody>%n</table>");
         } else if (offset > 0) {
@@ -520,23 +516,5 @@ public class InspectionWebService {
         return b.toString();
     }
 
-    /**
-     * Get the last modification of the set of triples passed as argument.
-     *
-     * @return
-     */
-    private Date lastModified(RepositoryConnection conn, Resource resource) throws RepositoryException {
-        Date last_modified = new Date(0);
-        for (Statement triple : listOutgoing(conn, resource)) {
-            if(triple instanceof KiWiTriple) {
-                KiWiTriple t = (KiWiTriple)triple;
-                if (t.getCreated().getTime() > last_modified.getTime()) {
-                    last_modified = t.getCreated();
-                }
-            }
-        }
-        return last_modified;
-
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java
index 30de0f8..9b7cbe4 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java
@@ -52,7 +52,6 @@ import org.apache.marmotta.platform.core.api.io.MarmottaIOService;
 import org.apache.marmotta.platform.core.api.templating.TemplatingService;
 import org.apache.marmotta.platform.core.api.triplestore.ContextService;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
-import org.apache.marmotta.platform.core.services.sesame.KiWiSesameUtil;
 import org.apache.marmotta.platform.core.services.sesame.ResourceSubjectMetadata;
 import org.openrdf.model.Resource;
 import org.openrdf.repository.RepositoryConnection;
@@ -300,7 +299,7 @@ public class MetaWebService {
                 };
 
                 // build response
-                Response response = Response.ok(entity).lastModified(KiWiSesameUtil.lastModified(r, conn)).build();
+                Response response = Response.ok(entity).lastModified(ResourceUtils.getLastModified(conn, r)).build();
                 response.getMetadata().add("ETag", "W/\"" + ETagGenerator.getWeakETag(conn, r) + "\"");
                 
                 if (!mimetype.contains("html")) { // then create a proper filename

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java
index 3de0d7d..fe3fe5d 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/ResourceWebService.java
@@ -54,7 +54,6 @@ import org.apache.marmotta.platform.core.api.content.ContentService;
 import org.apache.marmotta.platform.core.api.io.MarmottaIOService;
 import org.apache.marmotta.platform.core.api.templating.TemplatingService;
 import org.apache.marmotta.platform.core.api.triplestore.SesameService;
-import org.apache.marmotta.platform.core.services.sesame.KiWiSesameUtil;
 import org.openrdf.model.Resource;
 import org.openrdf.model.URI;
 import org.openrdf.repository.RepositoryConnection;
@@ -411,7 +410,7 @@ public class ResourceWebService {
 
                 if(bestType != null) {
                     Response response = buildGetResponse(r, bestType);
-                    response.getMetadata().add("Last-Modified", KiWiSesameUtil.lastModified(r, conn));
+                    response.getMetadata().add("Last-Modified", ResourceUtils.getLastModified(conn, r));
                     response.getMetadata().add("ETag", "W/\"" + ETagGenerator.getWeakETag(conn, r) + "\"");
                     return response;
                 } else {

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8fdc1498/platform/marmotta-core/src/test/java/org/apache/marmotta/platform/core/test/base/TestStoreProvider.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/test/java/org/apache/marmotta/platform/core/test/base/TestStoreProvider.java b/platform/marmotta-core/src/test/java/org/apache/marmotta/platform/core/test/base/TestStoreProvider.java
new file mode 100644
index 0000000..984a3cb
--- /dev/null
+++ b/platform/marmotta-core/src/test/java/org/apache/marmotta/platform/core/test/base/TestStoreProvider.java
@@ -0,0 +1,9 @@
+package org.apache.marmotta.platform.core.test.base;
+
+/**
+ * A triple store provider for tests. Uses a Sesame in-memory store for holding triples.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class TestStoreProvider {
+}