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 2015/04/18 11:48:58 UTC
[6/7] clerezza git commit: CLEREZZA-960: mainly renicing
CLEREZZA-960: mainly renicing
Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/83342fb7
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/83342fb7
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/83342fb7
Branch: refs/heads/master
Commit: 83342fb773dcd833ee7e1e048bd6a7c70b17594d
Parents: 98a83b6
Author: Reto Gmuer <re...@apache.org>
Authored: Sat Apr 18 09:46:50 2015 +0000
Committer: Reto Gmuer <re...@apache.org>
Committed: Sat Apr 18 09:48:39 2015 +0000
----------------------------------------------------------------------
.../clerezza/platform/content/Editor.java | 45 +++++++++++---------
1 file changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/clerezza/blob/83342fb7/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 f011815..095f5fa 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
@@ -69,7 +69,7 @@ import org.wymiwyg.commons.util.dirbrowser.PathNode;
*/
@Component
@Service(Object.class)
-@Property(name="javax.ws.rs", boolValue=true)
+@Property(name = "javax.ws.rs", boolValue = true)
@Path("tools/editor")
public class Editor extends FileServer {
@@ -78,18 +78,15 @@ public class Editor extends FileServer {
@Reference
private TcManager tcManager;
-
+
@Reference
private Serializer serializer;
-
private static final Logger logger = LoggerFactory.getLogger(Editor.class);
private Providers providers;
private final String rdfXml = "application/rdf+xml";
-
-
-
+
/**
* On activation the {@link FileServer} is prepared
*
@@ -99,7 +96,6 @@ public class Editor extends FileServer {
configure(context.getBundleContext());
}
-
/**
* The providers are injected by the Jax-rs implementation and used to
* locate readers for the RDF content of the body
@@ -111,13 +107,12 @@ public class Editor extends FileServer {
this.providers = providers;
}
-
@GET
@Path("get")
public GraphNode getDiscobit(@QueryParam("resource") IRI uri,
@QueryParam("graph") IRI graphUri) {
- final Graph mGraph = graphUri == null ? cgProvider.getContentGraph() :
- tcManager.getGraph(graphUri);
+ final Graph mGraph = graphUri == null ? cgProvider.getContentGraph()
+ : tcManager.getGraph(graphUri);
return new GraphNode(uri, mGraph);
}
@@ -125,8 +120,8 @@ public class Editor extends FileServer {
* replaces the subgraph serialized with RDF/XML in <code>revokedString
* </code> with the one from <code>assertedString</code>.
*
- * @param graphUri the graph within which the replacement has to take place or null
- * for the content graph
+ * @param graphUri the graph within which the replacement has to take place
+ * or null for the content graph
* @param assertedString the asserted ImmutableGraph as RDF/XML
* @param revokedString the revoked ImmutableGraph as RDF/XML
*/
@@ -140,7 +135,7 @@ public class Editor extends FileServer {
rdfFormat = rdfXml;
}
MediaType mediaType = MediaType.valueOf(rdfFormat);
- MessageBodyReader<ImmutableGraph> graphReader = providers.getMessageBodyReader(ImmutableGraph.class, ImmutableGraph.class, null,mediaType);
+ MessageBodyReader<ImmutableGraph> graphReader = providers.getMessageBodyReader(ImmutableGraph.class, ImmutableGraph.class, null, mediaType);
final ImmutableGraph assertedGraph;
final ImmutableGraph revokedGraph;
try {
@@ -150,13 +145,13 @@ public class Editor extends FileServer {
logger.error("reading graph {}", ex);
throw new WebApplicationException(ex, 500);
}
- final Graph mGraph = graphUri == null ? cgProvider.getContentGraph() :
- tcManager.getGraph(graphUri);
+ final Graph mGraph = graphUri == null ? cgProvider.getContentGraph()
+ : tcManager.getGraph(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"));
+ System.out.println("Revoked:");
+ logGraph(revokedGraph);
+ System.out.println("Asserted:");
+ logGraph(assertedGraph);
GraphUtils.removeSubGraph(mGraph, revokedGraph);
} catch (NoSuchSubGraphException ex) {
throw new RuntimeException(ex);
@@ -164,6 +159,16 @@ public class Editor extends FileServer {
mGraph.addAll(assertedGraph);
}
+ private void logGraph(Graph graph) {
+ serializer.serialize(System.out, graph, "text/turtle");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ serializer.serialize(baos, graph, "text/turtle");
+ if (new String(baos.toByteArray()).contains("\r")) {
+ System.out.println("The above graph conatins \\r");
+ }
+ System.out.println();
+ }
+
@GET
//this is to work around
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@@ -173,5 +178,5 @@ public class Editor extends FileServer {
logger.debug("serving static {}", node);
return node;
}
-
+
}