org.springframework.cloud.dataflow.rest.util

## Class DeploymentPropertiesUtils

- java.lang.Object
- - org.springframework.cloud.dataflow.rest.util.DeploymentPropertiesUtils

-     public final class DeploymentPropertiesUtils
      extends Object

  Provides utility methods for formatting and parsing deployment properties.
  Author:
    Eric Bottard, Mark Fisher, Janne Valkealahti, Christian Tzolov, Gunnar Hillert, Ilayaperumal Gopinathan

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Map<String,String>` | `convert(Properties properties)` Convert Properties to a Map with String keys and String values.
    `static Map<String,String>` | `extractAndQualifyDeployerProperties(Map<String,String> input, String appName)` Retain only properties that are meant for the deployer of a given app (those that start with `deployer.[appname]` or `deployer.*`) and qualify all property values with the `spring.cloud.deployer.` prefix.
    `static String` | `format(Map<String,String> properties)` Returns a String representation of deployment properties as a comma separated list of key=value pairs.
    `static Map<String,String>` | `parse(String s)` Parses a String comprised of 0 or more comma-delimited key=value pairs where each key has the format: `app.[appname].[key]` or `deployer.[appname].[key]`.
    `static List<String>` | `parseArgumentList(String s, String delimiter)` Parses a String comprised of 0 or more delimited key=value pairs where each key has the format: `app.[appname].[key]` or `deployer.[appname].[key]`.
    `static Map<String,String>` | `parseDeploymentProperties(String deploymentProperties, File propertiesFile, int which)` Parses a deployment properties conditionally either from properties string or file which can be legacy properties file or yaml.
    `static List<String>` | `parseParamList(String s, String delimiter)` Parses a String comprised of 0 or more delimited key=value pairs where each key has the format: `app.[appname].[key]` or `deployer.[appname].[key]`.
    `static Map<String,String>` | `qualifyDeployerProperties(Map<String,String> input, String appName)` Retain all properties that are meant for the deployer of a given app (those that start with `deployer.[appname]` or `deployer.*` and qualify all property values with the `spring.cloud.deployer.` prefix.
    `static List<String>` | `removeQuoting(List<String> params)` Parses a list of command line parameters and returns a list of parameters which doesn't contain any special quoting either for values or whole parameter.
    `static void` | `validateDeploymentProperties(Map<String,String> properties)` Ensure that deployment properties only have keys starting with `app.`, `deployer.` or, `spring.cloud.scheduler.`.
    `static void` | `validateSkipperDeploymentProperties(Map<String,String> properties)` Ensure that deployment properties only have keys starting with `app.`, `deployer.` or `version.`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### parse

          public static Map<String,String> parse(String s)

      Parses a String comprised of 0 or more comma-delimited key=value pairs where each key has the format: `app.[appname].[key]` or `deployer.[appname].[key]`. Values may themselves contain commas, since the split points will be based upon the key pattern.

      Logic of parsing key/value pairs from a string is based on few rules and assumptions 1. keys will not have commas or equals. 2. First raw split is done by commas which will need to be fixed later if value is a comma-delimited list.

      Parameters:
        `s` - the string to parse
      Returns:
        the Map of parsed key value pairs

    - #### parseParamList

          public static List<String> parseParamList(String s,
                                                    String delimiter)

      Parses a String comprised of 0 or more delimited key=value pairs where each key has the format: `app.[appname].[key]` or `deployer.[appname].[key]`. Values may themselves contain commas, since the split points will be based upon the key pattern.

      Logic of parsing key/value pairs from a string is based on few rules and assumptions 1. keys will not have commas or equals. 2. First raw split is done by commas which will need to be fixed later if value is a comma-delimited list.

      Parameters:
        `s` - the string to parse
        `delimiter` - delimiter used to split the string into pairs
      Returns:
        the List key=value pairs

    - #### parseArgumentList

          public static List<String> parseArgumentList(String s,
                                                       String delimiter)

      Parses a String comprised of 0 or more delimited key=value pairs where each key has the format: `app.[appname].[key]` or `deployer.[appname].[key]`. Values may themselves contain commas, since the split points will be based upon the key pattern.

      Logic of parsing key/value pairs from a string is based on few rules and assumptions 1. keys will not have commas or equals. 2. First raw split is done by commas which will need to be fixed later if value is a comma-delimited list.

      Parameters:
        `s` - the string to parse
        `delimiter` - delimiter used to split the string into pairs
      Returns:
        the List key=value pairs

    - #### parseDeploymentProperties

          public static Map<String,String> parseDeploymentProperties(String deploymentProperties,
                                                                     File propertiesFile,
                                                                     int which)
                                                              throws IOException

      Parses a deployment properties conditionally either from properties string or file which can be legacy properties file or yaml.
      Parameters:
        `deploymentProperties` - the deployment properties string
        `propertiesFile` - the deployment properties file
        `which` - the flag to choose between properties or file
      Returns:
        the map of parsed properties
      Throws:
        `IOException` - if file loading errors

    - #### validateDeploymentProperties

          public static void validateDeploymentProperties(Map<String,String> properties)

      Ensure that deployment properties only have keys starting with `app.`, `deployer.` or, `spring.cloud.scheduler.`. In case non supported key is found `IllegalArgumentException` is thrown.
      Parameters:
        `properties` - the properties to check

    - #### validateSkipperDeploymentProperties

          public static void validateSkipperDeploymentProperties(Map<String,String> properties)

      Ensure that deployment properties only have keys starting with `app.`, `deployer.` or `version.`. In case non supported key is found `IllegalArgumentException` is thrown.
      Parameters:
        `properties` - the properties to check

    - #### extractAndQualifyDeployerProperties

          public static Map<String,String> extractAndQualifyDeployerProperties(Map<String,String> input,
                                                                               String appName)

      Retain only properties that are meant for the deployer of a given app (those that start with `deployer.[appname]` or `deployer.*`) and qualify all property values with the `spring.cloud.deployer.` prefix.
      Parameters:
        `input` - the deplopyment properties
        `appName` - the app name
      Returns:
        deployment properties for the spepcific app name

    - #### qualifyDeployerProperties

          public static Map<String,String> qualifyDeployerProperties(Map<String,String> input,
                                                                     String appName)

      Retain all properties that are meant for the deployer of a given app (those that start with `deployer.[appname]` or `deployer.*` and qualify all property values with the `spring.cloud.deployer.` prefix.
      Parameters:
        `input` - the deplopyment properties
        `appName` - the app name
      Returns:
        deployment properties for the spepcific app name

    - #### format

          public static String format(Map<String,String> properties)

      Returns a String representation of deployment properties as a comma separated list of key=value pairs.
      Parameters:
        `properties` - the properties to format
      Returns:
        the properties formatted as a String

    - #### convert

          public static Map<String,String> convert(Properties properties)

      Convert Properties to a Map with String keys and String values.
      Parameters:
        `properties` - the properties object
      Returns:
        the equivalent `Map<String,String>`

    - #### removeQuoting

          public static List<String> removeQuoting(List<String> params)

      Parses a list of command line parameters and returns a list of parameters which doesn't contain any special quoting either for values or whole parameter.
      Parameters:
        `params` - the params
      Returns:
        the list

Copyright © 2021 Pivotal Software, Inc.. All rights reserved.