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;
}
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);
}
}
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);
}
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);
}
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);
}
}
Aggregations