You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by hsp <pi...@ibest.com.br> on 2006/03/09 15:55:18 UTC

Difference between nodetypes structure.

Hi;
I would to know what is the difference between the following implementation code:
"   Node fileNode = parentnode.addNode(file.getName(), "nt:file");
     Node resNode = fileNode.addNode("jcr:content", "nt:resource");
     resNode.setProperty("jcr:mimeType", mimeType);
     resNode.setProperty("jcr:encoding", "");
     resNode.setProperty("jcr:data", new FileInputStream(file));
...."
 and the another:

" Node fileNode = parentnode.addNode(file.getName(), "nt:file");
  fileNode.setProperty("jcr:mimeType", mimeType);
  fileNode.setProperty("jcr:encoding", "");
  fileNode.setProperty("jcr:data", new FileInputStream(file));
...."

What is the consequences, considerations. Is it wrong? Is the first implementation necessary? What is the best pratice for?

Thanks
Helio

Re: Difference between nodetypes structure.

Posted by Tobias Bocanegra <to...@day.com>.
hi helio,
the first implementation is necessary, since a nt:file is defined to
have a jcr:content child node. the nt:file does not define the
jcr:data or jcr:mimeType properties.

have a look at those relevant nodetypes again:

[nt:hierarchyNode]
  - jcr:created (date) mandatory autocreated protected initialize

[nt:file] > nt:hierarchyNode
  + jcr:content (nt:base) primary mandatory

[nt:resource] > mix:referenceable
  - jcr:encoding (string)
  - jcr:mimeType (string) mandatory
  - jcr:data (binary) primary mandatory
  - jcr:lastModified (date) mandatory ignor


regards, toby

On 3/9/06, hsp <pi...@ibest.com.br> wrote:
> Hi;
> I would to know what is the difference between the following implementation code:
> "   Node fileNode = parentnode.addNode(file.getName(), "nt:file");
>      Node resNode = fileNode.addNode("jcr:content", "nt:resource");
>      resNode.setProperty("jcr:mimeType", mimeType);
>      resNode.setProperty("jcr:encoding", "");
>      resNode.setProperty("jcr:data", new FileInputStream(file));
> ...."
>  and the another:
>
> " Node fileNode = parentnode.addNode(file.getName(), "nt:file");
>   fileNode.setProperty("jcr:mimeType", mimeType);
>   fileNode.setProperty("jcr:encoding", "");
>   fileNode.setProperty("jcr:data", new FileInputStream(file));
> ...."
>
> What is the consequences, considerations. Is it wrong? Is the first implementation necessary? What is the best pratice for?
>
> Thanks
> Helio
>


--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---