jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Edelson <justinedel...@gmail.com>
Subject Re: session export / import
Date Tue, 22 Jun 2010 19:46:28 GMT
On 6/22/10 1:44 PM, bruno coelho wrote:
> hi all,
> 
> I'm developing a way of doing backups of our JCR repository built with
> Jackrabbit.
> 
> I started by creating a node "/bruno" and used
>    *session.exportDocumentView("/", outputStream, skipBinary, noRecurse);*
> to export all the content to a xml file.
> 
> then I use
>    *session.importXML("/", inputStream,
> ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);*
> to import the xml file:
> 
> <?xml version="1.0" encoding="UTF-8"?>
>   <jcr:root jcr:primaryType="rep:root" xmlns:fn="
> http://www.w3.org/2005/xpath-functions" xmlns:fn_old="
> http://www.w3.org/2004/10/xpath-functions" xmlns:xs="
> http://www.w3.org/2001/XMLSchema" xmlns:jcr="http://www.jcp.org/jcr/1.0"
> xmlns:ctgt="http://www.yunit.pt/contingut/ctn/1.0" xmlns:mix="
> http://www.jcp.org/jcr/mix/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
> xmlns:rep="internal" xmlns:nt="http://www.jcp.org/jcr/nt/1.0">
>    <jcr:system jcr:primaryType="rep:system">
>        <jcr:versionStorage jcr:primaryType="rep:versionStorage"/>
>        <jcr:activities jcr:primaryType="rep:Activities"/>
>        <jcr:nodeTypes jcr:primaryType="rep:nodeTypes">
>         [...]
>            <ctgt:nosamenamesiblings jcr:primaryType="nt:nodeType"
> jcr:hasOrderableChildNodes="true" jcr:isMixin="false"
> jcr:nodeTypeName="ctgt:nosamenamesiblings"><jcr:propertyDefinition
> jcr:primaryType="nt:propertyDefinition" jcr:autoCreated="false"
> jcr:mandatory="false" jcr:multiple="true" jcr:onParentVersion="COPY"
> jcr:protected="false" jcr:requiredType="UNDEFINED"/><jcr:propertyDefinition
> jcr:primaryType="nt:propertyDefinition" jcr:autoCreated="false"
> jcr:mandatory="false" jcr:multiple="false" jcr:onParentVersion="COPY"
> jcr:protected="false" jcr:requiredType="UNDEFINED"/><jcr:childNodeDefinition
> jcr:primaryType="nt:childNodeDefinition" jcr:autoCreated="false"
> jcr:defaultPrimaryType="ctgt:nosamenamesiblings" jcr:mandatory="false"
> jcr:onParentVersion="VERSION" jcr:protected="false"
> jcr:sameNameSiblings="false"/></ctgt:nosamenamesiblings>
>        [...]
>        </jcr:nodeTypes>
>    </jcr:system>
>    <bruno jcr:primaryType="ctgt:nosamenamesiblings"
> creationDate="1277226878544" deleted="0" lastModifiedDate="1277226878544"
> name="/bruno" objectFQN="yunit.contingut.content.dataObjects.Folder"
> status="WORK_IN_PROGRESS"/>
> </jcr:root>
> 
> my problem is that the import creates another node instead of replacing the
> existing one.
> it creates a node in /jcr:root/bruno and should replace the node /bruno.
> 
> from the specification the importer uses the UUID to check if the node
> exists in the target repository
> but I open the xml file there's no UUID in the attributes of the nodes.
> is this correct? if so how can the importer know if a node already exist or
> not?
You need to use referenceable nodes. Simply adding the mixin
mix:referenceable to the nodes you want to replace or add the mixin as a
parent node type at the time of node type creation (last I checked JR
doesn't allow for mixins to be added to a node type once the type has
been created) should do the trick. However, I would suggest using system
view especially when dealing with unstructured data (unless I'm missing
something ctgt:nosamenamesibilings is basically nt:unstructured without
support for SNS).

Justin

> 
> am I doing something wrong?
> 
> thanks in advance.
> 
> 
> best regards,
> 
> bruno coelho
> 


Mime
View raw message