jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hendy Irawan <he...@soluvas.com>
Subject Re: Node Type Registration in JCR 2.0
Date Fri, 08 Apr 2011 15:14:52 GMT
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.

Mime
View raw message