use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineManager method check.
public CheckRepositoryVO check(CheckRepositoryVO checkRepositoryVO) {
if (StringUtils.isEmpty(checkRepositoryVO.getRepository())) {
checkRepositoryVO.setRepositoryExists(false);
} else {
Pipeline checkPipeline = new Pipeline();
checkPipeline.setRepository(checkRepositoryVO.getRepository());
checkPipeline.setRepositoryToken(checkRepositoryVO.getToken());
setCurrentVersion(checkPipeline);
if (StringUtils.isEmpty(checkPipeline.getRepositoryError())) {
checkRepositoryVO.setRepositoryExists(true);
} else {
checkRepositoryVO.setRepositoryExists(false);
}
}
return checkRepositoryVO;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineManager method create.
public Pipeline create(final PipelineVO pipelineVO) throws GitClientException {
Assert.isTrue(GitUtils.checkGitNaming(pipelineVO.getName()), messageHelper.getMessage(MessageConstants.ERROR_INVALID_PIPELINE_NAME, pipelineVO.getName()));
if (StringUtils.isEmpty(pipelineVO.getRepository())) {
Assert.isTrue(!gitManager.checkProjectExists(pipelineVO.getName()), messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_REPO_EXISTS, pipelineVO.getName()));
String repository = gitManager.createRepository(pipelineVO.getTemplateId() == null ? defaultTemplate : pipelineVO.getTemplateId(), pipelineVO.getName(), pipelineVO.getDescription());
pipelineVO.setRepository(repository);
} else {
CheckRepositoryVO checkRepositoryVO = new CheckRepositoryVO();
checkRepositoryVO.setRepository(pipelineVO.getRepository());
checkRepositoryVO.setToken(pipelineVO.getRepositoryToken());
checkRepositoryVO = this.check(checkRepositoryVO);
if (!checkRepositoryVO.isRepositoryExists()) {
gitManager.createRepository(pipelineVO.getTemplateId() == null ? defaultTemplate : pipelineVO.getTemplateId(), pipelineVO.getDescription(), pipelineVO.getRepository(), pipelineVO.getRepositoryToken());
}
}
Pipeline pipeline = pipelineVO.toPipeline();
setFolderIfPresent(pipeline);
pipeline.setOwner(securityManager.getAuthorizedUser());
return crudManager.save(pipeline);
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineManager method loadByNameOrId.
public Pipeline loadByNameOrId(String identifier) {
Pipeline pipeline = null;
try {
pipeline = pipelineDao.loadPipeline(Long.parseLong(identifier));
} catch (NumberFormatException e) {
LOGGER.trace(e.getMessage(), e);
}
if (pipeline == null) {
pipeline = pipelineDao.loadPipelineByName(identifier);
}
Assert.notNull(pipeline, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NOT_FOUND, identifier));
setCurrentVersion(pipeline);
pipeline.setHasMetadata(this.metadataManager.hasMetadata(new EntityVO(pipeline.getId(), AclClass.PIPELINE)));
return pipeline;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineManager method update.
@Transactional(propagation = Propagation.REQUIRED)
public Pipeline update(final PipelineVO pipelineVO) {
String pipelineVOName = pipelineVO.getName();
Assert.notNull(pipelineVOName, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NAME_IS_EMPTY));
Assert.isTrue(GitUtils.checkGitNaming(pipelineVOName), messageHelper.getMessage(MessageConstants.ERROR_INVALID_PIPELINE_NAME, pipelineVOName));
Pipeline dbPipeline = load(pipelineVO.getId());
dbPipeline.setName(pipelineVOName);
dbPipeline.setDescription(pipelineVO.getDescription());
dbPipeline.setParentFolderId(pipelineVO.getParentFolderId());
setFolderIfPresent(dbPipeline);
pipelineDao.updatePipeline(dbPipeline);
return dbPipeline;
}
use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.
the class PipelineVersionManager method addConfiguration.
public List<ConfigurationEntry> addConfiguration(Long id, ConfigurationEntry configuration) throws GitClientException {
Assert.isTrue(configuration.checkConfigComplete(), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_INVALID));
String configurationName = configuration.getName();
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
checkDefaultConfig(configuration, currentConfigurations);
List<ConfigurationEntry> updatedConf = removeConfig(configurationName, currentConfigurations);
updatedConf.add(configuration);
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_UPDATE, configurationName);
return saveUpdatedConfiguration(configurationName, pipeline, updatedConf, message);
}
Aggregations