Not sure what fails, but you could simplify your code and use the registerNodeTypes() methods of the JackrabbitNodeTypeManager that take an input stream. See the code snippet at the bottom of http://jackrabbit.apache.org/node-types.html For the content type you will have to use JackrabbitNodeTypeManager.TEXT_XML when using the xml format for nodetypes.
Regards, Alex On Mon, Mar 30, 2009 at 6:54 PM, Kooper <[email protected]> wrote: > > Hi, > I have an issue with import/export node types in JackRabbit. I have method > for import nodetypes: > > public static void importNodeType(Session session, String fileName) > throws InvalidNodeTypeDefException, > RepositoryException, > ParseException, IOException { > Workspace ws = session.getWorkspace(); > NodeTypeManagerImpl ntTypeMgr = (NodeTypeManagerImpl) ws > .getNodeTypeManager(); > NodeTypeRegistry ntr = ntTypeMgr.getNodeTypeRegistry(); > InputStream inputStream = new FileInputStream(fileName); > NodeTypeDef[] defs = NodeTypeReader.read(inputStream); > Set coll = new HashSet(); > for (int i = 0; i < defs.length; i++) { > coll.add(defs[i]); > } > > ntr.registerNodeTypes(coll); > > } > > and xml file with node types: > <nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0" > xmlns:mix="http://www.jcp.org/jcr/mix/1.0" > xmlns:jcr="http://www.jcp.org/jcr/1.0" > > <nodeType name="Value Test" isMixin="true" hasOrderableChildNodes="false" > primaryItemName="" > > <supertypes> > <supertype>nt:base</supertype> > </supertypes> > <propertyDefinitions> > <propertyDefinition name="Animals" requiredType="String" autoCreated="false" > mandatory="false" onParentVersion="COPY" protected="false" multiple="false" >> > <valueConstraints> > <valueConstraint>Dog</valueConstraint> > <valueConstraint>Cat</valueConstraint> > <valueConstraint>Bird</valueConstraint> > <valueConstraint>Bear</valueConstraint> > <valueConstraint>Spider</valueConstraint> > <valueConstraint>Snake</valueConstraint> > </valueConstraints> > </propertyDefinition> > <propertyDefinition name="Country" requiredType="String" autoCreated="false" > mandatory="false" onParentVersion="COPY" protected="false" multiple="false" >> > <valueConstraints> > <valueConstraint>Ukraine</valueConstraint> > <valueConstraint>USA</valueConstraint> > </valueConstraints> > </propertyDefinition> > <propertyDefinition name="Conference" requiredType="String" > autoCreated="false" mandatory="false" onParentVersion="COPY" > protected="false" multiple="false" > > <valueConstraints> > <valueConstraint>Big10</valueConstraint> > <valueConstraint>Big12</valueConstraint> > <valueConstraint>SEC</valueConstraint> > <valueConstraint>PAC10</valueConstraint> > </valueConstraints> > </propertyDefinition> > </propertyDefinitions> > </nodeType> > </nodeTypes> > > import completes successfullty no exception thrown but custom_node.xml seems > to miss all propertyDefinitions in it. > e.g: > <nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0" > xmlns:mix="http://www.jcp.org/jcr/mix/1.0" > xmlns:jcr="http://www.jcp.org/jcr/1.0" > > <nodeType name="Value Test" isMixin="true" hasOrderableChildNodes="false" > primaryItemName="" > > <supertypes> > <supertype>nt:base</supertype> > </supertypes> > </nodeType> > </nodeTypes> > > Does anyone meet the issue and could help me with it? > Thank you in advance > -- > View this message in context: > http://www.nabble.com/propertyDefinition-fails-to-import-tp22787679p22787679.html > Sent from the Jackrabbit - Users mailing list archive at Nabble.com. > > -- Alexander Klimetschek [email protected]
