October 30, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Connecting to IBM FileNet 4.0 Outside of a Java Application Server

  • December 29, 2008
  • By Anthony Lee
  • Send Email »
  • More Articles »

FileNetConnectionTest.java

Once the environment is set up, you can start looking into the FileNetConnectionTest.java code. The FileNet API is organized by packages for the Content Engine (com.filenet.api.*) and Process Engine (filenet.vw.api.*). In the sample code, the goal is to connect successfully to both CE and PE, and retrieve a list of Document Class properties and Queues.

FileNetConnectionTest.java (Download)

Static Variables

There are a few static application parameters that you will use in the sample code.

FILENET_USERNAME
The Login ID for the user that you want to connect to FileNet with. Any content or workflows updated will be attributed to this user.

FILENET_PASSWORD
The password for the user

A simple test to see whether a user has sufficient rights to do certain functions via the API is to log in to Workplace and attempt to do the functionality that you are trying through the API. An example is, if you are trying to get a list of Document Classes through the API, you should be able to do the same in Workplace.

FILENET_URI
The URI that the application should use to connect to FileNet. This URI is used by both the CE and PE, and should point to the CE server. Because I'm using WebSphere with the EJB transport, the URI is in the format of "iiop://[server]:[port]/FileNet/Engine". Adjust the URI according to your platforms EJB syntax.

CE_DOMAIN
The Domain represents a logical grouping of physical resources. A single Domain may contain multiple Object Stores.

CE_OBJECTSTORE
An Object Store represents a location in which CE folders and content are managed on the server. The Object Store name can be found in FEM or by logging into Workplace and looking at the list of Object Stores on the left side.

Each Object Store has its own set of Document Classes that can be defined. There is a default Document Class called 'Document' that serves as the base Document Class.

PE_CONNECTION_POINT
Connection Points have replaced the Routers from FileNet 3.5 and enables connection to a PE Isolated Region. The PE Isolated Region is like the CE Object Store in that it holds PE queues, rosters, and other workflow configurations. Connection Points can be managed through FEM.

Main Code

In this section, I'll break down the main test method in the sample code and explain the API calls being made. The sample code starts off by logging into the CE first.

Connection ceConnection =
   Factory.Connection.getConnection(FILENET_URI);

The CE API contains Factory.* classes to create CE objects. To establish a Connection object, call the Factory.Connection class to create one by passing in the URI. This Connection object represents a logical connection to a FileNet Domain.

Subject ceSubject =
   UserContext.createSubject(ceConnection, FILENET_USERNAME,
      FILENET_PASSWORD, null);

Next, to use JAAS, you create a Subject object. You pass in the username and password you want to use. The third parameter is for the JAAS stanza. Passing in 'null' means you want to use the default FileNet JAAS stanza, which is called 'FileNetP8'. The server authenticates the user and returns the JAAS subject.

UserContext.get().pushSubject(ceSubject);

Before running any further CE API calls, it is necessary to push a Subject object onto the UserContext stack. This sets the user pushed as the active user for subsequent CE API calls.

Domain ceDomain =
   Factory.Domain.fetchInstance(ceConnection, CE_DOMAIN, null);

Now that you have a valid Subject on the stack, you can retrieve objects from the FileNet server. In this case, you call a fetch* to retrieve a Domain from the FileNet server by passing in the Connection object you created earlier and the Domain name that you want to retrieve. The third parameter represents a PropertyFilter object; it controls what properties should be returned. For the sample, I've left this as null so that all non-object properties are returned by default.

ObjectStore ceObjectStore =
   Factory.ObjectStore.fetchInstance(ceDomain, CE_OBJECTSTORE,
                                     null);

Because the Domain is a container for CE resources, you now can retrieve your Object Store. You use the same type of call as retrieving the Domain, but instead you pass in the Domain object and the Object Store name. Once again, you pass in a 'null' for the PropertyFilter.

Once you get a valid Object Store object, you are now logged in and ready to use the rest of the CE API.

The next couple lines show how you would retrieve the properties of a Document Class.

ClassDefinition classDef =
   Factory.ClassDefinition.fetchInstance(ceObjectStore,
                                         "Document", null);

Tags: API



Page 3 of 5



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel