Author: reto
Date: Sat May 14 10:52:47 2011
New Revision: 1103033
URL: http://svn.apache.org/viewvc?rev=1103033&view=rev
Log:
CLEREZZA-525: first proxy refactoring steps: reduced method visibility, added
commments.
Modified:
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala
incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
incubator/clerezza/trunk/parent/rdf.web.proxy/rdf.web.proxy.core/src/main/scala/org/apache/clerezza/rdf/web/proxy/WebProxy.scala
Modified:
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala?rev=1103033&r1=1103032&r2=1103033&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
(original)
+++
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
Sat May 14 10:52:47 2011
@@ -29,7 +29,6 @@ import javax.ws.rs.core.{Response, Conte
import org.apache.clerezza.rdf.utils.{UnionMGraph, GraphNode}
import org.apache.clerezza.rdf.core.impl.SimpleMGraph
import org.apache.clerezza.rdf.scala.utils.{EasyGraphNode, EasyGraph}
-import org.apache.clerezza.rdf.web.proxy.WebProxy
import java.util.Iterator
import org.apache.clerezza.rdf.core.{Triple, MGraph, UriRef}
import java.net._
@@ -38,6 +37,7 @@ import javax.ws.rs._
import java.io.{StringWriter, IOException, OutputStreamWriter}
import collection.JavaConversions._
import java.lang.Appendable
+import org.apache.clerezza.rdf.web.proxy.{Cache, WebProxy}
object PingBack {
@@ -156,7 +156,7 @@ class PingBack {
val pingInfo = webProxy.getResourceInfo(pingTo)
//initially I just test if something about pingback is there.
//todo: make the subject the resource itself.
- val filter = pingInfo.theGraph.filter(null, RDF.`type`,
PINGBACK.Container)
+ val filter = pingInfo.semantics(Cache.CacheOnly).filter(null,
RDF.`type`, PINGBACK.Container)
val res = if (filter.hasNext) try {
val to = new URL(pingTo.getUnicodeString)
if (to.getProtocol == "http" || to.getProtocol ==
"https") {
Modified:
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala?rev=1103033&r1=1103032&r2=1103033&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala
(original)
+++
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala
Sat May 14 10:52:47 2011
@@ -226,7 +226,7 @@ class XmlPerson(args: XmlResult.Argument
* in the cache?
*
*/
- def definedHere(uri: UriRef):Boolean =
uri.getUnicodeString.startsWith(webIdInfo.representationUri)
+ def definedHere(uri: UriRef):Boolean =
uri.getUnicodeString.startsWith(webIdInfo.graphUriRef.getUnicodeString)
def personHtml(p: RichGraphNode): NodeSeq = {
Modified:
incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala?rev=1103033&r1=1103032&r2=1103033&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
(original)
+++
incubator/clerezza/trunk/parent/platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
Sat May 14 10:52:47 2011
@@ -87,7 +87,7 @@ class WebIdGraphsService extends WebProx
val unionGraph = if (isLocal) {
new UnionMGraph(localGraph,
systemTriples)
} else {
- new UnionMGraph(localGraph,
theGraph, systemTriples)
+ new UnionMGraph(localGraph,
semantics(Cache.CacheOnly), systemTriples)
}
new SecuredMGraph(unionGraph,
localGraphUri, tcManager.getTcAccessController)
}
@@ -100,7 +100,7 @@ class WebIdGraphsService extends WebProx
lazy val localGraphUri = {
if (isLocal) graphUriRef
else {
- new
UriRef(platformConfig.getDefaultBaseUri.getUnicodeString+"user/"+representationUri)
+ new
UriRef(platformConfig.getDefaultBaseUri.getUnicodeString+"user/"+graphUriRef.getUnicodeString)
}
}
Modified:
incubator/clerezza/trunk/parent/rdf.web.proxy/rdf.web.proxy.core/src/main/scala/org/apache/clerezza/rdf/web/proxy/WebProxy.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.web.proxy/rdf.web.proxy.core/src/main/scala/org/apache/clerezza/rdf/web/proxy/WebProxy.scala?rev=1103033&r1=1103032&r2=1103033&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/rdf.web.proxy/rdf.web.proxy.core/src/main/scala/org/apache/clerezza/rdf/web/proxy/WebProxy.scala
(original)
+++
incubator/clerezza/trunk/parent/rdf.web.proxy/rdf.web.proxy.core/src/main/scala/org/apache/clerezza/rdf/web/proxy/WebProxy.scala
Sat May 14 10:52:47 2011
@@ -93,8 +93,9 @@ class WebProxy {
def fetchSemantics(uri: UriRef, update: Cache.Value = Cache.Fetch):
Option[GraphNode] = {
val resource = getResourceInfo(uri, update)
return try {
- Some(new GraphNode(uri, resource.theGraph))
+ Some(new GraphNode(uri,
resource.semantics(Cache.CacheOnly)))
} catch {
+ //It seems this is never thrown
case e: NoSuchEntityException => None
}
@@ -124,6 +125,9 @@ class WebProxy {
class ResourceInfo(url: UriRef) {
val uriString = url.getUnicodeString
+ /**
+ * true if the resource uri starts with a baseUri of this
instance
+ */
lazy val isLocal: Boolean = {
import scala.collection.JavaConversions._
//todo: the base uris are checked on every invocation.
This seems somewhat heavy.
@@ -132,7 +136,7 @@ class WebProxy {
// the graph containing the local cache of the resource
//todo: watch out: if someone can just make us add graphs to
tcmanager even when there is no data...
- lazy val theGraph: MGraph = try {
+ private lazy val theGraph: MGraph = try {
val g = tcManager.getMGraph(graphUriRef)
g
} catch {
@@ -150,7 +154,7 @@ class WebProxy {
* the URI of the representation, the information resource,
which ends up
* being our handle on the graph too.
*/
- lazy val representationUri = {
+ private lazy val graphUriString = {
val hashPos = uriString.indexOf('#')
if (hashPos != -1) {
uriString.substring(0, hashPos) //though could
there not be an odd case of hash and redirects?
@@ -161,12 +165,14 @@ class WebProxy {
}
}
-
+ /**
+ * the uri from which the description of this resource was
dereferenced
+ */
lazy val graphUriRef = {
- new UriRef(representationUri)
+ new UriRef(graphUriString)
}
- lazy val finalRedirectLocation = {
+ private lazy val finalRedirectLocation = {
finalRedirectLocationFor(url.getUnicodeString)
}
@@ -216,7 +222,7 @@ class WebProxy {
//todo: add GRDDL functionality, so that other return types can
be processed too
//todo: enable ftp and other formats (though content
negotiation won't work there)
private def updateGraph() {
- val url = new URL(representationUri)
+ val url = new URL(graphUriString)
val connection = url.openConnection()
connection match {
case hc: HttpURLConnection =>
hc.addRequestProperty("Accept", acceptHeader);