reschke commented on a change in pull request #408:
URL: https://github.com/apache/jackrabbit-oak/pull/408#discussion_r743025486
##########
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:
in the arguments for "RepositoryException"; actually *missing* whitespace
##########
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:
```suggestion
throw new RepositoryException("Invalid item implementation '" +
item.getClass().getName() + "'. Excpected
org.apache.jackrabbit.oak.jcr.session.ItemImpl");
```
##########
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() + "'. Expected " + ItemImpl.class.getName());
Review comment:
I'd make that
~~~
"Expected: " + ItemImpl.class.getName() + "."
~~~
But that's just for aesthetics.
--
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]