You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2021/10/27 07:54:46 UTC
[sling-org-apache-sling-api] 01/01: SLING-7975 API for reordering
of resources
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 55b161275df31e2f76f194962361f920d621ccd6
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Wed Oct 27 09:50:12 2021 +0200
SLING-7975 API for reordering of resources
---
.../org/apache/sling/api/resource/ResourceResolver.java | 16 ++++++++++++++++
.../java/org/apache/sling/api/resource/package-info.java | 2 +-
.../sling/api/wrappers/ResourceResolverWrapper.java | 9 +++++++++
3 files changed, 26 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..7991d52 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, PersistenceException, IllegalArgumentException;
+
+ /**
* 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;
diff --git a/src/main/java/org/apache/sling/api/wrappers/ResourceResolverWrapper.java b/src/main/java/org/apache/sling/api/wrappers/ResourceResolverWrapper.java
index 67c2fbf..a3b17b1 100644
--- a/src/main/java/org/apache/sling/api/wrappers/ResourceResolverWrapper.java
+++ b/src/main/java/org/apache/sling/api/wrappers/ResourceResolverWrapper.java
@@ -19,6 +19,8 @@ package org.apache.sling.api.wrappers;
import java.util.Iterator;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import javax.servlet.http.HttpServletRequest;
import org.apache.sling.api.resource.LoginException;
@@ -280,6 +282,13 @@ public class ResourceResolverWrapper implements ResourceResolver {
return ResourceResolverResourceWrapper.wrap(this, wrapped.create(parent, name, properties));
}
+
+ @Override
+ public boolean orderBefore(@NotNull Resource parent, @NotNull String name, @Nullable String followingSiblingName)
+ throws UnsupportedOperationException, PersistenceException, IllegalArgumentException {
+ return wrapped.orderBefore(parent, name, followingSiblingName);
+ }
+
@Override
public void revert() {
wrapped.revert();