Search in sources :

Example 1 with RepositoryConfiguration

use of org.jboss.pnc.model.RepositoryConfiguration in project pnc by project-ncl.

the class RepositoryConfigurationMock method newTestRepository.

public static RepositoryConfiguration newTestRepository() {
    RepositoryConfiguration repositoryConfiguration = new RepositoryConfiguration();
    repositoryConfiguration.setId(1645886423);
    repositoryConfiguration.setExternalUrl("externalUrl");
    repositoryConfiguration.setInternalUrl("internalUrl");
    repositoryConfiguration.setPreBuildSyncEnabled(true);
    return repositoryConfiguration;
}
Also used : RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration)

Example 2 with RepositoryConfiguration

use of org.jboss.pnc.model.RepositoryConfiguration in project pnc by project-ncl.

the class SCMRepositoryProviderImpl method validateBeforeUpdating.

@Override
public void validateBeforeUpdating(Integer id, SCMRepository restEntity) {
    super.validateBeforeUpdating(id, restEntity);
    RepositoryConfiguration entityInDb = findInDB(id);
    if (!entityInDb.getInternalUrl().equals(restEntity.getInternalUrl())) {
        throw new InvalidEntityException("Updating internal URL is prohibited. SCMRepo: " + id);
    }
    if (restEntity.getExternalUrl() != null && !restEntity.getExternalUrl().equals(entityInDb.getExternalUrl())) {
        validateRepositoryWithExternalURLDoesNotExist(restEntity.getExternalUrl(), id);
    }
}
Also used : RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

Example 3 with RepositoryConfiguration

use of org.jboss.pnc.model.RepositoryConfiguration in project pnc by project-ncl.

the class SCMRepositoryProviderImpl method createSCMRepositoryFromValues.

private SCMRepository createSCMRepositoryFromValues(String externalScmUrl, String internalScmUrl, boolean preBuildSyncEnabled) {
    RepositoryConfiguration.Builder built = RepositoryConfiguration.Builder.newBuilder().internalUrl(internalScmUrl).preBuildSyncEnabled(preBuildSyncEnabled);
    if (externalScmUrl != null) {
        built.externalUrl(externalScmUrl);
    }
    RepositoryConfiguration entity = repository.save(built.build());
    log.info("Created SCM repository: {}.", entity.toString());
    return mapper.toDTO(entity);
}
Also used : RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration)

Example 4 with RepositoryConfiguration

use of org.jboss.pnc.model.RepositoryConfiguration in project pnc by project-ncl.

the class SCMRepositoryProviderImpl method validateRepositoryWithExternalURLDoesNotExist.

private void validateRepositoryWithExternalURLDoesNotExist(String externalUrl, Integer ignoreId) throws ConflictedEntryException {
    RepositoryConfiguration repositoryConfiguration = repositoryConfigurationRepository.queryByExternalScm(externalUrl);
    if (repositoryConfiguration != null && !repositoryConfiguration.getId().equals(ignoreId)) {
        String message = "SCM Repository already exists (id: " + repositoryConfiguration.getId() + ")";
        throw new ConflictedEntryException(message, RepositoryConfiguration.class, repositoryConfiguration.getId().toString());
    }
    String internalUrl = repour.translateExternalUrl(externalUrl);
    validateRepositoryWithInternalURLDoesNotExist(internalUrl, ignoreId);
}
Also used : RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration) ConflictedEntryException(org.jboss.pnc.facade.validation.ConflictedEntryException)

Example 5 with RepositoryConfiguration

use of org.jboss.pnc.model.RepositoryConfiguration in project pnc by project-ncl.

the class SCMRepositoryProviderImpl method onRepoCloneSuccess.

private void onRepoCloneSuccess(String internalScmUrl, Integer taskId, Consumer<RepositoryCreated> consumer, JobNotificationType jobType, String externalURL, boolean preBuildSyncEnabled) {
    RepositoryConfiguration existing = repository.queryByPredicates(withExactInternalScmRepoUrl(internalScmUrl));
    if (existing != null) {
        RepositoryCreationFailure error = new RepositoryCreationFailure(jobType, RC_REPO_CREATION_CONFLICT, existing, taskId.toString());
        notifier.sendMessage(error);
    } else {
        SCMRepository scmRepo = createSCMRepositoryFromValues(externalURL, internalScmUrl, preBuildSyncEnabled);
        RepositoryCreated notification = new RepositoryCreated(taskId, Integer.parseInt(scmRepo.getId()));
        consumer.accept(notification);
    }
}
Also used : RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration) SCMRepository(org.jboss.pnc.dto.SCMRepository) RepositoryCreationFailure(org.jboss.pnc.dto.notification.RepositoryCreationFailure)

Aggregations

RepositoryConfiguration (org.jboss.pnc.model.RepositoryConfiguration)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)4 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)3 RepositoryCreationFailure (org.jboss.pnc.dto.notification.RepositoryCreationFailure)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Consumer (java.util.function.Consumer)2 Function (java.util.function.Function)2 Pattern (java.util.regex.Pattern)2 PermitAll (javax.annotation.security.PermitAll)2 Stateless (javax.ejb.Stateless)2 Inject (javax.inject.Inject)2 BpmEventType (org.jboss.pnc.bpm.BpmEventType)2 BpmManager (org.jboss.pnc.bpm.BpmManager)2 RestConnector (org.jboss.pnc.bpm.RestConnector)2 BpmStringMapNotificationRest (org.jboss.pnc.bpm.model.BpmStringMapNotificationRest)2 RepositoryCloneSuccess (org.jboss.pnc.bpm.model.RepositoryCloneSuccess)2 RepositoryCreationProcess (org.jboss.pnc.bpm.model.RepositoryCreationProcess)2