use of org.jboss.pnc.facade.validation.EmptyEntityException in project pnc by project-ncl.
the class OperationsManagerImpl method newDeliverableAnalyzerOperation.
@Override
public DeliverableAnalyzerOperation newDeliverableAnalyzerOperation(String milestoneId, Map<String, String> inputParams) {
ProductMilestone milestone = productMilestoneRepository.queryById(ProductMilestoneMapper.idMapper.toEntity(milestoneId));
if (milestone == null) {
throw new EmptyEntityException("Milestone with id " + milestoneId + " doesn't exist");
}
String operationId = Sequence.nextBase32Id();
MDCUtils.addProcessContext(operationId);
org.jboss.pnc.model.DeliverableAnalyzerOperation operation = org.jboss.pnc.model.DeliverableAnalyzerOperation.Builder.newBuilder().progressStatus(ProgressStatus.NEW).submitTime(Date.from(Instant.now())).productMilestone(milestone).operationParameters(inputParams).user(userService.currentUser()).id(operationId).build();
repository.save(operation);
analysisStatusChangedEventNotifier.fire(new OperationChangedEvent(operation, null));
return operation;
}
use of org.jboss.pnc.facade.validation.EmptyEntityException in project pnc by project-ncl.
the class BrewPusherImpl method getLatestSuccessfullyExecutedBuildRecord.
/**
* @param buildRecordId
* @return Latest build record with status success or null if the build record does not exist.
* @throws InconsistentDataException when there is no SUCCESS status before NO_REBUILD_REQUIRED
* @throws InvalidEntityException when the status is not SUCCESS or NO_REBUILD_REQUIRED
*/
private BuildRecord getLatestSuccessfullyExecutedBuildRecord(Base32LongID buildRecordId) {
BuildRecord buildRecord = buildRecordRepository.findByIdFetchProperties(buildRecordId);
if (buildRecord == null) {
throw new EmptyEntityException("Build record not found.");
}
switch(buildRecord.getStatus()) {
case SUCCESS:
return buildRecord;
case NO_REBUILD_REQUIRED:
// if status is NO_REBUILD_REQUIRED, find the associated BuildRecord which was linked as the no rebuild
// cause
BuildRecord noRebuildCause = buildRecord.getNoRebuildCause();
if (noRebuildCause != null) {
return noRebuildCause;
} else {
String message = "There is no SUCCESS build before NO_REBUILD_REQUIRED.";
log.error(message);
throw new InconsistentDataException(message);
}
default:
// Build status is not SUCCESS or NO_REBUILD_REQUIRED.
throw new OperationNotAllowedException("Not allowed to push failed build.");
}
}
Aggregations