Previous     Contents     Index     Next     
iPlanet Portal Server Reference Guide



Chapter 5   Content Provider API




Content Provider Overview

The iPlanet Portal Server software allows multiple sources of information, applications, and services to be displayed within a single page or set of pages that the user can view in a browser. The page in which the content is included is known as the desktop. The various sources of content are displayed in rectangular areas arranged in rows and columns within the desktop called channels. A Java class, called a provider, is responsible for converting the content in a file, or the output of an application or service into the proper format for a channel. A number of providers are shipped with the Portal Server including a bookmark provider, an application provider, and a notes provider. As the desktop is imaged, each provider is queried in turn for the content of its associated channel. Some providers are capable of generating multiple channels based upon their configuration. This chapter details the basics of developing new content channels for the desktop and introduces a sample provider.


Content Provider Functionality

The iPlanet Portal Server desktop is designed to have four possible content layouts, with various combinations of `thick' and `thin' columns. The main desktop layout template consists of basic HTML to define the look (colors, logo, etc.) of the page, and tags designed to be replaced with the content for each of the columns.

The content for the columns will be provided by providers, which are custom Java classes. The Java classes are invoked by the desktop Servlet and the output is inserted into the output of the entire desktop for display. Each provider may define the look of the content section of part, or, the whole layout.

Channels can define their width as either thick or thin. This loosely defines the amount of horizontal screen real estate for the channel; a thick channel subjectively gets more horizontal screen real estate than a thin one. The absolute width is dependent upon the size of the browser window. A channel will expand veritcally as needed; there is no restriction on vertical sizing of a channel. Providers designed for the `thin' column should not be placed in the `thick' column and vice-versa.



Using the Sample Providers



The iPlanet Portal Server package includes several sample Content Providers in the SUNWips package. The following sections explain the process to compile the providers, and add them to an existing iPlanet Portal Server installation.

See the iPlanet Portal Server Administration Guide for information on adding custom providers.



Tip See Appendix B, "Putting Code Together", an iPlanet Portal Server desktop provider sample application that touches on the public APIs available for integrating an application with the iPlanet Portal Server desktop.




Compiling Sample Provider Code

Before compiling the sample provider code, set certain environment variables:

  • setenv PATH $PATH:/usr/java/bin:/usr/ccs/bin

  • JAVA_HOME to the Java directory (usually /usr/java)

  • IPS_BASE to the product installation directory (usually /opt)

To compile the Sample Providers, use the following process:

  1. Change to the top level of the samples directory.


    # cd /opt/SUNWips/samples

  2. Make the samples:


    # make



    Tip Create a short shell script to more easily recompile the samples. The following sample works well with a default installation.

    #!/bin/sh
    JAVA_HOME=/usr/java
    IPS_BASE=/opt
    export JAVA_HOME IPS_BASE IPS_ROOT
    cd $IPS_ROOT
    make





Implementing the Content Provider API

To use the Content Provider API, develop classes that implement or extend the ProfileProviderAdapter, or the ProviderAdapter.



Note Complete documentation for all methods and classes is in the Javadocs, available in the installation at: http://yourserver:port/docs/en_US/javadocs




Provider Sample Code

The following sample code implements a minimal Provider (HelloWorld). Compile this code as above, then use the process documented above to add this provider to the Portal Server system.

Code Example 5-1 HelloWorld Content Provider 

package com.iplanet.portalserver.providers.helloworld;

import java.lang.*;
import java.util.Map;

import com.iplanet.portalserver.providers.*;

/**
* This class implements a provider that prints the hello world message.
* It does not use the iPS Profile Service.
* <p>
* This class
* only overrides the methods in the class <code>ProviderAdapter</code>
* that it needs to customize. In a production environment, you should
* always implement all of the method in the <code>Provider</code> interface.
* <p>
* When installing this class, you MUST register it with the desktop under
* the same name returned by the <code>getName()</code> method!
*/

public class HelloWorldProvider extends ProviderAdapter implements Provider {

public HelloWorldProvider() {
}

public StringBuffer getContent(Map m) throws ProviderException {
StringBuffer content = new StringBuffer("Hello World!");

return content;
}

public String getTitle() {
return "Hello World Provider";
}

public String getDescription() {
return "This provider says 'Hello World!'";
}

public String getName() {
return "iwtHelloWorldProvider";
}

public String getBackgroundColor() {
return "#CCCCCC";
}
}


Previous     Contents     Index     Next     
Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.

Last Updated May 04, 2000