Porting Stock Quote Custom Provider From Sun ONE
by Jagruti Trivedi
|
| 1) content.template | Views the description file for Channel content |
| 2) edit.template | Views the description file for the edit page |
| 3) iwtStockQuote.java | Provides the Stock Quote Service for Custom Provider |
| 4) StockService.java | Defines the basic elements for a stock service provider |
| 5) QuoteDataType.java | Encapsulates the quote properties that are going to be displayed in the stock quote |
| 6) YahooStockService.java | Implements the stock service using the Yahoo! quote server |
| 7) iwtStockQuote.xml | Displays the profile properties of the Provider |
Testing the Stock Quote Custom Provider Application on Sun ONE Portal Server 3.0 explains the workings of the Stock Quote Custom Provider application on Portal Server 3.0. In addition, it provides Quote.tar, which consists of all files that comprise the Stock Quote application for Portal Server 3.0. Finally, it demonstrates the process of how to test the Stock Quote application.
3. Identifying the Files to Change and Making Changes
From the list of files mentioned in Section 2, only two files need to be changed. The first is iwtStockQuote.java, which acts as an interface between Portal Server 3.0 and the content display that uses the Provider API. The second is iwtStockQuote.xml, which describes the Display Profile properties for Provider and Channel.
The template syntax has not changed from PS 3.0 to PS 6.0 so, there is no need to modify the content.template and edit.template files.
Sun ONE Portal Server 6.0 Migration Guide Appendix C describes the API changes. Because of these changes, if the user tries to compile the files from Portal Server 3.0 for use on Portal Server 6.0 without making any changes, they will get numerous compiler errors. This is because:
A. Portal Server 3.0 uses the Java 2 Platform, Standard Edition (J2SE), version 1.2, whereas Portal Server 6.0 uses J2SE version 1.3.1_04. This requires JAVA_HOME to point to the appropriate Java platform version.
B. The .jar files needed are different; use the following settings:
CLASSPATH=$(BASEDIR)/SUNWps/sdk/desktop/desktopsdk.jar:
$(BASEDIR)/SUNWam/lib/servlet.jar:
$(BASEDIR)/SUNWam/lib/am_services.jar:
$(BASEDIR)/SUNWam/lib/am_sdk.jar
C. API changes have been made, as was mentioned previously.
This section will enumerate the API changes that affect the Stock Quote application.
* package name changes:
com.iplanet.portalserver.* to com.sun.portal.*
* com.iplanet.portalserver.util.Debug has been moved to com.iplanet.am.util.Debug
It is good practice to use ProviderContext from the com.sun.portal.providers.context package for debugging functionality.
- use getProviderContext().debugMessage("message here")
- use getProviderContext().isDebugMessageEnabled
* The Portal Server 3.0 DesktopURL(getSession(),...) method assists in generating URLs for access to desktop applications.
In Portal Server 6.0, this functionality is now available from the ProviderContext method pc.getDesktopURL(req),...
This method throws a java.net.MalFormedURLException, so be sure to have an appropriate import statement.
* Relevant signature changes have been made to the following methods:
init(Session) --> init(HttpServletRequest)
In ProfileProviderAdapter - the three major methods have undergone signature changes:
getContent(Map) -->
getContent(HttpServletRequest req, HttpServletResponse
res)
getEdit(Map) -->
getEdit(HttpRequest req, HttpServletResponse res)
processEdit(Map) -->
processEdit(HttpServletRequest, HttpServletResponse)
This makes it necessary to remove and add the following packages.
Remove
com.iplanet.portalserver.session.Session
Remove
com.iplanet.portalserver.session.SessionException
Remove
com.iplanet.portalserver.util.Debug
Remove
com.iplanet.portalserver.profile.*
Add
com.sun.portal.providers.ProviderException
Add
javax.servlet.http.HttpServletRequest;
Add
javax.servlet.http.HttpServletResponse;
Note: 1. The methods getContent(), getEdit() and processEdit() with the Map argument are deprecated so, it is good practice to use the above methods with the HttpServletRequest,HttpServletResponse argument.
Note: 2. The methods with the arguments HttpServletRequest and HttpServletResponse removes the dependency on specific service APIs, and makes them a separate service layer.
* Usage changes for the following methods:
- use getStringProperty(tag,default)
This method requires a try/catch
block because the method throws a
ProviderException
- use getTemplate(...) in
place of TagSwapper.doswap()
- use HttpServletRequest.getParameter() for
Channel,container etc., parameters
* Delete the following methods:
- TagModuleManager
- store()
In Making Manual Changes in the iwtStockQuote.java File you can see the manual changes you need to make when converting from PS 3.0 to PS 6.0. This file includes code for both PS 3.0 and PS 6.0. It is color-coded to indicate which lines in the PS 3.0 code must be deleted or changed for PS 6.0. It also includes color-coded lines that must be added for PS 6.0.
For a detailed and comprehensive list of changes between Sun ONE Portal Server 3.0 and Sun ONE Portal Server 6.0, please refer to Sun One Portal Server Migration Guide Appendix C.
QuoteStock6.0.tar contains a complete package of all the files ported for Stock Quote Custom Provider for Portal Server 6.0 in a tar format. Untar the file and follow the steps described in Section 4 for manual loading/deploying.
D. Changes in the Structure of the Display Profile in the .xml File
The second file that needs to be changed is iwtStockQuote.xml. The Display Profile structure has changed significantly from PS 3.0 to PS 6.0. The following describes the mapping of XML from PS 3.0 to PS 6.0, with regard to the sample Stock Quote Custom Provider application.
The Provider preference properties (that is, favorites) go into the Provider Display profile definition. In addition to the preferences, other Provider-related information like title, description, isEditable, editType, width, helpURL, and refreshTime go into the Provider Display profile definition.
Remaining properties that are related to the display of the Channel with respect to other Channels like row, column, hasFrame, isDetached, isMinimized, isMinimizable, isDetachable, isMovable, isRemovable, etc., go into the tablecontainer display profile in which this Channel is contained. The property names are not exactly the same. Please refer to the Developers' Guide for more information.
In addition, the Provider Display Profile also contains fontFace1 and productName.
The following properties go into the tablecontainerprovider Display Profile, which contains the Channel based on this Provider:
row ->
channelsRow Collection
column ->
channelsColumn Collection
hasFrame ->
channelsHasFrame Collection
isMovable ->
channelsIsMovable Collection
isRemovable ->
channelsIsRemovable Collection
font face="Courier New,Courier">isDetached ->
channelsIsDetached Collection
isDetachable ->
channelsIsDetachable Collection
isMinimized ->
channelsIsMinimized Collection
font face="Courier New,Courier">isMinimizable ->
channelsIsMinimizable Collection
Other preferences like favorites go into Collection.
For example: In PS 3.0, iwtStockQuote.xml is
<iwt:Component
name="iwtStockQuote"
ver="1.0"
desc="Display Stock Quotes"
resB="iwtStockQuote"
idx="a100">
</iwt:Att>
<iwt:Att name="iwtStockQuote-description"
type="string"
idx="a100"
userConfigurable="false"
>
<Val>Display Stock Quotes</Val>
<Rperm>ADMIN</Rperm>
<Rperm>OWNER</Rperm>
</iwt:Att>
In PS 6.0, iwt6SQ.xml becomes
<Provider
name="ietStockQuote" class="Quote.iwtStockQuote">
<Properties>
<String name="title" value="Stock Quote"/>
<String name="iwtStockQuote-description" value="Display Stock Quote"/>
</Properties>
</Provider>
There is no tag like iwt:.
Following is an example of Collection:
In PS 3.0:
<iwt:Att
name="iwtStockQuote-favorites"
type="stringlist"
desc="Favorite Quotes"
idx="a200"
userConfigurable="true"
>
<Val>SUNW</Val>
<Val>CSCO</Val>
<Val>SBUX</Val>
<Wperm>ADMIN</Wperm>
<Wperm>OWNER</Wperm>
<Rperm>ADMIN</Rperm>
<Rperm>OWNER</Rperm>
</iwt:Att>
In PS 6.0:
<Collection
name="favorites">
<String name="sunw" value="SUNW"/>
<String name="ge" value="GE"/>
<String name="utx" value="UTX"/>
</Collection>
Following is a complete Portal Server 6.0 iwtStockQuote.xml file:
<?xml version="1.0"
encoding="utf-8" standalone="no"?>
<!DOCTYPE
DisplayProfile SYSTEM "jar://resources/psdp.dtd">
<Provider name="StockQuote6Provider" class="Quote.iwtStockQuote">
<Properties>
<String name="title" value="Stock Quote"/>
<String name="description" value="desktop quote 6.0 porting provider"/>
<String name="refreshTime" value="0" advanced="true"/>
<String name="helpURL" value="desktop/userinfo.htm" advanced="true"/>
<String name="fontFace1" value="Sans-serif"/>
<String name="productName" value="Sun ONE Portal Server"/>
<String name="width" value="thin"/>
<String name="editType" value="edit_subset" advanced="true"/>
<Collection name="favorites">
<String name="sunw" value="SUNW"/>
<String name="ge" value="GE"/>
<String name="utx" value="UTX"/>
</Collection>
<Boolean name="isEditable" value="true" advanced="true"/>
</Properties>
</Provider>
NOTE: Use only upper or lowercase alphabetic characters and digits in Provider Name and Channel Name.
4. Loading/Deploying the Stock Quote Custom Provider Manually for Testing
There are three ways to load/deploy the custom Provider:
This document shows you manual loading for testing purpose. The added benefit to this method is that it gives the user a better idea of how the actual components get loaded.
Steps for Manual Loading:
1. Compile the source files that are changed for code conversion.
2. Create a directory structure that reflects the packaging of the Provider, under the user-defined class directory:
mkdir /etc/opt/SUNWps/desktop/classes/Quote
3. Copy the provider class into this directory:
cp xxx.class /etc/opt/SUNWps/desktop/classes/Quote
4. Create a directory that reflects the packaging of this provider under default directory:
mkdir /etc/opt/SUNWps/desktop/default/Quote
5. Copy the template files into this directory:
cp /etc/opt/SUNWps/desktop/default/Quote
6. Load the provider using the dpadmin command.
/opt/SUNWps/bin/dpadmin add -u
"-uid=amadmin,ou=People,o=Myorg.Sun.COM,o=isp"
-w password -g iwtSQ.xml
Note: Please make any necessary changes to reflect your organization name, console login and password if you are not using the existing settings.
7. To access the Channel content, the user needs to create the Channel. Here we use the DSAME GUI method instead of the dpadmin command to create the Channel via the newly-installed Custom Provider.
5. Creating a Channel Using the DSAME (Console) GUI
Users can create a Channel using dpadmin, but using the DSAME GUI is simpler. Creating a Channel Using the DSAME (Console) GUI shows this process.
6. Testing the Sample Stock Quote Application
See Testing the Sample Stock Quote Application on Sun ONE Portal Server 6.0.
7. References:
1) Portal Server 6.0 Migration Guide Appendix C
2) Portal Server 6.0 Developer's Guide
3) Portal Server 6.0 Installation Guide
4) Portal Server 3.0 Installation Guide
DOC ID# 1842