* @return
* @throws RepositoryException
* @throws DavException
*/
private static NodeTypeIterator getNodeTypes(Session session, ReportInfo info) throws RepositoryException, DavException {
NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
// check the simple types first...
if (info.containsContentElement(XML_REPORT_ALLNODETYPES, NAMESPACE)) {
return ntMgr.getAllNodeTypes();
} else if (info.containsContentElement(XML_REPORT_MIXINNODETYPES, NAMESPACE)) {
return ntMgr.getMixinNodeTypes();
} else if (info.containsContentElement(XML_REPORT_PRIMARYNODETYPES, NAMESPACE)) {
return ntMgr.getPrimaryNodeTypes();
} else {
// None of the simple types. test if a report for individual
// nodetype was request. If not, the request body is not valid.
List<Element> elemList = info.getContentElements(XML_NODETYPE, NAMESPACE);
if (elemList.isEmpty()) {
// throw exception if the request body does not contain a single nodetype element
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "NodeTypes report: request body has invalid format.");
}
// todo: find better solution...
List<NodeType> ntList = new ArrayList<NodeType>();
for (Element el : elemList) {
String nodetypeName = DomUtil.getChildTextTrim(el, XML_NODETYPENAME, NAMESPACE);
if (nodetypeName != null) {
ntList.add(ntMgr.getNodeType(nodetypeName));
}
}
return new NodeTypeIteratorAdapter(ntList);
}
}