Search in sources :

Example 1 with TaskLevel

use of alien4cloud.topology.task.TaskLevel in project alien4cloud by alien4cloud.

the class OrchestratorPropertiesValidationService method validate.

public PropertiesTask validate(OrchestratorDeploymentProperties orchestratorDeploymentProperties) {
    if (orchestratorDeploymentProperties == null || StringUtils.isBlank(orchestratorDeploymentProperties.getOrchestratorId())) {
        return null;
    }
    Map<String, PropertyDefinition> deploymentProperties = orchestratorDeploymentService.getDeploymentPropertyDefinitions(orchestratorDeploymentProperties.getOrchestratorId());
    if (MapUtils.isEmpty(deploymentProperties)) {
        return null;
    }
    Map<String, String> properties = orchestratorDeploymentProperties.getProviderDeploymentProperties();
    if (properties == null) {
        properties = Maps.newHashMap();
    }
    PropertiesTask task = null;
    List<String> required = Lists.newArrayList();
    for (Entry<String, PropertyDefinition> entry : deploymentProperties.entrySet()) {
        if (entry.getValue().isRequired()) {
            String value = properties.get(entry.getKey());
            if (StringUtils.isBlank(value)) {
                required.add(entry.getKey());
            }
        }
    }
    if (CollectionUtils.isNotEmpty(required)) {
        task = new PropertiesTask(Maps.<TaskLevel, List<String>>newHashMap());
        task.setCode(TaskCode.ORCHESTRATOR_PROPERTY);
        task.getProperties().put(TaskLevel.REQUIRED, required);
    }
    return task;
}
Also used : PropertiesTask(alien4cloud.topology.task.PropertiesTask) TaskLevel(alien4cloud.topology.task.TaskLevel) List(java.util.List) PropertyDefinition(org.alien4cloud.tosca.model.definitions.PropertyDefinition)

Aggregations

PropertiesTask (alien4cloud.topology.task.PropertiesTask)1 TaskLevel (alien4cloud.topology.task.TaskLevel)1 List (java.util.List)1 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)1