private static PageNode createPageNode(DescriptionService service, NodeContext<NodeContext<?>> node) {
PageNode pageNode = new PageNode();
pageNode.setName(node.getName());
NodeState nodeState = node.getState();
if (nodeState.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(nodeState.getLabel());
}
pageNode.setIcon(nodeState.getIcon());
long startPublicationTime = nodeState.getStartPublicationTime();
if (startPublicationTime != -1) {
pageNode.setStartPublicationDate(new Date(startPublicationTime));
}
long endPublicationTime = nodeState.getEndPublicationTime();
if (endPublicationTime != -1) {
pageNode.setEndPublicationDate(new Date(endPublicationTime));
}
pageNode.setVisibility(nodeState.getVisibility());
pageNode.setPageReference(nodeState.getPageRef() != null ? nodeState.getPageRef().format() : null);
pageNode.setProperties(new Properties(nodeState.getAttributesState()));
if (node.getNodes() != null) {
ArrayList<PageNode> children = new ArrayList<PageNode>(node.getNodeCount());
for (NodeContext<?> child : node.getNodes()) {
@SuppressWarnings("unchecked")