Skip to content

Commit

Permalink
OAK-11397 Expose methods to get the expanded name/path from Item in
Browse files Browse the repository at this point in the history
JackrabbitSession
  • Loading branch information
kwin committed Feb 1, 2025
1 parent 2502f4c commit 8ce6c4e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,24 @@ default Node getParentOrNull(@NotNull Item item) throws RepositoryException {
return null;
}
}

/**
* Returns the expanded name of the given {@code Item}.
* @param item the item for which to retrieve the name
* @return the name of the item in expanded form.
* @throws RepositoryException if another error occurs.
* @since 1.76.0
* @see <a href="https://s.apache.org/jcr-2.0-spec/3_Repository_Model.html#3.2.5.1%20Expanded%20Form">JCR 2.0, 3.2.5.1 Expanded Form</a>
*/
@NotNull String getExpandedName(@NotNull Item item) throws RepositoryException;

/**
* Returns the expanded path of the given {@code Item}.
* @param item the item for which to retrieve the name
* @return the path of the item in expanded form.
* @throws RepositoryException if another error occurs.
* @since 1.76.0
* @see <a href="https://s.apache.org/jcr-2.0-spec/3_Repository_Model.html#3.2.5.1%20Expanded%20Form">JCR 2.0, 3.2.5.1 Expanded Form</a>
*/
@NotNull String getExpandedPath(@NotNull Item item) throws RepositoryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
/**
* Jackrabbit extensions for JCR core interfaces
*/
@org.osgi.annotation.versioning.Version("2.9.0")
@org.osgi.annotation.versioning.Version("2.10.0")
package org.apache.jackrabbit.api;

Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ public String getJcrPath(String oakPath) {
return namePathMapper.getJcrPath(oakPath);
}

@Override
@NotNull
public String getExpandedJcrPath(@NotNull String oakPath) {
return namePathMapper.getExpandedJcrPath(oakPath);
}

/**
* Returns the Oak path for the given JCR path, or throws a
* {@link javax.jcr.RepositoryException} if the path can not be mapped.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,4 +852,16 @@ public String toString() {
}
return "null";
}

@Override
@NotNull
public String getExpandedName(@NotNull Item item) throws RepositoryException {
return checkItemImpl(item).sessionContext.getExpandedJcrName(item.getName());
}

@Override
@NotNull
public String getExpandedPath(@NotNull Item item) throws RepositoryException {
return checkItemImpl(item).sessionContext.getExpandedJcrPath(item.getPath());
}
}

0 comments on commit 8ce6c4e

Please sign in to comment.