Package com.ibm.dbb.task.configuration
Class ConfigurationParser
- java.lang.Object
-
- com.ibm.dbb.task.configuration.ConfigurationParser
-
public class ConfigurationParser extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ConfigurationParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.fasterxml.jackson.databind.JsonNode
fileToJson(java.lang.String schemaPath)
static java.util.Map<java.lang.String,java.lang.Object>
getApplicationConfiguration(java.lang.String file)
Reads an application configuration file and validates it against the application configuration schema.static java.util.Map<java.lang.String,java.lang.Object>
getBuildConfiguration()
Reads the default build configuration file in the DBB installation build folder and validates it against the build configuration schema.static java.util.Map<java.lang.String,java.lang.Object>
getBuildConfiguration(java.lang.String file)
Reads a build configuration file and validates it against the build configuration schema.static java.util.Map<java.lang.String,java.lang.Object>
getDependencyFile(java.lang.String file)
Reads a dependency file and validates it against the dependency file schema.static com.networknt.schema.SpecVersion.VersionFlag
getVersionFlag(com.networknt.schema.SpecVersion.VersionFlag version)
static com.fasterxml.jackson.databind.JsonNode
mapToJson(java.util.Map<java.lang.String,java.lang.Object> map)
static java.util.Map<java.lang.String,java.lang.Object>
parseYaml(java.lang.String path)
Parses a yaml file at the specified path.static com.fasterxml.jackson.databind.JsonNode
streamToJson(java.io.InputStream stream)
static com.fasterxml.jackson.databind.JsonNode
stringToJson(java.lang.String string)
static void
validateAppConfigurationVersion(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap)
Validates the version variable in a map representing an application configuration.static void
validateApplicationConfiguration(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap)
Validate an application configuration map.static void
validateBuildConfiguration(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap)
Validate a build configuration map.static void
validateBuildConfigurationVersion(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap)
Validates the version variable in a map representing a build configuration.static void
validateConfiguration(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap, java.lang.String schemaPath)
Validate a configuration map against a specified schema.
-
-
-
Method Detail
-
getApplicationConfiguration
public static java.util.Map<java.lang.String,java.lang.Object> getApplicationConfiguration(java.lang.String file) throws java.io.IOException, BuildException
Reads an application configuration file and validates it against the application configuration schema.- Parameters:
file
- A path to a configuration file.- Throws:
com.networknt.schema.JsonSchemaException
- if the configuration file does not match its schema.java.io.IOException
- if there is a problem loading the schema into the validator.BuildException
- if there is a problem reading the file, the map is missing a version variable in its root level, or if it contains an invalid version.
-
validateApplicationConfiguration
public static void validateApplicationConfiguration(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap) throws java.io.IOException, BuildException
Validate an application configuration map.- Parameters:
file
- The name of the file that the configuration map was parsed from for generating error messages if needed.configurationMap
- The configuration map to be validated.- Throws:
com.networknt.schema.JsonSchemaException
- if the configuration map does not match the schema.java.io.IOException
- if there is a problem with loading the schema into the validator.BuildException
- if the map is missing a version variable in its root level or if it contains an invalid version.
-
getBuildConfiguration
public static java.util.Map<java.lang.String,java.lang.Object> getBuildConfiguration() throws java.io.IOException, BuildException
Reads the default build configuration file in the DBB installation build folder and validates it against the build configuration schema.- Throws:
com.networknt.schema.JsonSchemaException
- if the configuration file does not match its schema.java.io.IOException
- if there is a problem loading the schema into the validator.BuildException
- if there is a problem reading the file, the map is missing a version variable in its root level, or if it contains an invalid version.
-
getBuildConfiguration
public static java.util.Map<java.lang.String,java.lang.Object> getBuildConfiguration(java.lang.String file) throws java.io.IOException, BuildException
Reads a build configuration file and validates it against the build configuration schema.- Parameters:
file
- A path to a configuration file.- Throws:
com.networknt.schema.JsonSchemaException
- if the configuration file does not match its schema.java.io.IOException
- if there is a problem loading the schema into the validator.BuildException
- if there is a problem reading the file, the map is missing a version variable in its root level, or if it contains an invalid version.
-
getDependencyFile
public static java.util.Map<java.lang.String,java.lang.Object> getDependencyFile(java.lang.String file) throws java.io.IOException, BuildException
Reads a dependency file and validates it against the dependency file schema.- Parameters:
file
- A path to a configuration file.- Throws:
com.networknt.schema.JsonSchemaException
- if the configuration file does not match the schema.java.io.IOException
- if there is a problem loading the schema into the validator.BuildException
- there is a problem reading the file.
-
validateBuildConfiguration
public static void validateBuildConfiguration(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap) throws java.io.IOException, BuildException
Validate a build configuration map.- Parameters:
file
- The name of the file that the configuration map was parsed from for generating error messages if needed.configurationMap
- The configuration map to be validated.- Throws:
com.networknt.schema.JsonSchemaException
- if the configuration map does not match the schema.java.io.IOException
- if there is a problem with loading the schema into the validator.BuildException
- if the map is missing a version variable in its root level or if it contains an invalid version.
-
validateConfiguration
public static void validateConfiguration(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap, java.lang.String schemaPath) throws java.io.IOException
Validate a configuration map against a specified schema.- Parameters:
file
- The name of the file that the configuration map was parsed from for generating error messages if needed.configurationMap
- The configuration map to be validated.schemaPath
- The path to the JSON schema.- Throws:
com.networknt.schema.JsonSchemaException
- if the configuration map does not match the schema.java.io.IOException
- if there is a problem with loading the schema into the validator.
-
validateBuildConfigurationVersion
public static void validateBuildConfigurationVersion(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap) throws BuildException
Validates the version variable in a map representing a build configuration.- Parameters:
file
- The name of the file that the configuration map was parsed from for generating error messages if needed.configurationMap
- The configuration map to be validated.- Throws:
BuildException
- if the map is missing a version variable in its root level or if it contains an invalid version.
-
validateAppConfigurationVersion
public static void validateAppConfigurationVersion(java.lang.String file, java.util.Map<java.lang.String,java.lang.Object> configurationMap) throws BuildException
Validates the version variable in a map representing an application configuration.- Parameters:
file
- The name of the file that the configuration map was parsed from for generating error messages if needed.configurationMap
- The configuration map to be validated.- Throws:
BuildException
- if the map is missing a version variable in its root level or if it contains an invalid version.
-
parseYaml
public static java.util.Map<java.lang.String,java.lang.Object> parseYaml(java.lang.String path) throws BuildException
Parses a yaml file at the specified path.- Parameters:
path
- of the file to parse- Returns:
- Map
Representing the YAML file data - Throws:
BuildException
- if either the file does not exist, there is some error with reading it, or the object returned from the parser was not a map because the yaml file is a different type of object like a list or some other.
-
mapToJson
public static com.fasterxml.jackson.databind.JsonNode mapToJson(java.util.Map<java.lang.String,java.lang.Object> map) throws com.fasterxml.jackson.databind.JsonMappingException, com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.databind.JsonMappingException
com.fasterxml.jackson.core.JsonProcessingException
-
fileToJson
public static com.fasterxml.jackson.databind.JsonNode fileToJson(java.lang.String schemaPath) throws java.io.IOException
- Throws:
java.io.IOException
-
streamToJson
public static com.fasterxml.jackson.databind.JsonNode streamToJson(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
stringToJson
public static com.fasterxml.jackson.databind.JsonNode stringToJson(java.lang.String string) throws com.fasterxml.jackson.databind.JsonMappingException, com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.databind.JsonMappingException
com.fasterxml.jackson.core.JsonProcessingException
-
getVersionFlag
public static com.networknt.schema.SpecVersion.VersionFlag getVersionFlag(com.networknt.schema.SpecVersion.VersionFlag version)
-
-