private Page unmarshalPage(StaxNavigator<Element> navigator) throws XMLStreamException {
requiresChild(navigator, Element.NAME);
String name = getRequiredContent(navigator, true);
Page page = new Page();
page.setName(name);
// TODO: Need valid way to ensure a sequence of xml elements, with a mix of required and optional elements.
Element current = navigator.sibling();
while (current != null) {
switch (current) {
case TITLE:
page.setTitle(getContent(navigator, false));
current = navigator.sibling();
break;
case DESCRIPTION:
page.setDescription(getContent(navigator, false));
current = navigator.sibling();
break;
case ACCESS_PERMISSIONS:
page.setAccessPermissions(unmarshalAccessPermissions(navigator, true));
current = navigator.sibling();
break;
case EDIT_PERMISSION:
page.setEditPermission(unmarshalEditPermission(navigator));
current = navigator.sibling();
break;
case SHOW_MAX_WINDOW:
page.setShowMaxWindow(parseRequiredContent(navigator, ValueType.BOOLEAN));
current = navigator.sibling();
break;
case MOVE_APPLICATIONS_PERMISSIONS:
page.setMoveAppsPermissions(unmarshalPermissions(navigator, false));
current = navigator.sibling();
break;
case MOVE_CONTAINERS_PERMISSIONS:
page.setMoveContainersPermissions(unmarshalPermissions(navigator, false));
current = navigator.sibling();
break;
case CONTAINER:
if (page.getChildren() == null) {
page.setChildren(new ArrayList<ModelObject>());
}
page.getChildren().add(unmarshalContainer(navigator.fork()));
current = navigator.sibling();
break;
case PORTLET_APPLICATION:
if (page.getChildren() == null) {
page.setChildren(new ArrayList<ModelObject>());
}
page.getChildren().add(unmarshalPortletApplication(navigator.fork()));
current = navigator.sibling();
break;
case GADGET_APPLICATION:
if (page.getChildren() == null) {
page.setChildren(new ArrayList<ModelObject>());
}
page.getChildren().add(unmarshalGadgetApplication(navigator.fork()));
current = navigator.sibling();
break;
case UNKNOWN:
throw unknownElement(navigator);
default: