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