Search in sources :

Example 1 with WriteOperationsNotAllowedException

use of org.neo4j.graphdb.WriteOperationsNotAllowedException in project neo4j by neo4j.

the class Invocation method executeStatements.

private void executeStatements() {
    try {
        while (outputError == null) {
            memoryPool.reserveHeap(Statement.SHALLOW_SIZE);
            try {
                Statement statement = readStatement();
                if (statement == null) {
                    return;
                }
                executeStatement(statement);
            } finally {
                memoryPool.releaseHeap(Statement.SHALLOW_SIZE);
            }
        }
    } catch (InputFormatException e) {
        handleNeo4jError(Status.Request.InvalidFormat, e);
    } catch (KernelException | Neo4jException | AuthorizationViolationException | WriteOperationsNotAllowedException e) {
        handleNeo4jError(e.status(), e);
    } catch (DeadlockDetectedException e) {
        handleNeo4jError(Status.Transaction.DeadlockDetected, e);
    } catch (Exception e) {
        Throwable cause = e.getCause();
        if (cause instanceof Status.HasStatus) {
            handleNeo4jError(((Status.HasStatus) cause).status(), cause);
        } else {
            handleNeo4jError(Status.Statement.ExecutionFailed, e);
        }
    }
}
Also used : Status(org.neo4j.kernel.api.exceptions.Status) Statement(org.neo4j.server.http.cypher.format.api.Statement) DeadlockDetectedException(org.neo4j.kernel.DeadlockDetectedException) Neo4jException(org.neo4j.exceptions.Neo4jException) InputFormatException(org.neo4j.server.http.cypher.format.api.InputFormatException) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) Neo4jException(org.neo4j.exceptions.Neo4jException) WriteOperationsNotAllowedException(org.neo4j.graphdb.WriteOperationsNotAllowedException) KernelException(org.neo4j.exceptions.KernelException) InputFormatException(org.neo4j.server.http.cypher.format.api.InputFormatException) ConnectionException(org.neo4j.server.http.cypher.format.api.ConnectionException) AuthorizationViolationException(org.neo4j.graphdb.security.AuthorizationViolationException) InvalidSemanticsException(org.neo4j.exceptions.InvalidSemanticsException) DeadlockDetectedException(org.neo4j.kernel.DeadlockDetectedException) OutputFormatException(org.neo4j.server.http.cypher.format.api.OutputFormatException) WriteOperationsNotAllowedException(org.neo4j.graphdb.WriteOperationsNotAllowedException) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) KernelException(org.neo4j.exceptions.KernelException) AuthorizationViolationException(org.neo4j.graphdb.security.AuthorizationViolationException)

Example 2 with WriteOperationsNotAllowedException

use of org.neo4j.graphdb.WriteOperationsNotAllowedException in project neo4j-documentation by neo4j.

the class ReadOnlyDocTest method makeSureDbIsOnlyReadable.

@Test
public void makeSureDbIsOnlyReadable() {
    // when
    try (Transaction tx = graphDb.beginTx()) {
        tx.createNode();
        tx.commit();
        fail("expected exception");
    }// then
     catch (Exception e) {
        assertTrue("Database should be in read only mode", Exceptions.contains(e, c -> c instanceof WriteOperationsNotAllowedException));
    // ok
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) IOException(java.io.IOException) WriteOperationsNotAllowedException(org.neo4j.graphdb.WriteOperationsNotAllowedException) ReadOnlyDbException(org.neo4j.kernel.api.exceptions.ReadOnlyDbException) WriteOperationsNotAllowedException(org.neo4j.graphdb.WriteOperationsNotAllowedException) Test(org.junit.Test)

Aggregations

WriteOperationsNotAllowedException (org.neo4j.graphdb.WriteOperationsNotAllowedException)2 IOException (java.io.IOException)1 Test (org.junit.Test)1 InvalidSemanticsException (org.neo4j.exceptions.InvalidSemanticsException)1 KernelException (org.neo4j.exceptions.KernelException)1 Neo4jException (org.neo4j.exceptions.Neo4jException)1 Transaction (org.neo4j.graphdb.Transaction)1 AuthorizationViolationException (org.neo4j.graphdb.security.AuthorizationViolationException)1 DeadlockDetectedException (org.neo4j.kernel.DeadlockDetectedException)1 ReadOnlyDbException (org.neo4j.kernel.api.exceptions.ReadOnlyDbException)1 Status (org.neo4j.kernel.api.exceptions.Status)1 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)1 ConnectionException (org.neo4j.server.http.cypher.format.api.ConnectionException)1 InputFormatException (org.neo4j.server.http.cypher.format.api.InputFormatException)1 OutputFormatException (org.neo4j.server.http.cypher.format.api.OutputFormatException)1 Statement (org.neo4j.server.http.cypher.format.api.Statement)1