@ApiOperation(value="Evaluates rules by executing commands on the rule session",
response=ServiceResponse.class, code=200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error") })
@POST
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response manageContainer(@Context HttpHeaders headers,
@ApiParam(value = "Container id where rules should be evaluated on", required = true) @PathParam("id") String id,
@ApiParam(value = "Commands to be executed on rule engine given as BatchExecutionCommand type", required = true) String cmdPayload) {
Variant v = getVariant(headers);
String contentType = getContentType(headers);
String classType = getClassType(headers);
MarshallingFormat format = MarshallingFormat.fromType(contentType);
if (format == null) {
format = MarshallingFormat.valueOf(contentType);
}
logger.debug("Received request with content '{}'", cmdPayload);
Object result = delegate.callContainer(id, cmdPayload, format, classType);
Header conversationIdHeader = buildConversationIdHeader(id, registry, headers);
try {
String response = marshallerHelper.marshal(id, format.getType(), result, ContainerLocatorProvider.get().getLocator());
logger.debug("Returning OK response with content '{}'", response);
return createResponse(response, v, Response.Status.OK, conversationIdHeader);
} catch (IllegalArgumentException e) {
String response = marshallerHelper.marshal(format.getType(), result);
logger.debug("Returning OK response with content '{}'", response);
return createResponse(response, v, Response.Status.OK, conversationIdHeader);
}
}