On 19.11.2009, at 06:01, Patricio Echagüe <[email protected]> wrote:

Hi all, I did a research on the email list to see if someone has run into
this.

I'm trying to register a CND file a created. Jackrabbit web page suggests
the following [1].

My question is, where should I place that piece of code? Since it receives a
session, i figure that the CND is attached to a workspace.

Is there any way to execute this code at the moment the repository is
created so that the new node types are available for all workspaces?

the node type registry is repository-global, i.e. the registered node types are available in all workspaces.

cheers
stefan


I hope my questions make sense.

Thanks


[1] http://jackrabbit.apache.org/node-types.html

import javax.jcr.Session;
import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
import java.io.FileInputStream;

public class CustomNodeTypeExample {
   public static void RegisterCustomNodeTypes(Session session, String
cndFileName)
       throws Exception {

       // Get the JackrabbitNodeTypeManager from the Workspace.
// Note that it must be cast from the generic JCR NodeTypeManager to the
       // Jackrabbit-specific implementation.
       JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
              session.getWorkspace().getNodeTypeManager();
       // Register the custom node types defined in the CND file
       manager.registerNodeTypes(new FileInputStream(cndFileName),
              JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
   }
}




--
Patricio.-

Reply via email to