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
Hi,
   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,

    /user
    /user/blogSpace
    /user/blogSpace/<yyyy>/<mm>
    /user/blogSpace/<yyyy>/<mm>/blogEntry
    /user/blogSpace/<yyyy>/<mm>/blogEntry/comment
    /library
    /library/images
    /library/images/<avatar>

------------------------------------------------------------------------------------------------------------------------------

<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

[blog:comment]
    - 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
user
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 ?

    ChildNodeDefinition
    Name *
    RequiredPrimaryTypes UNDEFINED
    ...
    SameNameSiblings false

If we can, how can we define it ? and is ItemExistsException throwed
immediately
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
sameNameSiblings.

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


-------------------------------------------------------------------------------------------------------------------------------

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

    ChildNodeDefinition
    Name *
    RequiredPrimaryType[nt:hierarchyNode]

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 ?
Javadoc
says it throws a PathNotFoundException if we try to create a node without
creating
intermediate nodes.

---------------------------------------------------------------------------------------------------------------------------

So we have to come with a way to name the blog entries. Title may not be a
good
candidate because they may white spacses and '.', '/', ':', '[', ']', '*',
''',
'"' charactors. Would a simple sequential numbering work ? Is there a better
way
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
jcr:created
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");
linkedFile.setProperty("jcr:content",root.getNode("library/xxx/yyy"));

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");
content.setProperty("image",imageInputStream);

user.setProperty("avatar",manAvator);

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

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



BR,
Nandana

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