Search in sources :

Example 6 with RepositoryCreationResponse

use of org.jboss.pnc.dto.response.RepositoryCreationResponse 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

RepositoryCreationResponse (org.jboss.pnc.dto.response.RepositoryCreationResponse)6 SCMRepository (org.jboss.pnc.dto.SCMRepository)3 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 PermitAll (javax.annotation.security.PermitAll)1 Stateless (javax.ejb.Stateless)1 Inject (javax.inject.Inject)1 ClientException (org.jboss.pnc.client.ClientException)1 MDCWrappers (org.jboss.pnc.common.concurrent.MDCWrappers)1 MDCUtils (org.jboss.pnc.common.logging.MDCUtils)1