use of org.kie.server.api.marshalling.MarshallingFormat in project businessautomation-cop by redhat-cop.
the class CustomResource method insertFireReturn.
@GET
@Path("/{aliasId}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response insertFireReturn(@Context HttpHeaders headers, @PathParam("aliasId") String alias) {
Variant v = getVariant(headers);
String contentType = getContentType(headers);
MarshallingFormat format = MarshallingFormat.fromType(contentType);
if (format == null) {
format = MarshallingFormat.valueOf(contentType);
}
MarshallerHelper marshallerHelper = new MarshallerHelper(context);
try {
// get all the containers with the given alias
List<KieContainerInstanceImpl> filteredContainers = context.getContainersForAlias(alias);
List<ProcessInstance> instances = new ArrayList<ProcessInstance>();
// for each container obtain a list of active process instances
filteredContainers.forEach(container -> {
String containerId = container.getContainerId();
ProcessInstanceList instanceList = runtimeDataService.getProcessInstancesByDeploymentId(containerId, Arrays.asList(1), 0, 0, "", true);
logger.debug("Found " + instanceList.getItems().size() + " active process instances in container with id " + containerId);
instances.addAll(instanceList.getItems());
});
// return the list to the client
ProcessInstanceList finalList = new ProcessInstanceList(instances);
String result = marshallerHelper.marshal(format.toString(), finalList);
logger.debug("Returning OK response with content '{}'", result);
return createResponse(result, v, Response.Status.OK);
} catch (Exception e) {
// in case marshalling failed return the call container response to keep
// backward compatibility
String response = "Execution failed with error : " + e.getMessage();
logger.debug("Returning Failure response with content '{}'", response);
return createResponse(response, v, Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.kie.server.api.marshalling.MarshallingFormat in project rhpam-7-openshift-image by jboss-container-images.
the class HelloRulesClient method getMarshallingFormat.
private MarshallingFormat getMarshallingFormat() {
// can use xstream, xml (jaxb), or json
String type = System.getProperty("MarshallingFormat", "jaxb");
if (type.trim().equalsIgnoreCase("jaxb")) {
type = "xml";
}
MarshallingFormat marshallingFormat = MarshallingFormat.fromType(type);
logger.debug(String.format("---------> %s MarshallingFormat.%s", marshallingFormat.getType(), marshallingFormat.name()));
return marshallingFormat;
}
Aggregations