incubator-graffito-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Kiessler <oliver.kiess...@gmail.com>
Subject Re: Custom node types
Date Sat, 11 Jun 2005 17:13:04 GMT
2005/6/11, Roy Russo <roy.russo@jboss.com>:
> Thank you Oliver. I saw the JIRA tasks.
> 
> As I suspected, the file is autogenerated after setting the node types
> programatically. I'll post to the jackrabbit list, as I am stuck when it
> comes to adding new ones in my code. Thanks!

here is some example code that might help you getting started:

            NodeTypeDef ntd = new NodeTypeDef();
            ntd.setName(new
QName("http://incubator.apache.org/graffito", "folder"));
            ntd.setMixin(false);
            ntd.setOrderableChildNodes(false);

            PropDefImpl propDefImpl = new PropDefImpl();                    
            propDefImpl.setName(PropDef.ANY_NAME);
            propDefImpl.setRequiredType(PropertyType.UNDEFINED);
            propDefImpl.setAutoCreated(false);
            propDefImpl.setMandatory(false);
            propDefImpl.setOnParentVersion(OnParentVersionAction.IGNORE);
            propDefImpl.setProtected(false);
            propDefImpl.setMultiple(false);
            propDefImpl.setDeclaringNodeType(ntd.getName());

            ntd.setSupertypes(new QName[] { new
QName("http://www.jcp.org/jcr/nt/1.0", "base") });
            ntd.setPropertyDefs(new PropDef[] {propDefImpl});

            NodeDefImpl def = getChildNodeDef(ntd.getName());
            ntd.setChildNodeDefs(new NodeDef[] {def});

            Workspace wsp = getSession().getWorkspace();
            NodeTypeManager ntMgr = wsp.getNodeTypeManager();
            NodeTypeRegistry ntReg = ((NodeTypeManagerImpl)
ntMgr).getNodeTypeRegistry();
            ntReg.registerNodeType(ntd);    

regards,
oliver

Mime
View raw message