Hi All,
I am trying to check if a node exist under a path and set some property. but when i try to check a path through session it returns PathNotFoundException instead of true/false.
if(!destSession.nodeExists(dRootPath)) / if(!destSession.itemExists(dRootPath))
is there any other way?
Regards,
Vikram.
Solved! Go to Solution.
According to the stacktrace you get the exception in the "session.getNode()" API call, not in "session.nodeExists()". Thus it's perfectly valid.
How are you getting the session? Does the service-user that you use has "read" access on that path?
Views
Replies
Total Likes
i am using service user with admin rights. for now the node is not exist, in future it might be. so i want to check if the node exist or not then set property.
As per Session (Content Repository for Java Technology API Version 2.0) it should return true/false
Regards,
Vikram
Views
Replies
Total Likes
Use javax.jcr.Node's method named hasNode() - see Javadocs.
Node (Content Repository for Java Technology API Version 2.0)
This method returns false if this node does not exist.
Hi,
could you post the stacktrace? It seems an interesting behavior.
Thanks,
Antonio
For testing sake - use the admin login call to get session and whitelist the OSGi bundle. See if the API works properly then.
Views
Replies
Total Likes
Hi All,
please find the sample code (using admin session) and exception below.
to use hasNode() from Node API we need to have the root node. i am trying to check the root node with session and then get it.
if(!destSession.nodeExists(dFolderPath)) {
log.info("Node not found. creating : " + dFolderPath);
Node rootFolderNode = destSession.getNode(dParentPath);
}else{
log.info("Folder Exist : " + dFolderPath);
}
Exception:
javax.jcr.PathNotFoundException: /content/dam/geometrixx/migration/snowboarding
at org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntryImpl.getDeepNodeEntry(NodeEntryImpl.java:395) ~[jackrabbit-jcr2spi-2.10.0.jar:na]
at org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManagerImpl.getNodeEntry(HierarchyManagerImpl.java:137) ~[jackrabbit-jcr2spi-2.10.0.jar:na]
at org.apache.jackrabbit.jcr2spi.ItemManagerImpl.getNode(ItemManagerImpl.java:168) ~[jackrabbit-jcr2spi-2.10.0.jar:na]
at org.apache.jackrabbit.jcr2spi.SessionImpl.getNode(SessionImpl.java:513) ~[jackrabbit-jcr2spi-2.10.0.jar:na]
Views
Replies
Total Likes
Hi,
could you attach the entire java class? Just to try to reproduce it.
Thanks,
Antonio
Views
Replies
Total Likes
According to the stacktrace you get the exception in the "session.getNode()" API call, not in "session.nodeExists()". Thus it's perfectly valid.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies