Search in sources :

Example 11 with InvalidEntityException

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;
}
Also used : ProgressStatus(org.jboss.pnc.api.enums.ProgressStatus) Operation(org.jboss.pnc.model.Operation) DeliverableAnalyzerOperation(org.jboss.pnc.model.DeliverableAnalyzerOperation) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

Example 12 with InvalidEntityException

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;
        }
    }
}
Also used : RepositoryViolationException(org.jboss.pnc.facade.validation.RepositoryViolationException) ProductMilestoneCloseResult(org.jboss.pnc.dto.ProductMilestoneCloseResult) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException) ProductMilestoneRelease(org.jboss.pnc.model.ProductMilestoneRelease)

Example 13 with InvalidEntityException

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);
    }
}
Also used : SCMRepository(org.jboss.pnc.dto.SCMRepository) RepositoryCreationResponse(org.jboss.pnc.dto.response.RepositoryCreationResponse) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

Aggregations

InvalidEntityException (org.jboss.pnc.facade.validation.InvalidEntityException)13 List (java.util.List)3 RepositoryViolationException (org.jboss.pnc.facade.validation.RepositoryViolationException)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Stateless (javax.ejb.Stateless)2 Inject (javax.inject.Inject)2 ProgressStatus (org.jboss.pnc.api.enums.ProgressStatus)2 StreamHelper.nullableStreamOf (org.jboss.pnc.common.util.StreamHelper.nullableStreamOf)2 ArtifactQuality (org.jboss.pnc.enums.ArtifactQuality)2 UserService (org.jboss.pnc.facade.util.UserService)2 ConflictedEntryException (org.jboss.pnc.facade.validation.ConflictedEntryException)2 BuildMapper (org.jboss.pnc.mapper.api.BuildMapper)2 Artifact (org.jboss.pnc.model.Artifact)2 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)2 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)2