You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2014/02/19 12:30:22 UTC
git commit: CLEREZZA-838: extracted GraphNodeProvider interface to
rdf.utils
Repository: clerezza
Updated Branches:
refs/heads/master 47b78a929 -> e2469df77
CLEREZZA-838: extracted GraphNodeProvider interface to rdf.utils
Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/e2469df7
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/e2469df7
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/e2469df7
Branch: refs/heads/master
Commit: e2469df778d1a7e6222a51699096a215de16a275
Parents: 47b78a9
Author: retobg <re...@apache.org>
Authored: Wed Feb 19 12:29:20 2014 +0100
Committer: retobg <re...@apache.org>
Committed: Wed Feb 19 12:29:20 2014 +0100
----------------------------------------------------------------------
.../resources/OSGI-INF/serviceComponents.xml | 2 +-
.../accountcontrolpanel/ProfilePanel.scala | 2 +-
.../platform/content/DiscobitsTypeHandler.java | 2 +-
.../clerezza/platform/content/Editor.java | 9 +
.../resources/OSGI-INF/serviceComponents.xml | 6 +-
.../graphnodeprovider/GraphNodeProvider.scala | 244 ------------------
.../PlatformGraphNodeProvider.scala | 245 +++++++++++++++++++
.../jaxrs/TypeHandlerSpace.java | 2 +-
.../typehandlerspace/wink/TypeHandlerSpace.java | 2 +-
.../typerendering/CallbackRenderer.java | 2 +-
.../typerendering/CallbackRendererImpl.java | 2 +-
.../platform/typerendering/RendererFactory.java | 2 +-
.../typerendering/RenderletRendererImpl.java | 4 +-
.../TypeRenderletRendererImpl.java | 2 +-
.../graphnodeprovider/GraphNodeProvider.java | 51 ++++
15 files changed, 319 insertions(+), 258 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
index 4807d2e..8e50481 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
@@ -66,7 +66,7 @@
<property name="service.pid" value="org.apache.clerezza.platform.accountcontrolpanel.ProfilePanel"/>
<reference name="userManager" interface="org.apache.clerezza.platform.usermanager.UserManager"
cardinality="1..1" policy="static" bind="bindUserManager" unbind="unbindUserManager"/>
- <reference name="graphNodeProvider" interface="org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider"
+ <reference name="graphNodeProvider" interface="org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider"
cardinality="1..1" policy="static" bind="bindGraphNodeProvider" unbind="unbindGraphNodeProvider"/>
<reference name="keygenSrvc" interface="org.apache.clerezza.ssl.keygen.KeygenService"
cardinality="1..1" policy="static" bind="bindKeygenSrvc" unbind="unbindKeygenSrvc"/>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
----------------------------------------------------------------------
diff --git a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
index 0104077..d46f9f1 100644
--- a/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
+++ b/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
@@ -23,7 +23,7 @@ import java.util.Arrays
import java.util.Collections
import java.util.Iterator
import ontologies.CONTROLPANEL
-import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider
import org.apache.clerezza.ssl.keygen.CertSerialisation
import org.apache.clerezza.ssl.keygen.Certificate
import org.apache.clerezza.foafssl.ontologies.CERT
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
----------------------------------------------------------------------
diff --git a/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java b/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
index 55a21d3..a92ff01 100644
--- a/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
+++ b/platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
@@ -18,7 +18,7 @@
*/
package org.apache.clerezza.platform.content;
-import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider;
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider;
import org.apache.clerezza.rdf.metadata.MetaDataGenerator;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.content/src/main/java/org/apache/clerezza/platform/content/Editor.java
----------------------------------------------------------------------
diff --git a/platform.content/src/main/java/org/apache/clerezza/platform/content/Editor.java b/platform.content/src/main/java/org/apache/clerezza/platform/content/Editor.java
index 4a9a598..5e7940d 100644
--- a/platform.content/src/main/java/org/apache/clerezza/platform/content/Editor.java
+++ b/platform.content/src/main/java/org/apache/clerezza/platform/content/Editor.java
@@ -19,6 +19,7 @@
package org.apache.clerezza.platform.content;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
@@ -52,6 +53,7 @@ import org.apache.clerezza.rdf.core.Graph;
import org.apache.clerezza.rdf.core.MGraph;
import org.apache.clerezza.rdf.core.UriRef;
import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.serializedform.Serializer;
import org.apache.clerezza.rdf.utils.GraphNode;
import org.apache.clerezza.rdf.utils.MGraphUtils;
import org.apache.clerezza.web.fileserver.BundlePathNode;
@@ -76,6 +78,9 @@ public class Editor extends FileServer {
@Reference
private TcManager tcManager;
+
+ @Reference
+ private Serializer serializer;
private static final Logger logger = LoggerFactory.getLogger(Editor.class);
@@ -148,6 +153,10 @@ public class Editor extends FileServer {
final MGraph mGraph = graphUri == null ? cgProvider.getContentGraph() :
tcManager.getMGraph(graphUri);
try {
+ serializer.serialize(System.out, revokedGraph, "text/turtle");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ serializer.serialize(baos, revokedGraph, "text/turtle");
+ System.out.println(new String(baos.toByteArray()).contains("\r"));
MGraphUtils.removeSubGraph(mGraph, revokedGraph);
} catch (NoSuchSubGraphException ex) {
throw new RuntimeException(ex);
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.graphnodeprovider/src/main/resources/OSGI-INF/serviceComponents.xml
----------------------------------------------------------------------
diff --git a/platform.graphnodeprovider/src/main/resources/OSGI-INF/serviceComponents.xml b/platform.graphnodeprovider/src/main/resources/OSGI-INF/serviceComponents.xml
index c1e1a5a..7494186 100644
--- a/platform.graphnodeprovider/src/main/resources/OSGI-INF/serviceComponents.xml
+++ b/platform.graphnodeprovider/src/main/resources/OSGI-INF/serviceComponents.xml
@@ -22,10 +22,10 @@
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
- <scr:component enabled="true" name="org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider">
- <implementation class="org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider"/>
+ <scr:component enabled="true" name="org.apache.clerezza.platform.graphnodeprovider.PlatformGraphNodeProvider">
+ <implementation class="org.apache.clerezza.platform.graphnodeprovider.PlatformGraphNodeProvider"/>
<service servicefactory="false">
- <provide interface="org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider"/>
+ <provide interface="org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider"/>
</service>
<reference name="tcManager" interface="org.apache.clerezza.rdf.core.access.TcManager"
cardinality="1..1" policy="static" bind="bindTcManager" unbind="unbindTcManager"/>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala
----------------------------------------------------------------------
diff --git a/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala b/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala
deleted file mode 100644
index 5c9f12b..0000000
--- a/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/GraphNodeProvider.scala
+++ /dev/null
@@ -1,244 +0,0 @@
-package org.apache.clerezza.platform.graphnodeprovider
-
-/*
- * 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.
- */
-
-import java.net.{HttpURLConnection, URL}
-import org.slf4j.scala._
-import org.apache.clerezza.rdf.core.access._
-import org.apache.clerezza.rdf.core._
-import org.apache.clerezza.platform.config.PlatformConfig
-import org.apache.clerezza.platform.Constants
-import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider
-import org.apache.clerezza.platform.users.WebIdGraphsService
-import org.apache.clerezza.rdf.utils.{UnionMGraph, UriMutatingTripleCollection, GraphNode}
-import java.util.concurrent.locks.Lock
-import org.apache.clerezza.platform.usermanager.UserManager
-import java.security.{PrivilegedAction, AccessController}
-
-/**
- * A service that returns a GraphNode for a specified named resource, the returned GraphNode has
- * as BaseGraph the ContentGraph provided by the ContentGraphProvider and the for remote uris the
- * Graphs they dereference to and for local URIs with a path-section starting with /user/{username}/
- * the local-public-graph of that user.
- */
-class GraphNodeProvider extends Logging {
-
- /**
- * Get a GraphNode for the specified resource, see class comments for details.
- */
- def get(uriRef: UriRef): GraphNode = {
- val uriString = uriRef.getUnicodeString
- val isLocal: Boolean = {
- import scala.collection.JavaConversions._
- //we assume all non http* uris to be local
- !uriString.toLowerCase.startsWith("http") || platformConfig.getBaseUris.exists(baseUri => uriString.startsWith(baseUri.getUnicodeString))
- }
- get(uriRef, isLocal)
- }
-
- /**
- * Get a GraphNode for the specified resource, The resource is assumed to be local, i.e. the method behaves like
- * get(UriRef) for a Uri with an authority section contained in the Set retuned by
- * <code>org.apache.clerezza.platform.config.PlatformConfig#getBaseUris()</code>
- */
- def getLocal(uriRef: UriRef): GraphNode = {
- get(uriRef, true)
- }
-
-
- /**
- *return true iff getLocal(uriRef).getNodeContext.size > 0
- */
- def existsLocal(uriRef: UriRef): Boolean = {
- val cgGraph = cgProvider.getContentGraph
- lazy val localInstanceUri = {
- val uri = new java.net.URI(uriRef.getUnicodeString)
- new UriRef(Constants.URN_LOCAL_INSTANCE + uri.getPath)
- }
- //TODO handle /user/
- existsInGraph(uriRef,cgGraph) || existsInGraph(localInstanceUri, cgGraph)
- }
-
- private[this] def existsInGraph(nodeUri: UriRef, tc: LockableMGraph): Boolean = {
- var readLock: Lock = tc.getLock.readLock
- readLock.lock
- try {
- return tc.filter(nodeUri, null, null).hasNext || tc.filter(null, null, nodeUri).hasNext
- }
- finally {
- readLock.unlock
- }
- }
-
-
- private def get(uriRef: UriRef, isLocal: Boolean): GraphNode = {
- val uriString = uriRef.getUnicodeString
-
-
- val uriPath = {
- val uri = new java.net.URI(uriString)
- uri.getPath
- }
-
- lazy val uriPrefix = {
- val uri = new java.net.URI(uriString)
- uri.getScheme+"://"+uri.getAuthority
- }
-
- val anyHostUri = new UriRef(Constants.URN_LOCAL_INSTANCE + uriPath)
-
- var mGraphs: List[TripleCollection] = Nil
-
- def addToUnion(mGraph: LockableMGraph) {
- //adding uncondinionately if (existsInGraph(uriRef, mGraph)) {
- mGraphs ::= mGraph
- //}
- if (isLocal) {
- if (existsInGraph(anyHostUri, mGraph)) {
- mGraphs ::= new UriMutatingTripleCollection(mGraph, Constants.URN_LOCAL_INSTANCE, uriPrefix)
- }
- }
- }
-
- val cgGraph = cgProvider.getContentGraph
-
- addToUnion(cgGraph)
-
- if (isLocal && uriPath.startsWith("/user/")) {
- val nextSlash = uriPath.indexOf('/',6)
- if (nextSlash != -1) {
- val userName = uriPath.substring(6, nextSlash)
- val webIdOption = AccessController.doPrivileged(new PrivilegedAction[Option[UriRef]]() {
- def run(): Option[UriRef] = {
- val userNode: GraphNode = userManager.getUserInSystemGraph(userName)
- if (userNode != null) {
- userNode.getNode match {
- case u: UriRef => Some(u)
- case _ => None
- }
- } else {
- None
- }
- }
- }
- )
- webIdOption match {
- case Some(u) => {
- val webIdInfo = webIdGraphsService.getWebIdInfo(u)
- addToUnion(webIdInfo.localPublicUserData)
- }
- case None => ;
- }
- }
- }
-
- if (!isLocal) {
- /**
- * As the resource might identify something other than a document we use this to find the redirect location
- */
- lazy val redirectLocationString = {
- val acceptHeader = "application/rdf+xml,*/*;q.1"
- val url = new URL(uriString)
- val connection = url.openConnection()
- connection match {
- case hc : HttpURLConnection => {
- hc.setRequestMethod("HEAD");
- hc.setInstanceFollowRedirects(false)
- hc.addRequestProperty("Accept", acceptHeader)
- hc.getResponseCode match {
- case HttpURLConnection.HTTP_SEE_OTHER => {
- val location = hc.getHeaderField("Location")
- if (location == null) {
- throw new RuntimeException("No Location Headers in 303 response")
- }
- location
- }
- case _ => uriString
- }
- }
- case _ => uriString
- }
- }
-
- //TODO add method to WebProxy to get the graph location location
- val graphUriString = {
- val hashPos = uriString.indexOf('#')
- if (hashPos != -1) {
- uriString.substring(0, hashPos)
- } else {
- redirectLocationString
- }
- }
-
- addToUnion(tcManager.getMGraph(new UriRef(graphUriString)))
- }
-
- val unionMGraph = new UnionMGraph(mGraphs:_*);
- new GraphNode(uriRef, unionMGraph)
- }
-
- private var tcManager: TcManager = null;
-
- protected def bindTcManager(tcManager: TcManager) = {
- this.tcManager = tcManager
- }
-
- protected def unbindTcManager(tcManager: TcManager) = {
- this.tcManager = null
- }
-
- private var platformConfig: PlatformConfig = null;
-
- protected def bindPlatformConfig(c: PlatformConfig) = {
- this.platformConfig = c
- }
-
- protected def unbindPlatformConfig(c: PlatformConfig) = {
- this.platformConfig = null
- }
-
- private var cgProvider: ContentGraphProvider = null
- protected def bindCgProvider(p: ContentGraphProvider) {
- this.cgProvider = p
- }
- protected def unbindCgProvider(p: ContentGraphProvider) {
- this.cgProvider = null
- }
-
- private var webIdGraphsService: WebIdGraphsService = null
- protected def bindWebIdGraphsService(webIdGraphsService: WebIdGraphsService): Unit = {
- this.webIdGraphsService = webIdGraphsService
- }
-
- protected def unbindWebIdGraphsService(webIdGraphsService: WebIdGraphsService): Unit = {
- this.webIdGraphsService = null
- }
-
- private var userManager: UserManager = null
-
- protected def bindUserManager(userManager: UserManager): Unit = {
- this.userManager = userManager
- }
-
- protected def unbindUserManager(userManager: UserManager): Unit = {
- this.userManager = null
- }
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/PlatformGraphNodeProvider.scala
----------------------------------------------------------------------
diff --git a/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/PlatformGraphNodeProvider.scala b/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/PlatformGraphNodeProvider.scala
new file mode 100644
index 0000000..6918a5e
--- /dev/null
+++ b/platform.graphnodeprovider/src/main/scala/org/apache/clerezza/platform/graphnodeprovider/PlatformGraphNodeProvider.scala
@@ -0,0 +1,245 @@
+package org.apache.clerezza.platform.graphnodeprovider
+
+/*
+ * 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.
+ */
+
+import java.net.{HttpURLConnection, URL}
+import org.slf4j.scala._
+import org.apache.clerezza.rdf.core.access._
+import org.apache.clerezza.rdf.core._
+import org.apache.clerezza.platform.config.PlatformConfig
+import org.apache.clerezza.platform.Constants
+import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider
+import org.apache.clerezza.platform.users.WebIdGraphsService
+import org.apache.clerezza.rdf.utils.{UnionMGraph, UriMutatingTripleCollection, GraphNode}
+import java.util.concurrent.locks.Lock
+import org.apache.clerezza.platform.usermanager.UserManager
+import java.security.{PrivilegedAction, AccessController}
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider
+
+/**
+ * A service that returns a GraphNode for a specified named resource, the returned GraphNode has
+ * as BaseGraph the ContentGraph provided by the ContentGraphProvider and the for remote uris the
+ * Graphs they dereference to and for local URIs with a path-section starting with /user/{username}/
+ * the local-public-graph of that user.
+ */
+class PlatformGraphNodeProvider extends GraphNodeProvider with Logging {
+
+ /**
+ * Get a GraphNode for the specified resource, see class comments for details.
+ */
+ def get(uriRef: UriRef): GraphNode = {
+ val uriString = uriRef.getUnicodeString
+ val isLocal: Boolean = {
+ import scala.collection.JavaConversions._
+ //we assume all non http* uris to be local
+ !uriString.toLowerCase.startsWith("http") || platformConfig.getBaseUris.exists(baseUri => uriString.startsWith(baseUri.getUnicodeString))
+ }
+ get(uriRef, isLocal)
+ }
+
+ /**
+ * Get a GraphNode for the specified resource, The resource is assumed to be local, i.e. the method behaves like
+ * get(UriRef) for a Uri with an authority section contained in the Set retuned by
+ * <code>org.apache.clerezza.platform.config.PlatformConfig#getBaseUris()</code>
+ */
+ def getLocal(uriRef: UriRef): GraphNode = {
+ get(uriRef, true)
+ }
+
+
+ /**
+ *return true iff getLocal(uriRef).getNodeContext.size > 0
+ */
+ def existsLocal(uriRef: UriRef): Boolean = {
+ val cgGraph = cgProvider.getContentGraph
+ lazy val localInstanceUri = {
+ val uri = new java.net.URI(uriRef.getUnicodeString)
+ new UriRef(Constants.URN_LOCAL_INSTANCE + uri.getPath)
+ }
+ //TODO handle /user/
+ existsInGraph(uriRef,cgGraph) || existsInGraph(localInstanceUri, cgGraph)
+ }
+
+ private[this] def existsInGraph(nodeUri: UriRef, tc: LockableMGraph): Boolean = {
+ var readLock: Lock = tc.getLock.readLock
+ readLock.lock
+ try {
+ return tc.filter(nodeUri, null, null).hasNext || tc.filter(null, null, nodeUri).hasNext
+ }
+ finally {
+ readLock.unlock
+ }
+ }
+
+
+ private def get(uriRef: UriRef, isLocal: Boolean): GraphNode = {
+ val uriString = uriRef.getUnicodeString
+
+
+ val uriPath = {
+ val uri = new java.net.URI(uriString)
+ uri.getPath
+ }
+
+ lazy val uriPrefix = {
+ val uri = new java.net.URI(uriString)
+ uri.getScheme+"://"+uri.getAuthority
+ }
+
+ val anyHostUri = new UriRef(Constants.URN_LOCAL_INSTANCE + uriPath)
+
+ var mGraphs: List[TripleCollection] = Nil
+
+ def addToUnion(mGraph: LockableMGraph) {
+ //adding uncondinionately if (existsInGraph(uriRef, mGraph)) {
+ mGraphs ::= mGraph
+ //}
+ if (isLocal) {
+ if (existsInGraph(anyHostUri, mGraph)) {
+ mGraphs ::= new UriMutatingTripleCollection(mGraph, Constants.URN_LOCAL_INSTANCE, uriPrefix)
+ }
+ }
+ }
+
+ val cgGraph = cgProvider.getContentGraph
+
+ addToUnion(cgGraph)
+
+ if (isLocal && uriPath.startsWith("/user/")) {
+ val nextSlash = uriPath.indexOf('/',6)
+ if (nextSlash != -1) {
+ val userName = uriPath.substring(6, nextSlash)
+ val webIdOption = AccessController.doPrivileged(new PrivilegedAction[Option[UriRef]]() {
+ def run(): Option[UriRef] = {
+ val userNode: GraphNode = userManager.getUserInSystemGraph(userName)
+ if (userNode != null) {
+ userNode.getNode match {
+ case u: UriRef => Some(u)
+ case _ => None
+ }
+ } else {
+ None
+ }
+ }
+ }
+ )
+ webIdOption match {
+ case Some(u) => {
+ val webIdInfo = webIdGraphsService.getWebIdInfo(u)
+ addToUnion(webIdInfo.localPublicUserData)
+ }
+ case None => ;
+ }
+ }
+ }
+
+ if (!isLocal) {
+ /**
+ * As the resource might identify something other than a document we use this to find the redirect location
+ */
+ lazy val redirectLocationString = {
+ val acceptHeader = "application/rdf+xml,*/*;q.1"
+ val url = new URL(uriString)
+ val connection = url.openConnection()
+ connection match {
+ case hc : HttpURLConnection => {
+ hc.setRequestMethod("HEAD");
+ hc.setInstanceFollowRedirects(false)
+ hc.addRequestProperty("Accept", acceptHeader)
+ hc.getResponseCode match {
+ case HttpURLConnection.HTTP_SEE_OTHER => {
+ val location = hc.getHeaderField("Location")
+ if (location == null) {
+ throw new RuntimeException("No Location Headers in 303 response")
+ }
+ location
+ }
+ case _ => uriString
+ }
+ }
+ case _ => uriString
+ }
+ }
+
+ //TODO add method to WebProxy to get the graph location location
+ val graphUriString = {
+ val hashPos = uriString.indexOf('#')
+ if (hashPos != -1) {
+ uriString.substring(0, hashPos)
+ } else {
+ redirectLocationString
+ }
+ }
+
+ addToUnion(tcManager.getMGraph(new UriRef(graphUriString)))
+ }
+
+ val unionMGraph = new UnionMGraph(mGraphs:_*);
+ new GraphNode(uriRef, unionMGraph)
+ }
+
+ private var tcManager: TcManager = null;
+
+ protected def bindTcManager(tcManager: TcManager) = {
+ this.tcManager = tcManager
+ }
+
+ protected def unbindTcManager(tcManager: TcManager) = {
+ this.tcManager = null
+ }
+
+ private var platformConfig: PlatformConfig = null;
+
+ protected def bindPlatformConfig(c: PlatformConfig) = {
+ this.platformConfig = c
+ }
+
+ protected def unbindPlatformConfig(c: PlatformConfig) = {
+ this.platformConfig = null
+ }
+
+ private var cgProvider: ContentGraphProvider = null
+ protected def bindCgProvider(p: ContentGraphProvider) {
+ this.cgProvider = p
+ }
+ protected def unbindCgProvider(p: ContentGraphProvider) {
+ this.cgProvider = null
+ }
+
+ private var webIdGraphsService: WebIdGraphsService = null
+ protected def bindWebIdGraphsService(webIdGraphsService: WebIdGraphsService): Unit = {
+ this.webIdGraphsService = webIdGraphsService
+ }
+
+ protected def unbindWebIdGraphsService(webIdGraphsService: WebIdGraphsService): Unit = {
+ this.webIdGraphsService = null
+ }
+
+ private var userManager: UserManager = null
+
+ protected def bindUserManager(userManager: UserManager): Unit = {
+ this.userManager = userManager
+ }
+
+ protected def unbindUserManager(userManager: UserManager): Unit = {
+ this.userManager = null
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.typehandlerspace.jaxrs2/src/main/java/org/apache/clerezza/platform/typehandlerspace/jaxrs/TypeHandlerSpace.java
----------------------------------------------------------------------
diff --git a/platform.typehandlerspace.jaxrs2/src/main/java/org/apache/clerezza/platform/typehandlerspace/jaxrs/TypeHandlerSpace.java b/platform.typehandlerspace.jaxrs2/src/main/java/org/apache/clerezza/platform/typehandlerspace/jaxrs/TypeHandlerSpace.java
index 5bd4559..75e91f8 100644
--- a/platform.typehandlerspace.jaxrs2/src/main/java/org/apache/clerezza/platform/typehandlerspace/jaxrs/TypeHandlerSpace.java
+++ b/platform.typehandlerspace.jaxrs2/src/main/java/org/apache/clerezza/platform/typehandlerspace/jaxrs/TypeHandlerSpace.java
@@ -29,7 +29,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;
-import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider;
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider;
import org.apache.clerezza.platform.typehandlerspace.TypeHandlerDiscovery;
import org.apache.clerezza.rdf.core.Resource;
import org.apache.clerezza.rdf.core.UriRef;
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.typehandlerspace.wink/src/main/java/org/apache/clerezza/platform/typehandlerspace/wink/TypeHandlerSpace.java
----------------------------------------------------------------------
diff --git a/platform.typehandlerspace.wink/src/main/java/org/apache/clerezza/platform/typehandlerspace/wink/TypeHandlerSpace.java b/platform.typehandlerspace.wink/src/main/java/org/apache/clerezza/platform/typehandlerspace/wink/TypeHandlerSpace.java
index 2d6742f..7cad851 100644
--- a/platform.typehandlerspace.wink/src/main/java/org/apache/clerezza/platform/typehandlerspace/wink/TypeHandlerSpace.java
+++ b/platform.typehandlerspace.wink/src/main/java/org/apache/clerezza/platform/typehandlerspace/wink/TypeHandlerSpace.java
@@ -38,7 +38,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.clerezza.jaxrs.extensions.ResourceMethodException;
-import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider;
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider;
import org.apache.clerezza.platform.typehandlerspace.TypeHandlerDiscovery;
import org.apache.clerezza.rdf.core.Resource;
import org.apache.clerezza.rdf.core.UriRef;
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRenderer.java
----------------------------------------------------------------------
diff --git a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRenderer.java b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRenderer.java
index 61e2968..05c0784 100644
--- a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRenderer.java
+++ b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRenderer.java
@@ -48,7 +48,7 @@ public interface CallbackRenderer {
/**
* Renders a specified named resource using the GraphNode returned by
- * <code>org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider#get(org.apache.clerezza.rdf.core.UriRef)</code>.
+ * <code>org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider#get(org.apache.clerezza.rdf.core.UriRef)</code>.
*
* Otherwise same as render(GraphNode, .GraphNode, String, OutputStream)
*
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRendererImpl.java
----------------------------------------------------------------------
diff --git a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRendererImpl.java b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRendererImpl.java
index 6be854f..0f0a82a 100644
--- a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRendererImpl.java
+++ b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/CallbackRendererImpl.java
@@ -32,7 +32,7 @@ import javax.ws.rs.core.UriInfo;
import org.apache.clerezza.rdf.core.UriRef;
import org.apache.clerezza.rdf.utils.GraphNode;
-import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider;
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider;
/**
*
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RendererFactory.java
----------------------------------------------------------------------
diff --git a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RendererFactory.java b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RendererFactory.java
index a1ccd2c..ed3f372 100644
--- a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RendererFactory.java
+++ b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RendererFactory.java
@@ -21,7 +21,7 @@ package org.apache.clerezza.platform.typerendering;
import java.util.*;
import javax.ws.rs.core.MediaType;
-import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider;
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider;
import org.apache.clerezza.platform.typepriority.TypePrioritizer;
import org.apache.clerezza.platform.typerendering.utils.MediaTypeMap;
import org.apache.clerezza.platform.typerendering.utils.RegexMap;
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RenderletRendererImpl.java
----------------------------------------------------------------------
diff --git a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RenderletRendererImpl.java b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RenderletRendererImpl.java
index fecfaa9..f984ddb 100644
--- a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RenderletRendererImpl.java
+++ b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/RenderletRendererImpl.java
@@ -31,7 +31,7 @@ import javax.ws.rs.core.UriInfo;
import org.apache.clerezza.rdf.core.UriRef;
import org.apache.clerezza.rdf.utils.GraphNode;
import org.osgi.framework.BundleContext;
-import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider;
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider;
/**
*
@@ -52,7 +52,7 @@ class RenderletRendererImpl implements Renderer {
private GraphNodeProvider graphNodeProvider;
- RenderletRendererImpl(UriRef renderingSpecification, org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider graphNodeProvider,
+ RenderletRendererImpl(UriRef renderingSpecification, org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider graphNodeProvider,
Renderlet renderlet, MediaType mediaType,
RendererFactory rendererFactory,
BundleContext bundleContext) {
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/TypeRenderletRendererImpl.java
----------------------------------------------------------------------
diff --git a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/TypeRenderletRendererImpl.java b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/TypeRenderletRendererImpl.java
index cb04fec..aea9e6d 100644
--- a/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/TypeRenderletRendererImpl.java
+++ b/platform.typerendering/platform.typerendering.core/src/main/java/org/apache/clerezza/platform/typerendering/TypeRenderletRendererImpl.java
@@ -26,7 +26,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
-import org.apache.clerezza.platform.graphnodeprovider.GraphNodeProvider;
+import org.apache.clerezza.rdf.utils.graphnodeprovider.GraphNodeProvider;
import org.apache.clerezza.rdf.utils.GraphNode;
import org.osgi.framework.BundleContext;
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e2469df7/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java
new file mode 100644
index 0000000..3f839e9
--- /dev/null
+++ b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java
@@ -0,0 +1,51 @@
+package org.apache.clerezza.rdf.utils.graphnodeprovider;
+
+/*
+ * 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.
+ */
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.utils.GraphNode;
+
+/**
+ * A service that returns a GraphNode for a specified named resource, the
+ * returned GraphNode has as BaseGraph the ContentGraph provided by the
+ * ContentGraphProvider and the for remote uris the Graphs they dereference to
+ * and for local URIs with a path-section starting with /user/{username}/ the
+ * local-public-graph of that user.
+ */
+public interface GraphNodeProvider {
+
+ /**
+ * Get a GraphNode for the specified resource, see class comments for
+ * details.
+ */
+ GraphNode get(UriRef uriRef);
+
+ /**
+ * Get a GraphNode for the specified resource, The resource is assumed to be
+ * local, i.e. the method behaves like get(UriRef) for a Uri with an
+ * authority section contained in the Set retuned by
+ * <code>org.apache.clerezza.platform.config.PlatformConfig#getBaseUris()</code>
+ */
+ GraphNode getLocal(UriRef uriRef);
+
+ /**
+ * return true iff getLocal(uriRef).getNodeContext.size > 0
+ */
+ boolean existsLocal(UriRef uriRef);
+}