Search in sources :

Example 1 with TransactionLifecycleException

use of org.neo4j.server.rest.transactional.error.TransactionLifecycleException in project neo4j by neo4j.

the class TransactionalService method executeStatementsInNewTransaction.

@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public Response executeStatementsInNewTransaction(final InputStream input, @Context final UriInfo uriInfo, @Context final HttpServletRequest request) {
    try {
        usage.get(features).flag(http_tx_endpoint);
        SecurityContext securityContext = AuthorizedRequestWrapper.getSecurityContextFromHttpServletRequest(request);
        long customTransactionTimeout = HttpHeaderUtils.getTransactionTimeout(request, log);
        TransactionHandle transactionHandle = facade.newTransactionHandle(uriScheme, false, securityContext, customTransactionTimeout);
        return createdResponse(transactionHandle, executeStatements(input, transactionHandle, uriInfo.getBaseUri(), request));
    } catch (TransactionLifecycleException e) {
        return invalidTransaction(e, uriInfo.getBaseUri());
    }
}
Also used : SecurityContext(org.neo4j.kernel.api.security.SecurityContext) TransactionHandle(org.neo4j.server.rest.transactional.TransactionHandle) TransactionLifecycleException(org.neo4j.server.rest.transactional.error.TransactionLifecycleException) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 2 with TransactionLifecycleException

use of org.neo4j.server.rest.transactional.error.TransactionLifecycleException in project neo4j by neo4j.

the class TransactionalService method commitNewTransaction.

@POST
@Path("/commit")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public Response commitNewTransaction(final InputStream input, @Context final UriInfo uriInfo, @Context final HttpServletRequest request) {
    final TransactionHandle transactionHandle;
    try {
        SecurityContext securityContext = AuthorizedRequestWrapper.getSecurityContextFromHttpServletRequest(request);
        long customTransactionTimeout = HttpHeaderUtils.getTransactionTimeout(request, log);
        transactionHandle = facade.newTransactionHandle(uriScheme, true, securityContext, customTransactionTimeout);
    } catch (TransactionLifecycleException e) {
        return invalidTransaction(e, uriInfo.getBaseUri());
    }
    final StreamingOutput streamingResults = executeStatementsAndCommit(input, transactionHandle, uriInfo.getBaseUri(), request);
    return okResponse(streamingResults);
}
Also used : TransactionHandle(org.neo4j.server.rest.transactional.TransactionHandle) SecurityContext(org.neo4j.kernel.api.security.SecurityContext) StreamingOutput(javax.ws.rs.core.StreamingOutput) TransactionLifecycleException(org.neo4j.server.rest.transactional.error.TransactionLifecycleException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 SecurityContext (org.neo4j.kernel.api.security.SecurityContext)2 TransactionHandle (org.neo4j.server.rest.transactional.TransactionHandle)2 TransactionLifecycleException (org.neo4j.server.rest.transactional.error.TransactionLifecycleException)2 Path (javax.ws.rs.Path)1 StreamingOutput (javax.ws.rs.core.StreamingOutput)1