jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francisco Carriedo Scher <fcarrie...@gmail.com>
Subject Creating a nt:linkedFile
Date Tue, 20 Mar 2012 21:31:49 GMT

i have been trying to create a nt:linkedFile node but i don't know what is

[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

I am operating the repository through Webdav and i create the nodes with
the following code:

    private Node importFile(Node folderNode, String filename, String
mimeType, String encoding, Binary binary) throws RepositoryException,
        // create the file node - see section of the spec
        // By default nodes are overwritten...
        if(fileExists(folderNode.getPath(), filename))
            deleteItem(folderNode.getPath(), filename);

        Node fileNode = folderNode.addNode(filename, "nt:file");
//        fileNode.addMixin("mix:lockable");
        // create the mandatory child node for a file node -> jcr:content
        // otherwise, an exception will arise when saving the session (and
no node will be saved)
        Node resNode = fileNode.addNode("jcr:content", "nt:resource");
        resNode.setProperty("jcr:mimeType", mimeType);
        resNode.setProperty("jcr:encoding", encoding);
        resNode.setProperty("jcr:data", binary);
        Calendar lastModified = Calendar.getInstance();
        resNode.setProperty("jcr:lastModified", lastModified);
        return fileNode;

In the JCR 2.0 spec i read "*The content node must be referenceable.*",
does this reffer to the fileNode or the resNode above?

And i try to create the links with:

            fileToLink = session.getNode(pathToLink);
            folderNode = session.getNode(directoryForLink);

            newLink = folderNode.addNode(linkname);
            newLink.setProperty("reference", fileToLink);

            newLink = folderNode.addNode(linkname,
            newLink.addNode(JcrConstants.JCR_CONTENT, fileToLink.getPath());
            // Exception arises at this point...

This must be a really basic action but i didn't find a clear explanation of
what REFERENCE type is...

Thanks in advance for your attention!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message