Previous Contents Index Next |
iPlanet Portal Server: Mobile Access Pack Programmer's Guide |
Appendix B Sample Tasks
The various sections in this appendix include sample tasks for:
Configuring the Attributes
Use these sample configuration scenarios to set up and customize your Mobile Access Pack server. Note that many of the tasks discussed in this chapter can be performed from the administration console and for more information on performing these tasks from the administration console, please refer to the Mobile Access Pack Administration Guide.Customizing the Client Detection Interface
This section discusses how to modify existing component attributes and how to add new attributes to a component.
This section discusses how to modify attributes in the component XML file. To modify the attributes:
Log in to the machine running the Mobile Access Pack server and become superuser.
# <iPS_install_base>/SUNWips/bin/ipsadmin get component <component_name> > <filename>
- Here, replace:
iPS_install_base with the installed location of the iPlanet Portal Server
Open the file and edit the attributes in the file containing the component attributes.component_name with the name of the profile component to customize. For example, replace component_name with iwtMailProvider to customize the mail channel.
filename with the name of the file to redirect the output to
Save and close the file.
- This is the file to which the ipsadmin command output was directed to.
# <iPS_install_base>/SUNWips/bin/ipsadmin change component <component_name> <filename>
Restart the server.
- Here, replace:
To add an attribute to a Mobile Access Pack server component:
Log in to the machine running the Mobile Access Pack server and become superuser.
# <iPS_install_base>/SUNWips/bin/ipsadmin delete component <component_name>
- Here, replace:
iPS_install_base with the installed location of the iPlanet Portal Server
component_name with the name of the profile component to update. For example, replace component_name with iwtClient.
Open the component XML file in /etc/opt/SUNWips/xml directory and add the new attribute to this file.
- This removes the current portal profile for the component.
Import the newly updated component XML file in to the portal profile settings. For example, to import, enter:
- For backup purposes, make a copy of the original XML file before adding the new attribute. For example, enter:
# cp /etc/opt/SUNWips/xml/iwtClient.xml OldiwtClient.xml
# <iPS_install_base>/SUNWips/bin/ipsadmin -import <component_name>.xml
Restart the server.
- Here, replace:
When modifying template files, please follow the following recommendations:
Log in to the Mobile Access Pack server and become superuser.
Create a directory similar to the default directory in /etc/opt/SUNWips/desktop/default. For example:
Copy files from the default directory in /etc/opt/SUNWips/desktop/default over to the new directory. For example, enter:
Modify the copied files in the new directory.
- Although you can copy all the files under the default directory, we recommend you only copy files you wish to change and/or customize over to the NewDesktop directory. When copying files, use the same directory hierarchy to the template files.
Modify the iwtDesktop-type attribute. That is, enter the path to the directory that contains the customized desktop templates in this attribute. For example, specify the path to the NewDesktop.
- Do not modify files under the default directory.
Restart the server.
- The path must be relative to /etc/opt/SUNWips/desktop. If the server cannot find the required files under the directory you specify here, it will default to the files in the default directory.
Note Do not modify the original template files in the default directory as this will break uninstall and/or upgrade.
The Mobile Access Pack server includes support for generic HTML, cHTML, and WML clients. In order to extend support for other markup languages (or clientTypes), for example, XYZ markup language, refer to the sample XYZ configuration scenario in this section.
For information on adding a clientType from the administration console, please see Chapter 3 in the Mobile Access Pack Administration Guide. From the command line:
Log in to the Mobile Access Pack server machine and become super user.
Change directories to /etc/opt/SUNWips.
- Develop the appropriate templates to translate the content produced by the Mobile Access Pack server providers for display on an xyz client.
Configuring Authentication for XYZ Clients:
Assuming that XYZ clients are not a derivative of WML or cHTML:
Change directories to auth/default and create a directory for XYZ. That is, enter:
Copy files from either html, wml, or chtml directory to the xyz directory. That is, enter:
Modify and save the xyz template files to support XYZ clients.
- Do not modify or change the name of the files copied from the chtml directory.
Specify the supported authentication modules for the XYZ clients. That is:
- See "Authentication Template Files" for more information on template files in this directory.
- From the Administration Console:
Log in to the administration console and select Manage Platform Settings.
Select Authentication and Show Advanced Settings.
Specify the supported authentication modules for XYZ clients under Supported Auth Modules for Clients.
Select Submit.
- For example, enter xyz|Ldap and select Add.
Specify the loginWorkerClass for XYZ clients. That is, modify the iwtAuth-loginWorkerClasses attribute value to include the newly added clientType. See iwtAuth-loginWorkerClasses for more information.
- From the command line, incorporate the supported authentication modules for XYZ clients in the iwtAuth-supportedAuthModules attribute using the ipsadmin command.
- See Chapter 8 "Attributes and Schemas" for more information on modifying this attribute.
- See Chapter 8 "Attributes and Schemas" for more information on this attribute.
Configuring Channels for XYZ clients:
Do not modify files in the /etc/opt/SUNWips/desktop/<default> directory. See "Modifying the Attributes" for more information.
Change directories to desktop/<NewDesktop>/. That is, enter:
# cd /etc/opt/SUNWips/<NewDesktop>
Create a XYZ directory under the provider directory.
- For each provider content that will be delivered to the XYZ client, create a subdirectory for the XYZ client under that provider directory. For example, to provide mail channel on the XYZ client:
Change directories to the mail provider directory. Enter:
Create a directory for XYZ clients here. Enter:
Copy files from html, chtml, or wml directory over to the xyz directory. For example, enter:
Modify and save the template files to support clients that use the XYZ markup language.
- Refer to Chapter 5 "Application JSPs" and Chapter 4 "Content Provider Template Files" for more information on these template files.
Modify the iwtClient-clientTypes attribute to define device characteristics of XYZ clients.
- See "Client Detection Module Attributes" and modify this attribute accordingly. For example, to modify this attribute, enter:
<VAL>clientType=XYZ|userAgent=XYZ|contentType=text/xyz|fileIdentifi er=xyz|filePath=my_xyz|charset=ISO-8859-1;UTF-8</VAL>
- This adds the XYZ clientType and includes important client specific information to support the XYZ clients.
Enabling Content Delivery for XYZ Clients:
In order to set up and deliver content via channels to the newly configured XYZ client:
Log in to the Mobile Access Pack server machine and become super user.
The xyz client is now displayed in the Mobile Devices page from the user's desktop page and it has access to all of the channels that were made available to it.Modify the iwtDesktop-clientAllProviders, iwtDesktop-clientUserSelectedProviders, and iwtDesktop-clientChannelListModules attributes. To modify, see "Configuring the Attributes" for more information. See also "Desktop Attributes" for information on:
iwtDesktop-clientAllProviders and enter:
xyz|iwtUserInfoProvider;iwtXMLProvider;iwtPostitProvider
iwtDesktop-clientUserSelectedProviders and enter:
- This indicates that a user information channel, an XML channel, and a PostIt channel are supported for a xyz client.
iwtDesktop-clientChannelListModules and enter:
- This makes the xyz client available to the end user from the Mobile Devices page on their desktop.
xyz|com.iplanet.portalserver.desktop.util.channellist.ClientChannel List.
- This adds the clientType to the Client Specific Channel List Module.
Customizing the Client Detection Interface
This section provides instructions for:
Developing a Customized Client Detector
Developing a Customized Client Detector
Client detection can be achieved by creating a client detector object that will:
Parse data from the HTTPServletRequest of the requesting client
In order to develop such a client detector, the client detection class must:Perform some method of matching based on the stored clientTypes and their corresponding properties
Implement an interface called ClientDetectionInterface.
The class can then look at the header information provided by the client in it's request, match it against the clientType and its device specific characteristics saved in the Client Data, and return the clientType that it has received from the Client Data object.Contain a method called getClientType which will be passed to the HTTPServletRequest from the requesting client.
Sample Client Detection Interface
public class SampleCDM implements ClientDetectionInterface {* Detects the client type based on the Request
* @param request HttpServletRequest
* @return a String representing the clientType
* @exception ClientDetectionException if there is an error retrieving the client data.
public String getClientType(HttpServletRequest request) throws
public String HTTPheaderCheck(String HTTPheader){
See Appendix A "API Descriptions" for detailed information on the Mobile Access Pack server client detection interface. After developing the client detector class:
Change the profile settings to enable client detection using the newly developed class. To change:
Modify the iwtAuth-clientDetectionEnabled attribute value.
Ensure that the class is placed in the webserver's classpath.
Modify the iwtAuth-clientDetectionClass attribute to use the newly developed client detector class.
- See "iwtAuth-clientDetectionEnabled" and modify this attribute value by referring to "Configuring the Attributes".
- See "iwtAuth-clientDetectionClass" for more information on this attribute and modify this attribute value by referring to "Configuring the Attributes".
Modifying the Default Client Detector
By default, the Mobile Access Pack client detection module performs a substring matching to match the requesting client's HTTP header value (or userAgent) against the Client Data objects. To change the module to use regular expression matching:
Write a class that makes use of the ClientDetectionInterface.
public class SampleCDM implements ClientDetectionInterface {
public String getClientType (HttpServletRequest req) throws
// get the user-agent from the HttpServletRequest
String clientType = userAgentCheck(String user-agent);
if ((clientType.equals("")) || (clientType == null))
Client.getDefaultInstance().getProperty("clientType");
public String userAgentCheck(String userAgent){
// Implement the regular expression checking within this
// return the clientType if it matches, empty String if it
Ensure that the class is placed in the webserver's classpath
Login to the Administration Console and select Manage Platform Settings.
Select Authentication and select Show Advanced Settings.
Ensure that Client Detection is enabled.
Add the customized Client Detection class into the Client Detector class attribute.
In order to provide assistance with content to the mobile device users, the Mobile Access Pack server provides a mechanism to display help for the user's home page and for each channel in the appropriate markup language.
Enabling Help Content Delivery on a Mobile Device
This section discusses how to deliver help content to a mobile device user.
Each provider uses the Provider API (PAPI) interface to find which methods are called by the various desktop classes to create the desktop. The two methods, hasHelp() and getHelp(), are used by the Mobile Access Pack server to display a help link for each provider. See "Client Help" for more information on these methods.
When configuring the help link for a channel:
Create the hasHelp() and getHelp() methods for each supported provider. Use the sample methods below when writing these methods.
- The Mobile Access Pack server providers include these methods in the class file. Develop only the help content for the Mobile Access Pack server providers and proceed to Step 2. The sample methods discussed here are only for providers who do not have the help mechanism built into them.
Sample hasHelp() method
The hasHelp() method must return the boolean value of true or false depending on whether or not the attribute iwtComponent-clientHelpLinks is found in the profile for the component.public class WirelessSampleProvider() extends SampleProvider{
Vector clientLinks = getListProperty("iwtSampleProvider",
for (Enumeration e = clientHelpLinks.elements();
if ((String)e.nextElement() == clientType){
Sample getHelp() method
The getHelp()method must return the URL that corresponds to the specified clientType.public class SampleProvider() extends ProfileProviderAdapter{
Vector clientLinks = getListProperty("iwtSampleProvider",
for (Enumeration e = clientHelpLinks.elements();
String link = (String)e.nextElement();
if (link.indexOf(clientType) > -1){
StringTokenizer tok = new StringTokenizer(link, "|");
String temp = tok.nextToken();
String userLocale = getStringProperty("iwtUser", "locale",
String localizedUrl = "/docs/" + userLocale+ "/online_help/"
String proto = SystemProperties.get("ips.server.protocol");
String host = SystemProperties.get("ips.server.hostname");
String port = SystemProperties.get("ips.server.port");
help = new URL(proto, host, Integer.parseInt(port),
} catch (MalformedURLException mue){
debug.error("Unable to create help link");
Add the clientHelpLinks attribute (see <channelName>-clientHelpLinks for more information) to the profile for the component. To add, refer to "Configuring the Attributes" for more information.
- Help is now made available in the user's mobile device home page under the Options selection.
Developing and Storing the Help Files
Develop help content for all supported clientTypes and their channels and store the files under <iPS_install_base>/SUNWips/public_html/docs/<locale>/online_help.
Making a Provider Client Aware
This section discusses how to make a provider serve content to multiple clientTypes (such as cHTML and WML). In order to service multiple clients, a provider must become aware of the type of client requesting its service; that is, a provider must become client aware. Use the sample set up scenario in this section when making a provider client aware.
The sample HelloWorld3 Provider (HelloWorld3Provider) in (<iPS_install_base>/SUNWips/sample/desktop/classes/com/iplanet/portalserver/providers/helloworld3) is the provider used in our example here.
Content Delivery
The WirelessHelloWorld3Provider uses template files to display its content and to determine its presentability. That is, if template for a specific clientType is available, the WirelessHelloWorld3Provider will support display of content on that clientType.
Package
The WirelessHelloWorld3Provider resides in the same package as the other iPlanet Portal Server providers:package com.iplanet.portalserver.providers.helloworld3;
Inheritance
Inheritance provides the provider with the functionality of the Provider API (PAPI). The WirelessHelloWorld3Provider inherits from the existing HelloWorld3Provider provider.public class WirelessHelloWorld3Provider extends HelloWorld3Provider
Class Variables
The WirelessHelloWorld3Provider contains the following class variables and includes a variable for the one generic content template that is used in the getContent() method.private static final String contentTemplate = "display.template";
private String clientType = null;
private boolean isGenericHTML;
private boolean isPresentable;
Init Method
public void init(String n, Session s) throws ProviderException
ClientType
ClientType refers to the list of clients (such as HTML, cHTML, and/or WML) supported by the provider. Retrieval of the clientType value stored in the session is necessary to determine the value of the isGenericHTML attribute. This attribute is used to determine whether or not to invoke the superclass method.clientType = s.getProperty("ips.clientType");
isGenericHTML = (Client.getInstance(clientType).
getProperty("genericHTML")).equals("true");
} catch (SessionException se) {
throw new ProviderException("Unable to retrieve Session client
} catch (ClientException ce) {}
Presentability
Presentability refers to determining whether or not to service the client based on whether or not the requesting clientType is supported by the provider. That is, the WirelessHelloWorld3Provider is presentable if a template is found for the requesting clientType.Presentability, in this example, is based on the following logic:
* If the content template is found, then the channel is presentable to the client.
* If isGenericHTML is true, then the superclass method will be used, and the client is assumed to be presentable.
template = getTemplate(contentTemplate);
} catch (ProviderException e) {
Content Retrieval
Content retrieval is based on the getContent() method.public StringBuffer getContent(Map m) throws ProviderException
First, check to see if the client is a generic HTML client, defined by the isGenericHTML attribute. If the boolean value is true, then invoke the superclass getContent() method.
If the value of the isGenericHTML variable is false, then retrieve the client specific content template. The getTemplate() method will use the client's filePath attribute in the Client Data to locate the template.
StringBuffer content = getTemplate(contentTemplate);
The following will determine if the provider is presentable:
public boolean isPresentable() {
The following method, required as defined by the Provider interface, provides the provider with a mechanism to indicate whether or not it is editable from a particular clientType. If this method returns true, then there must be a client aware getEdit() method.
* Determine if the provider is editable
Installation
It is assumed that the existing iwtHelloWorld3Provider component has been installed on the system.
Sample iwtHelloWorld3Provider Template Files
Create the client specific template files for this provider. The template files are typically located in /etc/opt/SUNWips/desktop/default. In order to set up the template files, enter:# mkdir iwtHelloWorld3Provider
# mkdir /iwtHelloWorld3Provider/wml
# touch /iwtHelloWorld3Provider/wml/display.template
# mkdir /iwtHelloWorld3Provider/chtml
# touch /iwtHelloWorld3Provider/chtml/display.template
The display.template file contains something similar to the following:
# cat ./iwtHelloWorld3Provider/wml/display.template
# cat ./iwtHelloWorld3Provider/chtml/display.template
Log in to the Mobile Access Pack server administration console and select Manage Domains.
Select the domain and expand Applications.
Select Desktop and select iwtHelloWorld3Provider from the list of Available Channels.
Select the Edit Channel button to display the profile settings for the provider.
Change the Provider Class Name to com.iplanet.portalserver.providers.helloworld3.WirelessHelloWorld3Provider and select Submit.
Select Show Advanced Options and modify the Client Specific Available Providers for the clients supported by this provider. For Example,
- This will enable use of the new class that provides the client awareness.
Sample WirelessHelloWorld3Provider Class File
Create the WirelessHelloWorld3Provider class file or modify a copy of the HelloWorld3Provider class file in iPS_install_base/SUNWips/sample/desktop/classes/com/iplanet/portalserver/providers/helloworld3 directory.package com.iplanet.portalserver.providers.helloworld3;
import com.iplanet.portalserver.client.Client;
import com.iplanet.portalserver.client.ClientException;
import com.iplanet.portalserver.providers.helloworld3.HelloWorld3Provider;
import com.iplanet.portalserver.providers.ProfileProviderAdapter;
import com.iplanet.portalserver.providers.ProviderException;
import com.iplanet.portalserver.session.Session;
import com.iplanet.portalserver.session.SessionID;
import com.iplanet.portalserver.session.SessionException;
The following example shows how to use the existing HelloWorld3Provider to create a new Mobile Access Pack provider that is client aware.
public class WirelessHelloWorld3Provider extends HelloWorld3Provider{
private static final String contentTemplate = "display.template";
private String clientType = null;
private boolean isGenericHTML;
private boolean isPresentable;
public WirelessHelloWorld3Provider() {}
* Presentability of the provider to the desktop is based on the client type and content template retrieval
* @exception ProviderException
public void init(String n, Session s) throws ProviderException {
clientType = s.getProperty("ips.clientType");
isGenericHTML = (Client.getInstance(clientType).
getProperty("genericHTML")).equals("true");
} catch (SessionException se) {
throw new ProviderException("Unable to retrieve Session
} catch (ClientException ce) {}
* if (content template found), then the channel is presentable
* if genericHTML is true, then use parent methods for html markup and do not check for the template.
template = getTemplate(contentTemplate);
} catch (ProviderException e) {
* @return StringBuffer of the provider content.
* @exception ProviderException
public StringBuffer getContent(Map m) throws ProviderException {
StringBuffer content = getTemplate(contentTemplate);
* Determine if the provider is editable
* Determine if the provider is presentable
public boolean isPresentable() {
Implementing the Client Data API
In order to access the Client Data and retrieve any Client Data for the device accessing the desktop, within the Provider, develop a method to:
Retrieve the clientType string value from the Session using the ips.clientType property.
The client instance can be used to access the client's properties in the Client Data via the Client API. For more information, see "Client Data".Retrieve the client instance using the clientType value retrieved from the Session.
Initializing a Provider with the Init Method
The following is an example usage of the Client API that relies on the init method defined in the Provider API (PAPI).
com.iplanet.portalserver.providers
Class ProfileProviderAdapter
java.lang.Object+--com.iplanet.portalserver.providers.ProviderAdapter
+--com.iplanet.portalserver.providers.ProfileProviderAdapter
init
public void init(java.lang.String n, Session s)This initializes the provider. If additional initialization is required by the provider, this method can be overriden. However, the overriding init() call must always have super.init() as the first statement executed.
Parameters:
n - The unique indentifying name for this provider.
Example:
A following is an example implementation of this method in a non-wireless provider:public void init(String n, Session s) throws ProviderException {
Using the Session API to Retrieve the Client Type
In order to make a provider client aware, retrieve the clientType from the Session. This clientType represents the type of client accessing the desktop. The clientType value is used as an index to retrieve appropriate Client Data objects which is subsequently used to access the client's file path and device specfic template files using the file lookup mechanism.
com.iplanet.portalserver.session
Class Session
java.lang.Object+--com.iplanet.portalserver.session.Session
Use the getProperty() method to retrieve the clientType. Use the ips.clientType property name and retrieve the clientType value stored in the Session. The following example retrieves the clientType value within the Provider's init() method.
* Gets the property stored in this session.
* @param name The property name.
* @return The property value in String format.
* @exception A SessionException is thrown if the session reached its maximum
* session time, or the session was destroyed, or there was an error during
* communication with session service.
public String getProperty(String name) throws SessionException
Example:
private String clientType = null;public void init(String n, Session s) throws ProviderException {
clientType = s.getProperty("ips.clientType");
} catch (SessionException se) {
throw new ProviderException("Unable to retrieve Session
The provider can also be made to use the inherited PAPI getSession() method to retrieve the Session object. This object is set by the super.init(n, s). So, in the above example, replace:
clientType = s.getProperty("ips.clientType");
clientType = getSession().getProperty("ips.clientType");
After retrieving the clientType from the Session, use it to retrieve the client instance.
com.iplanet.portalserver.client
+--com.iplanet.portalserver.client.Client
getInstance
public static Client getInstance(String clientType) throws ClientException { }The following example includes the retrieval of the clientType from the Session.
private String clientType = null;
public void init(String n, Session s) throws ProviderException {
clientType = s.getProperty("ips.clientType");
clientObj = Client.getInstance(clientType);
} catch (SessionException se) {
throw new ProviderException("Unable to retrieve Session
} catch (ClientException ce) { }
getProperty
After establishing the client instance, use the Client getProperty() method to retrieve data or properties from the Client Data objects.public String getProperty(String name) throws ClientException { }
The following example includes the:
Retrieval of the client type from the Session
Retrieval of the Client instance
Retrieval of the genericHTML property value from the Client Data and setting it to a boolean
private String clientType = null;
private boolean isGenericHTML = null;
public void init(String n, Session s) throws ProviderException {
clientType = s.getProperty("ips.clientType");
clientObj = Client.getInstance(clientType);
isGenericHTML = Boolean.valueOf(clientObj.
getProperty("genericHTML")).booleanValue();
} catch (SessionException se) {
throw new ProviderException("Unable to retrieve Session
getDefaultInstance
Use the Client API getDefaultInstance() method to retrieve the client instance corresponding to the default clientType.public static Client getDefaultInstance() { }
Client clientObj = Client.getDefaultInstance();
getClientType
Use the Client API getClientType() method to retrieve the clientType string value for the current client instance.public String getClientType() { }
The following example retrieves the default client instance and checks to see if the value of the variable clientType corresponds to the current client instance.
// the variable clientType has been assigned previously
if (Client.getDefaultInstance().getClientType().equals(clientType)) {
getAllInstances
Use the Client API getAllInstances() method to retrieve an iterator of Client Data objects for all known client types.Iterator knownClients = Client.getAllInstances();
while (knownClients.hasNext()) {
client = (Client)knownClients.next();
String clientName = client.getProperty("clientType");
String clientUA = client.getProperty("userAgent");
// do something with the value
System.out.println("Client=" + clientName);
System.out.println("UserAgent=" + clientUA);
} catch (ClientException ce) { }
getPropertyNames
Use the Client API getPropertyNames() method to retrieve a set of property names for the Client instancepublic Set getPropertyNames() { }
The following example retrieves all the client instances and all the property names for each client.
Iterator knownClients = Client.getAllInstances();
while (knownClients.hasNext()) {
client = (Client)knownClients.next();
clientProps = new HashSet(client.getPropertyNames());
String clientName = client.getProperty("clientType");
for (Iterator it=clientProps.iterator(); it.hasNext();) {
System.out.println("clientProps->" + clientName + "->"
profileChanged
public void profileChanged(ProfileEvent event) { }
Previous Contents Index Next
Copyright © 2001 Sun Microsystems, Inc. All rights reserved.
Last Updated November 14, 2001