if (index != -1) {
realPath = path.substring(0, index);
revisionId = path.substring(index + 1);
}
NodeImpl node = new NodeImpl(realPath);
node.setRevisionId(MongoUtil.toMongoRepresentation(revisionId));
Map<String, Object> properties = null;
for (@SuppressWarnings("rawtypes")
Iterator iterator = jsonObject.keys(); iterator.hasNext();) {
String key = (String) iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
String childPath = PathUtils.concat(realPath, key);
Node childNode = parseNode(childPath, (JSONObject) value);
node.addChildNodeEntry(childNode);
} else {
if (properties == null) {
properties = new HashMap<String, Object>();
}
Object converted = JsonUtil.toJsonValue(value.toString());
properties.put(key, converted);
}
}
if (properties != null) {
for (Map.Entry<String, Object> entry : properties.entrySet()) {
node.addProperty(entry.getKey(), convertObjectValue(entry.getValue()));
}
}
return node;
}