AquaLogic User Interaction Development Guide

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

Implementing a Profile Service

To implement a profile service, follow these step by step instructions.

This section describes the details of how to create a profile service by taking you step by step through the implementation of a sample profile service. This is a very simple profile service, and is not intended for use in a production environment.

The functional requirement for this profile service is simply:


  • For any request, return the user's profile property "REGION" set to "WEST".

The following interfaces will be implemented to create this profile service:


  • IProfileProvider
  • IUser

These interfaces are in the Plumtree.Remote.Profile namespace (C#) or the plumtree.remote.profile package (Java). Any exceptions thrown in this code can be found in Plumtree.Remote (C#) or plumtree.remote (Java).

For the complete code of this example, see the sample code on the Developer Center.

For details of the classes described in this section, see the IDK API documentation for .NET or Java.

Except for in the example Java code, this section uses C# method names. In the IDK, methods are named the same in C# or Java, except for leading letter capitalization. For example, IProfileProvider.GetGlobalSignature() in the C# API is IProfileProvider.getGlobalSignature() in the Java API.

  1. Implement the IProfileProvider Interface

    The IProfileProvider interface is used by the portal to initiate access to, and obtain user profile information from, the back-end repository. The portal calls the methods of IProfileProvider in the following order:


    1. IProfileProvider.Initialize()
    2. IProfileProvider.GetGlobalSignature()
    3. IProfileProvider.AttachToUser()
    4. IProfileProvider.Shutdown()

    To implement the IProfileProvider interface:

    1. Implement IProfileProvider.Initialize

      Initialize() allows the profile service to initialize a session and create a connection to the back-end repository. The method is passed two objects from the portal: PropertyList and ProfileInfo. PropertyList is the list of attributes mapped to properties on the Property Map page of the Profile Source object in the portal. ProfileInfo is a set of name-value pairs, populated with information entered in the portal Service Configuration Interface (SCI) editor by a portal administrator. Typically, this is information such as credentials for connecting to the back-end system.

      Java:

      private String[] m_propertyList;
      protected String[] getPropertyList()
      {
          return m_propertyList;
      }
      public void initialize(String[] propertyList,
                     ProfileInfo profileInfo)
        throws ServiceException
      {
          this.m_propertyList = propertyList;
      }

      C#:

      private string[] m_propertyList;
      internal string[] GetPropertyList()
      {
         return m_propertyList;
      }
      public void Initialize(string[] PropertyList,
                     ProfileInfo ProfileSourceInfo)
      {
          this.m_propertyList = PropertyList;
      }

      In this example profile service, the PropertyList is stored in the m_propertyList member variable, where it can later be accessed by the IUser implementation. The IUser implementation requires the PropertyList to determine which properties to retrieve.

    2. Implement IProfileProvider.GetGlobalSignature

      GetGlobalSignature() allows the portal to determine whether profile information for any of the users has changed. The portal compares the string returned from GetGlobalSignature() with the string returned from GetGlobalSignature() during the previous run of the profile service job. If the two strings match, the job stops. The IDK does not enforce any restrictions on the string used for the global signature; it can be a last-modified date, a random number, or another identifier.

      Java:

      public String getGlobalSignature()
        throws ServiceException
      {
          return new Date().toString();
      }

      C#:

      public string GetGlobalSignature()
      {
          return System.DateTime.Now.Ticks.ToString();
      }

      This profile service returns a string representation of the current date and time. This ensures the job will continue to AttachToUser().

    3. Implement IProfileProvider.AttachToUser

      AttachToUser() is called for each user within the group or groups configured in the Profile Source editor in the portal. The first three parameters passed to AttachToUser() identify which user the profile service should retrieve from the back-end system:


      • UserID: The portal user ID. Can be used via the PRC to look up other user attributes.
      • LoginName: The portal login name. If this user was added using an authentication service, this value corresponds to ChildUser.UserName.
      • UniqueName: Usually the name used to look up the user in the back-end system. If the user was added using an authentication service, this value corresponds to ChildUser.UserUniqueName.

      If these parameters do not identify a valid user, a NoSuchUserException should be thrown.

      The final parameter, LastSignature, is the signature returned by IUser.GetUserSignature() during the previous job.

      Java:

      public IUser attachToUser(int userId, String loginName,
                      String uniqueName, String lastSignature)
        throws ServiceException
      {
          return new User(this);
      }

      C#:

      public IUser AttachToUser(int UserID, string LoginName,
                      string UniqueName, string LastSignature)
      {
          return new User(this);
      }

      For this profile service, AttachToUser() simply returns an instance of User, the IUser implementation. This is appropriate for this implementation because the profile service updates the "Region" property to "WEST" regardless of the portal user being queried.

    4. Implement IProfileProvider.Shutdown

      As a performance optimization, the portal might call the Shutdown() method. No parameters are received or returned. This method is optional on both ends; the profile service might not receive the Shutdown message, and, if received, the profile service can ignore the call to Shutdown().

      Shutdown() can be used to clean up resources used by the profile service; however, you should not rely on it being called.

  2. Implement the IUser Interface

    Returned by IProfileProvider.AttachToUser(), the IUser interface is used by the portal to synchronize profile property information for a specific user. The portal calls the methods of IUser in the following order:


    1. IUser.GetUserSignature()
    2. IUser.GetUserProperties()
    Note: For this profile service, the IUser interface implementation, User, has a constructor that accepts a parameter of type Profile (the IProfileProvider implementation), which is stored in the private member m_profile. This is variable is used in GetUserProperties() to access the PropertyList.
    1. Implement IUser.GetUserSignature

      GetUserSignature() is similar to IProfileProvider.GetGlobalSignature(), except it allows the portal to determine if a specific user's profile information has changed. If the returned string matches the string returned from GetUserSignature() during the previous job, GetUserProperties() is not called. The IDK does not enforce any restrictions on the string used for the global signature; it can be a last-modified date, a random number, or another identifier.

      Java:

      public String getUserSignature()
        throws ServiceException
      {
          return new Date().toString();
      }

      C#:

      public string GetUserSignature()
      {
          return System.DateTime.Now.Ticks.ToString();
      }

      This profile service returns a string representation of the current date and time. This ensures GetUserProperties() is called each time the job runs.

    2. Implement IUser.GetUserProperties

      Typically, GetUserProperties() will access the PropertyList object from the IProfileProvider implementation, retrieving values for each property in the PropertyList from the back-end system. GetUserProperties then builds a UserPropertyInfo object to return to the portal. The portal maps the back-end property names with portal properties and updates the portal property values.

      Java:

      public UserPropertyInfo getUserProperties()
        throws ServiceException
      {
          String prop;
          UserPropertyInfo info = new UserPropertyInfo();
          for (int i=0; i < m_profile.getPropertyList().length; i++)
          {
            prop = m_profile.getPropertyList()[i];
            if (prop.equalsIgnoreCase("REGION"))
            {
              info.put(prop, "WEST");
            }
          }
          return info;
      }

      C#:

      public UserPropertyInfo GetUserProperties()
      {
          String prop;
          UserPropertyInfo info = new UserPropertyInfo();
          for (int i=0; i < m_profile.GetPropertyList().Length; i++)
          {
             prop = m_profile.GetPropertyList()[i];
             if (prop.ToUpper().Equals("REGION"))
             {
               info.Put(prop, "WEST");
             }
          }
          return info;
      }

      In this profile service, a for loop checks each property in the PropertyList against the string "REGION". If "REGION" is found, a UserPropertyInfo object is updated with name "REGION" and value "WEST" and returned to the portal.


  Back to Top      Previous Next