Oracle Beehive Release 1 (1.5) Java Content Repository API
Oracle Beehive Release 1 (1.5) Java Content Repository API
Oracle Beehive Release 1 (1.5) 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:
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.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().
In your Oracle Beehive JCR API client, you must specify the following information to connect to Oracle Beehive:
Initial Context Factory Object: This is used for resolving names during Java Naming and Directory Interface (JNDI) lookup. The samples featured here use oracle.j2ee.rmi.RMIInitialContextFactory.
Java Naming Provider URL: This is the location of the Oracle Beehive JCR service. It has the following form:
Security Credentials: Specify the password of oc4jadmin.
Set these parameters in the Oracle Beehive repository (represented by the class BeehiveRepositoryConfigruation) in one of the following ways:
In a map that contains these connection attributes:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");
env.put(Context.SECURITY_CREDENTIALS, "Welcome1");
env.put(Context.PROVIDER_URL, "opmn:ormi://example.com:6003:BEEAPP/jcr-service");
BeehiveRepositoryConfiguration config = new BeehiveRepositoryConfiguration(env);
Through the setter methods in a BeehiveRepositoryConfiguration object:
BeehiveRepositoryConfiguration config = new BeehiveRepositoryConfiguration();
config.setInitialContextFactory("oracle.j2ee.rmi.RMIInitialContextFactory");
config.setSecurityPrincipal("oc4jadmin");
config.setSecurityCredentials("Welcome1");
config.setConnectionUrl("opmn:ormi://example.com:6003:BEEAPP/jcr-service");
In the BeehiveRepositoryConfiguration constructor:
BeehiveRepositoryConfiguration config = new BeehiveRepositoryConfiguration(
"oracle.j2ee.rmi.RMIInitialContextFactory",
"oc4jadmin",
"Welcome1",
"opmn:ormi://example.com:6003:BEEAPP/jcr-service");
Using ORMI Tunneling through HTTP
Oracle Beehive JCR clients may connect to Oracle Beehive with HTTP/HTTPS by using ORMI tunneling through HTTP. This is useful if your Oracle Beehive instance is behind a firewall and you do not want to open the ORMI port in your firewall.
Use the following for the Java Naming Provider URL:
You may use https in place of http if you have configured it for your Oracle Beehive instance. If you are using default HTTP/HTTPS ports (such as 80/443), you may omit the HTTP/HTTPS port number.
You may create and configure a non-oc4jadmin user for EJB lookup and executing remote methods of the Oracle Beehive JCR server. The following steps create a non-oc4jadmin user named jcruser with the password Welcome1:
Restart the BEEAPP component with the following command:
<Oracle Beehive home>/beehive/bin/beectl restart --component <Identifier of the BEEAPP component>
Using a Non-oc4jadmin user for EJB Lookup on Oracle Beehive JCR Server
If you are not using a user with OC4J administrator privileges for EJB lookup, perform the following additional steps:
Provision the jcrrmi role with subject.propagation privileges. Add the highlighted text in the <Oracle Beehive home>/j2ee/BEEAPP/config/system-jazn-data.xml file:
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
The following is the output of RepositoryTest.java:
Stored the repository object Root node name: /
Retrieved the repository object by JNDI lookup
Listing the enterprise
====================================
doc
beeadmin's Personal Workspace
====================================
DONE
Edit the hosts file of the client computer (that will access the Oracle Beehive JCR server) and add the IP address and the host name of the Oracle Beehive JCR server.
For Windows XP, the location of this file is C:\WINDOWS\system32\drivers\etc\hosts For Linux and UNIX-based operating systems, it is /etc/hosts.
For example, if the IP address and host name of your Oracle Beehive JCR server is 10.20.30.40 and example.com, respectively, add the following line to the hosts file:
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.
The following table lists the parameters you may change with the beectl utility:
Name
Description
JCRServerEnabled
If set to true, the Oracle Beehive JCR service will service clients, otherwise, it will throw an exception. Default value: true.
UploadBufferSize
Size of buffer to use in piecewise copies between
streams during document uploads to the Oracle Beehive JCR service. For example, if its value is 1, then
one byte at a time is copied from the input stream. Default value is listed in the output of beectl list_properties --component _JcrServletService.
MaxDownloadBufferSize
Maximum buffer size to use in piecewise
copies between streams during document downloads from the Oracle Beehive JCR service. Default value is listed in the output of beectl list_properties --component _JcrServletService.
AuthenticationScheme
If set to DIGEST, the Oracle Beehive JCR service digest authentication to authenticate the client. If set to BASIC, it uses basic authentication. Default value: DIGEST.
JcrSessionTimeout
Length of time (in minutes) before the client session expires.
You may not configure the following properties:
Alias
ServiceApplication
ServiceInstances
Site
Status
To modify a property, call the beectl modify_property command. Afterwards, call the beectl actiavte_configuration to commit your changes.
Redeploying Oracle Beehive JCR Service
Upgrade the service with an archive file. Call the command beectl upgrade_service_application --archive <Path to Oracle Beehive JCR service EAR file>
<Path to Oracle Beehive JCR service EAR file> is the full path name of the archive file jcr-service.ear.
Retrieve the component identifier for the component JcrServletServiceInstance with the command beectl list_components.
Call the command beectl upgrade_service_instance --service_instance_id --component <Identifier of JcrServletServiceInstance>