package alien4cloud.paas.cloudify3.blueprint;

import java.nio.file.Path;

import alien4cloud.model.components.AbstractPropertyValue;
import alien4cloud.model.components.ScalarPropertyValue;
import alien4cloud.model.topology.NodeTemplate;
import alien4cloud.paas.cloudify3.CloudifyOrchestratorFactory;
import alien4cloud.paas.cloudify3.configuration.MappingConfiguration;
import alien4cloud.paas.cloudify3.model.DeploymentPropertiesNames;
import alien4cloud.paas.cloudify3.service.OrchestratorDeploymentPropertiesService;
import alien4cloud.paas.cloudify3.service.PropertyEvaluatorService;
import alien4cloud.paas.cloudify3.service.model.CloudifyDeployment;
import alien4cloud.utils.MapUtil;

public class CommonGenerationUtil extends AbstractGenerationUtil {

    private OrchestratorDeploymentPropertiesService deploymentPropertiesService;

    public CommonGenerationUtil(MappingConfiguration mappingConfiguration, CloudifyDeployment alienDeployment, Path recipePath,
            PropertyEvaluatorService propertyEvaluatorService, OrchestratorDeploymentPropertiesService deploymentPropertiesService) {
        super(mappingConfiguration, alienDeployment, recipePath, propertyEvaluatorService);

        this.deploymentPropertiesService = deploymentPropertiesService;
    }

    public String getMonitoringInterval() {
        return deploymentPropertiesService.getValueOrDefault(alienDeployment.getProviderDeploymentProperties(),
                DeploymentPropertiesNames.MONITORING_INTERVAL_INMINUTE);
    }

    public String getCfyScriptVersion() {
        return CloudifyOrchestratorFactory.CFY_SCRIPT_VERSION;
    }

    public String getScalarPropertyValue(NodeTemplate nodeTemplate, String propertyName) {
        AbstractPropertyValue value = (AbstractPropertyValue) MapUtil.get(nodeTemplate.getProperties(), propertyName);
        if (value != null) {
            return ((ScalarPropertyValue) value).getValue();
        }

        return "";
    }

}

@@ -68,16 +68,62 @@
 .Path;%0A%0A
+import org.apache.commons.lang3.StringUtils;%0A%0A
 import a
@@ -2001,10 +2001,397 @@
 %0A    %7D%0A%0A
+    public String truncateString(String toBeAbbreviated, int maxWidth) %7B%0A        if (StringUtils.isEmpty(toBeAbbreviated)) %7B%0A            return toBeAbbreviated;%0A        %7D else %7B%0A            if (toBeAbbreviated.length() %3E maxWidth) %7B%0A                return toBeAbbreviated.substring(0, maxWidth);%0A            %7D else %7B%0A                return toBeAbbreviated;%0A            %7D%0A        %7D%0A    %7D%0A
 %7D%0A

Add utility function for azure