Class ModelUtility
- java.lang.Object
-
- org.apache.sling.provisioning.model.ModelUtility
-
public abstract class ModelUtility extends java.lang.Object
Model utility
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ModelUtility.ArtifactVersionResolver
Optional artifact dependency version resolverstatic class
ModelUtility.ResolverOptions
Parameter builder class forgetEffectiveModel(Model, ResolverOptions)
method.static interface
ModelUtility.VariableResolver
Optional variable resolver
-
Constructor Summary
Constructors Constructor Description ModelUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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").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
merge(Model base, Model additional)
Deprecated.Use {linkMergeUtility.merge(Model, Model)
static void
merge(Model base, Model additional, boolean handleRemove)
static java.util.Map<Traceable,java.lang.String>
validate(Model model)
Validates the model.static java.util.Map<Traceable,java.lang.String>
validateIncludingVersion(Model model)
Validates the model and checks that each feature has a valid version.
-
-
-
Method Detail
-
merge
@Deprecated public static void merge(Model base, Model additional)
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 public static void merge(Model base, Model additional, boolean handleRemove)
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:
java.lang.IllegalArgumentException
- If a variable can't be replaced or configuration properties can't be parsed
-
getEffectiveModel
public static Model getEffectiveModel(Model model)
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:
java.lang.IllegalArgumentException
- If a variable can't be replaced or configuration properties can't be parsed- Since:
- 1.3
-
getEffectiveModel
public static Model getEffectiveModel(Model model, ModelUtility.ResolverOptions options)
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:
java.lang.IllegalArgumentException
- If a variable can't be replaced or configuration properties can't be parsed- Since:
- 1.3
-
validate
public static java.util.Map<Traceable,java.lang.String> validate(Model model)
Validates the model.- Parameters:
model
- The model to validate- Returns:
- A map with errors or
null
if valid.
-
applyVariables
public static Model applyVariables(Model model, ModelUtility.VariableResolver resolver)
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:
java.lang.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:
java.lang.IllegalArgumentException
- If the provider does not allow unresolved version and a version could not be resolved- Since:
- 1.3
-
validateIncludingVersion
public static java.util.Map<Traceable,java.lang.String> validateIncludingVersion(Model model)
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
-
-