use of com.thoughtworks.go.config.exceptions.ConflictException in project gocd by gocd.
the class ExtractTemplateFromPipelineEntityConfigUpdateCommand method canContinue.
@Override
public boolean canContinue(CruiseConfig cruiseConfig) {
PipelineConfig pipelineConfig = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString(pipelineName));
if (pipelineConfig == null) {
throw new RecordNotFoundException(EntityType.Pipeline, pipelineName);
}
if (pipelineConfig.hasTemplate()) {
throw new ConflictException(EntityType.Pipeline.alreadyUsesATemplate(pipelineName));
}
PipelineTemplateConfig templateByName = cruiseConfig.getTemplates().templateByName(this.newTemplate.name());
if (templateByName != null) {
throw new ConflictException(EntityType.Template.alreadyExists(this.newTemplate.name()));
}
if (new NameTypeValidator().isNameInvalid(this.newTemplate.name().toString())) {
throw new BadRequestException(NameTypeValidator.errorMessage("template", this.newTemplate.name()));
}
return true;
}
Aggregations