Utility Classes

The utility classes are important in the Web Center environment. Their use is not required in a standalone application.

ActionUtils.java

The class ActionUtils implements commonly used methods for action handling:

Method Description

getExceptionForward

Returns the exception forward from an exception

getFormConfiguration

Returns the form configuration for the given form name

getForwardFromRequest

Returns the forward name calculated from the request parameters

getParameters

Reads the parameters from an action mapping

Refer to the Javadoc for the correct syntax of the method calls.

DataUtils.java

The class DataUtils implements commonly used methods for data handling and manipulation.

In the WebCenter JSP environment, the following static getters are important since they return an instance implementing the interfaces provided by the API:

Interface Method providing an instance of the interface

Approval

getApprovalSupport

Assignment

getAssignmentSupport

Certification

getCertificationSupport

Delegation

getDelegationSupport

Delegations

getDelegationsSupport

Objects

getObjectSupport

RequestWorkflow

getRequestWorkflowSupport

Session

getSessionSupport

Users

getUserSupport

All the methods listed above are called with one parameter, the HTTP session of the request.

Sample call:

Objects support = DataUtils.getObjectSupport(session);

The following methods are used to read data from the storage layer or to store the data in the storage cache (without saving the object):

Method Description

fetchDataset

Retrieves the dataset with the given name from the storage

storeSelectedBeanData

Stores the data with the given attribute names in the storage cache

storeBeanData

Stores the bean property data with the given attribute name

storeAllBeanData

Stores all bean property data

storeBeanArrayData

Stores data from a table (e.g. match rules).

Refer to the Javadoc for the correct syntax of the method calls.

fetchDataset returns an array of DirectoryEntryBean. It uses listObjects from the Objects API to retrieve the data and converts the list structure to the bean array.

The following code sample shows how to use storeSelectedBeanData to save the data of a form to the selected user:

Objects objects = DataUtils.getObjectSupport(session);

String dn =
    (String)session.getAttribute("com.siemens.webMgr.selectedUser");
DynaLocaleForm form =
    (DynaLocaleForm)session.getAttribute
        ((String)pageContext.getAttribute("formName"));

DynaBean bean = (DynaBean)form;
Map formMap = form.getMap();
String[] fieldnames =
    (String[])formMap.keySet().toArray
        (new String[formMap.keySet().size()]);
DataUtils.storeSelectedBeanData(bean, dn, fieldnames, null, session);

DirectoryEntryBean

The class DirectoryEntryBean implements a DynaBean to hold the properties of a single directory entry.If tables are displayed in webCenter (for example, assigned roles / permissions / groups, result of a user search, parameters, …) the values are stored in arrays of DirectoryEntryBean.

Method Description

initialize

Initializes the entry with default values

assignEntryData

Sets the entry data for this bean. This method is applied during bulk-data reading from the support bean.

get

Returns the value of a simple property with the specified name.

set

Sets the value of a simple property with the specified name.

Refer to the Javadoc for the complete set of methods and for the correct syntax of the method calls.

Example:
Get the DN of a selected object in a JSP (see deleteObjects.jsp)

String itemStr = (String)pageContext.getAttribute("item");
DirectoryEntryBean[] dataset =
    (DirectoryEntryBean[])pageContext.getAttribute("dataset");
int num = Integer.parseInt(itemStr);
if (dataset != null && num < dataset.length) {
    Users userSupport = DataUtils.getUserSupport(session);
    String objectId = (String)(String)dataset[num].get("dn");
    ...
}

DNUtilities

The class DNUtilities provides static DN utility methods:

Method Description

isDN

Checks whether the argument is a distinguished name.

equals

Checks whether two distinguished names are equal.

getLastRDN

Returns the relative distinguished name of a dn.

getParent

Returns the parent DN.

removeFirstRDN

Removes the first RDN from a DN.

makeDN

Builds a DN from type, value, and parent dn.

getNamePart

Returns the value of the RDN component for the given index.

getLastNamePart

Returns the RDN’s name part.

isLastRDNType

Checks whether the provided RDN type equals to the last RDN’s type.

isWorkflowDN

Checks for a request workflow DN.

makeActivityDN

Builds an activity DN from the workflow instance id and the activity name.

makeWorkflowDN

Builds a workflow DN from the workflow instance id.

getReversedNameParts

Returns the DN’s component values in reverse order.

Refer to the Javadoc for the correct syntax of the method calls.

Message

The static class Message provides utility methods to access the message attributes in the session:

Method Description

set

Sets a text, parameters and the confirmation flag.

getText

Retrieves the message.

setText

Sets a message text.

getConfirmationFlag

Retrieves the confirmation flag.

setConfirmationFlag

Sets the confirmation flag.

getParameters

Retrieves the message parameters.

setParameters

Sets the message parameters.

clear

Clears the message, the message parameters and the confirmation flag.

save

Returns message, confirmation flag and parameters as an array of Object.

restore

Restores message, confirmation flag and parameters to the session.

Refer to the Javadoc for the correct syntax of the method calls.

FilterUtilities

The class FilterUtilities provides static utility methods for the handling of LDAP filters:

Method Description

getFilter

Creates an LDAP filter from attribute name, type of operation and value.

getFilter

Creates an LDAP filter from a list of filters and the conjunction. Returns the default filter for an empty list.

escape

Escapes special characters in a value.

countSignificantChars

Counts the significant characters in a value. Wildcards and white spaces are not counted.

Refer to the Javadoc for the correct syntax of the method calls.