Author: bblfish
Date: Wed Nov 10 21:44:38 2010
New Revision: 1033733
URL: http://svn.apache.org/viewvc?rev=1033733&view=rev
Log:
Changed the logic for content negotiations. Added XHTML and HTML mime types to
do this.
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/SupportedFormat.java
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala?rev=1033733&r1=1033732&r2=1033733&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.users/core/src/main/scala/org/apache/clerezza/platform/users/WebIdGraphsService.scala
Wed Nov 10 21:44:38 2010
@@ -79,15 +79,21 @@ class WebIdGraphsService() {
(for (f <- parser.getSupportedFormats) yield {
val qualityOfFormat = {
f match {
- //the default format
+ //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.5";
- case _ => "0.8";
+ //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
+ //ligher (contain less
presentation markup), and it is also possible that HTML does not
+ //contain any RDFa, but
just points to another format.
+ case SupportedFormat.XHTML =>
"0.5";
+ //we prefer XHTML over
html, because parsing (shoule) be easier
+ case SupportedFormat.HTML =>
"0.4";
+ //all other formats
known currently are structured formats
+ case _ => "0.8"
}
}
f+"; q="+qualityOfFormat+","
- }).mkString +" *; q=.1"
+ }).mkString +" *; q=.1" //with grddl should add */*
}
def getWebIdGraphs(webId: UriRef): WebIdGraphs = {
@@ -143,16 +149,15 @@ class WebIdGraphsService() {
}
lazy val localGraph = try {
- val g = tcManager.getMGraph(localGraphUri)
- g
+ tcManager.getMGraph(localGraphUri)
} catch {
case e: NoSuchEntityException => {
import
scala.collection.JavaConversions._
tcManager.getTcAccessController.
setRequiredReadPermissionStrings(localGraphUri,
- List(new
TcPermission(Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ).toString))
+
List(new
TcPermission(Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ).toString))
tcManager.createMGraph(localGraphUri)
- }
+ }
}
lazy val representationGraphUri = {
@@ -227,7 +232,7 @@ class WebIdGraphsService() {
}
new SecuredMGraph(unionGraph,
localGraphUri, tcManager.getTcAccessController)
}
- })
+ })
}
}
}
\ No newline at end of file
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/SupportedFormat.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/SupportedFormat.java?rev=1033733&r1=1033732&r2=1033733&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/SupportedFormat.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/SupportedFormat.java
Wed Nov 10 21:44:38 2010
@@ -16,34 +16,37 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.clerezza.rdf.core.serializedform;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation is used to annotate {...@link ParsingProvider}s to indicate
- * the format(s) they support.
- *
- * @author reto
- */
-...@target({ElementType.TYPE})
-...@retention(RetentionPolicy.RUNTIME)
-public @interface SupportedFormat {
-
- public static final String RDF_XML = "application/rdf+xml";
- public static final String TURTLE = "text/turtle";
- public static final String X_TURTLE = "application/x-turtle";
- public static final String N_TRIPLE = "text/rdf+nt";
- public static final String N3 = "text/rdf+n3";
- public static final String RDF_JSON = "application/rdf+json";
- /**
- * A list of format Identifiers (typically MIME-types) types without
- * parameter (without ';'-character).
- * E.g. {"application/rdf+xml","application/turtle"}
- */
- String[] value();
-
-}
+package org.apache.clerezza.rdf.core.serializedform;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation is used to annotate {...@link ParsingProvider}s to indicate
+ * the format(s) they support.
+ *
+ * @author reto
+ */
+...@target({ElementType.TYPE})
+...@retention(RetentionPolicy.RUNTIME)
+public @interface SupportedFormat {
+
+ public static final String RDF_XML = "application/rdf+xml";
+ public static final String TURTLE = "text/turtle";
+ public static final String X_TURTLE = "application/x-turtle";
+ public static final String N_TRIPLE = "text/rdf+nt";
+ public static final String N3 = "text/rdf+n3";
+ public static final String RDF_JSON = "application/rdf+json";
+ //both html and xhtml can be rdf formats with RDFa
+ public static final String XHTML = "application/xhtml+xml";
+ public static final String HTML = "text/html";
+
+ /**
+ * A list of format Identifiers (typically MIME-types) types without
+ * parameter (without ';'-character).
+ * E.g. {"application/rdf+xml","application/turtle"}
+ */
+ String[] value();
+}