Author: reto
Date: Tue May 17 21:37:39 2011
New Revision: 1104571
URL: http://svn.apache.org/viewvc?rev=1104571&view=rev
Log:
CLEREZZA-533: uris with a hash are not dereferenced. Added SCB to name. Removed
unreacheable code.
Modified:
incubator/clerezza/trunk/parent/rdf.storage.web/pom.xml
incubator/clerezza/trunk/parent/rdf.storage.web/src/main/scala/WebProxy.scala
Modified: incubator/clerezza/trunk/parent/rdf.storage.web/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.storage.web/pom.xml?rev=1104571&r1=1104570&r2=1104571&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/rdf.storage.web/pom.xml (original)
+++ incubator/clerezza/trunk/parent/rdf.storage.web/pom.xml Tue May 17 21:37:39
2011
@@ -8,7 +8,7 @@
<artifactId>rdf.storage.web</artifactId>
<version>0.1-incubating-SNAPSHOT</version>
<packaging>bundle</packaging>
- <name>Clerezza - Caching Web Storage Provider</name>
+ <name>Clerezza - SCB Caching Web Storage Provider</name>
<description>A (currently read-only) storage provider retrieving graphs
from the web. It
implements a caching proxy, relying on another provider for storing
triples.</description>
<dependencies>
Modified:
incubator/clerezza/trunk/parent/rdf.storage.web/src/main/scala/WebProxy.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.storage.web/src/main/scala/WebProxy.scala?rev=1104571&r1=1104570&r2=1104571&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/rdf.storage.web/src/main/scala/WebProxy.scala
(original)
+++
incubator/clerezza/trunk/parent/rdf.storage.web/src/main/scala/WebProxy.scala
Tue May 17 21:37:39 2011
@@ -160,6 +160,10 @@ class WebProxy extends WeightedTcProvide
*/
def getGraph(name: UriRef, updatePolicy: Cache.Value): Graph = {
logger.debug("getting graph " + name)
+ if (name.getUnicodeString.indexOf('#') != -1) {
+ logger.debug("not dereferencing URI with hash sign")
+ throw new NoSuchEntityException(name)
+ }
val cacheGraphName = new UriRef("urn:x-localinstance:/cache/" +
name.getUnicodeString)
//todo: follow redirects and keep track of them
//todo: keep track of headers especially date and etag. test
for etag similarity
@@ -185,31 +189,15 @@ class WebProxy extends WeightedTcProvide
tcProvider.createGraph(cacheGraphName,
remoteTriples)
}
}
- try {
- //the logic here is not quite right, as we don't look
at time of previous fetch.
- updatePolicy match {
- case Cache.Fetch => try {
- tcProvider.getGraph(cacheGraphName)
- } catch {
- case e: NoSuchEntityException =>
updateGraph(); tcProvider.getGraph(cacheGraphName)
- }
- case Cache.ForceUpdate => updateGraph();
tcProvider.getGraph(cacheGraphName)
- case Cache.CacheOnly =>
tcProvider.getGraph(cacheGraphName)
- }
- } catch {
- case ex: PrivilegedActionException => {
- var cause: Throwable = ex.getCause
- if
(cause.isInstanceOf[UnsupportedOperationException]) {
- throw
cause.asInstanceOf[UnsupportedOperationException]
- }
- if
(cause.isInstanceOf[EntityAlreadyExistsException]) {
- throw
cause.asInstanceOf[EntityAlreadyExistsException]
- }
- if (cause.isInstanceOf[RuntimeException]) {
- throw
cause.asInstanceOf[RuntimeException]
- }
- throw new RuntimeException(cause)
+ //the logic here is not quite right, as we don't look at time
of previous fetch.
+ updatePolicy match {
+ case Cache.Fetch => try {
+ tcProvider.getGraph(cacheGraphName)
+ } catch {
+ case e: NoSuchEntityException => updateGraph();
tcProvider.getGraph(cacheGraphName)
}
+ case Cache.ForceUpdate => updateGraph();
tcProvider.getGraph(cacheGraphName)
+ case Cache.CacheOnly =>
tcProvider.getGraph(cacheGraphName)
}
}
@@ -223,6 +211,8 @@ class WebProxy extends WeightedTcProvide
f match {
//the default, well established format
case SupportedFormat.RDF_XML => "1.0";
+ //n3 is a bit less well defined and/or
many parsers supports only subsets
+ case SupportedFormat.N3 => "0.6";
//we prefer most dedicated formats to
(X)HTML, not because those are "better",
//but just because it is quite likely
that the pure RDF format will be
//lighter (contain less presentation
markup), and it is also possible that HTML does not