raducotescu commented on a change in pull request #36:
URL: 
https://github.com/apache/sling-org-apache-sling-api/pull/36#discussion_r737418157



##########
File path: 
src/main/java/org/apache/sling/api/security/ResourceAccessSecurity.java
##########
@@ -98,6 +98,16 @@
      */
     boolean canCreate(@NotNull String absPathName, @NotNull ResourceResolver 
resourceResolver);
 
+    /**
+     * Check whether child resources can be reordered.

Review comment:
       `s/Check/Checks/`

##########
File path: src/main/java/org/apache/sling/api/resource/ResourceResolver.java
##########
@@ -691,6 +691,24 @@ void delete(@NotNull Resource resource)
     @NotNull Resource create(@NotNull Resource parent, @NotNull String name, 
Map<String, Object> properties)
     throws PersistenceException;
 
+    /**
+     * Reorders the child resources returned by {@link #getChildren(Resource)} 
and {@link #listChildren(Resource)} so that a given resource 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 resources to 
reorder.
+     * @param name the name of the child resource 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 order of the child resources in {@code 
parent} has 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)
+     * @see #listChildren(Resource)
+     * @see #getChildren(Resource)
+     */
+    boolean orderBefore(@NotNull Resource parent, @NotNull String name, 
@Nullable String followingSiblingName) throws UnsupportedOperationException, 
PersistenceException, IllegalArgumentException;

Review comment:
       Rather than throwing `UOE` and `PE`, couldn't we just return `false`? 
Implementations should log the reason for returning `false`.

##########
File path: 
src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
##########
@@ -509,6 +509,28 @@ public boolean isLive(final @NotNull ResolveContext<T> 
ctx) {
         throw new PersistenceException("create is not supported.");
     }
 
+    /**
+     * Reorders the child resources returned by {@link 
#listChildren(ResolveContext, Resource)} so that a given resource is listed 
before the given sibling resource.
+     * 
+     * The changes are transient until {@link #commit(ResolveContext)} is 
called..
+     * 
+     * @param ctx The {@link ResolveContext}.
+     * @param parent the parent resource containing the child resources to 
reorder.
+     * @param name the name of the child resource 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 order of the child resources in {@code 
parent} has 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 1.3.0 (Sling API Bundle 2.24.0)
+     * @see #listChildren(Resource)
+     * @see #getChildren(Resource)
+     */
+    public boolean orderBefore(final @NotNull ResolveContext<T> ctx, final 
@NotNull Resource parent, final @NotNull String name, final @Nullable String 
followingSiblingName)

Review comment:
       Same question as above regarding the exceptions.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to