PostBuilder builder = new PostBuilder(passEntityUri, client); builder.body(content, (String) params.get("content-type")); } else { builder.body(content); builder.slug((String)params.get("slug")); builder.digestSha256((String) params.get("sha256")); builder.digestMd5((String) params.get("md5")); builder.digestSha1((String) params.get("sha1")); builder.filename((String) params.get("filename")); } catch (FcrepoOperationFailedException e) { throw new RuntimeException(e.getMessage(), e); try (FcrepoResponse response = builder.perform()) { return response.getLocation(); } catch (Exception e) {
@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); } }
/** * Make a POST request to create a new resource within an LDP container. * * @param url the URL of the resource to which to POST * @return a post request builder object */ public PostBuilder post(final URI url) { return new PostBuilder(url, this); }
@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"); } } }
PostBuilder builder = new PostBuilder(passEntityUri, client); builder.body(content, (String) params.get("content-type")); } else { builder.body(content); builder.slug((String)params.get("slug")); builder.digestSha256((String) params.get("sha256")); builder.digestMd5((String) params.get("md5")); builder.digestSha1((String) params.get("sha1")); builder.filename((String) params.get("filename")); } catch (FcrepoOperationFailedException e) { throw new RuntimeException(e.getMessage(), e); try (FcrepoResponse response = builder.perform()) { return response.getLocation(); } catch (Exception e) {