/** * Fill-in the inputs properties definitions (and default values) based on the properties * definitions from the topology. * * @param topology The deployment topology to impact. */ public void processInputProperties(DeploymentTopology topology) { Map<String, String> inputProperties = topology.getInputProperties(); Map<String, PropertyDefinition> inputDefinitions = topology.getInputs(); if (inputDefinitions == null || inputDefinitions.isEmpty()) { topology.setInputProperties(null); } else { if (inputProperties == null) { inputProperties = Maps.newHashMap(); topology.setInputProperties(inputProperties); } else { Iterator<Map.Entry<String, String>> inputPropertyEntryIterator = inputProperties.entrySet().iterator(); while (inputPropertyEntryIterator.hasNext()) { Map.Entry<String, String> inputPropertyEntry = inputPropertyEntryIterator.next(); if (!inputDefinitions.containsKey(inputPropertyEntry.getKey())) { inputPropertyEntryIterator.remove(); } else { try { constraintPropertyService.checkSimplePropertyConstraint( inputPropertyEntry.getKey(), inputPropertyEntry.getValue(), inputDefinitions.get(inputPropertyEntry.getKey())); } catch (ConstraintViolationException | ConstraintValueDoNotMatchPropertyTypeException e) { // Property is not valid anymore for the input, remove the old value inputPropertyEntryIterator.remove(); } } } } for (Map.Entry<String, PropertyDefinition> inputDefinitionEntry : inputDefinitions.entrySet()) { String existingValue = inputProperties.get(inputDefinitionEntry.getKey()); if (existingValue == null) { String defaultValue = inputDefinitionEntry.getValue().getDefault(); if (defaultValue != null) { inputProperties.put(inputDefinitionEntry.getKey(), defaultValue); } } } } }