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());
*// 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 <[email protected]>
>
> 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
> [email protected]
>
>
>
>