@Test public void getModificHistory() throws WebApplicationException, TTException, SAXException, IOException, ParserConfigurationException { final NodeIdRepresentation rid = new NodeIdRepresentation( CoreTestHelper.getStorage(CoreTestHelper.PATHS.PATH1.getFile())); rid.deleteResource(CoreTestHelper.RESOURCENAME, 8); final OutputStream output = new ByteArrayOutputStream(); treetank.getModificHistory(CoreTestHelper.RESOURCENAME, "1-2", false, output, true); final InputStream inpSt = new ByteArrayInputStream( ((ByteArrayOutputStream) output).toByteArray()); final Document doc = xmlDocument(inpSt); final NodeList nodes = doc.getElementsByTagName("continent"); final int changeditems = nodes.getLength(); assertEquals(ASSEQUALS, 1, changeditems); }
public OutputStream getModificHistory(final String resourceName, final String revisionRange, final boolean nodeid, final OutputStream output, final boolean wrap) throws JaxRxException, TTException { final StringTokenizer tokenizer = new StringTokenizer(revisionRange, "-"); final long revision1 = Long.valueOf(tokenizer.nextToken()); final long revision2 = Long.valueOf(tokenizer.nextToken()); if (revision1 < revision2 && revision2 <= getLastRevision(resourceName)) { long maxRestidRev1 = 0; long maxRestidRev2 = 0; AbsAxis axis = null; INodeReadTrx rtx = null; ISession session = null; final List<Long> modificRestids = new LinkedList<Long>(); final List<Long> restIdsRev1 = new LinkedList<Long>(); try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); axis = new XPathAxis(rtx, "./ modificRestids.add(nodeKey); } restIdsRev1.remove(nodeKey); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); final List<Long> restIdsRev1New = new LinkedList<Long>(); for (Long nodeKey : restIdsRev1) { rtx.moveTo(nodeKey); final long parentKey = rtx.getNode().getParentKey(); if (!restIdsRev1.contains(parentKey)) { restIdsRev1New.add(nodeKey); } } rtx.moveTo(ROOT_NODE); rtx.close(); if (wrap) { output.write(beginResult.getBytes()); } rtx = new NodeReadTrx(session.beginBucketRtx(revision2)); for (Long nodeKey : modificRestids) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision2).call(); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); for (Long nodeKey : restIdsRev1New) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision1).call(); } if (wrap) { output.write(endResult.getBytes()); } rtx.moveTo(ROOT_NODE); } catch (final Exception globExcep) { throw new JaxRxException(globExcep); } finally { WorkerHelper.closeRTX(rtx, session); } } else { throw new JaxRxException(400, "Bad user request"); } return output; }
DatabaseRepresentation { public OutputStream getModificHistory(final String resourceName, final String revisionRange, final boolean nodeid, final OutputStream output, final boolean wrap) throws JaxRxException, TTException { final StringTokenizer tokenizer = new StringTokenizer(revisionRange, "-"); final long revision1 = Long.valueOf(tokenizer.nextToken()); final long revision2 = Long.valueOf(tokenizer.nextToken()); if (revision1 < revision2 && revision2 <= getLastRevision(resourceName)) { long maxRestidRev1 = 0; long maxRestidRev2 = 0; AbsAxis axis = null; INodeReadTrx rtx = null; ISession session = null; final List<Long> modificRestids = new LinkedList<Long>(); final List<Long> restIdsRev1 = new LinkedList<Long>(); try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); axis = new XPathAxis(rtx, "./ modificRestids.add(nodeKey); } restIdsRev1.remove(nodeKey); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); final List<Long> restIdsRev1New = new LinkedList<Long>(); for (Long nodeKey : restIdsRev1) { rtx.moveTo(nodeKey); final long parentKey = rtx.getNode().getParentKey(); if (!restIdsRev1.contains(parentKey)) { restIdsRev1New.add(nodeKey); } } rtx.moveTo(ROOT_NODE); rtx.close(); if (wrap) { output.write(beginResult.getBytes()); } rtx = new NodeReadTrx(session.beginBucketRtx(revision2)); for (Long nodeKey : modificRestids) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision2).call(); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); for (Long nodeKey : restIdsRev1New) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision1).call(); } if (wrap) { output.write(endResult.getBytes()); } rtx.moveTo(ROOT_NODE); } catch (final Exception globExcep) { throw new JaxRxException(globExcep); } finally { WorkerHelper.closeRTX(rtx, session); } } else { throw new JaxRxException(400, "Bad user request"); } return output; } }
DatabaseRepresentation { public OutputStream getModificHistory(final String resourceName, final String revisionRange, final boolean nodeid, final OutputStream output, final boolean wrap) throws JaxRxException, TTException { final StringTokenizer tokenizer = new StringTokenizer(revisionRange, "-"); final long revision1 = Long.valueOf(tokenizer.nextToken()); final long revision2 = Long.valueOf(tokenizer.nextToken()); if (revision1 < revision2 && revision2 <= getLastRevision(resourceName)) { long maxRestidRev1 = 0; long maxRestidRev2 = 0; AbsAxis axis = null; INodeReadTrx rtx = null; ISession session = null; final List<Long> modificRestids = new LinkedList<Long>(); final List<Long> restIdsRev1 = new LinkedList<Long>(); try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); axis = new XPathAxis(rtx, "./ modificRestids.add(nodeKey); } restIdsRev1.remove(nodeKey); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); final List<Long> restIdsRev1New = new LinkedList<Long>(); for (Long nodeKey : restIdsRev1) { rtx.moveTo(nodeKey); final long parentKey = rtx.getNode().getParentKey(); if (!restIdsRev1.contains(parentKey)) { restIdsRev1New.add(nodeKey); } } rtx.moveTo(ROOT_NODE); rtx.close(); if (wrap) { output.write(beginResult.getBytes()); } rtx = new NodeReadTrx(session.beginBucketRtx(revision2)); for (Long nodeKey : modificRestids) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision2).call(); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); for (Long nodeKey : restIdsRev1New) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision1).call(); } if (wrap) { output.write(endResult.getBytes()); } rtx.moveTo(ROOT_NODE); } catch (final Exception globExcep) { throw new JaxRxException(globExcep); } finally { WorkerHelper.closeRTX(rtx, session); } } else { throw new JaxRxException(400, "Bad user request"); } return output; } DatabaseRepresentation(final IStorage pDatabase, final IBackendFactory pStorageFac,
        final IRevisioning pRevision); }
DatabaseRepresentation { public OutputStream getModificHistory(final String resourceName, final String revisionRange, final boolean nodeid, final OutputStream output, final boolean wrap) throws JaxRxException, TTException { final StringTokenizer tokenizer = new StringTokenizer(revisionRange, "-"); final long revision1 = Long.valueOf(tokenizer.nextToken()); final long revision2 = Long.valueOf(tokenizer.nextToken()); if (revision1 < revision2 && revision2 <= getLastRevision(resourceName)) { long maxRestidRev1 = 0; long maxRestidRev2 = 0; AbsAxis axis = null; INodeReadTrx rtx = null; ISession session = null; final List<Long> modificRestids = new LinkedList<Long>(); final List<Long> restIdsRev1 = new LinkedList<Long>(); try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); axis = new XPathAxis(rtx, "./ modificRestids.add(nodeKey); } restIdsRev1.remove(nodeKey); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); final List<Long> restIdsRev1New = new LinkedList<Long>(); for (Long nodeKey : restIdsRev1) { rtx.moveTo(nodeKey); final long parentKey = rtx.getNode().getParentKey(); if (!restIdsRev1.contains(parentKey)) { restIdsRev1New.add(nodeKey); } } rtx.moveTo(ROOT_NODE); rtx.close(); if (wrap) { output.write(beginResult.getBytes()); } rtx = new NodeReadTrx(session.beginBucketRtx(revision2)); for (Long nodeKey : modificRestids) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision2).call(); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); for (Long nodeKey : restIdsRev1New) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision1).call(); } if (wrap) { output.write(endResult.getBytes()); } rtx.moveTo(ROOT_NODE); } catch (final Exception globExcep) { throw new JaxRxException(globExcep); } finally { WorkerHelper.closeRTX(rtx, session); } } else { throw new JaxRxException(400, "Bad user request"); } return output; } DatabaseRepresentation(final IStorage pDatabase, final IBackendFactory pStorageFac,
        final IRevisioning pRevision); void createResource(final InputStream inputStream, final String resourceName); StreamingOutput getResource(final String resourceName,
        final Map<QueryParameter, String> queryParams); StreamingOutput performQueryOnResource(final String resource, final String query,
        final Map<QueryParameter, String> otherParams); StreamingOutput getResourcesNames(); void add(final InputStream input, final String resource); void deleteResource(final String resourceName); final boolean shred(final InputStream xmlInput, final String resource); long getLastRevision(final String resourceName); OutputStream getModificHistory(final String resourceName, // NOPMD this method needs alls these
        // functions
        final String revisionRange, final boolean nodeid, final OutputStream output, final boolean wrap); void revertToRevision(final String resourceName, final long backToRevision); }
DatabaseRepresentation { public OutputStream getModificHistory(final String resourceName, final String revisionRange, final boolean nodeid, final OutputStream output, final boolean wrap) throws JaxRxException, TTException { final StringTokenizer tokenizer = new StringTokenizer(revisionRange, "-"); final long revision1 = Long.valueOf(tokenizer.nextToken()); final long revision2 = Long.valueOf(tokenizer.nextToken()); if (revision1 < revision2 && revision2 <= getLastRevision(resourceName)) { long maxRestidRev1 = 0; long maxRestidRev2 = 0; AbsAxis axis = null; INodeReadTrx rtx = null; ISession session = null; final List<Long> modificRestids = new LinkedList<Long>(); final List<Long> restIdsRev1 = new LinkedList<Long>(); try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); axis = new XPathAxis(rtx, "./ modificRestids.add(nodeKey); } restIdsRev1.remove(nodeKey); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); final List<Long> restIdsRev1New = new LinkedList<Long>(); for (Long nodeKey : restIdsRev1) { rtx.moveTo(nodeKey); final long parentKey = rtx.getNode().getParentKey(); if (!restIdsRev1.contains(parentKey)) { restIdsRev1New.add(nodeKey); } } rtx.moveTo(ROOT_NODE); rtx.close(); if (wrap) { output.write(beginResult.getBytes()); } rtx = new NodeReadTrx(session.beginBucketRtx(revision2)); for (Long nodeKey : modificRestids) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision2).call(); } rtx.moveTo(ROOT_NODE); rtx.close(); rtx = new NodeReadTrx(session.beginBucketRtx(revision1)); for (Long nodeKey : restIdsRev1New) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision1).call(); } if (wrap) { output.write(endResult.getBytes()); } rtx.moveTo(ROOT_NODE); } catch (final Exception globExcep) { throw new JaxRxException(globExcep); } finally { WorkerHelper.closeRTX(rtx, session); } } else { throw new JaxRxException(400, "Bad user request"); } return output; } DatabaseRepresentation(final IStorage pDatabase, final IBackendFactory pStorageFac,
        final IRevisioning pRevision); void createResource(final InputStream inputStream, final String resourceName); StreamingOutput getResource(final String resourceName,
        final Map<QueryParameter, String> queryParams); StreamingOutput performQueryOnResource(final String resource, final String query,
        final Map<QueryParameter, String> otherParams); StreamingOutput getResourcesNames(); void add(final InputStream input, final String resource); void deleteResource(final String resourceName); final boolean shred(final InputStream xmlInput, final String resource); long getLastRevision(final String resourceName); OutputStream getModificHistory(final String resourceName, // NOPMD this method needs alls these
        // functions
        final String revisionRange, final boolean nodeid, final OutputStream output, final boolean wrap); void revertToRevision(final String resourceName, final long backToRevision);  }