You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by alartin <al...@gmail.com> on 2007/03/19 09:09:19 UTC

Best Practice using Jackrabbit

Hi, all

   I try to write an open-sourced demo application to illustrate some simple
and basic features of Jackrabbit. The whole plan is listed below. My goal is
to build a step by step tutorial for java developer to use JCR/Jackrabbit in
their application. I hope experts here give some suggestions and
discussions. Thanks in advance.
-------------------------------------------------------------------------------------------------------------------
## JackRabbit based QnA System Design ##

# Date: 2007-03-15
# Version: 0.1

1. Motivation
Java Content Repository Technology(JCR) aims to provide a common
specification and interface in
content management field. As the most popular and open-sourced
implementation of JCR, Apache
JackRabbit is a good choice for developers who plan to build applications on
the top of JCR.
Although there are a few open-sourced CMS&ECM like jLibrary, OpenKm and
Nuxeo5 available for 
them to figure out how to build their applications using JackRabbit, they
are too complex and
the examples provided by JackRabbit are too simple. We need a demo
application with an easy and
clear problem domain to inllustrate the usage of JackRabbit especially in
mapping the nodes and
properties to their application level models and objects.

2. Goal
We aim to build a QnA system like Y!Answers but with rather simpler and
fewer functions on the top
of JackRabbit. We try to inllustrate the best practice of using
JCR/Jackrabbit. The QnA system
will be designed to be simple but applicable.

3. QnA System Introduction
In this section, we will give a brief introduction and requirements to this
system. Briefly speaking,
a QnA system includes: questions, answers, comments, users and
administrators. Users may post questions
to the system, they also can answer other's questions and give comments to
both questions and answers.
User can vote on answers and if he is the poster of the corresponding
question, he can choose the 
best answer.

Note: For simpleness, the rule of QnA system is different and rather easier
than Y!Answers and only
supports text information and no deadline to a question.

Rules: Any registered user can post a question with a score, any registered
users including himself 
may give answers, the questioner can choose the best answer and the score
will be given to the answerer.
If the questioner change the best answer, the score will not be withdrawn
and simply given again to
the author of the new best answer. If a question is deleted, all answers and
comments will be deleted too.
But the score(if there is a best answer) will not be withdrawn.


Now, let's talk about problem domain.

3.1 Question
    1. A question must have a title (String)
    2. A question must have a cotent (String)
    3. A question must have a status (String, the value will be one of
"open","voting","close")
    4. If a quesion is posted and no answers to it, it will be marked with
"open"
    5. Once a question has an answer, it will be marked with "voting"
    6. Once the poster of a question chooses a best answer, it will be
marked with "close"
    7. The poster of a question can let it always "open" if he is not
satisfied with all answers  
    8. A question must at least have one Tag(String) to facilitate
classification
    9. A question must have an author
    10. A question must have a creation date(Calendar?)
    11. A question may have many answers
    12. A question may have many comments
    13. A question is not versionable and can not be modifed once it is
posted.
    14. A question can be modifed/deleted by manager or admin
    15. A question must have a isAbused(boolean), any user can report abuse
    16. A question must have a score(int), it will be given to the user
whose answer is the best.
    
3.2 Answer
    1. An answer can not exist alone, it must be associated with one
question
    2. An answer must have a cotent
    3. An answer must have an author
    4. An answer must have a creation date
    5. An answer must have a isBest
    6. An answer must have a vote
    7. An answer may have many comments
    8. An answer is not versionable and can not be modifed once it is posted
    9. An answer can be deleted by manager or admin
    10. An answer must have a abused, any user can report abuse
    
3.3 Comment
    1. A comment can not exist alone, it must be associated with one
question or answer
    2. A comment must have an author
    3. A comment must have a content
    4. A comment is not versionable and can not be modifed once it is posted
    5. A comment can be deleted by manager or admin
    6. A comment must have a abused, any user can report abuse
    
3.4 User
    1. A user must have a username
    2. A user must have a password
    3. A user must have a score
    4. A user must have a role(the value will be one of "admin",
"manager","general")
    5. A user must have a frozen, if true, this user/account will be frozen
       , it will be a punishment to the users who get many abuse reports
    6. Any user's role will be assigned to "general" with permissions of
posting 
       questions,answers,comments and reporting abuse after registration.
    7. A manager can delete questions,answers,comments,freeze users in
addition to the permissions above
    8. An admin can delete or change the role of users in addition to the
permissions above
    9. A user must have a list of questions he posted
    10. A user must have a list of answers he posted
    11. A user must have a list of comments he posted
    
    
4. Mapping in JCR/JackRabbit
Everything can be treated as node or property in JCR. The main task of this
section is to build a bridge
between problem domain and JCR concepts. Since we often use term of
"Modelling" when making abstractions from
entities in problem domain into objects in OOP, we here use term of
"Mapping" when we using nodes 
or properties of JCR/JackRabbit in the objects after modelling. The
"Mapping" will answer questions like:
"Should I make my object a node or a property?" or "Should I make my object
as a subnode of one node or just
let that node reference it?" . The "Mapping" in JCR/JackRabbit is as what
you do when trying to make your objects
into tables of RDBMS.

4.1 Entry Abstract Class
  
     Variables:
     1. String content
     2. User author
     3. Calendar creation
     4. boolean abused
     
     Since it is an abstract class, we do not need to map it in
JCR/JackRabbit

4.2 Question Class

     Variables:
     1. String title
     2. String content
     3. String status
     4. Set<String> tags
     5. Calendar creation
     6. User author
     7. List<Answer> answers
     8. List<Comment> comments
     9. int score
     10. boolean abused
     
     Because we need to reference the question object in the answer object,a
question should be mapped
     to a referenceable node. The title should be mapped to a property
     
4.3 Answer Class

     Variables:
     1. Question question
     2. String content
     3. User author
     4. Calendar creation
     5. boolean best
     6. int vote
     7. List<Comment> comments
     8. boolean abused
     
4.4 Comment Class

     Variables:
     1. Entry entry  (A comment may be associated with either a Question or
an Answer)
     2. User author
     3. String content
     4. Calendar creation
     5. boolean abused
     
4.5 User Class

     Variables:
     1. String username
     2. String password
     3. String role
     4. int score
     5. boolean frozen
     6. List<Question> questions
     7. List<Answer> answers
     8. List<Comment> comments 
-- 
View this message in context: http://www.nabble.com/Best-Practice-using-Jackrabbit-tf3425559.html#a9547815
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.