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:01:53 UTC

Nodetypes doubt (newbie).

I have the following doubt.

In the code bellow:
		        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", "");
                        ..............;
Can I set the properties directly for fileNode, instead have to create another node of nodetype nt:resource? Like this:
		        Node fileNode = parentnode.addNode(file.getName(), "nt:file");
		        fileNode.setProperty("jcr:mimeType", mimeType);
		        fileNode.setProperty("jcr:encoding", "");
		        resNode.setProperty("jcr:data", new FileInputStream(file));
                        .....;

What consequences, considerations, about the two kind of implementation?
Thanks;
Helio.



Re: Nodetypes doubt (newbie).

Posted by Torgeir Veimo <to...@pobox.com>.
On Thu, 2006-03-09 at 11:01 -0300, hsp wrote:
> I have the following doubt.

> Can I set the properties directly for fileNode, instead have to create another node of nodetype nt:resource? Like this:
> 		        Node fileNode = parentnode.addNode(file.getName(), "nt:file");
> 		        fileNode.setProperty("jcr:mimeType", mimeType);
> 		        fileNode.setProperty("jcr:encoding", "");
> 		        resNode.setProperty("jcr:data", new FileInputStream(file));
>                         .....;
> 
> What consequences, considerations, about the two kind of implementation?

If you created a new nodeType of your own design you could do that. The
nt:file node however is designed to have the content in a child node,
and will fail validation on save if you do it otherwise.

-- 
Torgeir Veimo <to...@pobox.com>