You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by mephisto29 <en...@collide.info> on 2010/01/29 15:41:57 UTC

Versioning

Hi,

first of all: Thanks for the good support via this list. Lots of my problems
has been solved just by reading your mails. But now I have a problem with
versioning and I don't know where to start :-)

I have created a cnd definition which looks like that:

<ns = 'http://http://www.example.com/jcr-ns/myproj'>
// Namespace declaration -base
<mix = 'http://www.jcp.org/jcr/mix/1.0'> 
<nt = 'http://www.jcp.org/jcr/nt/1.0'> 
// Name
[ns:myNode]

// Supertypes
>  ns:base, mix:versionable
- myNode:defaultLanguage (string) mandatory 
+ myNode:metadata
+ myNode:languages
+ myNode:content
 
[ns:metadata]
> mix:versionable
mixin
+ ns:metadataEntry
   mandatory
   multiple

[ns:metadataEntry]
> mix:versionable
mixin
+ ns:key
   mandatory
   multiple
+ ns:value
   mandatory
   multiple 
 
[ns:key]
> mix:versionable
mixin
- ns:id (string) mandatory 
- ns:xPath (string) mandatory 
- ns:class (string) mandatory
- ns:i18nType (string) mandatory 
- ns:metadataTokenisation(string) mandatory 
- ns:metadataValueCount(string) mandatory 
- ns:validator(string) mandatory 

Now I can store all my stuff in the right location inside Jackrabbit, but:
How does the versioning stuff work? What I did was:
-checkout a (previously stored) node of type myNode
-call this snippet (where childnode is the (checked out) myNode-Node):
Node metadataNode = childnode.addNode("ns:metadata", "ns:metadata");
        IMetadata metadata = myObject.getMetadata();
        Set metadataKeys = metadata.getAllMetadataKeys();
        for (MetadataKey metadataKey : metadataKeys) {
            Node metadataSubNode =
metadataNode.addNode("ns:metadataEntry","ns:metadataEntry");
            Node keyNode = metadataSubNode.addNode("ns:key","ns:key");
            keyNode.setProperty("ns:id", metadataKey .getId());
            keyNode.setProperty("ns:xPath", metadataKey .getXPath());
            keyNode.setProperty("ns:class", metadataKey
.getClass().getCanonicalName());
            keyNode.setProperty("ns:i18nType", metadataKey
.getI18nType().name());
            keyNode.setProperty("ns:metadataTokenisation",     
metadataKey.getMetadataTokenization().name());
            keyNode.setProperty("ns:metadataValueCount", metadataKey
.getMetadataValueCount().name());
            keyNode.setProperty("ns:validator",
iMetadataKey.getValidator().getClass().getCanonicalName());
            Node valueNode = metadataSubNode.addNode("ns:value",
"ns:value");
            ValueContainer valueContainer =
metadata.getMetadataValueContainer(metadataKey);
            String classNameForValue =
valueContainer.getValue().getClass().getCanonicalName();
            valueNode.setProperty("ns:class", classNameForValue);
[...]
            valueNode.setProperty("scy:value",
Base64.encodeToString(baos.toByteArray(), true));
        }

Then I call checkin() on childNode and what I want to have is a new Version.
What I get is different:
Either there are duplicate entries of "metadata" (if I add multiple to the
cnd in 'myNode' for metadata) or there is an javax.jcr.ItemExistsException
for the metadata node. 

What I want to have is that all the childnodes of myNode are somehow
replaced by the new values, so that I get a complete new version of
myNode...

As I am new to JCR/Jackrabbit it could be that I did some mistakes in the
cnd and/or the java code, so please be patient :-)

Cheers and (again) thx for your help,

 Jan




 
-- 
View this message in context: http://n4.nabble.com/Versioning-tp1415533p1415533.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: Versioning

Posted by mephisto29 <en...@collide.info>.
I Must have been blind!
Thx for this!



Am 29.01.2010 um 16:53 schrieb "Justin Edelson [via Jackrabbit]" <ml-node+1415612-1664100083@n4.nabble.com 
 >:

> The problem in with this line:
>  > Node metadataNode = childnode.addNode("ns:metadata",  
> "ns:metadata");
>
> If you want to change the existing metadata node, you should get it,  
> not
> add a new one.
>
> Justin
>
> On 1/29/10 9:41 AM, mephisto29 wrote:
>
> > Hi,
> >
> > first of all: Thanks for the good support via this list. Lots of  
> my problems
> > has been solved just by reading your mails. But now I have a  
> problem with
> > versioning and I don't know where to start :-)
> >
> > I have created a cnd definition which looks like that:
> >
> > <ns = 'http://http://www.example.com/jcr-ns/myproj'>
> > // Namespace declaration -base
> > <mix = 'http://www.jcp.org/jcr/mix/1.0'>
> > <nt = 'http://www.jcp.org/jcr/nt/1.0'>
> > // Name
> > [ns:myNode]
> >
> > // Supertypes
> >
> >>   ns:base, mix:versionable
> >>
> > - myNode:defaultLanguage (string) mandatory
> > + myNode:metadata
> > + myNode:languages
> > + myNode:content
> >
> > [ns:metadata]
> >
> >> mix:versionable
> >>
> > mixin
> > + ns:metadataEntry
> >     mandatory
> >     multiple
> >
> > [ns:metadataEntry]
> >
> >> mix:versionable
> >>
> > mixin
> > + ns:key
> >     mandatory
> >     multiple
> > + ns:value
> >     mandatory
> >     multiple
> >
> > [ns:key]
> >
> >> mix:versionable
> >>
> > mixin
> > - ns:id (string) mandatory
> > - ns:xPath (string) mandatory
> > - ns:class (string) mandatory
> > - ns:i18nType (string) mandatory
> > - ns:metadataTokenisation(string) mandatory
> > - ns:metadataValueCount(string) mandatory
> > - ns:validator(string) mandatory
> >
> > Now I can store all my stuff in the right location inside  
> Jackrabbit, but:
> > How does the versioning stuff work? What I did was:
> > -checkout a (previously stored) node of type myNode
> > -call this snippet (where childnode is the (checked out) myNode- 
> Node):
> > Node metadataNode = childnode.addNode("ns:metadata", "ns:metadata");
> >          IMetadata metadata = myObject.getMetadata();
> >          Set metadataKeys = metadata.getAllMetadataKeys();
> >          for (MetadataKey metadataKey : metadataKeys) {
> >              Node metadataSubNode =
> > metadataNode.addNode("ns:metadataEntry","ns:metadataEntry");
> >              Node keyNode = metadataSubNode.addNode 
> ("ns:key","ns:key");
> >              keyNode.setProperty("ns:id", metadataKey .getId());
> >              keyNode.setProperty("ns:xPath", metadataKey .getXPath 
> ());
> >              keyNode.setProperty("ns:class", metadataKey
> > .getClass().getCanonicalName());
> >              keyNode.setProperty("ns:i18nType", metadataKey
> > .getI18nType().name());
> >              keyNode.setProperty("ns:metadataTokenisation",
> > metadataKey.getMetadataTokenization().name());
> >              keyNode.setProperty("ns:metadataValueCount",  
> metadataKey
> > .getMetadataValueCount().name());
> >              keyNode.setProperty("ns:validator",
> > iMetadataKey.getValidator().getClass().getCanonicalName());
> >              Node valueNode = metadataSubNode.addNode("ns:value",
> > "ns:value");
> >              ValueContainer valueContainer =
> > metadata.getMetadataValueContainer(metadataKey);
> >              String classNameForValue =
> > valueContainer.getValue().getClass().getCanonicalName();
> >              valueNode.setProperty("ns:class", classNameForValue);
> > [...]
> >              valueNode.setProperty("scy:value",
> > Base64.encodeToString(baos.toByteArray(), true));
> >          }
> >
> > Then I call checkin() on childNode and what I want to have is a  
> new Version.
> > What I get is different:
> > Either there are duplicate entries of "metadata" (if I add  
> multiple to the
> > cnd in 'myNode' for metadata) or there is an  
> javax.jcr.ItemExistsException
> > for the metadata node.
> >
> > What I want to have is that all the childnodes of myNode are somehow
> > replaced by the new values, so that I get a complete new version of
> > myNode...
> >
> > As I am new to JCR/Jackrabbit it could be that I did some mistakes  
> in the
> > cnd and/or the java code, so please be patient :-)
> >
> > Cheers and (again) thx for your help,
> >
> >   Jan
> >
> >
> >
> >
> >
> >
>
>
>
> View message @ http://n4.nabble.com/Versioning-tp1415533p1415612.html
> To unsubscribe from Versioning, click here.
>

-- 
View this message in context: http://n4.nabble.com/Versioning-tp1415533p1415639.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: Versioning

Posted by Justin Edelson <ju...@gmail.com>.
The problem in with this line:
 > Node metadataNode = childnode.addNode("ns:metadata", "ns:metadata");

If you want to change the existing metadata node, you should get it, not 
add a new one.

Justin

On 1/29/10 9:41 AM, mephisto29 wrote:
> Hi,
>
> first of all: Thanks for the good support via this list. Lots of my problems
> has been solved just by reading your mails. But now I have a problem with
> versioning and I don't know where to start :-)
>
> I have created a cnd definition which looks like that:
>
> <ns = 'http://http://www.example.com/jcr-ns/myproj'>
> // Namespace declaration -base
> <mix = 'http://www.jcp.org/jcr/mix/1.0'>
> <nt = 'http://www.jcp.org/jcr/nt/1.0'>
> // Name
> [ns:myNode]
>
> // Supertypes
>    
>>   ns:base, mix:versionable
>>      
> - myNode:defaultLanguage (string) mandatory
> + myNode:metadata
> + myNode:languages
> + myNode:content
>
> [ns:metadata]
>    
>> mix:versionable
>>      
> mixin
> + ns:metadataEntry
>     mandatory
>     multiple
>
> [ns:metadataEntry]
>    
>> mix:versionable
>>      
> mixin
> + ns:key
>     mandatory
>     multiple
> + ns:value
>     mandatory
>     multiple
>
> [ns:key]
>    
>> mix:versionable
>>      
> mixin
> - ns:id (string) mandatory
> - ns:xPath (string) mandatory
> - ns:class (string) mandatory
> - ns:i18nType (string) mandatory
> - ns:metadataTokenisation(string) mandatory
> - ns:metadataValueCount(string) mandatory
> - ns:validator(string) mandatory
>
> Now I can store all my stuff in the right location inside Jackrabbit, but:
> How does the versioning stuff work? What I did was:
> -checkout a (previously stored) node of type myNode
> -call this snippet (where childnode is the (checked out) myNode-Node):
> Node metadataNode = childnode.addNode("ns:metadata", "ns:metadata");
>          IMetadata metadata = myObject.getMetadata();
>          Set metadataKeys = metadata.getAllMetadataKeys();
>          for (MetadataKey metadataKey : metadataKeys) {
>              Node metadataSubNode =
> metadataNode.addNode("ns:metadataEntry","ns:metadataEntry");
>              Node keyNode = metadataSubNode.addNode("ns:key","ns:key");
>              keyNode.setProperty("ns:id", metadataKey .getId());
>              keyNode.setProperty("ns:xPath", metadataKey .getXPath());
>              keyNode.setProperty("ns:class", metadataKey
> .getClass().getCanonicalName());
>              keyNode.setProperty("ns:i18nType", metadataKey
> .getI18nType().name());
>              keyNode.setProperty("ns:metadataTokenisation",
> metadataKey.getMetadataTokenization().name());
>              keyNode.setProperty("ns:metadataValueCount", metadataKey
> .getMetadataValueCount().name());
>              keyNode.setProperty("ns:validator",
> iMetadataKey.getValidator().getClass().getCanonicalName());
>              Node valueNode = metadataSubNode.addNode("ns:value",
> "ns:value");
>              ValueContainer valueContainer =
> metadata.getMetadataValueContainer(metadataKey);
>              String classNameForValue =
> valueContainer.getValue().getClass().getCanonicalName();
>              valueNode.setProperty("ns:class", classNameForValue);
> [...]
>              valueNode.setProperty("scy:value",
> Base64.encodeToString(baos.toByteArray(), true));
>          }
>
> Then I call checkin() on childNode and what I want to have is a new Version.
> What I get is different:
> Either there are duplicate entries of "metadata" (if I add multiple to the
> cnd in 'myNode' for metadata) or there is an javax.jcr.ItemExistsException
> for the metadata node.
>
> What I want to have is that all the childnodes of myNode are somehow
> replaced by the new values, so that I get a complete new version of
> myNode...
>
> As I am new to JCR/Jackrabbit it could be that I did some mistakes in the
> cnd and/or the java code, so please be patient :-)
>
> Cheers and (again) thx for your help,
>
>   Jan
>
>
>
>
>
>