private ObjectNode doResolve(Uri uri) throws ObjectNotFoundException, ServiceAccessException {
// check resolve cache first
ResourceId resourceId = checkResolveCache(uri);
if (resourceId == null) {
UriPath uriPath = new UriPath(uri.toString());
String[] segments = uriPath.tokens();
String rootUriStr = uri.getScope().toString();
if (!"/".equals(rootUriStr)) {
rootUriStr += "/";
}
String currentUriStr = rootUriStr;
Uri currentUri = new Uri(uri.getToken(), uri.getNamespace(), currentUriStr);
ResourceId currentResourceId = ResourceId.create(currentUri, currentUriStr);
int start = new UriPath(rootUriStr).tokens().length;
for (int i = start; i < segments.length; i++) {
// cacheResolve(currentUri, currentResourceId);
// TODO: make it work with caching here :-(
ObjectNode objectNode = currentResourceId.getStore().retrieveObject(currentResourceId);
objectNode.setUri(currentUriStr);
currentUriStr = uriPath.subUriPath(0, i + 1).toString();
currentUri = new Uri(uri.getToken(), uri.getNamespace(), currentUriStr);
String currentUuri = objectNode.getBindingUuri(segments[i]);
if (currentUuri == null) {
throw new ObjectNotFoundException(currentUriStr);
}