DatabaseRepresentation { public OutputStream getModificHistory( final String resourceName, final String revisionRange, final boolean nodeid, final OutputStream output, final boolean wrap) throws JaxRxException, SirixException { final StringTokenizer tokenizer = new StringTokenizer(revisionRange, "-"); final int revision1 = Integer.valueOf(tokenizer.nextToken()); final int revision2 = Integer.valueOf(tokenizer.nextToken()); if (revision1 < revision2 && revision2 <= getLastRevision(resourceName)) { long maxRestidRev1 = 1; long maxRestidRev2 = 1; Database database = null; Axis axis = null; NodeReadTrx rtx = null; Session session = null; final List<Long> modificRestids = new LinkedList<Long>(); final List<Long> restIdsRev1 = new LinkedList<Long>(); try { database = Databases.openDatabase(mStoragePath); session = database.getSession(new SessionConfiguration.Builder( resourceName).build()); rtx = session.beginNodeReadTrx(revision1); axis = new XPathAxis(rtx, "./ modificRestids.add(nodeKey); } restIdsRev1.remove(nodeKey); } rtx.moveTo(Fixed.DOCUMENT_NODE_KEY.getStandardProperty()); rtx.close(); rtx = session.beginNodeReadTrx(revision1); final List<Long> restIdsRev1New = new LinkedList<Long>(); for (Long nodeKey : restIdsRev1) { rtx.moveTo(nodeKey); final long parentKey = rtx.getParentKey(); if (!restIdsRev1.contains(parentKey)) { restIdsRev1New.add(nodeKey); } } rtx.moveTo(Fixed.DOCUMENT_NODE_KEY.getStandardProperty()); rtx.close(); if (wrap) { output.write(beginResult.getBytes()); } rtx = session.beginNodeReadTrx(revision2); for (Long nodeKey : modificRestids) { rtx.moveTo(nodeKey); WorkerHelper.serializeXML(session, output, false, nodeid, nodeKey, revision2).call(); } rtx.moveTo(Fixed.DOCUMENT_NODE_KEY.getStandardProperty()); rtx.close(); rtx = session.beginNodeReadTrx(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(Fixed.DOCUMENT_NODE_KEY.getStandardProperty()); } catch (final Exception globExcep) { throw new JaxRxException(globExcep); } finally { WorkerHelper.closeRTX(rtx, session, database); } } else { throw new JaxRxException(400, "Bad user request"); } return output; } DatabaseRepresentation(final File storagePath); 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(); boolean 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 int backToRevision);  }
@Test public void getModificHistory() throws WebApplicationException, SirixException, SAXException, IOException, ParserConfigurationException { final NodeIdRepresentation rid = new NodeIdRepresentation( TestHelper.PATHS.PATH1.getFile()); rid.deleteResource(RESOURCENAME, 8); final OutputStream output = new ByteArrayOutputStream(); sirix.getModificHistory(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); }