parentUri.insert(0, node.getName()).insert(0, "/");
getPath(node.getParent(), parentUri);
}
private static PageNode createPageNode(DescriptionService service, NodeContext<NodeContext<?>> node) {
PageNode pageNode = new PageNode();
pageNode.setName(node.getName());
if (node.getState().getLabel() == null) {
Map<Locale, Described.State> descriptions = service.getDescriptions(node.getId());
if (descriptions != null && !descriptions.isEmpty()) {
I18NString labels = new I18NString();
for (Map.Entry<Locale, Described.State> entry : descriptions.entrySet()) {
labels.add(new LocalizedString(entry.getValue().getName(), entry.getKey()));
}
pageNode.setLabels(labels);
}
} else {
pageNode.setLabel(node.getState().getLabel());
}
pageNode.setIcon(node.getState().getIcon());
long startPublicationTime = node.getState().getStartPublicationTime();
if (startPublicationTime != -1) {
pageNode.setStartPublicationDate(new Date(startPublicationTime));
}
long endPublicationTime = node.getState().getEndPublicationTime();
if (endPublicationTime != -1) {
pageNode.setEndPublicationDate(new Date(endPublicationTime));
}
pageNode.setVisibility(node.getState().getVisibility());
pageNode.setPageReference(node.getState().getPageRef() != null ? node.getState().getPageRef().format() : null);
if (node.getNodes() != null) {
ArrayList<PageNode> children = new ArrayList<PageNode>(node.getNodeCount());
for (NodeContext<?> child : node.getNodes()) {
@SuppressWarnings("unchecked")
NodeContext<NodeContext<?>> childNode = (NodeContext<NodeContext<?>>) child;
children.add(createPageNode(service, childNode));
}
pageNode.setChildren(children);
} else {
pageNode.setChildren(new ArrayList<PageNode>(0));
}
return pageNode;
}