Package org.apache.sling.caconfig.spi

## Interface ConfigurationPersistenceStrategy2

    @ConsumerType
    public interface ConfigurationPersistenceStrategy2

Defines how configuration data is stored in the configuration resource. This SPI allows application to define their own content structure and node types to be used for configuration data storage.

### Method Summary

All Methods Instance Methods Abstract Methods
`boolean` `deleteConfiguration​(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull String configResourcePath)` Delete configuration or configuration collection data from repository using the inner-most context path as reference.
`@Nullable String` `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.
`@Nullable org.apache.sling.api.resource.Resource` `getCollectionItemResource​(@NotNull org.apache.sling.api.resource.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.
`@Nullable String` `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.
`@Nullable String` `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.
`@Nullable org.apache.sling.api.resource.Resource` `getCollectionParentResource​(@NotNull org.apache.sling.api.resource.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.
`@Nullable String` `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.
`@Nullable String` `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.
`@Nullable org.apache.sling.api.resource.Resource` `getResource​(@NotNull org.apache.sling.api.resource.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.
`@Nullable String` `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 org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull String configResourcePath, @NotNull ConfigurationPersistData data)` Stores configuration data for a singleton configuration resource.
`boolean` `persistConfigurationCollection​(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull String configResourceCollectionParentPath, @NotNull ConfigurationCollectionPersistData data)` Stores configuration data for a configuration resource collection.

### Method Detail

#### getResource

    @Nullable
    @Nullable org.apache.sling.api.resource.Resource getResource​(@NotNull
                                                                 @NotNull org.apache.sling.api.resource.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.

Parameters:
  `resource` - Singleton configuration resource
Returns:
  Transformed configuration resource. If null is returned this strategy does not support the given configuration resource.

#### getCollectionParentResource

    @Nullable
    @Nullable org.apache.sling.api.resource.Resource getCollectionParentResource​(@NotNull
                                                                                 @NotNull org.apache.sling.api.resource.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.

Parameters:
  `resource` - Configuration collection parent resource
Returns:
  Transformed configuration resource. If null is returned this strategy does not support the given configuration resource.

#### getCollectionItemResource

    @Nullable
    @Nullable org.apache.sling.api.resource.Resource getCollectionItemResource​(@NotNull
                                                                               @NotNull org.apache.sling.api.resource.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.

Parameters:
  `resource` - Configuration collection item resource
Returns:
  Transformed configuration resource. If null is returned this strategy does not support the given configuration resource.

#### getResourcePath

    @Nullable
    @Nullable String getResourcePath​(@NotNull
                                     @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.

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

    @Nullable
    @Nullable String getCollectionParentResourcePath​(@NotNull
                                                     @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.

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

    @Nullable
    @Nullable String getCollectionItemResourcePath​(@NotNull
                                                   @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.

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

    @Nullable
    @Nullable String getConfigName​(@NotNull
                                   @NotNull String configName,
                                   @Nullable
                                   @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.

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

    @Nullable
    @Nullable String getCollectionParentConfigName​(@NotNull
                                                   @NotNull String configName,
                                                   @Nullable
                                                   @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.

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

    @Nullable
    @Nullable String getCollectionItemConfigName​(@NotNull
                                                 @NotNull String configName,
                                                 @Nullable
                                                 @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.

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

    boolean persistConfiguration​(@NotNull
                                 @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                 @NotNull
                                 @NotNull String configResourcePath,
                                 @NotNull
                                 @NotNull ConfigurationPersistData data)

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.

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

    boolean persistConfigurationCollection​(@NotNull
                                           @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                           @NotNull
                                           @NotNull String configResourceCollectionParentPath,
                                           @NotNull
                                           @NotNull ConfigurationCollectionPersistData data)

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.

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

    boolean deleteConfiguration​(@NotNull
                                @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                @NotNull
                                @NotNull String configResourcePath)

Delete configuration or configuration collection data from repository using the inner-most context path as reference.

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).