kwin commented on a change in pull request #18:
URL:
https://github.com/apache/sling-org-apache-sling-jcr-resource/pull/18#discussion_r742298158
##########
File path:
src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
##########
@@ -478,6 +479,44 @@ public Resource create(final @NotNull
ResolveContext<JcrProviderState> ctx, fina
}
}
+ @Override
+ public boolean orderBefore(@NotNull ResolveContext<JcrProviderState> ctx,
@NotNull Resource parent, @NotNull String name,
+ @Nullable String followingSiblingName) throws PersistenceException
{
+ Node node = parent.adaptTo(Node.class);
+ try {
+ if (node == null) {
+ throw new PersistenceException("The resource " +
parent.getPath() + " cannot be adapted to Node. It is probably not provided by
the JcrResourceProvider");
+ }
+ // check if reordering necessary
+ NodeIterator nodeIterator = node.getNodes();
+ long existingNodePosition = -1;
+ long index = 0;
+ while (nodeIterator.hasNext()) {
+ Node childNode = nodeIterator.nextNode();
+ if (childNode.getName().equals(name)) {
+ existingNodePosition = index;
+ }
+ if (existingNodePosition >= 0) {
Review comment:
No, not necessarily. I added some tests. Hopefully they proof that
`true` is only returned in case the order is actually changed. Let me know if I
missed a case.
##########
File path:
src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
##########
@@ -478,6 +479,44 @@ public Resource create(final @NotNull
ResolveContext<JcrProviderState> ctx, fina
}
}
+ @Override
+ public boolean orderBefore(@NotNull ResolveContext<JcrProviderState> ctx,
@NotNull Resource parent, @NotNull String name,
+ @Nullable String followingSiblingName) throws PersistenceException
{
+ Node node = parent.adaptTo(Node.class);
+ try {
+ if (node == null) {
Review comment:
Done in
https://github.com/apache/sling-org-apache-sling-jcr-resource/pull/18/commits/d74a24df6297e7a78acd2127d19229a19752f5a4.
--
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]