Search in sources :

Example 1 with TemplatesScanner

use of com.epam.pipeline.manager.git.TemplatesScanner in project cloud-pipeline by epam.

the class FolderTemplateManager method create.

@Transactional(propagation = Propagation.REQUIRED)
public Folder create(final Folder folder, final String templateName) {
    TemplatesScanner templatesScanner = new TemplatesScanner(folderTemplatesDirectoryPath);
    Template template = templatesScanner.listTemplates().get(templateName);
    Assert.notNull(template, messageHelper.getMessage(MessageConstants.ERROR_FOLDER_TEMPLATE_NOT_FOUND, templateName));
    Assert.isTrue(StringUtils.hasText(folder.getName()), messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NAME_IS_EMPTY));
    FolderTemplate folderTemplate = parseTemplateJson(template.getDirPath(), folder.getName());
    Assert.isTrue(StringUtils.hasText(folderTemplate.getName()), messageHelper.getMessage(MessageConstants.ERROR_TEMPLATE_FOLDER_NAME_IS_EMPTY, templateName));
    Assert.isNull(folderDao.loadFolderByNameAndParentId(folderTemplate.getName(), folder.getParentId()), messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NAME_EXISTS, folderTemplate.getName(), folder.getParentId()));
    prepareTemplate(folderTemplate, folder.getName());
    createFolderFromTemplate(folder, folderTemplate);
    return folder;
}
Also used : TemplatesScanner(com.epam.pipeline.manager.git.TemplatesScanner) FolderTemplate(com.epam.pipeline.entity.templates.FolderTemplate) Template(com.epam.pipeline.entity.template.Template) FolderTemplate(com.epam.pipeline.entity.templates.FolderTemplate) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with TemplatesScanner

use of com.epam.pipeline.manager.git.TemplatesScanner in project cloud-pipeline by epam.

the class TemplateManager method getPipelineTemplates.

public Collection<Template> getPipelineTemplates() {
    TemplatesScanner templatesScanner = new TemplatesScanner(pipelineTemplatesDirectoryPath);
    Collection<Template> templates = templatesScanner.listTemplates().values();
    templates.forEach(template -> {
        if (template.getId().equals(pipelineDefaultTemplate)) {
            template.setDefaultTemplate(true);
        }
    });
    return templates;
}
Also used : TemplatesScanner(com.epam.pipeline.manager.git.TemplatesScanner) Template(com.epam.pipeline.entity.template.Template)

Aggregations

Template (com.epam.pipeline.entity.template.Template)2 TemplatesScanner (com.epam.pipeline.manager.git.TemplatesScanner)2 FolderTemplate (com.epam.pipeline.entity.templates.FolderTemplate)1 Transactional (org.springframework.transaction.annotation.Transactional)1