Class ModelUtility
java.lang.Object
org.apache.sling.provisioning.model.ModelUtility
Model utility
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Optional artifact dependency version resolverstatic final class
Parameter builder class forgetEffectiveModel(Model, ResolverOptions)
method.static interface
Optional variable resolver -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Model
applyArtifactVersions
(Model model, ModelUtility.ArtifactVersionResolver resolver) Resolves artifact versions that are no set explicitly in the provisioning file via the given resolver (version = "LATEST").static Model
applyVariables
(Model model, ModelUtility.VariableResolver resolver) Applies a set of variables to the given model.static Model
getEffectiveModel
(Model model) Replace all variables in the model and return a new model with the replaced values.static Model
getEffectiveModel
(Model model, ModelUtility.ResolverOptions options) Replace all variables in the model and return a new model with the replaced values.static Model
getEffectiveModel
(Model model, ModelUtility.VariableResolver resolver) Deprecated.static void
Deprecated.Use {linkMergeUtility.merge(Model, Model)
static void
Validates the model.validateIncludingVersion
(Model model) Validates the model and checks that each feature has a valid version.
-
Constructor Details
-
ModelUtility
public ModelUtility()
-
-
Method Details
-
merge
Deprecated.Use {linkMergeUtility.merge(Model, Model)
Merge the additional model into the base model.- Parameters:
base
- The base model.additional
- The additional model.
-
merge
Deprecated.Merge the additional model into the base model.- Parameters:
base
- The base model.additional
- The additional model.handleRemove
- Handle special remove run mode- Since:
- 1.2
-
getEffectiveModel
@Deprecated public static Model getEffectiveModel(Model model, ModelUtility.VariableResolver resolver) Deprecated.Replace all variables in the model and return a new model with the replaced values.- Parameters:
model
- The base model.resolver
- Optional variable resolver.- Returns:
- The model with replaced variables.
- Throws:
IllegalArgumentException
- If a variable can't be replaced or configuration properties can't be parsed
-
getEffectiveModel
Replace all variables in the model and return a new model with the replaced values.- Parameters:
model
- The base model.- Returns:
- The model with replaced variables.
- Throws:
IllegalArgumentException
- If a variable can't be replaced or configuration properties can't be parsed- Since:
- 1.3
-
getEffectiveModel
Replace all variables in the model and return a new model with the replaced values.- Parameters:
model
- The base model.options
- Resolver options.- Returns:
- The model with replaced variables.
- Throws:
IllegalArgumentException
- If a variable can't be replaced or configuration properties can't be parsed- Since:
- 1.3
-
validate
Validates the model.- Parameters:
model
- The model to validate- Returns:
- A map with errors or
null
if valid.
-
applyVariables
Applies a set of variables to the given model. All variables that are referenced anywhere within the model are detected and passed to the given variable resolver. The variable resolver may look up variables on it's own, or fall back to the variables already defined for the feature. All resolved variable values are collected and put to the "variables" section of the resulting model.- Parameters:
model
- Original modelresolver
- Variable resolver- Returns:
- Model with updated "variables" section.
- Throws:
IllegalArgumentException
- If a variable can't be replaced or configuration properties can't be parsed- Since:
- 1.3
-
applyArtifactVersions
public static Model applyArtifactVersions(Model model, ModelUtility.ArtifactVersionResolver resolver) Resolves artifact versions that are no set explicitly in the provisioning file via the given resolver (version = "LATEST"). If the resolver does not resolve to a version "LATEST" is left in the model. The resolver may decide to raise an IllegalArgumentException in this case if unresolved dependencies are no allowed.- Parameters:
model
- Original modelresolver
- Artifact version resolver- Returns:
- Model with updated artifact versions
- Throws:
IllegalArgumentException
- If the provider does not allow unresolved version and a version could not be resolved- Since:
- 1.3
-
validateIncludingVersion
Validates the model and checks that each feature has a valid version. This method first callsvalidate(Model)
and then checks that each feature has a version.- Parameters:
model
- The model to validate- Returns:
- A map with errors or
null
if valid. - Since:
- 1.9
-
getEffectiveModel(Model)
orgetEffectiveModel(Model, ResolverOptions)
instead