use of org.jboss.pnc.facade.validation.InvalidEntityException in project pnc by project-ncl.
the class OperationsManagerImpl method updateProgress.
@Override
public Operation updateProgress(Base32LongID id, ProgressStatus status) {
Operation operation = repository.queryById(id);
if (operation.getEndTime() != null) {
throw new InvalidEntityException("Operation " + operation + " is already finished!");
}
log.debug("Updating progress of operation " + operation + " to " + status);
if (operation.getStartTime() == null && status == ProgressStatus.IN_PROGRESS) {
operation.setStartTime(Date.from(Instant.now()));
}
ProgressStatus previousProgress = operation.getProgressStatus();
operation.setProgressStatus(status);
analysisStatusChangedEventNotifier.fire(new OperationChangedEvent(operation, previousProgress));
return operation;
}
use of org.jboss.pnc.facade.validation.InvalidEntityException in project pnc by project-ncl.
the class ProductMilestoneProviderImpl method doCloseMilestone.
private ProductMilestoneCloseResult doCloseMilestone(String id, Long milestoneReleaseId) {
org.jboss.pnc.model.ProductMilestone milestoneInDb = repository.queryById(Integer.valueOf(id));
if (milestoneInDb.getEndDate() != null) {
userLog.info("Milestone is already closed: no more modifications allowed");
throw new RepositoryViolationException("Milestone is already closed! No more modifications allowed");
}
if (milestoneInDb.getPerformedBuilds().size() == 0) {
throw new InvalidEntityException("No builds were performed in milestone!");
} else {
Optional<ProductMilestoneRelease> inProgress = releaseManager.getInProgress(milestoneInDb);
if (inProgress.isPresent()) {
userLog.warn("Milestone close is already in progress.");
return milestoneReleaseMapper.toDTO(inProgress.get());
} else {
log.debug("Milestone's 'end date' set; no release of the milestone in progress: will start release");
boolean useRHPAM = bpmConfig.isNewBpmForced() || userService.hasLoggedInUserRole(WORK_WITH_TECH_PREVIEW);
log.debug("Using RHPAM server: {}", useRHPAM);
ProductMilestoneRelease milestoneReleaseDb = releaseManager.startRelease(milestoneInDb, userService.currentUserToken(), useRHPAM, milestoneReleaseId);
ProductMilestoneCloseResult milestoneCloseResult = milestoneReleaseMapper.toDTO(milestoneReleaseDb);
return milestoneCloseResult;
}
}
}
use of org.jboss.pnc.facade.validation.InvalidEntityException in project pnc by project-ncl.
the class SCMRepositoryProviderImpl method createSCMRepository.
@Override
public RepositoryCreationResponse createSCMRepository(String scmUrl, String revision, Boolean preBuildSyncEnabled, JobNotificationType jobType, Consumer<RepositoryCreated> consumer, Optional<BuildConfiguration> buildConfiguration) {
log.trace("Received request to start RC creation with url autodetect: " + scmUrl + " (sync enabled? " + preBuildSyncEnabled + ")");
if (StringUtils.isEmpty(scmUrl))
throw new InvalidEntityException("You must specify the SCM URL.");
if (scmUrl.contains(config.getInternalScmAuthority())) {
// validation phase
validateInternalRepository(scmUrl);
validateRepositoryWithInternalURLDoesNotExist(scmUrl, null);
SCMRepository scmRepository = createSCMRepositoryFromValues(null, scmUrl, false);
consumer.accept(new RepositoryCreated(null, Integer.valueOf(scmRepository.getId())));
return new RepositoryCreationResponse(scmRepository);
} else {
validateRepositoryWithExternalURLDoesNotExist(scmUrl, null);
boolean sync = preBuildSyncEnabled == null || preBuildSyncEnabled;
Integer taskId = startRCreationTask(scmUrl, revision, sync, jobType, consumer, buildConfiguration);
return new RepositoryCreationResponse(taskId);
}
}
Aggregations