- entityPath(forEntity.getType(), forEntity.getId()));
- if(!entityNode.isPresent()) {
- return Optional.absent();
+ entityPath(forEntity.getType(), forEntity.getIdentifier()));
+ if (!entityNode.isPresent()) {
+ return Optional.empty();
+ }
+
+ // Check if there are any candidates, if there are none we do not really have ownership state
+ final MapEntryNode entity = (MapEntryNode) entityNode.get();
+ final Optional<DataContainerChild<? extends PathArgument, ?>> optionalCandidates =
+ entity.getChild(CANDIDATE_NODE_ID);
+ final boolean hasCandidates = optionalCandidates.isPresent()
+ && ((MapNode) optionalCandidates.get()).getValue().size() > 0;
+ if (!hasCandidates) {
+ return Optional.empty();