@Override protected void doRollback(final DefaultTransactionStatus status) { final FcrepoTransactionObject tx = (FcrepoTransactionObject)status.getTransaction(); try { getClient().post(URI.create(baseUrl + "/" + tx.getSessionId() + ROLLBACK)).perform(); } catch (final FcrepoOperationFailedException ex) { LOGGER.debug("Transaction rollback failed: ", ex); throw new TransactionSystemException("Could not rollback fcrepo transaction"); } finally { tx.setSessionId(null); } }
@Override protected void doBegin(final Object transaction, final TransactionDefinition definition) { final FcrepoResponse response; final InputStream is = null; final String contentType = null; final FcrepoTransactionObject tx = (FcrepoTransactionObject)transaction; if (tx.getSessionId() == null) { try { response = getClient().post(URI.create(baseUrl + TRANSACTION)) .body(is, contentType).perform(); } catch (final FcrepoOperationFailedException ex) { LOGGER.debug("HTTP Operation failed: ", ex); throw new CannotCreateTransactionException("Could not create fcrepo transaction"); } if (response != null && response.getLocation() != null) { tx.setSessionId(response.getLocation().toString().substring(baseUrl.length() + 1)); } else { throw new CannotCreateTransactionException("Invalid response while creating transaction"); } } }
@Override protected void doCommit(final DefaultTransactionStatus status) { final FcrepoTransactionObject tx = (FcrepoTransactionObject)status.getTransaction(); final InputStream is = null; final String contentType = null; try { getClient().post(URI.create(baseUrl + "/" + tx.getSessionId() + COMMIT)) .body(is, contentType).perform(); } catch (final FcrepoOperationFailedException ex) { LOGGER.debug("Transaction commit failed: ", ex); throw new TransactionSystemException("Could not commit fcrepo transaction"); } finally { tx.setSessionId(null); } }
break; case POST: response = fcrepoClient.post(URI.create(url)).body(in.getBody(InputStream.class), contentType).perform(); exchange.getIn().setBody(extractResponseBodyAsStream(response.getBody(), exchange)); break;