use of com.epam.pipeline.entity.template.Template in project cloud-pipeline by epam.
the class GitManager method createRepository.
public String createRepository(String templateId, String pipelineName, String description) throws GitClientException {
TemplatesScanner templatesScanner = new TemplatesScanner(templatesDirectoryPath);
Template template = templatesScanner.listTemplates().get(templateId);
Assert.notNull(template, "There is no such a template: " + templateId);
return getDefaultGitlabClient().createTemplateRepository(template, pipelineName, description, preferenceManager.getPreference(SystemPreferences.GIT_REPOSITORY_INDEXING_ENABLED), preferenceManager.getPreference(SystemPreferences.GIT_REPOSITORY_HOOK_URL)).getRepoUrl();
}
use of com.epam.pipeline.entity.template.Template in project cloud-pipeline by epam.
the class GitlabClient method findUser.
private Optional<GitlabUser> findUser(String userName) {
final RestTemplate template = new RestTemplate();
final HttpEntity headers = getAuthHeaders();
final String searchUri = UriComponentsBuilder.fromHttpUrl(String.format(GITLAB_API_USERS, gitHost)).queryParam("search", userName).build().toUriString();
ResponseEntity<List<GitlabUser>> response = template.exchange(searchUri, HttpMethod.GET, headers, new ParameterizedTypeReference<List<GitlabUser>>() {
});
return Optional.of(response).filter(r -> r.getStatusCode() == HttpStatus.OK).map(ResponseEntity::getBody).map(List::stream).flatMap(Stream::findFirst);
}
use of com.epam.pipeline.entity.template.Template 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.entity.template.Template 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