Here is some code I use. It's been written long before 1.0, and it might
just be a more sophisticated way to do this. However it works well all
the way to the latest trunk.
Hope it helps:
//-------------- CODE BEGINS HERE --------------------------------
public boolean doesNodeTypeExist(Session session, NodeType nt)
throws Exception {
// Obtain node type manager
NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
// Replace manager with jackrabbit's implementation of it
NodeTypeManagerImpl managerImpl = (NodeTypeManagerImpl) manager;
Workspace w = session.getWorkspace();
NamespaceResolver reg = (NamespaceResolver) w.getNamespaceRegistry();
QName qname = QName.fromJCRName(nt.getName(), reg);
return managerImpl.getNodeTypeRegistry().isRegistered( qname );
}
//-------------- CODE ENDS HERE --------------------------------
On Thu, 2006-07-27 at 20:08 +0200, Nicolas wrote:
> Hi,
>
> How can I know that a nodeType already exist? I can look for it in the list
> of all NodeTypes (but I need first to build it) or catch the exception but
> both are somewhat inelegant. Is there anothe way?
>
> Thanks
> Nico
> my blog! http://www.deviant-abstraction.net !!