jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Susanne James" <susi_8...@hotmail.com>
Subject Re: [Beginner]New Node Type Definition
Date Fri, 27 Jan 2006 13:46:34 GMT
Hello Jukka,

Thank you for your reply. It has clarified some confusions I had.

But still, I would to be sure about one more thing.

I have been doing tests on creating nodes of type nt:file, 
nt:unstructured....And I was having all the time weired errors like, 
"mandatory property.....created does not exist". And I thought it was 
strange, as property created of nt:hierarchyNode is not mandatory...And 
other similar errors.

So I just want to be sure of one more thing. Even for predefined nodes, it 
is not possible to define a node of a certain type, through JCR Node 
I want to add a node of type nt:file with jcr:content of nt:resource type.

For doing so, I have to create a convenience class.

And for creating a node of a custom new node type, I have to follow one of 
the two possibilities you have just mentioned.

What is most interesting for me at the moment is to know why I am getting 
these "strange" errors when creating a simple nt:file.

This is very important. Thank you in advance.
Best Regards

>From: Jukka Zitting <jukka.zitting@gmail.com>
>Reply-To: jackrabbit-dev@incubator.apache.org
>To: jackrabbit-dev@incubator.apache.org
>Subject: Re: [Beginner]New Node Type Definition
>Date: Fri, 27 Jan 2006 13:58:05 +0200
>On 1/21/06, sirène vip <sirene_vip@hotmail.com> wrote:
> > I want to create a new node type. It has to be extended from the nt:file
> > with few changements like having sameNameSiblings set to true. Nodes of 
> > new node type will be versionable.
>Sounds like you are looking for something like this:
>[yourNodeType] > nt:file, nt:versionable
>   multiple
> > 1. I found in the jcr API the Version Interface, but couldn't find any 
> > wrapping nt:file. Is there is one as for nt:version. And, if not, which
> > class should I use in order to implement my new class? or should I 
> > a class for the nt:file node type?
>The JCR node types are not Java classes, and there is no one-to-one
>mapping between those. You need to first define and register the node
>type in a content repository (see
>http://incubator.apache.org/jackrabbit/doc/nodetype/index.html). Then
>you can either access nodes of that type directly using the JCR Node
>interface, or indirectly by creating a more convenient wrapper class
>for the Node interface.
>For example a convenience class for accessing nt:file nodes could be:
>     public class FileNode {
>         private final Node node;
>         public FileNode(Node node) {
>             this.node = node;
>         }
>         public String getName() throws RepositoryException {
>             return node.getName();
>         }
>         public String getType() throws RepositoryException {
>             try {
>                 return 
>             } catch (PathNotFoundException e) {
>                 return null; // no mime type defined
>             }
>         }
>         public InputStream getContent() throws RepositoryException {
>             try {
>                 return 
>             } catch (PathNotFoundException e) {
>                 return null; // no content available
>             }
>         }
>     }
> > 2. Antoher confusing issue is on ChildNodeDefinition, which in the case 
> > nt:file, is a  jcr:content. I thought of implementing it as an inner 
> > but I don't know if I'm on the right way. To my knowledge, a
> > propertyDefinition should be implemented as an attribute, and a
> > NodeDefinition as a  class.
>There is no simple one-to-one mapping so the best solution depends on
>the actual node type in case.
>Jukka Zitting
>Yukatan - http://yukatan.fi/ - info@yukatan.fi
>Software craftmanship, JCR consulting, and Java development

On the road to retirement? Check out MSN Life Events for advice on how to 
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement

View raw message