use of io.crnk.operations.OperationResponse in project crnk-framework by crnk-project.
the class OperationsCall method getResponseObject.
public <T> T getResponseObject(int index, Class<T> clazz) {
checkResponsesAvailable();
OperationResponse response = responses.get(index);
return fromResource(response, clazz);
}
use of io.crnk.operations.OperationResponse in project crnk-framework by crnk-project.
the class OperationsRequestProcessor method process.
@Override
public void process(HttpRequestContext context) throws IOException {
if (context.accepts(JSONPATCH_CONTENT_TYPE)) {
try {
ObjectMapper mapper = moduleContext.getObjectMapper();
List<Operation> operations = Arrays.asList(mapper.readValue(context.getRequestBody(), Operation[].class));
List<OperationResponse> responses = operationsModule.apply(operations);
String responseJson = mapper.writeValueAsString(responses);
context.setContentType(JSONPATCH_CONTENT_TYPE);
context.setResponse(200, responseJson);
} catch (Exception e) {
LOGGER.error("failed to execute operations", e);
context.setResponse(500, (byte[]) null);
}
}
}
Aggregations