@Test public final void testModifyResource() throws JaxRxException, TTException { final InputStream inputStream = new ByteArrayInputStream("<testNode/>".getBytes()); long lastRevision = treetank.getLastRevision(RESOURCENAME); ridWorker.modifyResource(RESOURCENAME, NODEIDTOMODIFY, inputStream); assertEquals("Test modify resource", treetank.getLastRevision(RESOURCENAME), ++lastRevision); }
public void modifyResource(final String resourceName, final long nodeId, final InputStream newValue) throws JaxRxException { synchronized (resourceName) { ISession session = null; INodeWriteTrx wtx = null; boolean abort = false; if (mDatabase.existsResource(resourceName)) { try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); if (wtx.moveTo(nodeId)) { final long parentKey = wtx.getNode().getParentKey(); wtx.remove(); wtx.moveTo(parentKey); WorkerHelper.shredInputStream(wtx, newValue, EShredderInsert.ADDASFIRSTCHILD); } else { throw new JaxRxException(404, NOTFOUND); } } catch (final TTException exc) { abort = true; throw new JaxRxException(exc); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Requested resource not found"); } } }
NodeIdRepresentation { public void modifyResource(final String resourceName, final long nodeId, final InputStream newValue) throws JaxRxException { synchronized (resourceName) { ISession session = null; INodeWriteTrx wtx = null; boolean abort = false; if (mDatabase.existsResource(resourceName)) { try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); if (wtx.moveTo(nodeId)) { final long parentKey = wtx.getNode().getParentKey(); wtx.remove(); wtx.moveTo(parentKey); WorkerHelper.shredInputStream(wtx, newValue, EShredderInsert.ADDASFIRSTCHILD); } else { throw new JaxRxException(404, NOTFOUND); } } catch (final TTException exc) { abort = true; throw new JaxRxException(exc); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Requested resource not found"); } } } }
NodeIdRepresentation { public void modifyResource(final String resourceName, final long nodeId, final InputStream newValue) throws JaxRxException { synchronized (resourceName) { ISession session = null; INodeWriteTrx wtx = null; boolean abort = false; if (mDatabase.existsResource(resourceName)) { try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); if (wtx.moveTo(nodeId)) { final long parentKey = wtx.getNode().getParentKey(); wtx.remove(); wtx.moveTo(parentKey); WorkerHelper.shredInputStream(wtx, newValue, EShredderInsert.ADDASFIRSTCHILD); } else { throw new JaxRxException(404, NOTFOUND); } } catch (final TTException exc) { abort = true; throw new JaxRxException(exc); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Requested resource not found"); } } } NodeIdRepresentation(final IStorage pDatabase); }
NodeIdRepresentation { public void modifyResource(final String resourceName, final long nodeId, final InputStream newValue) throws JaxRxException { synchronized (resourceName) { ISession session = null; INodeWriteTrx wtx = null; boolean abort = false; if (mDatabase.existsResource(resourceName)) { try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); if (wtx.moveTo(nodeId)) { final long parentKey = wtx.getNode().getParentKey(); wtx.remove(); wtx.moveTo(parentKey); WorkerHelper.shredInputStream(wtx, newValue, EShredderInsert.ADDASFIRSTCHILD); } else { throw new JaxRxException(404, NOTFOUND); } } catch (final TTException exc) { abort = true; throw new JaxRxException(exc); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Requested resource not found"); } } } NodeIdRepresentation(final IStorage pDatabase); StreamingOutput getResource(final String resourceName, final long nodeId,
        final Map<QueryParameter, String> queryParams); StreamingOutput getResourceByAT(final String resourceName, final long nodeId,
        final Map<QueryParameter, String> queryParams, final EIdAccessType accessType); StreamingOutput performQueryOnResource(final String resourceName, final long nodeId,
        final String query, final Map<QueryParameter, String> queryParams); void deleteResource(final String resourceName, final long nodeId); void modifyResource(final String resourceName, final long nodeId, final InputStream newValue); void addSubResource(final String resourceName, final long nodeId, final InputStream input,
        final EIdAccessType type); }
NodeIdRepresentation { public void modifyResource(final String resourceName, final long nodeId, final InputStream newValue) throws JaxRxException { synchronized (resourceName) { ISession session = null; INodeWriteTrx wtx = null; boolean abort = false; if (mDatabase.existsResource(resourceName)) { try { session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); if (wtx.moveTo(nodeId)) { final long parentKey = wtx.getNode().getParentKey(); wtx.remove(); wtx.moveTo(parentKey); WorkerHelper.shredInputStream(wtx, newValue, EShredderInsert.ADDASFIRSTCHILD); } else { throw new JaxRxException(404, NOTFOUND); } } catch (final TTException exc) { abort = true; throw new JaxRxException(exc); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Requested resource not found"); } } } NodeIdRepresentation(final IStorage pDatabase); StreamingOutput getResource(final String resourceName, final long nodeId,
        final Map<QueryParameter, String> queryParams); StreamingOutput getResourceByAT(final String resourceName, final long nodeId,
        final Map<QueryParameter, String> queryParams, final EIdAccessType accessType); StreamingOutput performQueryOnResource(final String resourceName, final long nodeId,
        final String query, final Map<QueryParameter, String> queryParams); void deleteResource(final String resourceName, final long nodeId); void modifyResource(final String resourceName, final long nodeId, final InputStream newValue); void addSubResource(final String resourceName, final long nodeId, final InputStream input,
        final EIdAccessType type);  }