Class ConfigurationApi
- java.lang.Object
-
- org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity
-
- org.apache.sling.feature.extension.apiregions.api.config.ConfigurationApi
-
public class ConfigurationApi extends AttributeableEntity
A configuration api describes the set of supported OSGi configurations and framework properties. This object can be stored as an extension inside a feature model. This class is not thread safe.
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXTENSION_NAME
The name of the api regions extension.
-
Constructor Summary
Constructors Constructor Description ConfigurationApi()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
clear()
Clear the object and reset to defaultsprotected javax.json.JsonObjectBuilder
createJson()
Convert this object into JSONRegion
detectRegion()
Detect the region, either return the stored region or the default (GLOBAL)void
fromJSONObject(javax.json.JsonObject jsonObj)
Extract the metadata from the JSON object.static ConfigurationApi
getConfigurationApi(org.apache.sling.feature.Extension ext)
Get the configuration api from the extension.static ConfigurationApi
getConfigurationApi(org.apache.sling.feature.Feature feature)
Get the configuration api from the feature - if it exists.Map<String,ConfigurationDescriptionAddition>
getConfigurationDescriptionAdditions()
Get the map of configuration description additionsMap<String,ConfigurationDescription>
getConfigurationDescriptions()
Get the configuration descriptionsMap<String,FactoryConfigurationDescriptionAddition>
getFactoryConfigurationDescriptionAdditions()
Get the map of factory configuration description additionsMap<String,FactoryConfigurationDescription>
getFactoryConfigurationDescriptions()
Get the factory configuration descriptionsMap<org.apache.sling.feature.ArtifactId,Region>
getFeatureToRegionCache()
Get the feature to region cache to keep track of regions for origin featuresMap<String,FrameworkPropertyDescription>
getFrameworkPropertyDescriptions()
Get the framework propertiesSet<String>
getInternalConfigurations()
Deprecated.Please use empty configuration descriptions viagetConfigurationDescriptions()
Set<String>
getInternalFactoryConfigurations()
Deprecated.Please use empty factory configuration descriptions viagetFactoryConfigurationDescriptions()
Set<String>
getInternalFrameworkProperties()
Get the internal framework property namesMode
getMode()
Get the validation mode.Region
getRegion()
Get the api configuration regionboolean
isInternalConfiguration(String pid)
Check if the configuration is an internal configurationboolean
isInternalFactoryConfiguration(String factoryPid, String name)
Check if the factory configuration is an internal configurationstatic void
setConfigurationApi(org.apache.sling.feature.Feature feature, ConfigurationApi api)
Set the configuration api as an extension to the featureprotected void
setDefaults()
Apply the non-null default values.void
setMode(Mode value)
Set the validation modevoid
setRegion(Region value)
Set the api configuration region-
Methods inherited from class org.apache.sling.feature.extension.apiregions.api.config.AttributeableEntity
getAttributes, getBoolean, getInteger, getNumber, getString, getString, getStringArray, setString, setStringArray, toJSONObject
-
-
-
-
Field Detail
-
EXTENSION_NAME
public static final String EXTENSION_NAME
The name of the api regions extension.- See Also:
- Constant Field Values
-
-
Method Detail
-
getConfigurationApi
public static ConfigurationApi getConfigurationApi(org.apache.sling.feature.Feature feature)
Get the configuration api from the feature - if it exists. If the configuration api is updated, the containing feature is left untouched.setConfigurationApi(Feature, ConfigurationApi)
can be used to update the feature.- Parameters:
feature
- The feature- Returns:
- The configuration api or
null
. - Throws:
IllegalArgumentException
- If the extension is wrongly formatted
-
getConfigurationApi
public static ConfigurationApi getConfigurationApi(org.apache.sling.feature.Extension ext)
Get the configuration api from the extension. If the configuration api is updated, the containing extension is left untouched.- Parameters:
ext
- The extension- Returns:
- The configuration api or
null
if the extension isnull
. - Throws:
IllegalArgumentException
- If the extension is wrongly formatted
-
setConfigurationApi
public static void setConfigurationApi(org.apache.sling.feature.Feature feature, ConfigurationApi api)
Set the configuration api as an extension to the feature- Parameters:
feature
- The featureapi
- The configuration api- Throws:
IllegalStateException
- If the feature has already an extension of a wrong typeIllegalArgumentException
- If the api configuration can't be serialized to JSON
-
setDefaults
protected void setDefaults()
Description copied from class:AttributeableEntity
Apply the non-null default values.- Overrides:
setDefaults
in classAttributeableEntity
-
clear
public void clear()
Clear the object and reset to defaults- Overrides:
clear
in classAttributeableEntity
-
fromJSONObject
public void fromJSONObject(javax.json.JsonObject jsonObj) throws IOException
Extract the metadata from the JSON object. This method first callsclear()
.- Overrides:
fromJSONObject
in classAttributeableEntity
- Parameters:
jsonObj
- The JSON Object- Throws:
IOException
- If JSON parsing fails
-
getConfigurationDescriptions
public Map<String,ConfigurationDescription> getConfigurationDescriptions()
Get the configuration descriptions- Returns:
- Mutable map of configuration descriptions by pid
-
getFactoryConfigurationDescriptions
public Map<String,FactoryConfigurationDescription> getFactoryConfigurationDescriptions()
Get the factory configuration descriptions- Returns:
- Mutable map of factory descriptions by factory pid
-
getFrameworkPropertyDescriptions
public Map<String,FrameworkPropertyDescription> getFrameworkPropertyDescriptions()
Get the framework properties- Returns:
- Mutable map of framework properties
-
getInternalConfigurations
@Deprecated public Set<String> getInternalConfigurations()
Deprecated.Please use empty configuration descriptions viagetConfigurationDescriptions()
Get the internal configuration pids- Returns:
- Mutable set of internal configuration pids
-
getInternalFactoryConfigurations
@Deprecated public Set<String> getInternalFactoryConfigurations()
Deprecated.Please use empty factory configuration descriptions viagetFactoryConfigurationDescriptions()
Get the internal factory pids- Returns:
- Mutable set of internal factory configuration pids
-
isInternalConfiguration
public boolean isInternalConfiguration(String pid)
Check if the configuration is an internal configuration- Parameters:
pid
- The pid- Returns:
true
if it is an internal configuration- Since:
- 1.7.0
-
isInternalFactoryConfiguration
public boolean isInternalFactoryConfiguration(String factoryPid, String name)
Check if the factory configuration is an internal configuration- Parameters:
factoryPid
- The factory pidname
- Optional name of the configuration- Returns:
true
if it is an internal factory configuration- Since:
- 1.7.0
-
getInternalFrameworkProperties
public Set<String> getInternalFrameworkProperties()
Get the internal framework property names- Returns:
- Mutable set of internal framework property names
-
getRegion
public Region getRegion()
Get the api configuration region- Returns:
- The region or
null
-
setRegion
public void setRegion(Region value)
Set the api configuration region- Parameters:
value
- The region to set
-
detectRegion
public Region detectRegion()
Detect the region, either return the stored region or the default (GLOBAL)- Returns:
- The region
- Since:
- 1.1
-
getFeatureToRegionCache
public Map<org.apache.sling.feature.ArtifactId,Region> getFeatureToRegionCache()
Get the feature to region cache to keep track of regions for origin features- Returns:
- The cache
- Since:
- 1.1.
-
getMode
public Mode getMode()
Get the validation mode. The default isMode.STRICT
- Returns:
- The mode
- Since:
- 1.2
-
setMode
public void setMode(Mode value)
Set the validation mode- Parameters:
value
- The validation mode- Since:
- 1.2
-
createJson
protected javax.json.JsonObjectBuilder createJson() throws IOException
Convert this object into JSON- Overrides:
createJson
in classAttributeableEntity
- Returns:
- The json object builder
- Throws:
IOException
- If generating the JSON fails
-
getConfigurationDescriptionAdditions
public Map<String,ConfigurationDescriptionAddition> getConfigurationDescriptionAdditions()
Get the map of configuration description additions- Returns:
- The map, might be empty
- Since:
- 1.8
-
getFactoryConfigurationDescriptionAdditions
public Map<String,FactoryConfigurationDescriptionAddition> getFactoryConfigurationDescriptionAdditions()
Get the map of factory configuration description additions- Returns:
- The map, might be empty
- Since:
- 1.8
-
-