Class DefaultConfigurationPersistenceStrategy

java.lang.Object
org.apache.sling.caconfig.impl.def.DefaultConfigurationPersistenceStrategy
All Implemented Interfaces:
ConfigurationPersistenceStrategy2

public class DefaultConfigurationPersistenceStrategy extends Object implements ConfigurationPersistenceStrategy2
The default persistence strategy is quite simple: directly use the configuration resources. All existing properties are removed when new properties are stored in a singleton config resource. All existing child resources are removed when a new configs are stored for collection config resources.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    deleteConfiguration(@NotNull ResourceResolver resourceResolver, @NotNull String configResourcePath)
    Delete configuration or configuration collection data from repository using the inner-most context path as reference.
    getCollectionItemConfigName(@NotNull String configName, @Nullable String relatedConfigPath)
    Allows the strategy to transform the given configuration name for nested configurations according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    Allows the strategy to transform the given configuration resource according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    getCollectionItemResourcePath(@NotNull String resourcePath)
    Allows the strategy to transform the given configuration resource path according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    getCollectionParentConfigName(@NotNull String configName, @Nullable String relatedConfigPath)
    Allows the strategy to transform the given configuration name for nested configurations according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    Allows the strategy to transform the given configuration resource according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    getCollectionParentResourcePath(@NotNull String resourcePath)
    Allows the strategy to transform the given configuration resource path according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    getConfigName(@NotNull String configName, @Nullable String relatedConfigPath)
    Allows the strategy to transform the given configuration name for nested configurations according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    getResource(@NotNull Resource resource)
    Allows the strategy to transform the given configuration resource according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    getResourcePath(@NotNull String resourcePath)
    Allows the strategy to transform the given configuration resource path according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
    boolean
    persistConfiguration(@NotNull ResourceResolver resourceResolver, @NotNull String configResourcePath, @NotNull ConfigurationPersistData data)
    Stores configuration data for a singleton configuration resource.
    boolean
    persistConfigurationCollection(@NotNull ResourceResolver resourceResolver, @NotNull String configResourceCollectionParentPath, @NotNull ConfigurationCollectionPersistData data)
    Stores configuration data for a configuration resource collection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultConfigurationPersistenceStrategy

      public DefaultConfigurationPersistenceStrategy()
  • Method Details

    • getResource

      public Resource getResource(@NotNull @NotNull Resource resource)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration resource according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getResource in interface ConfigurationPersistenceStrategy2
      Parameters:
      resource - Singleton configuration resource
      Returns:
      Transformed configuration resource. If null is returned this strategy does not support the given configuration resource.
    • getCollectionParentResource

      public Resource getCollectionParentResource(@NotNull @NotNull Resource resource)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration resource according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getCollectionParentResource in interface ConfigurationPersistenceStrategy2
      Parameters:
      resource - Configuration collection parent resource
      Returns:
      Transformed configuration resource. If null is returned this strategy does not support the given configuration resource.
    • getCollectionItemResource

      public Resource getCollectionItemResource(@NotNull @NotNull Resource resource)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration resource according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getCollectionItemResource in interface ConfigurationPersistenceStrategy2
      Parameters:
      resource - Configuration collection item resource
      Returns:
      Transformed configuration resource. If null is returned this strategy does not support the given configuration resource.
    • getResourcePath

      public String getResourcePath(@NotNull @NotNull String resourcePath)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration resource path according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getResourcePath in interface ConfigurationPersistenceStrategy2
      Parameters:
      resourcePath - Configuration resource path (full path)
      Returns:
      Transformed configuration resource path. If null is returned this strategy does not support the given configuration resource path.
    • getCollectionParentResourcePath

      public String getCollectionParentResourcePath(@NotNull @NotNull String resourcePath)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration resource path according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getCollectionParentResourcePath in interface ConfigurationPersistenceStrategy2
      Parameters:
      resourcePath - Configuration collection parent resource path (full path)
      Returns:
      Transformed configuration resource path. If null is returned this strategy does not support the given configuration resource path.
    • getCollectionItemResourcePath

      public String getCollectionItemResourcePath(@NotNull @NotNull String resourcePath)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration resource path according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getCollectionItemResourcePath in interface ConfigurationPersistenceStrategy2
      Parameters:
      resourcePath - Configuration collection item resource path (full path)
      Returns:
      Transformed configuration resource path. If null is returned this strategy does not support the given configuration resource path.
    • getConfigName

      public String getConfigName(@NotNull @NotNull String configName, @Nullable @Nullable String relatedConfigPath)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration name for nested configurations according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getConfigName in interface ConfigurationPersistenceStrategy2
      Parameters:
      configName - Configuration name
      relatedConfigPath - Path of a configuration resource that was resolved in context of this configuration name. This can be used to detect if the persistence strategy supports the configuration location. If null it should be assumed that it matches.
      Returns:
      Transformed configuration name. If null is returned this strategy does not support the given configuration resource path.
    • getCollectionParentConfigName

      public String getCollectionParentConfigName(@NotNull @NotNull String configName, @Nullable @Nullable String relatedConfigPath)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration name for nested configurations according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getCollectionParentConfigName in interface ConfigurationPersistenceStrategy2
      Parameters:
      configName - Configuration name
      relatedConfigPath - Path of a configuration resource that was resolved in context of this configuration name. This can be used to detect if the persistence strategy supports the configuration location. If null it should be assumed that it matches.
      Returns:
      Transformed configuration name. If null is returned this strategy does not support the given configuration resource path.
    • getCollectionItemConfigName

      public String getCollectionItemConfigName(@NotNull @NotNull String configName, @Nullable @Nullable String relatedConfigPath)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Allows the strategy to transform the given configuration name for nested configurations according to it's persistent strategies, e.g. fetching the data from a child resource instead of the given resource.
      Specified by:
      getCollectionItemConfigName in interface ConfigurationPersistenceStrategy2
      Parameters:
      configName - Configuration name
      relatedConfigPath - Path of a configuration resource that was resolved in context of this configuration name. This can be used to detect if the persistence strategy supports the configuration location. If null it should be assumed that it matches.
      Returns:
      Transformed configuration name. If null is returned this strategy does not support the given configuration resource path.
    • persistConfiguration

      public boolean persistConfiguration(@NotNull @NotNull ResourceResolver resourceResolver, @NotNull @NotNull String configResourcePath, @NotNull @NotNull ConfigurationPersistData data)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Stores configuration data for a singleton configuration resource. The changes are written using the given resource resolver. They are not committed, this is left to the caller.
      Specified by:
      persistConfiguration in interface ConfigurationPersistenceStrategy2
      Parameters:
      resourceResolver - Resource resolver
      configResourcePath - Path to store configuration data to. The resource (and it's parents) may not exist and may have to be created.
      data - Configuration data to be stored. All existing properties are erased and replaced with the new ones.
      Returns:
      true if the data was persisted. false if persisting the data was not accepted by this persistence strategy (in case of error throw an exception).
    • persistConfigurationCollection

      public boolean persistConfigurationCollection(@NotNull @NotNull ResourceResolver resourceResolver, @NotNull @NotNull String configResourceCollectionParentPath, @NotNull @NotNull ConfigurationCollectionPersistData data)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Stores configuration data for a configuration resource collection. The changes are written using the given resource resolver. They are not committed, this is left to the caller.
      Specified by:
      persistConfigurationCollection in interface ConfigurationPersistenceStrategy2
      Parameters:
      resourceResolver - Resource resolver
      configResourceCollectionParentPath - Parent path to store configuration collection data to. The resource (and it's parents) may not exist and may have to be created.
      data - Configuration collection data. All existing collection entries on this context path level are erased and replaced with the new ones.
      Returns:
      true if the data was persisted. false if persisting the data was not accepted by this persistence strategy (in case of error throw an exception).
    • deleteConfiguration

      public boolean deleteConfiguration(@NotNull @NotNull ResourceResolver resourceResolver, @NotNull @NotNull String configResourcePath)
      Description copied from interface: ConfigurationPersistenceStrategy2
      Delete configuration or configuration collection data from repository using the inner-most context path as reference.
      Specified by:
      deleteConfiguration in interface ConfigurationPersistenceStrategy2
      Parameters:
      resourceResolver - Resource resolver
      configResourcePath - Path to store configuration data to. The resource (and it's parents) may not exist and may have to be created.
      Returns:
      true if the data was delete. false if deleting the data was not accepted by this persistence strategy (in case of error throw an exception).