Search in sources :

Example 1 with NoEntityException

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));
}
Also used : BuildImportResultRest(org.jboss.pnc.bpm.model.causeway.BuildImportResultRest) NoEntityException(org.jboss.pnc.bpm.NoEntityException) ProductMilestoneRelease(org.jboss.pnc.model.ProductMilestoneRelease) Date(java.util.Date)

Example 2 with NoEntityException

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);
    }
}
Also used : BpmEvent(org.jboss.pnc.bpm.model.BpmEvent) EmptyEntityException(org.jboss.pnc.facade.validation.EmptyEntityException) BpmEventType(org.jboss.pnc.bpm.BpmEventType) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) NoEntityException(org.jboss.pnc.bpm.NoEntityException)

Aggregations

NoEntityException (org.jboss.pnc.bpm.NoEntityException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 IOException (java.io.IOException)1 Date (java.util.Date)1 BpmEventType (org.jboss.pnc.bpm.BpmEventType)1 BpmEvent (org.jboss.pnc.bpm.model.BpmEvent)1 BuildImportResultRest (org.jboss.pnc.bpm.model.causeway.BuildImportResultRest)1 EmptyEntityException (org.jboss.pnc.facade.validation.EmptyEntityException)1 ProductMilestoneRelease (org.jboss.pnc.model.ProductMilestoneRelease)1