Class ArtifactRules
java.lang.Object
org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity
org.apache.sling.feature.extension.apiregions.api.artifacts.ArtifactRules
Artifact rules define additional rules for artifacts in a feature model.
The rules are stored as an extension in the feature model.
This class is not thread safe.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the object and reset to defaultsjakarta.json.JsonObjectBuilderConvert this object into JSONvoidfromJSONObject(jakarta.json.JsonObject jsonObj) Extract the metadata from the JSON object.static ArtifactRulesgetArtifactRules(org.apache.sling.feature.Extension ext) Get the artifact rules from the extension - if it exists.static ArtifactRulesgetArtifactRules(org.apache.sling.feature.Feature feature) Get the artifact rules from the feature - if it exists.Return the list of version rules for artifacts.Return the list of version rules for bundles.getMode()Get the validation mode.static voidsetArtifactRules(org.apache.sling.feature.Feature feature, ArtifactRules rules) Set the rules as an extension to the featureprotected voidApply the non-null default values.voidSet the validation modeMethods inherited from class org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity
getAttributes, getBoolean, getInteger, getNumber, getString, getString, getStringArray, setString, setStringArray, toJSONObject
-
Field Details
-
EXTENSION_NAME
The name of the feature model extension.- See Also:
-
-
Constructor Details
-
ArtifactRules
public ArtifactRules()Create a new rules object
-
-
Method Details
-
getArtifactRules
Get the artifact rules from the feature - if it exists. If the rules are updated, the containing feature is left untouched.setArtifactRules(Feature, ArtifactRules)can be used to update the feature.- Parameters:
feature- The feature- Returns:
- The rules or
null. - Throws:
IllegalArgumentException- If the extension is wrongly formatted
-
getArtifactRules
Get the artifact rules from the extension - if it exists. If the rules are updated, the containing feature is left untouched.setArtifactRules(Feature, ArtifactRules)can be used to update the feature.- Parameters:
ext- The extension- Returns:
- The rules or
nullif the extension isnull. - Throws:
IllegalArgumentException- If the extension is wrongly formatted
-
setArtifactRules
Set the rules as an extension to the feature- Parameters:
feature- The featurerules- The rules. Ifnullthe extension will be removed.- Throws:
IllegalStateException- If the feature has already an extension of a wrong typeIllegalArgumentException- If the rules can't be serialized to JSON
-
setDefaults
protected void setDefaults()Description copied from class:AttributeableEntityApply the non-null default values.- Overrides:
setDefaultsin classAttributeableEntity
-
clear
public void clear()Clear the object and reset to defaults- Overrides:
clearin classAttributeableEntity
-
createJson
Convert this object into JSON- Overrides:
createJsonin classAttributeableEntity- Returns:
- The json object builder
- Throws:
IOException- If generating the JSON fails
-
fromJSONObject
Extract the metadata from the JSON object. This method first callsclear().- Overrides:
fromJSONObjectin classAttributeableEntity- Parameters:
jsonObj- The JSON Object- Throws:
IOException- If JSON parsing fails
-
getMode
Get the validation mode. The default isMode.STRICT- Returns:
- The mode
-
setMode
Set the validation mode- Parameters:
value- The validation mode
-
getBundleVersionRules
Return the list of version rules for bundles. The returned list is mutable.- Returns:
- The list of rules, might be empty.
-
getArtifactVersionRules
Return the list of version rules for artifacts. The returned list is mutable.- Returns:
- the list of rules, might be empty.
-