jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nandana Mihindukulasooriya" <nandana....@gmail.com>
Subject Re: How to start thinking in JCR
Date Thu, 29 Mar 2007 02:29:35 GMT
   I should thank Brian, Xin and Jukka a lot for their valuable feedbacks
and I was able
to understand lot of things when I went through the JSR-170 again after
reading the feedbacks.
So I modified the CND,



<blog = 'http://jackrabbit.apache.org/jackrabbit-jcr-demo/1.0'>
<nt =  'http://www.jcp.org/jcr/nt/1.0' >
<jcr =  'http://www.jcp.org/jcr/1.0' >

[blog:user] > mix:referenceable
    - nickname  (string) mandatory
    - email  (string) mandatory
    - password (string) mandatory
    - avatar (reference) < blog:avatar
    + blogSpace [nt:folder] mandatory autocreated

[blog:blogEntry] > nt:hierarchyNode, mix:referenceable
    - content (string) mandatory primary
    - rate (long)
    + attachments (nt:folder) mandatory autocreated

    - content (string) mandatory primary
    - commenter (reference ) mandatory  < blog:user

[blog:avatar] > nt:file, mix:referenceable

blogspace , <yyyy> , <mm> , library, images will be type of [nt:folder]


Now we will create users using their unique user IDs like

Node root = session.getRootNode();
Node user = root.addNode("uniqueUserID","blog:user");

To avoid uniqueUserID conflit with other root's child nodes ( which are not
nodes ), can we use a namespace prefix as "id:uniqueID" with <id =
http://... > .

can we add something like this to root node to avoid non-unique userIDs ?

    Name *
    RequiredPrimaryTypes UNDEFINED
    SameNameSiblings false

If we can, how can we define it ? and is ItemExistsException throwed
or on save in jackrabbit implementation of jcr ?
If we can't is there any other way to prevent it ?

or can I make a one root note child like this and define it not to have

    - * [blog:user]
    - library [nt:folder] mandatory autocreated


As blogspace is of type nt:folder which has a child node definition,

    Name *

it can in turn have children of type nt:folder as nt:folder is a  subtype of
nt:hierarchyNode. So both <yyyy> and <mm> would be nodes of type nt:folder.
So we can use,

Node blogSpace = user.getNode("blogSpace");
Node year = blogspace.addNode("2007","nt:folder");
Node month = year.addNode("03","nt:folder");

Is there a way to create a node with intermediate created automatically ?
If there is a way, how can we declare the types of intermediate nodes ?
says it throws a PathNotFoundException if we try to create a node without
intermediate nodes.


So we have to come with a way to name the blog entries. Title may not be a
candidate because they may white spacses and '.', '/', ':', '[', ']', '*',
'"' charactors. Would a simple sequential numbering work ? Is there a better
to handle this ?

Node blogEntry = month.addNode("01","blog:blogEntry");
blogEntry.setProperty("content","my first blog entry");

As blogEntry is a subtype of nt:hierarchyNode, I would be able to use
property to get the created date of the blog.

To add an image attachment,

Node attachments = blogEntry.getNode("attachments");
Node linkedFile = attachments.addNode("attachment01","nt:linkedFile");

jcr:content property of the  nt:linkedFile  type  is of type reference.


To add a Comment

Node comment = blogEntry.addNode("01","blog:comment");
comment.setProperty("content","my first comment");
comment.setProperty("commenter", root.getNode("commenterID"));


To add a avator to a user,

Node library = root.getNode("library");
Node manAvatar = library.addNode("manAvator","blog:avatar");
Node content = manAvatar.getNode("jcr:content");


jcr:content is of type nt:base and how can we define that it has a property
which contains Binary data. Or shall I directly add "image" property to
type like

[blog:avatar] > nt:file,mix:referenceable
- image (binary) mandatory primary


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