Search in sources :

Example 6 with Pipeline

use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.

the class PipelineManager method updateToken.

@Transactional(propagation = Propagation.REQUIRED)
public Pipeline updateToken(final PipelineVO pipelineVO) {
    Pipeline dbPipeline = load(pipelineVO.getId());
    dbPipeline.setRepositoryToken(pipelineVO.getRepositoryToken());
    setCurrentVersion(dbPipeline);
    if (!StringUtils.isEmpty(dbPipeline.getRepositoryError())) {
        throw new IllegalArgumentException(messageHelper.getMessage(MessageConstants.ERROR_REPO_TOKEN_INVALID, dbPipeline.getRepository(), dbPipeline.getRepositoryError()));
    }
    pipelineDao.updatePipeline(dbPipeline);
    return dbPipeline;
}
Also used : Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Pipeline

use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.

the class PipelineManager method load.

public Pipeline load(Long id, boolean loadVersion) {
    Pipeline pipeline = pipelineDao.loadPipeline(id);
    Assert.notNull(pipeline, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NOT_FOUND, id));
    if (loadVersion) {
        setCurrentVersion(pipeline);
    }
    pipeline.setHasMetadata(this.metadataManager.hasMetadata(new EntityVO(id, AclClass.PIPELINE)));
    return pipeline;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 8 with Pipeline

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;
}
Also used : Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 9 with Pipeline

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);
}
Also used : CheckRepositoryVO(com.epam.pipeline.controller.vo.CheckRepositoryVO) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 10 with 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;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Aggregations

Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)88 Test (org.junit.Test)41 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)25 Transactional (org.springframework.transaction.annotation.Transactional)18 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)16 GitCommitEntry (com.epam.pipeline.entity.git.GitCommitEntry)14 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)13 Revision (com.epam.pipeline.entity.pipeline.Revision)12 Folder (com.epam.pipeline.entity.pipeline.Folder)10 Before (org.junit.Before)9 GitFile (com.epam.pipeline.entity.git.GitFile)8 GitRepositoryEntry (com.epam.pipeline.entity.git.GitRepositoryEntry)7 EnvVarsBuilderTest (com.epam.pipeline.manager.execution.EnvVarsBuilderTest)7 Date (java.util.Date)7 List (java.util.List)7 GitTagEntry (com.epam.pipeline.entity.git.GitTagEntry)6 PipelineUser (com.epam.pipeline.entity.user.PipelineUser)6 IsEmptyString.isEmptyString (org.hamcrest.text.IsEmptyString.isEmptyString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 EntityVO (com.epam.pipeline.controller.vo.EntityVO)5