use of org.jboss.pnc.bpm.NoEntityException in project pnc by project-ncl.
the class ProductMilestoneReleaseManager method storeResult.
private void storeResult(ProductMilestone milestone, MilestoneReleaseResultRest result) {
ProductMilestoneRelease productMilestoneRelease = updateRelease(milestone, result.getReleaseStatus().getMilestoneReleaseStatus()).orElseThrow(() -> new NoEntityException("ProductMilestoneRelease not found."));
for (BuildImportResultRest buildRest : ofNullableCollection(result.getBuilds())) {
storeBuildRecordPush(buildRest, productMilestoneRelease);
}
if (result.getReleaseStatus().getMilestoneReleaseStatus() == MilestoneCloseStatus.SUCCEEDED) {
// set milestone end date to now when the release process is successful
milestone.setEndDate(new Date());
milestoneRepository.save(milestone);
removeCurrentFlagFromMilestone(milestone);
}
productMilestoneCloseResultEvent.fire(mapper.toDTO(productMilestoneRelease));
}
use of org.jboss.pnc.bpm.NoEntityException 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