This is an automated email from the ASF dual-hosted git repository. kwin pushed a commit to branch feature/resource-reorder-api in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-api.git
commit 979fae3df0dc0ad66778d9796277be9a5711e13a Author: Konrad Windszus <[email protected]> AuthorDate: Wed Oct 27 09:50:12 2021 +0200 SLING-9850 API for reordering of resources --- .../org/apache/sling/api/resource/ResourceResolver.java | 16 ++++++++++++++++ .../java/org/apache/sling/api/resource/package-info.java | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/sling/api/resource/ResourceResolver.java b/src/main/java/org/apache/sling/api/resource/ResourceResolver.java index 372ec13..963f56b 100644 --- a/src/main/java/org/apache/sling/api/resource/ResourceResolver.java +++ b/src/main/java/org/apache/sling/api/resource/ResourceResolver.java @@ -692,6 +692,22 @@ public interface ResourceResolver extends Adaptable, Closeable { throws PersistenceException; /** + * Reorders the given resource so that it is listed before the given sibling resource. + * + * The changes are transient and require a call to {@link #commit()} for persisting. + * + * @param parent the parent resource containing the child resource to reorder. + * @param name the name of the resource child in {@code parent} to reorder. Must be an existing child name. + * @param followingSiblingName the name of the resource child in {@code parent} which should come after the reordered resource. If {@code null} is given the resource is ordered as last among all sibling resources. + * @return {@code true} in case the ordering of the child resources of {@code parent} have changed, {@code false} otherwise. + * @throws UnsupportedOperationException in case the underlying resource provider does not support ordering or the child resources of {@code parent} are provided by different providers. + * @throws IllegalArgumentException if either {@code name} or {@code followingSiblingName} are not existing child names of {@code parent}. + * @throws PersistenceException If the operation fails in the underlying resource provider, e.g. in case the parent resource does not support orderable children. + * @since 2.13.0 (Sling API Bundle 2.24.0) + */ + boolean orderBefore(@NotNull Resource parent, @NotNull String name, @Nullable String followingSiblingName) throws UnsupportedOperationException; + + /** * Revert all pending changes. * @throws IllegalStateException if this resource resolver has already been * {@link #close() closed}. diff --git a/src/main/java/org/apache/sling/api/resource/package-info.java b/src/main/java/org/apache/sling/api/resource/package-info.java index 2c8f5ae..ac05b61 100644 --- a/src/main/java/org/apache/sling/api/resource/package-info.java +++ b/src/main/java/org/apache/sling/api/resource/package-info.java @@ -17,7 +17,7 @@ * under the License. */ -@Version("2.12.3") +@Version("2.13.0") package org.apache.sling.api.resource; import org.osgi.annotation.versioning.Version;
