* @throws RepositoryException
* @throws DavException
*/
private static NodeTypeIterator getNodeTypes(Session session, ReportInfo info) throws RepositoryException, DavException {
NodeTypeIterator ntIter = null;
NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
// check the simple types first...
if (info.containsContentElement(XML_REPORT_ALLNODETYPES, NAMESPACE)) {
ntIter = ntMgr.getAllNodeTypes();
} else if (info.containsContentElement(XML_REPORT_MIXINNODETYPES, NAMESPACE)) {
ntIter = ntMgr.getMixinNodeTypes();
} else if (info.containsContentElement(XML_REPORT_PRIMARYNODETYPES, NAMESPACE)) {
ntIter = ntMgr.getPrimaryNodeTypes();
}
// None of the simple types. test if a report for individual nodetypes
// was request. If not, the request body is not valid.
if (ntIter == null) {
List ntList = new ArrayList();
List 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...
Iterator elemIter = elemList.iterator();
while (elemIter.hasNext()) {
Element el = ((Element)elemIter.next());
String nodetypeName = DomUtil.getChildTextTrim(el, XML_NODETYPENAME, NAMESPACE);
if (nodetypeName != null) {
ntList.add(ntMgr.getNodeType(nodetypeName));
}
}
ntIter = new IteratorHelper(Collections.unmodifiableCollection(ntList));
}