You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Kooper <se...@list.ru> on 2009/03/30 18:54:50 UTC

propertyDefinition fails to import

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.


Re: propertyDefinition fails to import

Posted by Kooper <se...@list.ru>.


Stefan Guggisberg wrote:
> 
> On Mon, Mar 30, 2009 at 6:54 PM, Kooper <se...@list.ru> 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?
> 
> the format is incorrect. omit the <propertyDefinitions/> element and
> everything should be working as expected. see [1] for a DTD for the
> (internal) node type serialization format.
> 
> cheers
> stefan
> 
> [1]
> http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml?view=markup
> 
>> 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.
>>
>>
> 
> 

Thank you very much for reply. It helped a lot.
-- 
View this message in context: http://www.nabble.com/propertyDefinition-fails-to-import-tp22787679p22825481.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: propertyDefinition fails to import

Posted by Stefan Guggisberg <st...@gmail.com>.
On Mon, Mar 30, 2009 at 6:54 PM, Kooper <se...@list.ru> 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?

the format is incorrect. omit the <propertyDefinitions/> element and
everything should be working as expected. see [1] for a DTD for the
(internal) node type serialization format.

cheers
stefan

[1] http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.xml?view=markup

> 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.
>
>

Re: propertyDefinition fails to import

Posted by Kooper <se...@list.ru>.

Alexander Klimetschek wrote:
> 
> 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
> 
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 
Hi thanks for reply, I tried the variant but result is the same. When I
refactor the xml to cnd everything works well, in both variants but I need
xml format. Xml seems to be valid and no exceptions thrown, so I even cannot
imagine what is the cause of the behaivour. May be someone met such
behaivour and solved the issue, I would be very grateful for help

-- 
View this message in context: http://www.nabble.com/propertyDefinition-fails-to-import-tp22787679p22821800.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: propertyDefinition fails to import

Posted by Alexander Klimetschek <ak...@day.com>.
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 <se...@list.ru> 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
alexander.klimetschek@day.com