Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

JCR in java

  Asked By: Jimmy    Date: Feb 26    Category: Java    Views: 862
  

Do any body knows about JCR ( JSR 170 ) ?

I need to know how can retrieve all content of workspace or node ?
Is it any way can gain one tree list ( all node , all content or item
(bindery file ) ?
How it`s possible to check is it( node , or item or workspace ) exist in
repository or workspace or node ?

Share: 

 

8 Answers Found

 
Answer #1    Answered By: Wade Jordan     Answered On: Feb 26

JCR is good for working with Tree structured data (like RDBMS is good for table data)
for example you can copy, clone or move a subtree of nodes using Session (javax.jcr.Session) object
you can use query api over nodes,
in JCR you can query nodes using SQL like commands and XPATH commands
this is the same XPATH used for XML DOM operation and of course it is better for tree operations.

www.day.com/.../Query.html

if information was not enough tell me to describe in more detail

can you please tell me a little more about your project?
I am interested to get to know more about companies using JCR in Iran.

 
Answer #2    Answered By: Roderick King     Answered On: Feb 26

I dont know why my answer doesn't reached the list the following is my
last post;
------------------------------------------------------


See this article:

www..ibm.com/developerworks/java/library/j-jcr/

and consider "Listing 9. Browsing a content repository" in it.


It's simple just like traversing a tree.


As mentioned in the article above you can use Xpath to search for a node.

 
Answer #3    Answered By: Fatih Farooq     Answered On: Feb 26

I am doing 2 week study in JCR ( This project is part Universities program in Iran )

I had look on JackRabbit , Alfersco , eXo , and etc. I study the JCR documentation too ,

But I have problem to run one simple example . I can create repository , workspace and node and also

save binary file in node , But for retrieving those things i have problem . for example I want show all content

( Workspaces m nodes , items, properties ) in tree also i wand save one binary file to my hard disk from that repository .

In other word I saved one file ( sample.gif or sample.pdf ) in my A workspace and in node A and in node A i saved that .

now i want show or download these file and save in some part of hard disk , i could`t do that , basically i think is every easy

think which i want to do , But the problem is I don`t know how and document was`t useful for me in this part ,

can you pls help me in some sample or do you know any good reference with i can go thought that and find my answers ,

 
Answer #4    Answered By: Isaac Evans     Answered On: Feb 26

it is easier if you don't display workspace, nodes, items in one tree.
it is better that user choses its workspaces other ways,
then you display tree as tree nodes and items as properties of node
at least it is much easier this way while you have only one node type in your tree.
other wise if you insist showing them all in one tree, if you are using JSF you can use different facets for different node types (Worspace, node, item)

I think as nasim said the jackrabbit examples are very good for start

http://jackrabbit.apache.org/doc/firststeps.html

if you want a complete JCR browser here is one open source application:

http://sourceforge.net/projects/jcrbrowser

a more complete open source application can be found here:

http://www.jlibrary.org/

if you still need more help post another message on the list

 
Answer #5    Answered By: Erin Dunn     Answered On: Feb 26

See this article:

www..ibm.com/developerworks/java/library/j-jcr/

and consider “Listing 9. Browsing a content repository” in it.



It’s simple just like traversing a tree.



As mentioned in the article above you can use Xpath to search for a node.

 
Answer #6    Answered By: Ana Bradley     Answered On: Feb 26

Jackrabbit is a great implementation of JCR, and Liferay portal uses jackrabbit as its Content Repository for Search Engine, Document Library. The source code of liferay could be a great sample to recognize most of its advantages in practice.
However you can go directly to jackrabbit website and use the first-steps samples if you are a novice to JCR.

http://jackrabbit.apache.org/doc/firststeps.html

 
Answer #7    Answered By: Bernard Gutierrez     Answered On: Feb 26

you can find all about jsr  in this address :
http://jcp.org/en/home/index
and if you exactly wanna know about jsr 170 :
http://jcp.org/en/jsr/detail?id=170

 
Answer #8    Answered By: Vilhelm Fischer     Answered On: Feb 26

I have done some samples on Jackrabbit.... I found this particular of code in my old works. it works. I can send you whole of the samples if you need... I have followed a tutorial to find this.


package toorin.jcr.repo;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Node;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.apache.jackrabbit.core.jndi.RegistryHelper;
import org.apache.jackrabbit.value.StringValue;
import org.apache.jackrabbit.value.DateValue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Hashtable;
import java.util.Calendar;

public class RepoClientJNDI {
protected Log logger = LogFactory.getLog(getClass());
public String connect() throws Exception {
logger.info(" .'.'.'.'.'.'.'.'. Start .'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.' ");
StringBuffer result = new StringBuffer();
String configFile = "toorin_repository/repository.xml";
String repHomeDir = "toorin_repository";

Hashtable env = new Hashtable();
// JNDI Directory service...

env.put(Context.INITIAL_CONTEXT_FACTORY , "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
env.put(Context.PROVIDER_URL,"localhost");
InitialContext ctx = new InitialContext(env);
RegistryHelper.registerRepository(ctx,"toorin_repo" , configFile , repHomeDir , true);
Repository r = (Repository)ctx.lookup("toorin_repo");
Session session = r.login(new SimpleCredentials("username", "password".toCharArray()),null);

try {
/*
Root
\
\
hello
\
\
world --+ message : hello, world!
|
+ prop1 : it is a content.
*/
Node root = session.getRootNode();
Node n = root.addNode("blog"); // root node is here
n.setProperty("blogtitle", new StringValue("Chasing Jackrabbit article"));
n.setProperty("blogauthor", new StringValue("Joe Blogger"));
n.setProperty("blogdate", new DateValue(Calendar.getInstance()));
n.setProperty("blogtext", new StringValue("JCR is an interesting API to lo learn."));
/*
We can subsequently look up the nodes in the repository via any of
the query mechanisms supported by a repository. JCR compliant repositories
must support at least XPATH, but Jackrabbit also supports SQL. The following
code snippet finds and lists all blog entries written by "Joe Blogger:"
*/
session.save();
Node node = root.getNode("blog/");
result.append(node.getPath());
result.append(node.getProperty("message").getString());
result.append(node.getProperty("prop1").getString());
result.append(node.getProperty("prop2").getString());
root.getNode("hello").remove();
result.append("hello node ");
session.save();
} finally {
session.logout();
logger.info(" .'.'.'.'.'.'.'.'. End .'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.' ");
}
return result.toString();
}
}

 
Didn't find what you were looking for? Find more on JCR in java Or get search suggestion and latest updates.




Tagged: