jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Guggisberg <stefan.guggisb...@gmail.com>
Subject Re: Strategy to register new node types.
Date Thu, 19 Nov 2009 07:58:50 GMT


On 19.11.2009, at 06:01, Patricio Echag├╝e <patricioe@gmail.com> 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.-

Mime
View raw message