jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Buchmann <david.buchm...@liip.ch>
Subject Re: Creating a nt:linkedFile
Date Wed, 21 Mar 2012 09:20:29 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

answer is inline

Am 20.03.2012 23:40, schrieb Francisco Carriedo Scher:
> Thanks Lukas for your quick response, anyway i'm affraid i am still missing
> something...
> 
> First i add the "mix:referenceable" not only to the nt:file node but to
> it's jcr:content node too for the nt:file to be linked later:
> 
> 
>         Node fileNode = folderNode.addNode(file.getName(), "nt:file");
>         fileNode.addMixin("mix:referenceable");
>         Node resNode = fileNode.addNode("jcr:content", "nt:resource");
>         resNode.addMixin("mix:referenceable");
>         resNode.setProperty("jcr:mimeType", mimeType);
>         resNode.setProperty("jcr:encoding", encoding);
>         resNode.setProperty("jcr:data", binary);
>         session.save();
> 
> 
> and then tried this code:
> 
>             folderNode = session.getNode(directoryForLink);
>             fileToLink = session.getNode(pathToLink);
> 
>             for (NodeType aux : fileToLink.getMixinNodeTypes())
>                 System.out.println(aux.getName());
>             *// PRINTS: mix:referenceable*
> 
>             resNode = fileToLink.getNode("jcr:content");
> 
>             for (NodeType aux : resNode.getMixinNodeTypes())
>                 System.out.println(aux.getName());
>             *// PRINTS: NOTHING*
> 
>             newLink = folderNode.addNode(linkname,
> JcrConstants.NT_LINKEDFILE);
>             newLink.addNode(JcrConstants.JCR_CONTENT,
> resNode.getIdentifier());

you try to add a node with the name that is in JCR_CONTENT and the type
of the identifier. that makes no sense for jcr. the reference is a
property. a child node can never be a reference.
you want to do something like:
newLink.setProperty("jcr:content", resNode);

then you can do link.getProperty("jcr:content").getNode() to get the
referenced node.

>             *// EXCEPTION RAISES (during the line above)        *
>             session.save();
> 
> and got this exception:
> 
> javax.jcr.nodetype.NoSuchNodeTypeException:
> {}c01df2eb-7af0-49c7-a7fd-1a4fbc3b9822
> 
> 
> Any idea? Thanks for your attention!
> 
> 
> 
> 
> 2012/3/20 Lukas Kahwe Smith <mls@pooteeweet.org>
> 
>>
>> On Mar 20, 2012, at 17:31 , Francisco Carriedo Scher wrote:
>>
>>> Hello,
>>>
>>> i have been trying to create a nt:linkedFile node but i don't know what
>> is
>>> "REFERENCE" in
>>>
>>> [nt:linkedFile] > nt:hierarchyNode
>>>  primaryitem jcr:content
>>>  - jcr:content (REFERENCE) mandatory
>>>
>>> I have tried with the path of the node i want to link, a reference
>> obtained
>>> through JcrUtils.getReferences(nodeToLink)... But different exceptions
>>> arised.
>>
>>
>> references work on UUID's
>> the target node needs to have the mixing type "mix:referenceable" which
>> would give it a UUID automatically on save.
>>
>> regards,
>> Lukas Kahwe Smith
>> mls@pooteeweet.org
>>
>>
>>
>>
> 

- -- 
Liip AG // Agile Web Development // T +41 26 422 25 11
CH-1700 Fribourg // PGP 0xA581808B // www.liip.ch
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9pnVwACgkQqBnXnqWBgIv48ACfUIgy5KBnVkr3NK7iRB30LIiv
jT4AoLNruVeXXYM1hOCuZ06Ojoy2DOYu
=msAN
-----END PGP SIGNATURE-----

Mime
View raw message