Search in sources :

Example 1 with ScopeVariableExpressionDTO

use of org.alien4cloud.tosca.variable.ScopeVariableExpressionDTO in project alien4cloud by alien4cloud.

the class VariableExpressionService method getInEnvironmentScope.

public List<ScopeVariableExpressionDTO> getInEnvironmentScope(String varName, String applicationId, String topologyVersion, String envId) {
    Application application = applicationService.getOrFail(applicationId);
    if (StringUtils.isBlank(envId)) {
        return Arrays.stream(applicationEnvironmentService.getAuthorizedByApplicationId(applicationId)).map(env -> getVariableDef(varName, Csar.createId(env.getApplicationId(), topologyVersion), env)).collect(Collectors.toList());
    } else {
        ApplicationEnvironment env = applicationEnvironmentService.getOrFail(envId);
        AuthorizationUtil.checkAuthorizationForEnvironment(application, env);
        return Lists.newArrayList(getVariableDef(varName, Csar.createId(env.getApplicationId(), topologyVersion), env));
    }
}
Also used : Arrays(java.util.Arrays) Setter(lombok.Setter) Getter(lombok.Getter) ApplicationEnvironmentService(alien4cloud.application.ApplicationEnvironmentService) EditorFileService(org.alien4cloud.tosca.editor.EditorFileService) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Inject(javax.inject.Inject) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) Map(java.util.Map) Application(alien4cloud.model.application.Application) ApplicationService(alien4cloud.application.ApplicationService) YamlParserUtil(alien4cloud.utils.YamlParserUtil) Csar(org.alien4cloud.tosca.model.Csar) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) Collection(java.util.Collection) ScopeVariableExpressionDTO(org.alien4cloud.tosca.variable.ScopeVariableExpressionDTO) EqualsAndHashCode(lombok.EqualsAndHashCode) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) AuthorizationUtil(alien4cloud.security.AuthorizationUtil) List(java.util.List) EnvironmentType(alien4cloud.model.application.EnvironmentType) Variable(org.alien4cloud.tosca.variable.model.Variable) QuickFileStorageService(org.alien4cloud.tosca.variable.QuickFileStorageService) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment)

Example 2 with ScopeVariableExpressionDTO

use of org.alien4cloud.tosca.variable.ScopeVariableExpressionDTO in project alien4cloud by alien4cloud.

the class VariableExpressionService method getScopeVariableExpressionDTO.

private ScopeVariableExpressionDTO getScopeVariableExpressionDTO(String varName, String scopeId, String scopeName, Map<String, Object> variables) {
    ScopeVariableExpressionDTO dto = new ScopeVariableExpressionDTO();
    dto.setScopeId(scopeId);
    dto.setScopeName(scopeName);
    dto.setVariable(new Variable(varName, YamlParserUtil.dump(variables.get(varName))));
    return dto;
}
Also used : Variable(org.alien4cloud.tosca.variable.model.Variable) ScopeVariableExpressionDTO(org.alien4cloud.tosca.variable.ScopeVariableExpressionDTO)

Aggregations

ScopeVariableExpressionDTO (org.alien4cloud.tosca.variable.ScopeVariableExpressionDTO)2 Variable (org.alien4cloud.tosca.variable.model.Variable)2 ApplicationEnvironmentService (alien4cloud.application.ApplicationEnvironmentService)1 ApplicationService (alien4cloud.application.ApplicationService)1 Application (alien4cloud.model.application.Application)1 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)1 EnvironmentType (alien4cloud.model.application.EnvironmentType)1 AuthorizationUtil (alien4cloud.security.AuthorizationUtil)1 YamlParserUtil (alien4cloud.utils.YamlParserUtil)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 EqualsAndHashCode (lombok.EqualsAndHashCode)1 Getter (lombok.Getter)1