Deployment Example: Deploying and Customizing the Documentum Portlet

Environment Classes

The environment layer is a set of classes in the com.documentum.web.env package that comprise base implementations, hooks and interfaces. The Environment class encapsulates an environment's specific behavior and functionality. WDK instantiates and uses the registered environment class whenever it requires information from its environment.

A portal-specific environment is implemented as a single Java class that extends the abstract Environment class and implements one or more of the com.documentum.web.env interfaces. WDK environments are packaged in where xxx is the name of the environment; for example, com.documentum.web.env.sun.

WDK instantiates an environment as a singleton object, and all threads call into the single instance. All methods implemented for a custom environment must be thread-safe. If you need to store state, the base Environment class provides instance methods to store and retrieve your attributes in the environment implementation.

The environment layer of WDK consists of a set of classes that provide a number of starting places for your integration depending on the type of portal server you have. The environment APIs are shown in the diagram below.

Figure 8–1 Environment APIs

The environment APIs are shown in this diagram.

The environment classes are the following:

AbstractEnvironment class

The AbstractEnvironment class is abstract and provides default implementations of environment APIs.

Environment class

The Environment class is also abstract. It extends AbstractEnvironment and adds default implementations for session and request access, dispatching, encryption, and portal API access.

Note –

Many of these APIs must be overridden for specific portals.

AppServerEnvironment class

The AppServerEnvironment Class provides a configured environment for integrating with J2EE Application Servers.

PortalEnvironment class

The PortalEnvironment class provides a configured environment for non-JSR-168 compliant portal servers. If you are integrating with a non-JSR-168 compliant Portal Server then you should extend the PortalEnvironment class.

Jsr168Environment class

The Jsr168Environment class provides a configured environment for integrating with JSR-168 compliant portal servers.

SunPortalEnvironment class

The SunPortalEnvironment Class integrates with the Sun Portal Server. (For specific versions, refer to the release notes.)

AbstractEnvironment Class

The AbstractEnvironment class provides a set of methods that return the environment interface contracts. The AbstractEnvironment class returns whether the environment is a Portal environment using the isPortalEnvironment() method. The current HttpServletRequest, HttpServletResponse, and HttpSession are returned from the getRequest(), getResponse(), and getSession() methods.

Environment Class

The Environment class is also an abstract class and cannot be instantiated directly. The Environment class provides default implementations for the lifecycle events, security, error handling, page dispatching, action processing, content transfer, branding, environment properties, and attribute storage. These implementations should be sufficient for most environments:


The lifecycle methods store the request, response and session objects in thread safe storage. If you are overriding any of these methods and you need to continue to store the objects in the thread safe storage, then you must call the superclass implementation.


The security methods encode and decode passwords and encrypt and decrypt the trusted authenticator password using a Caesar cipher. For details on trusted authentication, refer to User principal authentication. Methods also get the user name, password, and domain.

Error Handling

The error methods get the error URL and handle errors.

Page Dispatching

Page dispatching methods include forward and inline dispatch and access to the object. By default, pages are included and actions are processed before the page is rendered.

Action Processing

The queryExecute() method is provided to test action preconditions

Content Transfer Mechanism

The content transfer method returns the content transfer mechanism, which is UCF-based by default in portal environments.


The Environment class looks for mapping of WDK CSS classes to portal styles. For details on this mapping, refer to Portal styles

Environment Properties

The getResourceBundle() method returns the properties file that configures the environment.

Attribute Storage

Attribute storage methods get, set, and remove attributes from the environment's thread-safe local store. A log() method is also provided.

AppServerEnvironment Class

The AppServerEnvironment class inherits from Environment. The AppServerEnvironment class is used by WDK for non-portal J2EE applications such as Webtop. This class includes all of the implementations for running on a J2EE environment.

For backwards compatibility with previous versions of WDK, the following implementations are in the AppServerEnvironment class:

PortalEnvironment Class

The PortalEnvironment class inherits from Environment and serves as the superclass for all portal environment implementations. You can extend this class to support WDK portlets on a non-JSR-168 compliant portal server.

The following methods are implemented:


Turns on pre-processing.


Removes the action URL in order to force all server events to be posted through the component dispatcher.

handleError() and errorAcknowledged()

Report errors to the WDK's error message service and handles the user event that is generated when the user acknowledges an error dialog.


Turns on post-processing.

Jsr168Environment Class

The Jsr168Environment class inherits from PortalEnvironment. You can extend Jsr168Environment to integrate WDK portlets into a JSR-168 compliant portal server that does not have an environment supplied by Documentum. The following methods are implemented:

Lifecycle events

The onRequestStart() and onRequestFinish() methods provide access to the request events

Session access

The getUsername(), getUserPassword(), getDomain(), getDocbaseName(), getUserPrincipal(), and getLocale() methods provide access to the user's portal session.


The preProcess() method turns on pre-processing.

URL encoding

The encodeUrl() method returns a JSR-168 action URL.

JavaScript rewriting

The namespaceJsMethodName() method changes the supplied JavaScript function name to a name unique within the generated web page by prefixing that function with the portlet ID. The rewriteScriptTag() method prefixes the portlet ID to a supplied JavaScript function name.

Link rewriting methods

The rewriteATag() method rewrites the href and onclick attributes in a JavaScript call to prefix the call with the portlet ID. This gives the JavaScript call a unique name in the scope of the whole web page that is generated.

Preferences methods

Several methods enumerate preferences and look up or write preference values (user-level or portlet-level, or application-level). The Jsr168Environment class handles the writing of Portlet level preferences through the writePortletLevelPreference() method. The writing of user level preferences is not covered by the JSR-168 specification: They are written by vendor-specific environment classes.

Error methods

The getErrorUrl() method handles errors in a JSR-168 environment, passing the error to the stack trace.

SunPortalEnvironment Class

The SunPortalEnvironment class inherits from Jsr168Environment. The SunPortalEnvironment integrates with the Sun portal server. (For specific versions refer to the release notes.) This class implements the following methods:


Looks up the user principal for trusted authentication mode using classes in the com.iplanet.sso package.


Returns an enumeration of the preference types that can be written.


Uniquely identifies the HTML for two portlets on the same page in a Sun portal environment.


Writes preferences using APIs in the package.