@Override public Iterator<LiteralNode> descend(ContextNode contextNode) { return contextNode.getAllLiteralNodes(); } };
@Override public InterceptorResult after(Operation operation, Graph operationResultGraph, ExecutionContext executionContext) throws Xdi2MessagingException { for (LiteralNode literal : operationResultGraph.getRootContextNode(true).getAllLiteralNodes()) { String encryptedLiteralDataString = literal.getLiteralDataString(); if (encryptedLiteralDataString == null) continue; String literalDataString; try { literalDataString = this.getLiteralCryptoService().decryptLiteralDataString(encryptedLiteralDataString); } catch (Exception ex) { if (log.isDebugEnabled()) log.debug("Problem while decrypting literal string: " + ex.getMessage(), ex); continue; } Object literalData = AbstractLiteralNode.stringToLiteralData(literalDataString); literal.setLiteralData(literalData); } // done return InterceptorResult.DEFAULT; }
list.add(new MappingContextNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllContextNodes())); list.add(new MappingRelationStatementIterator(orderedGraph.getRootContextNode(true).getAllRelations())); list.add(new MappingLiteralNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllLiteralNodes()));
list.add(new MappingContextNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllContextNodes())); list.add(new MappingRelationStatementIterator(orderedGraph.getRootContextNode(true).getAllRelations())); list.add(new MappingLiteralNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllLiteralNodes()));
list.add(new MappingContextNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllContextNodes())); list.add(new MappingRelationStatementIterator(orderedGraph.getRootContextNode(true).getAllRelations())); list.add(new MappingLiteralNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllLiteralNodes()));
list.add(new MappingContextNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllContextNodes())); list.add(new MappingRelationStatementIterator(orderedGraph.getRootContextNode(true).getAllRelations())); list.add(new MappingLiteralNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllLiteralNodes()));
private void writeInternal(Graph graph, JsonObject jsonObject) throws IOException { // write ordered? Graph orderedGraph = null; IterableIterator<Statement> statements; if (this.isWriteOrdered()) { MemoryGraphFactory memoryGraphFactory = new MemoryGraphFactory(); memoryGraphFactory.setSortmode(MemoryGraphFactory.SORTMODE_ALPHA); orderedGraph = memoryGraphFactory.openGraph(); CopyUtil.copyGraph(graph, orderedGraph, null); List<Iterator<? extends Statement>> list = new ArrayList<Iterator<? extends Statement>> (); list.add(new MappingContextNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllContextNodes())); list.add(new MappingRelationStatementIterator(orderedGraph.getRootContextNode(true).getAllRelations())); list.add(new MappingLiteralNodeStatementIterator(orderedGraph.getRootContextNode(true).getAllLiteralNodes())); statements = new CompositeIterator<Statement> (list.iterator()); } else { statements = graph.getRootContextNode(true).getAllStatements(); } // ignore implied statements if (! this.isWriteImplied()) statements = new SelectingNotImpliedStatementIterator(statements); // write the statements for (Statement statement : statements) { XDIStatement XDIstatement = statement.getXDIStatement(); // put the statement into the JSON object this.putStatementIntoJsonObject(XDIstatement, jsonObject); } // done if (orderedGraph != null) orderedGraph.close(); }
assertFalse(root.getAllContextNodes().hasNext()); assertFalse(root.getAllRelations().hasNext()); assertFalse(root.getAllLiteralNodes().hasNext()); assertTrue(root.getAllContextNodes().hasNext()); assertTrue(root.getAllRelations().hasNext()); assertTrue(root.getAllLiteralNodes().hasNext()); assertTrue(root.getAllContextNodes().hasNext()); assertTrue(root.getAllRelations().hasNext()); assertTrue(root.getAllLiteralNodes().hasNext()); assertFalse(root.getAllContextNodes().hasNext()); assertFalse(root.getAllRelations().hasNext()); assertFalse(root.getAllLiteralNodes().hasNext());