User Management Guide

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Creating and Updating User Profiles

Developers can use BEA Workshop for WebLogic Platform to create JSP tags and controls that add and edit User Profiles. A User Profile consists of a username and any additional properties you collect and store about a user. These properties can be used to personalize the user’s experience in your portal.

Properties can consist of personal data, work-related data, geographic data, or something else that logically categorizes your users. For example, you could create a property set in BEA Workshop for WebLogic Platform called human resources that contains properties such as gender, hire date, and e-mail address.

You must use Workshop for WebLogic to programmatically create User Profiles and edit the profile’s default property values. Administrators can edit the profile’s property values in the Administration Console. See Editing User Profile Property Values for instructions.

When users log into a portal, the portal can access the property values and target them with personalized content, e-mails, pre-populated forms, and discounts based on the Personalization rules you set up. See the Interaction Management Guide for more information.

Developers can use the following Workshop for WebLogic to programmatically create and edit User Profile default property values:

This chapter includes the following sections:

 


Creating a User Profile

A User Profile is a collection of user property values for a user from all available user property sets. Each piece of metadata in a User Profile is called a user property. A User Profile property set organizes the properties that it contains and provides a convenient way to name a group of properties for a specific purpose. The properties you create can be used to define rules for Personalization, Delegated Administration, or Visitor Entitlement.

User properties can range from statically-defined properties (such as a user’s phone number and e-mail address) to dynamically-created and persisted properties (web site tracking information for the user, for example). A property set called personal could contain properties, such as age, gender, marital status, and address. Another property set called preferences could contain properties, such as hobby, favorite color, and news preference.

You must create User Profiles and edit the profile’s default values in Workshop for WebLogic. You can edit the profile’s values in Workshop for WebLogic or in the Administration Console.

WebLogic Portal provides a default User Profile property set called CustomerProperties.usr that contains common properties.

Note: You can also create an application-defined property set to store profile data for entities that are not users or groups. These entities include Communities and Web Services for Remote Portlets (WSRP), or a custom entity created by an application programmer. See the Interaction Management Guide for instructions on creating this type of property set.

This section contains the following topics:

Creating a User Profile Property Set

You can create a User Profile and a property set in Workshop for WebLogic. You can edit the profile’s default values in Workshop for WebLogic or in the Administration Console.

Perform the following steps to create a property set for a User Profile:

  1. In the BEA Workshop for WebLogic Platform Application window, right-click the data\src\userprofiles folder, and choose New > Other.
  2. Tip: You can customize the menu so that Property Sets appears as a choice on the New menu. See the Portal Development Guide for instructions.
  3. In the New dialog box, expand WebLogic Portal and then expand Property Sets.
  4. Select User Property Set and click Next, as shown in Figure 5-1.
  5. Figure 5-1 Create a User Profile Property Set


    Create a User Profile Property Set

  6. In the New User Property Set window, enter a name for the User Profile property set in the File name field. Keep the.usr file extension. For example, SalesRegion.usr.
  7. Click Finish. The User Profile Editor appears.

Adding Properties to a Property Set

After you create a property set by following the instructions in Creating a User Profile Property Set, you can capture user information by adding properties to the profile.

Perform the following steps to add properties to a User Profile property set:

  1. Select the User Profile in the Navigator window.
  2. In the Palette window, drag one of the following property types into the Editor window:
    • Single Unrestricted – A single unrestricted property can have only one value, but you can enter any value. For example, Country, Last Name, or Age.
    • Single Restricted – A single restricted property can have only one value, and you are restricted to selecting that value from a predefined list. For example, a Browser property could have possible values of Internet Explorer, Netscape, Opera, or Mozilla.
    • Multiple Unrestricted – A multiple unrestricted property can have multiple values, and you can enter any values. For example, an email property could contain one or more e-mail addresses.
    • Multiple Restricted – A multiple restricted property can have multiple values, and you are restricted to selecting the values from a predefined list. For example, a Forms property could allow a user to select a document, such as 1040EZ, 1040A, or 1040.
    • Figure 5-2 shows the property types for a property set.

      Figure 5-2 Drag a Property Type, Such as Multiple Restricted, to the User Profile Editor


       Drag a Property Type, Such as Multiple Restricted, to the User Profile Editor

  3. Select the Properties tab and select the Data Type for the property value. Select one of the following values from the drop-down list: Text, Numeric, Float (decimal), Boolean (true or false), or Date/Time. A Date/Time property must be java.sql.Timestamp type. Your selection determines the dialog box you see when you edit the Value field. For example, properties with a Boolean data type are automatically set to single restricted. If you edit the Data Type, the change removes anything previously entered in the Value field, because the types of values change.
  4. Figure 5-3 shows how to configure a multiple restricted type to reflect three sales regions called Americas, APAC, and EMEA. You could use this Sales Region property to target sales employees with personalized content.

    Figure 5-3 Enter User Profile Details in the Property Editor


    Enter User Profile Details in the Property Editor

  5. In the Selection Mode and Value Range fields in the Property Editor in Workshop for WebLogic, you can change the type of property. This field will already be populated, based on the type of property you dragged from the Palette window, but you can change a property from single unrestricted to multiple restricted.
  6. Note: Any change to Data Type, Selection Mode, or Value Range fields replaces anything previously entered in the Value field because the number of allowed values changes.

    Use the Value field to enter values for restricted types or to set the default value for unrestricted types. Click the ellipsis icon (...) to enter values. (If you picked Restricted in the Value Range field, enter the value in the Enter Property Value dialog box that appears and click Add after each entry. Click OK after you enter all values. If you picked Unrestricted in the Value Range field, enter the value in the Enter Property Value dialog box and click OK.) Any values you enter in this field will be removed if you change the Data Type, Selection Mode, or Value Range.)

    The properties you enter in the Property Editor appear in the User Profile Editor, as shown in Figure 5-4.

    Figure 5-4 View the Properties in the User Profile Editor


    View the Properties in the User Profile Editor

  7. After you add all the properties, save the file by choosing File > Save.
  8. Use the Administration Console to view the User Profile you set up in Workshop for WebLogic.
WARNING: You can also use the Property control to programmatically create and manage properties. However, properties created with this control do not appear in the Administration Console. You must modify and update them programmatically.

 


Editing Properties and Values

You can use Workshop for WebLogic to create User Profiles and the profile’s default values. You can edit the profile’s values in Workshop for WebLogic or in the Administration Console. See Editing User Profile Property Values for instructions on editing the values for property sets in the Administration Console.

This section contains the following topics:

Editing Properties and Values in the Property Editor

Developers use the User Profile editor in Workshop for WebLogic to create a User Profile and add the profile’s properties. Then you can edit properties and their default values that are part of each User’s Profile.

Perform the following steps to modify properties and their values in Workshop for WebLogic:

  1. Double-click the property set file in the Navigator window.
  2. Select the property in the User Profile Editor that you want to modify.
  3. Change the property or its value in the Property Editor window.
Tip: You can edit property values in the Administration Console.

Editing Properties and Values with JSP Tags

The <profile:getProperty> JSP tag retrieves property values for a specified property set. The <profile:setProperty> JSP tag updates a property value for either the session's current profile or for the Anonymous User Profile.

Typically, the <profile:getProperty> tag is used after the <profile:getProfile> tag is invoked to retrieve a profile for session use. The <profile:getprofile> JSP tag retrieves a User Profile and its properties. The <profile:getProperty> and <profile:setProperty> JSP tags let developers retrieve and rapidly edit properties for a large number of users. If the <profile:getProfile> tag was not used after you used the <profile:getProperty> tag, the specified property value is retrieved from the Anonymous User Profile.

See the Javadoc for more information on the Java class.

You can retrieve an authenticated User Profile by using the <profile:getProfile> JSP tag in a Page Flow as shown in the code sample in Listing 5-1.

Listing 5-1 Retrieve an Authenticated User Profile with the <profile:getProfile> Tag
<%@ page import="com.bea.p13n.usermgmt.SessionHelper"%>
<%@ taglib uri="http://www.bea.com/servers/p13n/tags/usermanagement"
prefix="profile"%>
<%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
<%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
Profile is: [<code><%= SessionHelper.getProfile(request) %></code>]<br>
<%-- This tag works for authenticated users. --%>
<profile:getProfile profileKey="<%=request.getUserPrincipal().getName()%>"
profileId="profile"/>
Profile is: [<code><%= profile %></code>]<br>

<%-- You would generally want to do this in your PageFlow, not your JSP. --%>
<netui-data:declareControl controlId="profileControl"
type="com.bea.p13n.controls.profile.UserProfileControl"/>
<netui-data:callControl resultId="getProfileFromRequestResult"
controlId="profileControl" method="getProfileFromRequest">
<netui-data:methodParameter
value="{request}"></netui-data:methodParameter>
</netui-data:callControl>
Profile is: [<code><netui:label value="
{pageContext.getProfileFromRequestResult}"></netui:label> </code>]<br>

If the user is registered, then the profile can be retrieved without a reference to the session, as shown in the code sample in Listing 5-2. This method is useful if you do not have access to the session object.

Listing 5-2 Retrieve a Registered User’s Profile Without a Session Reference
import com.bea.p13n.usermgmt.profile.ProfileFactory;
import com.bea.p13n.usermgmt.profile.ProfileNotFoundException;
import com.bea.p13n.usermgmt.profile.ProfileWrapper;
import java.rmi.RemoteException;
public class MyHelper
{
public static String helperMethod(String username)
{
try
{
ProfileWrapper profile =
ProfileFactory.getProfile(username,null);
// do something helpful here.
return profile.toString();
}
catch (RemoteException ex)
{
}
catch (ProfileNotFoundException ex)
{
}
return null;
}

For anonymous and tracked anonymous users, you must retrieve the profile from the session. Anonymous profiles have no identity. Tracked anonymous profiles have an identity that is not valid for authentication. A safe way to retrieve the identity for a user, based upon the User’s Profile type, is shown in Listing 5-3. This code sample retrieves the current ProfileWrapper and gets the username associated with the wrapper.

Listing 5-3 Retrieve a User’s Identity by Retrieving the Current ProfileWrapper
<%@ page import="com.bea.p13n.usermgmt.SessionHelper"%>
Profile Id is: [<code><%= SessionHelper.getUserId(request) %></code>]<br>

Use the following returned values to determine the user type:

Editing Properties and Values with Controls

Developers use the getProperty and setProperty actions in the Property control to let users retrieve property values for a property set and update property values for either the session's current profile or for the Anonymous User Profile.

WARNING: Properties created with this control do not appear in the WebLogic Portal Administration Console, and you must modify and update them programmatically.

For more information on using the Property control and its properties, see the Controls Javadoc.

Listing 5-4 shows how a user can use the setProperty action in the Property control to edit a Profile Wrapper. An example Page Flow (and associated JSP) that uses controls to offer a form for the user to set a favorite color is shown in the code sample. This example requires a Generalnfo.usr User Profile property set file to exist in the \userprofiles folder of the data project, with a single-valued, restricted, text FavoriteColor property. For more information, see the help in Workshop for WebLogic.

Listing 5-4 Use this index.jsp file with the Page Flow
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
<%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
<%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
<netui:html>
<body>
<netui:form action="setColor">
<table>
<tr valign="top">
<td>Favorite Color:</td>
<td>
<netui:select dataSource="{actionForm.color}"
defaultValue="{pageFlow.usersColor}"
optionsDataSource="{pageFlow.possibleColors}">
</netui:select>
</td>
</tr>
</table>
<br/>&nbsp;
<netui:button value="Set Color" type="submit"/>
</netui:form>
</body>
</netui.html>

Editing Properties and Values with the ProfileWrapper Object

Developers can change User Profile property values by calling the ProfileWrapper object directly. For more information, see the Javadoc.

 


Deleting a Property Set and Properties

You can use Workshop for WebLogic to delete individual properties from a property set, or you can delete an entire property set.

This section includes the following topics:

Deleting a Property

Perform the following steps to delete individual properties from a property set:

  1. In the Workshop for WebLogic Navigator window, expand the data\src\userprofiles folder, and double-click the User Profile property set you created.
  2. Select the property in the User Profile Editor window.
  3. Right-click the property and choose Delete. The property is deleted from the User Profile property set.

Deleting a Property Set

Perform the following steps to delete a property set:

  1. In the Workshop for WebLogic Application window, right-click the data\src\userprofiles folder, and select the User Profile you created.
  2. Right-click the property set and choose Delete to remove the property set.
  3. Click Yes to confirm the deletion.

You can also use the <profile:removeProperty> JSP tag or the removeProperty action in the Property control in your page flows to remove existing properties or profiles for users. See the Javadoc for more information.

Using Properties from an External User Store

If you created a UUP to access external user or group properties, you can use those properties to define rules for Personalization, Delegated Administration, or Visitor Entitlement.

After you create a UUP to access these properties in the external user store (for example, an openLDAP server) you can access those external properties only through WebLogic Portal's JSP tags, controls, or APIs. Those external properties are not yet accessible in the Administration Console.

You must surface those external properties in the Administration Console if you want to use those properties in defining rules for Personalization, Delegated Administration, or Visitor Entitlement.

Note: If the properties you surface from an external user store are read-only, you cannot update them in the Administration Console. To make those properties writable, your custom UUP would have to become writable.
  1. Create a UUP for the external user store. See Configuring a UUP for instructions.
  2. In Workshop for WebLogic, create a User Profile property set for the external user store. The name you give the property set must match the name of the provider’s PropertyMapping. To find the name of the property set, perform the following steps:
    1. Look in your enterprise application root directory and open the META-INF/p13n-profile-config.xml file.
    2. In the <!-- User Profile Manager --> section, locate the name entry for your external user store, such as:
    3. <property-adapter>
      <name>MyExternalStore</name>
      <property-mapping>MyExternalPropertySet</property-mapping>
      <ejb-jndi>my_uup.jar#ExternalEntityPropertyManager</ejb.jndi>
      </property-adapter>

      The name following the property-adapter line is the name you must give to the new property set. The name is case sensitive. For example, in the example shown, the property set would be named MyExternalStore.usr.

    4. If you are using the LDAP UUP provided by WebLogic Portal, name the property set newldap.usr.
  3. Add properties to the property set that exactly match the property names in the external store you want to surface.
  4. Save the property set file.
Note: After you have deployed your portal application to production, any modifications you make to User Profile properties in Workshop for WebLogic must be pushed to the running server. For more information, see the Production Operations Guide.

  Back to Top       Previous  Next