mreutegg commented on a change in pull request #408:
URL: https://github.com/apache/jackrabbit-oak/pull/408#discussion_r743099330
##########
File path:
oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java
##########
@@ -233,6 +233,35 @@ public Item performNullable() throws RepositoryException {
});
}
+ @Override
+ @Nullable
+ public Node getParentOrNull(@NotNull Item item) throws RepositoryException
{
+ checkAlive();
+ ItemImpl itemImpl = checkItemImpl(item);
+ checkContext(itemImpl, sessionContext);
+ return sd.performNullable(new ReadOperation<Node>("getParentOrNull") {
+ @Override
+ public Node performNullable() throws RepositoryException {
+ return NodeImpl.createNodeOrNull(itemImpl.dlg.getParent(),
sessionContext);
+ }
+ });
+ }
+
+ private static void checkContext(@NotNull ItemImpl item, @NotNull
SessionContext context) throws RepositoryException {
+ if (item.sessionContext != context) {
+ throw new RepositoryException("Item '"+item+"' has been obtained
through a different Session.");
+ }
+ }
+
+ @NotNull
+ private static ItemImpl checkItemImpl(@NotNull Item item) throws
RepositoryException {
+ if (item instanceof ItemImpl) {
+ return (ItemImpl) item;
+ } else {
+ throw new RepositoryException("Invalid item implementation
'"+item.getClass().getName()+"'. Excpected
org.apache.jackrabbit.oak.jcr.session.ItemImpl");
Review comment:
Use ItemImpl.class.getName() instead of String literal?
--
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]