Path p = itemId.getPath();
String uid = itemId.getUniqueID();
if (uid == null) {
return p;
} else {
NamePathResolver resolver = getNamePathResolver(sessionInfo);
String uri = super.getItemUri(itemId, sessionInfo);
String rootUri = getRootURI(sessionInfo);
String jcrPath;
if (uri.startsWith(rootUri)) {
jcrPath = uri.substring(rootUri.length());
} else {
log.warn("ItemURI " + uri + " doesn't start with rootURI (" + rootUri + ").");
// fallback:
// calculated uri does not start with the rootURI
// -> search /jcr:root and start substring behind.
String rootSegment = Text.escapePath(ItemResourceConstants.ROOT_ITEM_RESOURCEPATH);
jcrPath = uri.substring(uri.indexOf(rootSegment) + rootSegment.length());
}
jcrPath = Text.unescape(jcrPath);
return resolver.getQPath(jcrPath);
}
} else {
PropertyId pId = (PropertyId) itemId;
Path parentPath = getPath(pId.getParentId(), sessionInfo);
return getPathFactory().create(parentPath, pId.getName(), true);