This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.caconfig.spi-1.3.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-caconfig-spi.git
commit 811c499acfc931a9f76a17e253db58845105d5f0 Author: Stefan Seifert <[email protected]> AuthorDate: Sun Mar 19 14:53:02 2017 +0000 SLING-6669 introduce new SPI ConfigurationPersistenceStrategy2, deprecate ConfigurationPersistenceStrategy export ConfigurationPersistenceStrategyMultiplexer as part of the management API git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/caconfig/spi@1787626 13f79535-47bb-0310-9956-ffa450edef68 --- .../spi/ConfigurationPersistenceStrategy.java | 2 + .../spi/ConfigurationPersistenceStrategy2.java | 147 +++++++++++++++++++++ .../apache/sling/caconfig/spi/package-info.java | 2 +- 3 files changed, 150 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/sling/caconfig/spi/ConfigurationPersistenceStrategy.java b/src/main/java/org/apache/sling/caconfig/spi/ConfigurationPersistenceStrategy.java index 37f6de6..ff59784 100644 --- a/src/main/java/org/apache/sling/caconfig/spi/ConfigurationPersistenceStrategy.java +++ b/src/main/java/org/apache/sling/caconfig/spi/ConfigurationPersistenceStrategy.java @@ -28,8 +28,10 @@ import org.osgi.annotation.versioning.ConsumerType; /** * 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. + * @deprecated Please use {@link ConfigurationPersistenceStrategy2} instead. */ @ConsumerType +@Deprecated public interface ConfigurationPersistenceStrategy { /** diff --git a/src/main/java/org/apache/sling/caconfig/spi/ConfigurationPersistenceStrategy2.java b/src/main/java/org/apache/sling/caconfig/spi/ConfigurationPersistenceStrategy2.java new file mode 100644 index 0000000..854fd5c --- /dev/null +++ b/src/main/java/org/apache/sling/caconfig/spi/ConfigurationPersistenceStrategy2.java @@ -0,0 +1,147 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.caconfig.spi; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ResourceResolver; +import org.osgi.annotation.versioning.ConsumerType; + +/** + * 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. + */ +@ConsumerType +public 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. + * @param resource Singleton configuration resource + * @return Transformed configuration resource. If null is returned this strategy does not support the given configuration resource. + */ + @CheckForNull Resource getResource(@Nonnull 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. + * @param resource Configuration collection parent resource + * @return Transformed configuration resource. If null is returned this strategy does not support the given configuration resource. + */ + @CheckForNull Resource getCollectionParentResource(@Nonnull 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. + * @param resource Configuration collection item resource + * @return Transformed configuration resource. If null is returned this strategy does not support the given configuration resource. + */ + @CheckForNull Resource getCollectionItemResource(@Nonnull Resource resource); + + /** + * 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. + * @param resourcePath Configuration resource path (full path) + * @return Transformed configuration resource path. If null is returned this strategy does not support the given configuration resource path. + */ + @CheckForNull String getResourcePath(@Nonnull 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. + * @param resourcePath Configuration collection parent resource path (full path) + * @return Transformed configuration resource path. If null is returned this strategy does not support the given configuration resource path. + */ + @CheckForNull String getCollectionParentResourcePath(@Nonnull 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. + * @param resourcePath Configuration collection item resource path (full path) + * @return Transformed configuration resource path. If null is returned this strategy does not support the given configuration resource path. + */ + @CheckForNull String getCollectionItemResourcePath(@Nonnull String resourcePath); + + /** + * 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. + * @param configName Configuration name + * @param relatedConfigResource 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. + * @return Transformed configuration name. If null is returned this strategy does not support the given configuration resource path. + */ + @CheckForNull String getConfigName(@Nonnull String configName, @CheckForNull Resource relatedConfigResource); + + /** + * 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. + * @param configName Configuration name + * @param relatedConfigResource 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. + * @return Transformed configuration name. If null is returned this strategy does not support the given configuration resource path. + */ + @CheckForNull String getCollectionParentConfigName(@Nonnull String configName, @CheckForNull Resource relatedConfigResource); + + /** + * 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. + * @param configName Configuration name + * @param relatedConfigResource 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. + * @return Transformed configuration name. If null is returned this strategy does not support the given configuration resource path. + */ + @CheckForNull String getCollectionItemConfigName(@Nonnull String configName, @CheckForNull Resource relatedConfigResource); + + /** + * 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. + * @param resourceResolver Resource resolver + * @param configResourcePath Path to store configuration data to. The resource (and it's parents) may not exist and may have to be created. + * @param data Configuration data to be stored. All existing properties are erased and replaced with the new ones. + * @return 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). + */ + boolean persistConfiguration(@Nonnull ResourceResolver resourceResolver, + @Nonnull String configResourcePath, @Nonnull ConfigurationPersistData 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. + * @param resourceResolver Resource resolver + * @param configResourceCollectionParentPath Parent path to store configuration collection data to. + * The resource (and it's parents) may not exist and may have to be created. + * @param data Configuration collection data. All existing collection entries on this context path level are erased and replaced with the new ones. + * @return 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). + */ + boolean persistConfigurationCollection(@Nonnull ResourceResolver resourceResolver, + @Nonnull String configResourceCollectionParentPath, @Nonnull ConfigurationCollectionPersistData data); + + /** + * Delete configuration or configuration collection data from repository using the inner-most context path as reference. + * @param resourceResolver Resource resolver + * @param configResourcePath Path to store configuration data to. The resource (and it's parents) may not exist and may have to be created. + * @return 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). + */ + boolean deleteConfiguration(@Nonnull ResourceResolver resourceResolver, @Nonnull String configResourcePath); + +} diff --git a/src/main/java/org/apache/sling/caconfig/spi/package-info.java b/src/main/java/org/apache/sling/caconfig/spi/package-info.java index 8637a08..a2267d6 100644 --- a/src/main/java/org/apache/sling/caconfig/spi/package-info.java +++ b/src/main/java/org/apache/sling/caconfig/spi/package-info.java @@ -19,5 +19,5 @@ /** * SPI for applications hooking into the configuration infrastructure for parameterizing and customizing. */ [email protected]("2.0.0") [email protected]("2.1.0") package org.apache.sling.caconfig.spi; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
