use of org.jboss.pnc.bpm.model.BpmEvent in project pnc by project-ncl.
the class BpmEndpointImpl method notifyTask.
@Override
public void notifyTask(int taskId) {
String content;
JsonNode node;
try {
content = readContent(request.getInputStream());
node = JsonOutputConverterMapper.getMapper().readTree(content);
} catch (IOException e) {
throw new RuntimeException("Could not get JSON from request data. " + "Verify it is not empty and in the correct format.", e);
}
if (!node.has("eventType")) {
throw new RuntimeException("Request JSON does not contain required \"eventType\" field.");
}
String eventTypeName = node.get("eventType").asText();
BpmEventType eventType = nullableValueOf(eventTypeName);
if (eventType != null) {
BpmEvent notification;
try {
notification = JsonOutputConverterMapper.getMapper().readValue(node.traverse(), eventType.getType());
} catch (IOException e) {
throw new RuntimeException("Could not deserialize JSON request for event type '" + eventTypeName + "' " + " into '" + eventType.getType() + "'. JSON value: " + content, e);
}
logger.debug("Received notification {} for BPM task with id {}.", notification, taskId);
try {
bpmManager.notify(taskId, notification);
} catch (NoEntityException e) {
throw new EmptyEntityException(e.getMessage());
}
} else {
logger.info("Received notification with unknown eventType {}, ignoring it.", eventTypeName);
}
}
Aggregations