clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: CLEREZZA-868: editor backend supports graph assert/revoke in any serialization
Date Sun, 19 Jan 2014 21:01:47 GMT
Updated Branches:
  refs/heads/master 487ed6fce -> 8543665d7


CLEREZZA-868: editor backend supports graph assert/revoke in any serialization

Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/8543665d
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/8543665d
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/8543665d

Branch: refs/heads/master
Commit: 8543665d7ad57b61b60274b75b4653a39970763d
Parents: 487ed6f
Author: retobg <reto@apache.org>
Authored: Sun Jan 19 22:01:00 2014 +0100
Committer: retobg <reto@apache.org>
Committed: Sun Jan 19 22:01:00 2014 +0100

----------------------------------------------------------------------
 .../apache/clerezza/platform/content/Editor.java    | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/8543665d/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 62e277e..4a9a598 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
@@ -81,7 +81,8 @@ public class Editor extends FileServer {
     private static final Logger logger = LoggerFactory.getLogger(Editor.class);
 
     private Providers providers;
-    private final MediaType rdfXmlType = MediaType.valueOf("application/rdf+xml");
+    private final String rdfXml = "application/rdf+xml";
+    
     
     
     /**
@@ -128,13 +129,18 @@ public class Editor extends FileServer {
     @Path("post")
     public void postDiscobit(@QueryParam("graph") UriRef graphUri,
             @FormParam("assert") String assertedString,
-            @FormParam("revoke") String revokedString) {
-        MessageBodyReader<Graph> graphReader = providers.getMessageBodyReader(Graph.class,
Graph.class, null,rdfXmlType);
+            @FormParam("revoke") String revokedString,
+            @FormParam("rdfFormat") String rdfFormat) {
+        if (rdfFormat == null) {
+            rdfFormat = rdfXml;
+        }
+        MediaType mediaType = MediaType.valueOf(rdfFormat);
+        MessageBodyReader<Graph> graphReader = providers.getMessageBodyReader(Graph.class,
Graph.class, null,mediaType);
         final Graph assertedGraph;
         final Graph revokedGraph;
         try {
-            assertedGraph = graphReader.readFrom(Graph.class, Graph.class, new Annotation[0],
rdfXmlType, null, new ByteArrayInputStream(assertedString.getBytes()));
-            revokedGraph = graphReader.readFrom(Graph.class, Graph.class, new Annotation[0],
rdfXmlType, null, new ByteArrayInputStream(revokedString.getBytes()));
+            assertedGraph = graphReader.readFrom(Graph.class, Graph.class, new Annotation[0],
mediaType, null, new ByteArrayInputStream(assertedString.getBytes()));
+            revokedGraph = graphReader.readFrom(Graph.class, Graph.class, new Annotation[0],
mediaType, null, new ByteArrayInputStream(revokedString.getBytes()));
         } catch (IOException ex) {
             logger.error("reading graph {}", ex);
             throw new WebApplicationException(ex, 500);


Mime
View raw message