// Children nodes
ModelList children = model.get("children", ModelList.class);
if (node.isChildrenLoaded()) {
for (Node child : node) {
Model childModel = children.add();
PathAddress childAddress = address.append(child.getName());
if (scope > 0 || scope < 0) // Continue populating nodes in response
{
populateNode(child, scope - 1, childModel.setEmptyObject(), childAddress);
} else { // Populate node reference which can be followed
ModelReference nodeRef = childModel.set(childAddress);
nodeRef.set("name", child.getName());
}
}
}
// Page reference
ModelReference pageRef = model.get("page").asValue(ModelReference.class);
if (node.getPageId() != null) {
PageId pageId = node.getPageId();
pageRef.set("pageName", pageId.getPageName());
pageRef.set("siteName", pageId.getSiteId().getName());
pageRef.set("siteType", pageId.getSiteId().getType().getName());
// Set the address for the ref
PathAddress pageAddress = getPagesAddress(pageId.getSiteId()).append(pageId.getPageName());
pageRef.set(pageAddress);
}
}