You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Hendy Irawan <he...@soluvas.com> on 2011/04/08 17:14:52 UTC
Re: Node Type Registration in JCR 2.0
I want to update the article here:
http://jackrabbit.apache.org/node-types.html
to reflect the use of CndImporter instead of the deprecated Jackrabbit API.
But I don't have permissions.
How can I get permission, or will someone do it? :-)
Here's the updated article & code:
. . . . .
First you define your node types in a text file using the "Compact Namespace
and Node Type Definition" (CND) notation, then register them using the JCR
Commons CndImporter. The following code gives an example:
import java.io.FileReader;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.NodeTypeManager;
import org.apache.jackrabbit.commons.cnd.CndImporter;
public class CustomNodeTypeExample {
public static void RegisterCustomNodeTypes(Session session, String
cndFileName)
throws Exception {
// Register the custom node types defined in the CND file, using JCR
Commons CndImporter
NodeType[] nodeTypes = CndImporter.registerNodeTypes(new
FileReader(cndFileName), session);
for (NodeType nt : nodeTypes) {
System.out.println("Registered: " + nt.getName());
}
// You can also use JCR NodeTypeManager from the Workspace.
NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
// ... use manager here ...
}
}
You can also manage node types using NodeTypeManager JCR interface.
-----
Soluvas - Making eCommerce Work for You
--
View this message in context: http://jackrabbit.510166.n4.nabble.com/Node-Type-Registration-in-JCR-2-0-tp2532652p3436618.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.