Search in sources :

Example 1 with FailureEvent

use of org.neo4j.server.http.cypher.format.api.FailureEvent in project neo4j by neo4j.

the class LineDelimitedEventSourceJoltSerializer method handleEvent.

@Override
public final void handleEvent(OutputEvent event) {
    switch(event.getType()) {
        case STATEMENT_START:
            StatementStartEvent statementStartEvent = (StatementStartEvent) event;
            InputStatement inputStatement = JsonMessageBodyReader.getInputStatement(parameters, statementStartEvent.getStatement());
            writeStatementStart(statementStartEvent, inputStatement);
            break;
        case RECORD:
            writeRecord((RecordEvent) event);
            break;
        case STATEMENT_END:
            StatementEndEvent statementEndEvent = (StatementEndEvent) event;
            writeStatementEnd(statementEndEvent);
            break;
        case FAILURE:
            FailureEvent failureEvent = (FailureEvent) event;
            writeFailure(failureEvent);
            break;
        case TRANSACTION_INFO:
            TransactionInfoEvent transactionInfoEvent = (TransactionInfoEvent) event;
            writeErrorWrapper();
            writeTransactionInfo(transactionInfoEvent);
            break;
        default:
            throw new IllegalStateException("Unsupported event encountered:" + event.getType());
    }
}
Also used : TransactionInfoEvent(org.neo4j.server.http.cypher.format.api.TransactionInfoEvent) StatementStartEvent(org.neo4j.server.http.cypher.format.api.StatementStartEvent) FailureEvent(org.neo4j.server.http.cypher.format.api.FailureEvent) StatementEndEvent(org.neo4j.server.http.cypher.format.api.StatementEndEvent) InputStatement(org.neo4j.server.http.cypher.format.input.json.InputStatement)

Example 2 with FailureEvent

use of org.neo4j.server.http.cypher.format.api.FailureEvent in project neo4j by neo4j.

the class LineDelimitedEventSourceJoltSerializer method writeErrors.

private void writeErrors() {
    try {
        jsonGenerator.writeArrayFieldStart("errors");
        try {
            for (FailureEvent error : errors) {
                try {
                    jsonGenerator.writeStartObject();
                    jsonGenerator.writeObjectField("code", error.getStatus().code().serialize());
                    jsonGenerator.writeObjectField("message", error.getMessage());
                } finally {
                    jsonGenerator.writeEndObject();
                }
            }
        } finally {
            jsonGenerator.writeEndArray();
        }
    } catch (IOException e) {
        throw new ConnectionException("Failed to write to the response stream", e);
    }
}
Also used : FailureEvent(org.neo4j.server.http.cypher.format.api.FailureEvent) IOException(java.io.IOException) ConnectionException(org.neo4j.server.http.cypher.format.api.ConnectionException)

Example 3 with FailureEvent

use of org.neo4j.server.http.cypher.format.api.FailureEvent in project neo4j by neo4j.

the class ExecutionResultSerializer method writeErrors.

private void writeErrors() {
    try {
        ensureDocumentOpen();
        jsonGenerator.writeArrayFieldStart("errors");
        try {
            for (FailureEvent error : errors) {
                try {
                    jsonGenerator.writeStartObject();
                    jsonGenerator.writeObjectField("code", error.getStatus().code().serialize());
                    jsonGenerator.writeObjectField("message", error.getMessage());
                } finally {
                    jsonGenerator.writeEndObject();
                }
            }
        } finally {
            jsonGenerator.writeEndArray();
            currentState = State.ERRORS_WRITTEN;
        }
    } catch (IOException e) {
        throw new ConnectionException("Failed to write to the response stream", e);
    }
}
Also used : FailureEvent(org.neo4j.server.http.cypher.format.api.FailureEvent) IOException(java.io.IOException) ConnectionException(org.neo4j.server.http.cypher.format.api.ConnectionException)

Example 4 with FailureEvent

use of org.neo4j.server.http.cypher.format.api.FailureEvent in project neo4j by neo4j.

the class ExecutionResultSerializer method handleEvent.

public final void handleEvent(OutputEvent event) {
    switch(event.getType()) {
        case STATEMENT_START:
            StatementStartEvent statementStartEvent = (StatementStartEvent) event;
            InputStatement inputStatement = JsonMessageBodyReader.getInputStatement(parameters, statementStartEvent.getStatement());
            writeStatementStart(statementStartEvent, inputStatement);
            break;
        case RECORD:
            writeRecord((RecordEvent) event);
            break;
        case STATEMENT_END:
            StatementEndEvent statementEndEvent = (StatementEndEvent) event;
            writeStatementEnd(statementEndEvent);
            break;
        case FAILURE:
            FailureEvent failureEvent = (FailureEvent) event;
            writeFailure(failureEvent);
            break;
        case TRANSACTION_INFO:
            TransactionInfoEvent transactionInfoEvent = (TransactionInfoEvent) event;
            writeTransactionInfo(transactionInfoEvent);
            break;
        default:
            throw new IllegalStateException("Unsupported event encountered:" + event.getType());
    }
}
Also used : TransactionInfoEvent(org.neo4j.server.http.cypher.format.api.TransactionInfoEvent) StatementStartEvent(org.neo4j.server.http.cypher.format.api.StatementStartEvent) FailureEvent(org.neo4j.server.http.cypher.format.api.FailureEvent) StatementEndEvent(org.neo4j.server.http.cypher.format.api.StatementEndEvent) InputStatement(org.neo4j.server.http.cypher.format.input.json.InputStatement)

Aggregations

FailureEvent (org.neo4j.server.http.cypher.format.api.FailureEvent)4 IOException (java.io.IOException)2 ConnectionException (org.neo4j.server.http.cypher.format.api.ConnectionException)2 StatementEndEvent (org.neo4j.server.http.cypher.format.api.StatementEndEvent)2 StatementStartEvent (org.neo4j.server.http.cypher.format.api.StatementStartEvent)2 TransactionInfoEvent (org.neo4j.server.http.cypher.format.api.TransactionInfoEvent)2 InputStatement (org.neo4j.server.http.cypher.format.input.json.InputStatement)2