use of org.neo4j.server.http.cypher.format.api.ConnectionException in project neo4j by neo4j.
the class ExecutionResultSerializer method writeRecord.
void writeRecord(RecordEvent recordEvent) {
try {
TransactionStateChecker txStateChecker = TransactionStateChecker.create(transactionHandle.getContext());
jsonGenerator.writeStartObject();
try {
writer.write(jsonGenerator, recordEvent, txStateChecker);
} finally {
jsonGenerator.writeEndObject();
}
flush();
} catch (JsonGenerationException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new ConnectionException("Failed to write to the connection", e);
}
}
use of org.neo4j.server.http.cypher.format.api.ConnectionException in project neo4j by neo4j.
the class ExecutionResultSerializer method writeStatementEnd.
void writeStatementEnd(StatementEndEvent statementEndEvent) {
try {
jsonGenerator.writeEndArray();
if (inputStatement.includeStats()) {
writeStats(statementEndEvent.getQueryStatistics());
}
if (statementEndEvent.getQueryExecutionType().requestedExecutionPlanDescription()) {
writeRootPlanDescription(statementEndEvent.getExecutionPlanDescription());
}
// </result>
jsonGenerator.writeEndObject();
currentState = State.RESULTS_OPEN;
statementEndEvent.getNotifications().forEach(notifications::add);
} catch (JsonGenerationException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new ConnectionException("Failed to write to the connection", e);
}
}
use of org.neo4j.server.http.cypher.format.api.ConnectionException in project neo4j by neo4j.
the class ExecutionResultSerializer method writeStatementStart.
void writeStatementStart(StatementStartEvent statementStartEvent, InputStatement inputStatement) {
this.inputStatement = inputStatement;
this.writer = configureWriters(inputStatement.resultDataContents());
try {
ensureResultsFieldOpen();
jsonGenerator.writeStartObject();
Iterable<String> columns = statementStartEvent.getColumns();
writeColumns(columns);
jsonGenerator.writeArrayFieldStart("data");
currentState = State.STATEMENT_OPEN;
} catch (JsonGenerationException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new ConnectionException("Failed to write to the connection", e);
}
}
use of org.neo4j.server.http.cypher.format.api.ConnectionException in project neo4j by neo4j.
the class ExecutionResultSerializer method writeTransactionInfo.
void writeTransactionInfo(TransactionInfoEvent transactionInfoEvent) {
try {
ensureDocumentOpen();
ensureResultsFieldClosed();
writeNotifications(notifications);
writeErrors();
if (transactionInfoEvent.getCommitUri() != null) {
jsonGenerator.writeStringField("commit", transactionInfoEvent.getCommitUri().toString());
}
if (transactionInfoEvent.getNotification() == OPEN) {
jsonGenerator.writeObjectFieldStart("transaction");
if (transactionInfoEvent.getExpirationTimestamp() >= 0) {
String expires = Instant.ofEpochMilli(transactionInfoEvent.getExpirationTimestamp()).atZone(ZoneId.of("GMT")).format(DateTimeFormatter.RFC_1123_DATE_TIME);
jsonGenerator.writeStringField("expires", expires);
}
jsonGenerator.writeEndObject();
}
jsonGenerator.writeEndObject();
flush();
} catch (JsonGenerationException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new ConnectionException("Failed to write to the connection", e);
}
}
use of org.neo4j.server.http.cypher.format.api.ConnectionException in project neo4j by neo4j.
the class ExecutionResultSerializer method writeNotifications.
private void writeNotifications(Iterable<Notification> notifications) {
// don't add anything if notifications are empty
if (!notifications.iterator().hasNext()) {
return;
}
try {
ensureResultsFieldClosed();
jsonGenerator.writeArrayFieldStart("notifications");
try {
for (Notification notification : notifications) {
jsonGenerator.writeStartObject();
try {
jsonGenerator.writeStringField("code", notification.getCode());
jsonGenerator.writeStringField("severity", notification.getSeverity().toString());
jsonGenerator.writeStringField("title", notification.getTitle());
jsonGenerator.writeStringField("description", notification.getDescription());
writePosition(notification.getPosition());
} finally {
jsonGenerator.writeEndObject();
}
}
} finally {
jsonGenerator.writeEndArray();
}
} catch (IOException e) {
throw new ConnectionException("Failed to write to the response stream", e);
}
}
Aggregations