You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by hsp <pi...@ibest.com.br> on 2006/04/19 23:13:38 UTC
Listing of node types registered
Hi;
I am trying to register some custom node types in Jackrabbit, but when I try to create some node of some kind of node type I have registered (I think of) occurs an error saying that the node type doesn't exists, but the namespace have been registered because it is showing resolved.
I am trying to register the custom node types by an custom_nodetypes.xml file. If you prefer I can send this file. It seems ok, without sintax error.
The piece of code that register it is like:
try {
FileInputStream is=new FileInputStream(NODETYPES_RESOURCE);
if (is != null) {
try {
NodeTypeReader ntReader = new NodeTypeReader(is);
registerNamespaces(ntReader.getNamespaces(), session);
NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
NodeTypeDef[] nodeTypes = ntReader.getNodeTypeDefs();
List unregisteredNTs = new ArrayList();
for (int i = 0; i < nodeTypes.length; i++) {
try {
ntMgr.getNodeType(nodeTypes[i].getName());
} catch (NoSuchNodeTypeException e) {
// register the node type
unregisteredNTs.add(nodeTypes[i]);
}
}
ntMgr.getNodeTypeRegistry().registerNodeTypes(unregisteredNTs);
} catch (BaseException e) {
throw new RepositoryException(e.getMessage());
} catch (IOException e) {
throw new RepositoryException(e.getMessage());
} finally {
try {
is.close();
} catch (IOException e1) {
// ignore
}
}
}
} catch (Exception e) {
// TODO: handle exception
}
}