Skip Headers
Oracle® Application Server Wireless Developer's Guide
10g Release 2 (10.1.2)
B13819-02
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

16 Enabling User Customization

Each section of this document presents a different topic. These sections include:

16.1 Overview of User Preferences

OracleAS Wireless provides secure, reliable, and scalable facilities to manage User Preferences. User Preferences enable development of adaptable applications that personalize interactions and increase application efficiency. This facility allows rapid development and deployment of context-aware, multi-modal, multi-channel applications. The result is enhanced user experiences and turning a series of anonymous transactions into an enduring one-to-one customer relationship.

This chapter describes OracleAS Wireless's facilities for managing user preferences and step-by-step examples for how to apply the user preferences to develop advanced customization features. Customization typically refers to how a user adapts the system or how the system adapts to the particular needs and preferences of a user. The user-centric customization features give the users control over how they adapt the system to their needs and preferences. The system can also introduce mass customization techniques that apply user profiling (for example: by associating a user with like-minded group of users) to predict the user's needs and preferences, and adapt the system accordingly.

Customization can be performed by the applications that understand the users' needs based on their roles and preferences — for example, it is beneficial to present information in different ways to customers, suppliers, and employees. By knowing enough about a user's preferences and needs, the applications can intelligently enhance user experiences.

You can introduce mass customization techniques using automatic user profiling. The usage history of users can be found in the ptg_service_log and ptg_session_ log tables in the OracleAS Wireless repository; some of the examples in this chapter describe how to extend the OracleAS Wireless runtime to introduce mass customization. OracleAS Wireless includes a sample customization portal to enable end-users to manage their preferences from a PC browser.

The sample customization portal in OracleAS Wireless is developed using Oracle Cabo UI XML (uix) and UI Beans. The customization portal enables end users to customize their user preferences around the usual artifacts such as user devices, folders, applications (also known as services), bookmarks, notification events (also known as alerts), notification addresses, location marks, and presets. In addition, users can specify the contact rules and location privacy rules used by collaboration services. The UIX components and class library are categorized by specific functions. You can reuse the UIX components to rebrand the sample customization portal. By using and combining the UIX components, you can also develop your own brand of customization portals or integrate the customization wizards to your existing portals.


Note:

UIX is not required to customize the customization portal; any web UI framework may be used.

See Runtime API, Data Model API, and the sample UIX components for guidance when developing customization portals. You will find the concepts and examples provided in this chapter useful for designing the customization features to empower end users.


The example customization portal enables users to organize their folders, subscribe or unsubscribe to services and create or delete bookmarks and quicklinks under one or more customization profiles. Users can:

OracleAS Wireless also provides a sample Device Customization Portal that enables users to customize their personal portal directly from wireless devices, such as web phones and PDAs; the Device Customization Portal can be accessed from set-up buttons on wireless devices. This portal adapts to the limited display and input capability of the devices and provides a special mode to enable users to change user preference settings, organize their folders and service links, create, modify, or delete location marks, bookmarks, quick links, and customization profiles.

Multiple user customization profiles make the interaction from wireless devices more efficient and more personalized. Users can maintain one or more of their customization profiles and manage them from a PC or Device Customization Portal. They can switch between different customization profiles in their devices.

OracleAS Wireless includes the option to save the input values that a user has entered as a preset value for future invocations. Furthermore, OracleAS Wireless includes options to enter a symbolic name to represent presets. These symbolic names allow easy selection if there are more than one group of preset values. In addition, users can manage their presets from any device or PC.

Presets can contain as many attributes as required to match the fields in web forms. Application developers can create Preset Categories to define the attributes of the Presets. Each Preset Category consists of a Preset Category Name and any number of Preset Attributes. For example, the name of a Preset Category can be Auto-Fill Address Forms Fields whose first, second, and third attributes are Street, City, and ZIP. Users can have multiple Presets under this category, for example, my home, my work, Mom's home, which can be used to auto-fill the forms for driving direction services.

User Preferences in OracleAS Wireless include Contact Rules and Location Privacy and Authorization Rules. The Contact Rules are one of the user preference settings used by collaboration services and the messaging service. A Contact Rule describes how the user wishes to receive calls and messages. For example, a user can set a contact rule for meetings, wherein the user receives all notifications on a cell phone. You may define multiple contact rules, each with appropriate settings for a given set of circumstances. At any one time, only one contact rule is active. The active Contact Rule controls which devices are available to the user and the way in which the user wishes to be notified. The Location Privacy and Authorization Rules are used by location-based collaboration services. The location rules let the user control if and when their locations can be revealed to the location-based applications. The rules also let users authorize which services or users can query their locations.


Note:

For more information on Contact Rules, see OracleAS Wireless Administrator's Guide.

16.2 Multiple Customization Profiles

OracleAS Wireless enables development of user-centric web services that adapt the contents not only to the device and network capability but also to the end-user's preferences. The device portals typically provide a menu of services which may be organized under several folders and sub folders. Menu-driven device portals are designed to optimize the interactive efficiency of wireless devices. Service menus are usually static, but the portal may intelligently suggest new services to the user as it learns more about the user's needs and preferences. OracleAS Wireless Server enables end-users to personalize the portal by controlling the arrangement of services in the menus. The portal can suggest new services to the user, but the user still controls when to include or exclude each service in the user's personalized portal. Administrators can explicitly prevent end-users from rearranging or removing certain services (such as promotions, preferred partners, emergency services) from their personalized portals.

16.2.1 Concepts

Profiles enable users to create multiple personalized versions of the portals for their devices; the service menus may be different from one profile to another. For example, suppose that one of the folders for a user contains the following services:

  • E-mail

  • News

  • Stocks

  • Map

  • Phone Directory

  • Shopping

In the Home profile, the service menu in the folder may be customized as:

  • Phone Directory

  • E-mail

  • News

  • Stocks

The same folder may be customized differently for the Traveling profile as:

  • Map

  • Shopping

  • Phone Directory

Multiple profiles can be created for different roles, locations or contexts, device and network characteristics, or any other taxonomy.

Profiles may be created for each of these roles to increase efficiency and accessibility of services. For a traveling user who frequents multiple metropolitan centers, profiles may be created for each location. For example, a user's customization Profile for a cultural center (such as Rome, Italy) may include services for theaters, museums, and transit schedules. The same user may have another profile for the Lake Baikal area with a different combination of services. A location-aware portal can automatically set the session Profiles for users when they connect from different locations. A Profile may be associated with a Location Mark as described in the section on Location Marks.

OracleAS Wireless runtime controllers can be extended to automatically provision the Profiles for users, for example to provide different views of the portal from more than one type of device. The example in the following section describes how to automatically provision a profile for a user. Alternatively, end-users can create any number of Profiles for any context through the Customization Portal using a PC browser. Through OracleAS Wireless Tools, they can customize the arrangement of services for each of the Profiles.

Administrators can specify the default sorting rules for shared folders. Under the Profile architecture, end-users can alter the default sorting rules to personalize their own views of shared folders. They can choose from the following sorting rules:

  • specified sequence numbers

  • lexicographic ordering

  • date of creation

  • frequency of access

  • last access time

The sequence numbers, lexicographic ordering, and date-of-creation produce static views of the folders. Sorting by frequency of access or last access time produces a dynamic view of the folders. Furthermore, administrators can control the static or dynamic arrangements of some of the applications in a folder, such as emergency, promotion and preferred partner's services, that may not be rearranged by end-users. Administrators can designate the segments of the views that may be rearranged or hidden by end-users.

The view of a folder may be segmented such that one segment is sorted by the administrator's specification and another segment is sorted by a user's specification.

The Profile architecture enables end-users to specify the visibility of an application in the profile, provided the administrator does not explicitly disable the personalizable attribute of the application. This enables end-users to subscribe or unsubscribe to an application that may be placed in the user's folder by the system. The system may also apply location-based filtering of services in the location-enabled folders, which offers additional dynamism to the views that vary with the user's mobile position.

Applications that access runtime objects can get the current Profile from the ServiceContext.getProfile method. See Section 9.4.4, "MCS Runtime API" for a description of runtime objects. This method first looks up the Profile in the current Request. If the Request does not specify a Profile, the method looks in the runtime Session for the session Profile. If the session Profile is empty, then the method looks up the default Profile of the user. This resolution strategy lets the Request override the session Profile, and the session to override the default user profile. ServiceContext.getProfile will return null if no Profile is found. Applications should be designed to react with default behavior when the Profile is not specified.

16.2.2 Sample Applications

Example 16-1 illustrates how to automatically provision a user device, and the device Profile for each of the device types that a user may use. SampleRequestListener listens for the serviceBegin() event and provisions a new user device and Profile in lines [22], [25], and [27]; if the Request and Session do not already specify a Profile, line [17] and [19]. For the new Profile, it sets the user's home folder to sort the services in the home folder by the last access time of the service in line [36]. For each service that is view-customizable in line [39], it sets the service to be hidden in the Profile in line [40]. End-users can later customize the Profiles to unhide the services that they want to use. This must be done only once after the Profiles are first created. The listener then sets the Profile in the Request in line [54].

Example 16-1 Sample Applications

import oracle.panama.model.*;
import oracle.panama.rt.Session;
import oracle.panama.rt.Request;
import oracle.panama.rt.event.RequestAdapter;
import oracle.panama.rt.event.RequestEvent;
import oracle.panama.rt.event.AbortServiceException;
import oracle.panama.PanamaException;
 
public class SampleRequestListener extends RequestAdapter {
 
    public void serviceBegin(RequestEvent event) throws AbortServiceException {
        Request request = event.getRequest();
        Session session = request.getSession();
        User user = session.getUser();
 
        Profile profile = request.getProfile();         //[17]
 
        if (profile == null)
            profile = session.getProfile();                //[19]
        if (profile == null) {
            Device device = request.getDevice();
            String deviceName = device.getName();
            Profile deviceProfile;
            synchronized(user) {
                ModelFactory factory = MetaLocator.getInstance().getModelFactory();
                UserDevice userDevice = user.lookupUserDevice(deviceName);
                boolean deviceProfileCreated = false;
                if (userDevice == null) { 
                    userDevice = user.createUserDevice();    //[22]
                    userDevice.setName(deviceName);
                    userDevice.setDisplayName("My user device name for " + deviceName);
                    try {
                        factory.save();
                        deviceProfileCreated = true;
                    } catch (PanamaException ex) {
                        deviceProfile = null;
                    }
                }                
                deviceProfile = userDevice.getUserProfile();
                if (deviceProfile == null) {
                    deviceProfile = user.lookupProfile(deviceName);         //[25]
                    if (deviceProfile == null) { 
                        deviceProfile = user.createProfile(deviceName);      //[27]
                    }
                    try {
                        factory.save();
                        deviceProfileCreated = true;
                    } catch (PanamaException ex) {
                        deviceProfile = null;
                    }
                }
                
                if (deviceProfileCreated) {
                    boolean needCommit = false;
                    Folder home = user.getHomeFolder();
                    deviceProfile.setSortRule(home, SortRule.SORT_BY_ACCESS_TIME_ASCEND);    //[36]
                    Service[] services = home.getAccessibleUserServices(user);
                    for (int i = 0; i < services.length; i++) {
                        if (services[i].isViewCustomizable()) {           //[39]
                            deviceProfile.setHide(services[i], true);      //[40]
                            needCommit = true;
                        }
                    }
                    try {
                        if (needCommit)
                            factory.save();
                    } catch (PanamaException ex) {
 
                    }
                }
            }
                       }
        if (deviceProfile != null)
            request.setProfile(deviceProfile);                  //[54] 
 
}

16.3 Presets

OracleAS Wireless provides the facilities for developers and end-users to apply extensive customization to create personalized portals, which enhance the one-one relationships between the portal and each end-user. One of the key facilities is the Presets for storage of the user's personal information, preference settings, and frequently used input parameters on the server side so that the applications can use them to generate personalized responses.

The OracleAS Wireless repository contains the concept of a portal user with predefined persistent attributes. These basic attributes include name, gender, date-of-birth, country, language, locale, and others. Presets are persistent objects in the OracleAS Wireless repository that can be used to extend the repository schema, especially to incorporate new persistent attributes for user objects in the repository.

16.3.1 Presets Concept and Architecture

Presets are persistent objects in the OracleAS Wireless repository that can be used to extend the user schema and incorporate users' personal information into the repository. Developers of applications can define the Preset Categories to extend the user schema in application-specific ways, for example to incorporate the billing address, credit card charge account, bank accounts, brokerage accounts, stock portfolios, emergency contacts. These extended schemas may be defined and exclusively maintained by Personal Information Management (PIM) services.

Presets can also be used to incorporate user preferences into the repository. The standard user agent types and the device models in the repository describe the capabilities of devices. Individual end-users can customize some of the capabilities of the user agents. Presets for user agent profiles can be used to let end-users customize the capabilities of the user agent, for example, to enable or disable sound, select background color, select quality of service, or to disable images to minimize packet transmissions. The user agent profiles control the format of the content, but more general user preference profiles can affect the selection of the applications and response of the applications. For example, the user preference profile for sports, entertainment, technology and privacy requirements can be used by the applications to filter the contents. The Presets architecture enables the development of adaptive web services based on the emerging Composite Capability/Preference Profile (CC/PP), User Agent profile (WAP UAProf), and Platform for Privacy Preferences (P3P) standards (www.wapforum.org).

Presets can also store frequently-used input parameters for applications. The applications can define the attributes of Presets to closely match the forms used by the applications. These Presets can be used to auto-fill forms. The applications can store user inputs as the Presets for subsequent use. The Presets names uniquely identify the input parameter values and can be used as shorthand to significantly reduce the amount of data entry.

There are different categories of Presets in the repository. Each Presets relation contains a set of preset attribute values whose types and relations are defined by the Preset Category. A user may own one or more Presets relations in each of the Preset Categories. A Preset Category contains a collection of Preset Descriptors, each of which provide the metadata for the attributes in the Presets relation. The metadata of an attribute includes the name, type, size, format, and description of the attribute. For example, a Presets relation of the address book Preset Category may contain the name, address, and phone number attributes of a contact for the user. Such a Preset Category may be defined and exclusively maintained by a Personal Information Management (PIM) application. Another Preset Category may define the attributes of the Presets relations that contain the stock symbols, names, and classifications of the companies in the user's watch list or portfolio. The stock symbols in this category can be used as input parameters for the stock quote service.

The name of the Preset Category must be unique within the repository. Likewise, the name of the Preset Descriptor must be unique within the Preset Category to which it belongs. The name of the Presets relation is optional but if given a name, it must be unique among the Presets relations that are owned by the same user within the same Preset Category. Preset Categories created programmatically are marked as system by default; they are to be maintained by the applications exclusively. System-level Preset Categories are not visible in the customization portals and cannot be edited by end users directly. The applications can set the Preset Category to non-system so that end-users may edit its Presets in the customization portal.

16.3.2 Sample Applications

Preset Categories can be created programmatically as shown in the following examples. They can also be created from OracleAS Wireless Tools > Preset Definitions control panel.

16.3.2.1 Example 1: Adding Attributes to the User Schema

Example 16-2 shows how to create a Preset Category Billing Address to extend a user schema. The method first checks in line [13] if the Billing Address category already exists in the repository. If the category does not exist, the ModelFactory method createPresetCategory(Billing Address) is used to create the category in line [21]. Lines [23] through [27] define the first attribute Addressee Name of the category. Line [25] defines that the first attribute is comprised of a single line of text. In contrast, the second attribute Street Address is defined as a multi-line text field in line [31]. The new Preset Category is committed in line [47].

Example 16-2 Adding attributes to the user schema

import oracle.panama.model.ModelFactory;
import oracle.panama.model.PresetCategory;
import oracle.panama.model.PresetDescriptor;
import oracle.panama.ArgumentType;
import oracle.panama.PanamaException;
 
public void createAddressBook() throws PanamaException {
 
        ModelFactory factory = MetaLocator.getInstance().getModelFactory();
        ModelServices services = MetaLocator.getInstance().getModelServices();
 
 
        PresetCategory category;
        try {
            category = services.lookupPresetCategory("Billing Address");    [13]
        } catch (PanamaRuntimeException ex) {
            category = null;
        }
 
        if (category != null) {
            return;   // category already exists
        }
         category = factory.createPresetCategory("Billing Address");        [21]
 
        PresetDescriptor descriptor = category.createPresetDescriptor("Addressee Name");   [23]
        descriptor.setDescription("The name of the addressee");
        descriptor.setPresetType(ArgumentType.SINGLE_LINE);   [25]
        descriptor.setStoredType(Java.sql.Types.VARCHAR);
        descriptor.setSize(new Long(40));[27]
 
        descriptor = category.createPresetDescriptor("Street Address");
        descriptor.setDescription("The street address");
        descriptor.setPresetType(ArgumentType.MULTI_LINE);    [31]
        descriptor.setStoredType(Java.sql.Types.VARCHAR);
        descriptor.setSize(new Long(120));
 
        descriptor = category.createPresetDescriptor("State");
        descriptor.setDescription("The name of the state");
        descriptor.setPresetType(ArgumentType.SINGLE_LINE);
        descriptor.setStoredType(Java.sql.Types.VARCHAR);
        descriptor.setSize(new Long(2));
 
        descriptor = category.createPresetDescriptor("Zip code");
        descriptor.setDescription("The postal zip code");
        descriptor.setPresetType(ArgumentType.SINGLE_LINE);
        descriptor.setStoredType(Java.sql.Types.NUMERIC);
        descriptor.setSize(new Long(5));
 
        factory.save();   [47]
    }

The name of the Preset Category must be unique in the repository. The createPresetCategory() method of the ModelFactory will throw oracle.panama.model.NameUniquenessViolationException if the application tries to create a Preset Category with the same name. Likewise, the name of the Preset Descriptor must be unique within the Preset Category. The createPresetDescriptor() method of the PresetCategory will throw oracle.panama.model.NameUniquenessViolationException if the application tries to create the Preset Descriptor with the same name. The names of Preset Category and Preset Descriptor are case-sensitive and can contain any valid characters including spaces.

16.3.2.2 Example 2: Adding a Unique Presets Relation for a User

Example 16-3 shows how the Preset Category Billing Address is used to add persistent attributes to the user. If the Billing Address category does not exist, this method creates the new category. The example uses the unique object ID of the user as the name of the Presets. The new Presets relation is created in line [16], only if the look up method in line [13] does not find any existing Presets relation with the same name. The use of the object ID as the Presets name ensures that only one instance of the Presets relation for Billing Address is created for each user. The attribute values of the Presets relation are modified in lines [18] through [21]. The modified Presets relation is committed into the repository in line [23].

Example 16-3 Adding persistent attributes to a user

import oracle.panama.model.*;
 
public void addBillingAddress(User user, String addressee, String streetAddress,
                             String state, int zipCode) throws PanamaException {
        ModelFactory factory = MetaLocator.getInstance().getModelFactory();
        ModelServices services = MetaLocator.getInstance().getModelServices();
 
        PresetCategory category;
        try {
            category = services.lookupPresetCategory("Billing Address");
        } catch (PanamaRuntimeException ex) {
            createAddressBook();[9]
            category = services.lookupPresetCategory("Billing Address");
        }
 
        Presets presets = user.getPresets(category, Long.toString(user.getId()));[13]
 
        if (presets == null) {
            presets = user.createPresets(category, Long.toString(user.getId()));    [16]
        }
        
        presets.setPresetValue("Addressee Name", addressee);    [18]
        presets.setPresetValue("Street Address", streetAddress);
        presets.setPresetValue("State", state);
        presets.setPresetValue("Zip code", Integer.toString(zipCode));     [21]
 
 
        factory.save();   [23]
    }

The name of the Presets relation must be unique within the user's domain. If the application tries to create the Presets again with the same name for the same user, the createPresets() method of the user will throw the oracle.panama.model.NameUniquenessViolationException. The names of Presets relations are case-sensitive and can contain any valid characters including spaces.

16.3.2.3 Example 3: Adding a Unique Presets Relation for Users' Profiles

Profiles are repository objects that support multiple versions of personalized portals for each user. If a user has a Profile for Business and another Profile for Personal and requires a separate credit card charge account for each of the Profiles, then the code in Example 16-4 shows how to create the Credit Card Charge Account category and the Presets relation that is unique for each profile of the user. The unique presets name is created from the object ID of the User and the Profile in line [43] to ensure that only one Presets relation is created for each profile. The example also shows the use of preset type ArgumentType.ENUM for the Card Type attribute. The ENUM type enables you to specify the valid options for that attribute as shown in lines [28] and [30]. Lines [60] through [62] show the use of the Java.sql.Date type for persistent storage. The expiration date of the credit card is formatted using the Java.text.DateFormat utility in line [61] so that it can be parsed and stored as Date type in the repository.

Example 16-4 Adding unique presets to user profiles

import oracle.panama.model.*;
import Java.util.Date;
import Java.text.DateFormat;
 
public void addCreditAccount(User user, Profile profile, String cardNumber,
                            String cardType, int expireMonth, int expireYear)
                            throws PanamaException {
        ModelFactory factory = MetaLocator.getInstance().getModelFactory();
        ModelServices services = MetaLocator.getInstance().getModelServices();
 
        PresetCategory category;
        try {
            category = services.lookupPresetCategory("Credit Card Charge Account");
        } catch (PanamaRuntimeException ex1) {
            try {
                category = factory.createPresetCategory("Credit Card Charge Account");
            } catch (PanamaException ex2) {
                throw ex2;
            }
 
 
            PresetDescriptor descriptor = category.createPresetDescriptor("Account Number");
            descriptor.setDescription("The credit card account number");
            descriptor.setPresetType(ArgumentType.SINGLE_LINE);
            descriptor.setStoredType(Java.sql.Types.VARCHAR);
            descriptor.setSize(new Long(40));
 
            descriptor = category.createPresetDescriptor("Card Type");
            descriptor.setDescription("The type of credit card");
            descriptor.setPresetType(ArgumentType.ENUM);    [25]
            descriptor.setStoredType(Java.sql.Types.VARCHAR);
            descriptor.setSize(new Long(40));
            String cardTypes[] = { "Master", "Visa", "Discover", "American Express", "Diners Club" };      [28]
            try {
                descriptor.setOptions(cardTypes);     [30]
            } catch (TooManyOptionsException ex3) {
                throw new PanamaException(ex3);
            }
 
            descriptor = category.createPresetDescriptor("Expiration Date");
            descriptor.setDescription("The expiration date of the credit card");
            descriptor.setPresetType(ArgumentType.SINGLE_LINE);
            descriptor.setStoredType(Java.sql.Types.DATE);
 
            factory.save();      [40]
        }
 
        String presetsName = Long.toString(user.getId()) + "-" + Long.toString(profile.getId()); [43]
        Presets presets = profile.getPresets(category, presetsName);
        if (presets == null) {
            presets = profile.createPresets(category, presetsName);
        }
 
        presets.setPresetValue("Account Number", cardNumber);
        presets.setPresetValue("Card Type", cardType);
        Date date = new Date(expireYear, expireMonth, 1);   [60]
        String dateStr = DateFormat.getInstance().format(date);    [61]
        presets.setPresetValue("Expiration Date", dateStr);    [62]
 
        factory.save();     [64]
    }

16.3.2.4 Example 4: Selecting the Presets Relation Under the Current Profile

Example 16-5 contains a code example from a Request Listener illustrates how the Presets relation for the Credit Card Charge Account is accessed during the serviceBegin() event notification. The routine throws AbortServiceException if no valid credit card charge account is available for the user. It checks for request profile, session profile, or default user profile, in order, as shown in lines [14] and [16]. It composes the Presets name from the object ID of the User and Profile. If the Presets relation for Credit Card Charge Account is found, the listener provides the credit card information to the service as request parameters in lines[51] through [52].

Example 16-5 Accessing the Presets relation

import oracle.panama.rt.event.RequestEvent;
import oracle.panama.rt.event.AbortServiceException;
import oracle.panama.rt.Session;
import oracle.panama.rt.Request;
 
public void serviceBegin(RequestEvent event) throws AbortServiceException {
        Request request = event.getRequest();
        PresetCategory category;
        String presetsName;
        ModelServices services = MetaLocator.getInstance().getModelServices();
        String serviceName = request.getServicePath();
        User user;
 
        Profile profile = request.getProfile();      [14]
        if (profile == null) {
            profile = request.getSession().getProfile();    [16]
        }
        if (profile != null) {
            user = profile.getUser();
            presetsName = Long.toString(user.getId()) + "-" + Long.toString(profile.getId());
        } else {
            user = request.getSession().getUser();
            presetsName = Long.toString(user.getId());
        }
 
        try {
            category = services.lookupPresetCategory("Credit Card Charge Account");
        } catch (PanamaRuntimeException ex1) {
            throw new AbortServiceException("This service " + serviceName + " requires a valid charge account");
        }
 
        Presets presets = null;
        if (profile == null) {
            presets = user.getPresets(category, presetsName);
        } else { 
            presets = profile.getPresets(category, presetsName);
            if (presets == null) {
                presets = user.getPresets(category, presetsName);
            }
        }
 
        if (presets == null) {
 
            throw new AbortServiceException("This service " + serviceName + " requires a valid charge account");
        }
 
        String creditCardNumber;
        String cardType;
        String expiration;
        try {
            creditCardNumber = presets.getPresetValue("Account Number");
            cardType = presets.getPresetValue("Card Type");
            expiration = presets.getPresetValue("Expiration Date");
        } catch (PanamaException ex) {
            throw new AbortServiceException("This service " + serviceName + " requires a valid charge account");
        }
 
        if (! creditAvailable(creditCardNumber, cardType, expiration)) {
            throw new AbortServiceException("This service " + serviceName + " requires a valid charge account");
        }
 
        request.setParameter("Account Number", creditCardNumber);     [51]
        request.setParameter("Card Type", cardType);      [52]
        request.setParameter("Expiration Date", expiration);    [53]
    }

The above examples are based on a scenario that requires the applications to use well-defined naming conventions for the Presets relations, although the Presets names themselves are optional. The following example illustrates a Preset Category Appointments which allows multi-set entries. The identity of the Presets relation is provided by one of the attributes in the Presets relation. In this example, the Presets are created without names.

16.3.2.5 Example 5: Creating Presets without Given Name

Example 16-6 shows the Preset Category Appointments that lets users create appointment events. Since the attribute Short Title can be used to identify the events, the event Presets are created without names as shown in line [65]. All event Presets for the user can be retrieved from the repository as shown in line [97]. The Appointments category is set to non-system in line [25] so that the category can be included in the customization portal for end-users to edit. The example shows the use of DateFormat utility to save the event time in line [69] and retrieve it in line [105]. The expired events are deleted from the repository in line [112]. The example also shows the use of the regular expression to constrain the format of the Phone Number attribute. The regular expression is compatible with the public domain org.apache.regexp.RE toolset. The regular expression in line [59] is for the phone numbers in the US locale, which is:

"\s*[(]?[1-9]\d{2}[)]?\s*-?\s*\d{3}\s*-?\s*\d{4}"

without the escape characters. The setPresetValue() method, line [77], in the Presets will throw PanamaException if the value does not match the regular expression. The full regular expression syntax, which is compatible with the org.apache.regexp.RE toolset, is given in the next section.

Example 16-6 Creating presets

import oracle.panama.model.*;
import oracle.panama.PanamaException;
import oracle.panama.PanamaRuntimeException;
import oracle.panama.ArgumentType;
 
import Java.util.Vector;
import Java.util.Enumeration;
import Java.util.Date;
import Java.text.DateFormat;
import Java.text.ParseException;
 
public class SamplePresets {
 
    public void addAppointment(User user, String title, String memo, Date time,
                               boolean alarm, String phone) throws PanamaException {
        ModelFactory factory = MetaLocator.getInstance().getModelFactory();
        ModelServices services = MetaLocator.getInstance().getModelServices();
 
        PresetCategory category;
        try {
            category = services.lookupPresetCategory("Appointments");
        } catch (PanamaRuntimeException ex1) {
            try {
                category = factory.createPresetCategory("Appointments");
                category.setSystem(false);         [25]
            } catch (PanamaException ex2) {
                throw ex2;
            }
 
            PresetDescriptor descriptor = category.createPresetDescriptor("Short Title");
            descriptor.setDescription("Brief description of the event");
            descriptor.setPresetType(ArgumentType.SINGLE_LINE);
 
            descriptor.setStoredType(Java.sql.Types.VARCHAR);
            descriptor.setSize(new Long(40));
 
            descriptor = category.createPresetDescriptor("Memo");
            descriptor.setDescription("Memo for the event");
            descriptor.setPresetType(ArgumentType.MULTI_LINE);
            descriptor.setStoredType(Java.sql.Types.VARCHAR);
            descriptor.setSize(new Long(400));
 
            descriptor = category.createPresetDescriptor("Time");
            descriptor.setDescription("Time of event");
            descriptor.setPresetType(ArgumentType.SINGLE_LINE);
            descriptor.setStoredType(Java.sql.Types.VARCHAR);
            descriptor.setSize(new Long(40));
 
            descriptor = category.createPresetDescriptor("Alarm");
            descriptor.setDescription("Enable or disable alarm before event");
            descriptor.setPresetType(ArgumentType.SINGLE_LINE);
            descriptor.setStoredType(Java.sql.Types.VARCHAR);
            descriptor.setSize(new Long(1));
 
            descriptor = category.createPresetDescriptor("Phone Number");
            descriptor.setDescription("Optional phone number to ring for alarm");
            descriptor.setPresetType(ArgumentType.SINGLE_LINE);
            descriptor.setStoredType(Java.sql.Types.VARCHAR);
            descriptor.setSize(new Long(40));
            descriptor.setFormat("\\s*[(]?[1-9]\\d{2}[)]?\\s*-?\\s*\\d{3}\\s*-?\\s*\\d{4}");      [59]
            descriptor.setEmptyOK(true);
 
            factory.save();
        }
 
        Presets presets = user.createPresets(category);    [65]
 
        presets.setPresetValue("Short Title", title);
        presets.setPresetValue("Memo", memo);
        String timeStr = DateFormat.getDateTimeInstance().format(time);   [69]
        presets.setPresetValue("Time", timeStr);
        if (alarm) {
            presets.setPresetValue("Alarm", "Y");
        } else {
            presets.setPresetValue("Alarm", "Y");
 
        }
       try {
            presets.setPresetValue("Phone Number", phone);         [77]
        } catch (PanamaException ex) {
            // ignore
        }
 
        factory.save();
    }
 
    public Presets[] getAppointments(User user) throws PanamaException {
        ModelFactory factory = MetaLocator.getInstance().getModelFactory();
        ModelServices services = MetaLocator.getInstance().getModelServices();
 
        PresetCategory category;
        try {
            category = services.lookupPresetCategory("Appointments");
        } catch (PanamaRuntimeException ex1) {
            throw new PanamaException(ex1);
        }
 
        Date now = new Date(System.currentTimeMillis());
        Vector allPresets = user.getAllPresets(category);       [97]
        Enumeration enum = allPresets.elements();
        Vector pending = new Vector();
        while (enum.hasMoreElements()) {
            Presets event = (Presets) enum.nextElement();
            String timeStr = event.getPresetValue("Time");
            Date time;
            try {
                time = DateFormat.getDateTimeInstance().parse(timeStr);   [105]
            } catch (ParseException ex) {
                time = null;
            }
            if (time != null && time.after(now)) {
                pending.add(event);
            } else {
                user.deletePresets(category, new Long(event.getId()));    [112]
            }
        }
        factory.save();
 
        Presets presetsArray[] = new Presets[pending.size()];
        pending.copyInto(presetsArray);
        return presetsArray;
 
    }
 
}

16.3.3 Regular Expressions Syntax for the Presets Attribute Formats

The following tables shows the full regular expression syntax that can be used to define formats.

Table 16-1 Characters Used to Define Presets Attribute Formats

Character Description

char

Matches any identical character

\

Used as an escape character (for example: \*, \\, \w)

\\

Matches a single '\' character

\0nnn

Matches a character with given octet number

\xhh

Matches a character with given 8-bit hexadecimal value

\\uhhhh

Matches a character with given 16-bit hexadecimal value

\t

Matches a tab character

\n

Matches a newline character

\r

Matches a return character

\f

Matches a form feed character


Table 16-2 Character Classes

Character Description

[abc]

Simple character class

[a-zA-Z]

Range character class; range specified with "-" and "]" (for example: [x-z]

[^abc]

Negated character class, for exclusion tests.


Table 16-3 Standard POSIX Character Classes

Character Description

[:alnum:]

Alphanumeric characters.

[:alpha:]

Alphabetic characters.

[:digit:]

Numeric characters.

[:upper:]

Upper-case alphabetic characters.

[:lower:]

Lower-case alphabetic characters.

[:space:]

Space characters (such as space, tab, and formfeed, to name a few).


Table 16-4 Variable Classes

Class Description

.

Matches any character other than newline

\w

Matches an alphanumeric character

\W

Matches a non-alphanumeric character

\s

Matches a whitespace character

\S

Matches a non-whitespace character

\d

Matches a digit character

\D

Matches a non-digit character


Table 16-5 Boundary Matchers

Matcher Description

^

Matches the beginning of a line

$


Matches the end of a line

\b

Matches a word boundary

\B

Matches a non-word boundary


Table 16-6 Greedy Closures (match as many elements as possible)

Element Description

A*

Matches A 0 or more times (greedy)

A

Matches A 1 or more times (greedy)

A?

Matches A 1 or 0 times (greedy)

A{n}

Matches A exactly n times (greedy)

A{n,}

Matches A at least n times (greedy)

A{n,m}

Matches A at least n but not more than m times (greedy)


Table 16-7 Reluctant Closures (match as few elements as possible)

Element Description

A*?

Matches A 0 or more times (reluctant)

A?

Matches A 1 or more times (reluctant)

A??

Matches A 0 or 1 times (reluctant)


Table 16-8 Logical Operators

Operator Description

AB

Matches A followed by B (concatenation)

A|B

Matches either A or B(union)

(A)

Matches subexpression inside "(" and ")", not including "(" and ")"


16.4 Location Marks

Location awareness is a key feature of OracleAS Wireless. A user's location can be obtained from E911 or GPS units or Location Marks. Location Marks are user-defined locations. For example, an end-user may enter home, work and headquarters office addresses into their location-aware applications. Then, when using a restaurant look-up application, the application can use the current location to provide driving directions. To ensure security and privacy, users can control which applications can access their location.

Due to the limitations of certain mobile devices such as telephones, it is difficult to input or display lengthy alphanumeric strings. A location mark stores a piece of spatial information identified by a concise, easy-to-understand name. For example, My Home might be the name of a location mark, while the underlying spatial information might be 123 Main Street, Somewhere City, CA, 12345; Lon = -122.42, Lat = 37.58.

Users have complete control over their location marks and are easily able to select, create, delete and modify location with any device or PC.

Location marks also allow users to try what-if? scenarios; to make an application behave as if they were in a location different from their default or current location. For example, a user of an entertainment services application might be in Boston, but will be traveling to Montevideo in a few days. This person could set a location mark in Montevideo, and be presented with information relevant to the Montevideo area. Each user can have personalized location marks, which are stored in the Wireless repository.

Location marks are created using the Location Mark class. Users can also create location marks by logging into the OracleAS Wireless Customization Portal, clicking the Location Marks tab, and clicking Create. See Chapter 15, "Using Location Services" for more information on using Location Marks with Geocoding, Mapping, Routing, Traffic and Region Modeling services. Location Marks may be geocoded as a point (latitude and longitude) or a spatial region covering a metropolitan area.

Example 16-7 illustrates how a Location Mark for the user JohnBSmith's work address is created and assigned to the user's location profile NEDC AREA LOCATION PROFILE. The user can switch to this location profile from their device to adapt the responses from location-aware services.

Example 16-7 Creating location marks

public void createLocations() throws Exception {
        User user = services.lookupUser("JohnBSmith");
        Point point = SpatialManager.createPoint(-71.455, 42.7117);
        Location location = SpatialManager.createLocation(point,"", "","1 oracle drive", "", "nashua", "nh", "03062", "", "", "", "","us");       
        LocationMark locMark = factory.createLocationMark("NEDC AREA", user, location, 2.0);
        Profile locationProfile = user.createProfile("NEDC AREA LOCATION PROFILE");
        locationProfile.setLocationMark(locMark);
        factory.save();
    }

16.5 User Device Management

OracleAS Wireless enables users with multiple devices to easily manage and optimize their mobile experiences for each device. Users can manage their devices from either a PC or mobile device. In addition, users are easily able to modify their current default device.

A User Device objects is a means for grouping multiple device addresses under the same entity. This is useful for situations in which the same device may contain multiple User Agents or may use multiple protocols or channels, each with a different address or identification, but all emanating from the same physical entity. Furthermore, the preference settings, location settings, device settings in one User Agent may affect another User Agent on the same device. A customization profile is automatically created for each User Device object.

Once a user creates a new device profile, they can enter the following attributes for each device:

16.6 User and Group Management

OracleAS Wireless provides Group and User Management and Access Control Lists (also known as Roles) to restrict or grant access to any folder or application. Any user that is granted User Manager role is able to create, delete and modify groups and users through any device or PC.

Group and User objects represent a convenient mechanism to define access control on folders and applications. A user may be a member of one or more groups. Every folder or application is owned by a single user, but can be shared among a group of users by assigning the folder or application to the group. All users in a group are granted access to any folder or application when the folder or application is assigned to the group.

Users have full control over their own folders and applications placed under their private folders. They can create, delete, or modify applications in their private folders, especially Bookmarks and Quicklinks.

16.7 Service Management

OracleAS Wireless offers complete control to developers to manage what end-users can do in terms of folder management. Developers can offer groups or users complete flexibility with their Service Management or restricted use of Service Management.

Services and folders may be organized in the following ways:

End-user also have the ability to customize their mobile experience with Bookmarks and Quicklinks. This gives users the ability to link frequently-accessed services to the home deck or any other desired folder.