Oracle Beehive Java Content Repository (JCR) API implements the Content Repository API for Java Technology specification (Java Specification Request 170, version 1.0). You may find this specification at http://jcp.org/en/jsr/detail?id=170. The Content Repository API is a common, standardized Java interface for content repositories. With the Oracle Beehive JCR API, you may access and manipulate an Oracle Beehive instance’s workspaces and its data like a content repository.
The Content Repository API specification is divided into two compliance levels and a set of additional optional features that repositories of either level may support. Level 1 consists of read functions while level 2 adds additional write functions.
Oracle Beehive JCR API supports the following features specified by the Content Repository API specification:
Level 1 Repository Features
Retrieval and traversal of nodes and properties
Reading values of properties
Transient namespace remapping
Discovery of available node types
Discovery of access control permissions
Level 2 Repository Features
Adding and removing nodes and properties
Writing values of properties
Optional Features
Versioning
Locking
This module covers the following topics:
Requirements
Javadoc
Oracle Beehive Java Content Repository API Operations
Oracle Beehive Java Content Repository API Samples
Compiling and Running Samples
Requirements
To compile the examples in this module, the following .jar files must be in your classpath:
<Oracle home>/beehive/jlib/beehive_jcr-1.0.jar
<Oracle home>/j2ee/home/lib/ejb.jar
<Oracle home>/j2ee/home/lib/ejb30.jar
<Oracle home>/j2ee/home/lib/oc4j-internal.jar
<Oracle home>/j2ee/home/oc4jclient.jar
<Oracle home>/lib/xmlparserv2.jar
<Oracle home>/opmn/lib/optic.jar
Note: For a standalone client (for example, EntList.java and JcrClient.java), you only require beehive_jcr-1.0.jar in your classpath.
Javadoc
Refer to Oracle Beehive Java Content Repository Java API Reference.
Oracle Beehive Java Content Repository API Operations
The Oracle Beehive JCR API enables you to manipulate an Oracle Beehive instance’s workspaces and its data like a content repository as defined by the Content Repository API.
The content repository as a whole is represented by a javax.jcr.Repository object, which is acquired from the oracle.ocs.jcr.client.impl.RepositoryFactory class. A client connects to the repository by calling Repository.login(). This method takes one argument, an object of type javax.jcr.Credentials (in particular, a SimpleCredentials object). This object contains the user name and password of a user that may look up the JCR service. The login() method returns a Session object with which the client accesses the repository.
Content in a repository, such as folders and documents, are represented by nodes in a tree structure. You may access nodes by traversal access or direct access. Traversal access involves accessing nodes in relation to other nodes. For example, you may call Node.getNodes() to retrieve a NodeIterator, which will enable you to iterate through a given node’s child nodes. Direct access involves accessing nodes with absolute paths. If a node is referenceable, you can directly access a node by its Universally Unique Identifier (UUID). For example, you may directly access a node by its absolute path with Session.getItem() or by its UUID with Session.getNodeByUUID().
Oracle Beehive Java Content Repository API Samples
This section lists the following samples:
Sample of Level 1 Operations
Sample of Level 2 Operations
Sample of Invoking JCR API in a Servlet Application
Sample of Level 1 Operations
The following sample initializes the repository and performs a high-level traversal of the repository.
Successfully logged in. Session Object oracle.ocs.jcr.client.impl.SessionImpl@1dc0e7a
Added Folder Node to Workspace Node
About to add file NewFile1197504256484
Setting property of type BEEHIVE_CONTENT
Added the file and updated the content
Content = I got updated
Removed node
Sample of Invoking JCR API in a Servlet Application
To compile and run "Sample of Level 1 Operations" or "Sample of Level 2 Operations", ensure that all the .jar files listed in "Requirements" are in your classpath. Compile these samples with JDK 1.5 or later.
Deploying Servlets on Apache Tomcat
The following steps describe how to deploy the sample listed in "Sample of Invoking JCR API in a Servlet Application".
Requirements
JDK 1.5 or later
Apache Tomcat 5.5.2 or later
The .jar files listed in "Requirements" are available in the Apache Tomcat library path
Steps to Deploy JCR API Servlet
Create the directory jcrtest to hold the files of the servlet.
In the directory jcrtest, create the directory WEB-INF.
In the WEB-INF directory, create the following directory structure:
classes
lib
src
In the src directory, create the nested directory oracle/sample/jcr. Save the file ListEntNode.java in the jcr directory.
Copy the .jar files listed in "Requirements" to the lib directory.
In the WEB-INF directory, create a file named web.xml that contains the following (the string specified by the attribute xsi:schemaLocation should appear on one line):
Compile ListEntNode.java as described in "Compiling and Running Stand-Alone Applications". Ensure that the compiled ListEntNode.class file appears in the classes/oracle/sample/jcr directory.
Copy the jcrtest directory to <Apache Tomcat install directory>/webapps. Restart Apache Tomcat. Apache Tomcat will automatically deploy the servlet for you. Access the servlet with http://localhost:8080/jcrtest/listnodes (assuming that you are running Apache Tomcat on port 8080.