Home

Sun ONE Portal Server 6.2 Developer`s Guide

image

Contents

1. I The edit container s getEdit method is invoked and the leaf channel s name is determined from the request parameter II Once the leaf channel s name is determined the channel s isEditable method is invoked to determine if the channel is editable If the channel is determined to be not editable an exception is thrown on the Desktop If the channel can be edited the DesktopServlet also checks the editType for the leaf channel I If the leaf channel s edit type is EDIT COMPLETE the container calls the leaf channel s get Edit method and displays the edit page on the Desktop Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of the Provider API and Desktop Servlet EDIT SUBSET the container calls the leaf channel s getEdit method and the container s Edit Container wraps the leaf channel s content before displaying the Edit page ont the Desktop A container can define different edit container and the edit container name must be specified as well as the target channel name The default Desktop edit container name is stored in the Identity Server as a Desktop service attribute o EDIT SUBSET the Desktop servlet fetches the name of the edit container to use to wrap the channel s edit page The servlet fetches a handle to the edit container and then calls the edit container s get Edit method The edit container detects the original cha
2. examples WEB INF web xml portlet xml classes examples HelloWorldPortlet class 4 Create the WAR file That is change directories to examples and type the following command jar cvf examples war Deploy the Application The Sun ONE Portal Server software includes a deployment tool which will take your WAR file and deploy it into the portal server Before deploying the WAR file determine where to place the portlets inside the organization With the following command the sample portlets can be deployed into the organization pdeploy deploy u uid w adminpassword g d distinguishedname p ContainerAdminPassword examples war For more information on the pdeploy command see Sun ONE Portal Server 6 2 Administrator s Guide Chapter6 Developing and Deploying Portlets 177 Files Used by Portlets Create Channels from the Deployed Portlets Once the portlet is deployed the portal server is aware of the portlet defined in the application You can start to create channels based on the portlet To create channels see Sun ONE Portal Server 6 2 Administrators Guide for more information Files Used by Portlets portlet xml All portlet and portlet related configurations must be specified in the portlet xml file Each port let xml file contains one or more portlet definitions Each portlet definition defines information such as the portlet name portlet class portlet preferences and init parameters
3. Example Use of the RDM API to submit a query include lt stdio h gt include soif h include rdm h define MY_SCOPE varrius define MY_CSID x catalog budgie siroe com 6714 searchl define MY ATTR VIEW title content type int main int argc char argv RDMQuery myquery NULL CSID csid NULL RDMHeader myheader NULL SOIFStream out SOIF_PrintInitFile stdout Create the RDMQuery and specify its scope if myquery RDMQuery Create MY SCOPE perror RDMQuery_Create n exit 1 Set the view attributes of the RDMQuery RDMQuery SetViewAttr myquery MY ATTR VIEW Create the CSID that points to your search engine instance if csid CSID_Parse MY_CSID perror CSID Parse n exit 1 Create the RDMHeader if myheader RDMHeader_CreateRequest RDM_RD_REQ search csid perror RDMHeader_CreateRequest n exit 1 print the RDMHeader to the output SOIF stream print the RDMQuery to the output SOIF stream 230 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example of Submitting a Query Example 9 1 RDM API to Submit a Query Example Continued out gt print out myheader gt soif out gt print out myquery gt soif free the structures and exit RDMHeader Free myheader RDMQuery_Free myq
4. insert delete update Using Java To Add Entries to the Search Engine Database Default operation The server adds the RDs supplied as data The server deletes the RDs As with retrieve it is sufficient to list the RDs by url alone it is not necessary to supply values for the fields of the RDs The server modifies the RDs in the database by merging any existing fields with the fields supplied in the data If an attribute view list is supplied only those attributes will be updated The submit types are as follow persistent non persistent merged Data is added to the persistent part of each RD in the database When an RD is retrieved from the database or indexed any persistent fields take precedence over non persistent fields This allows you to manually edit the fields of an RD without having to worry that your edits will be lost the next time the RD is submitted by the robot for example This is the default type Data is normally added as non persistent data This is the default for retrieval When data is retrieved the persistent and non persistent fields are merged together with the persistent fields taking precedence over the non persistent fields You can view this as the persistent fields covering the non persistent fields Chapter 10 Using Java to Access the Search Engine Database 255 Using Java To Add Entries to the Search Engine Database 256 Sun ONE Portal Server 6 2 Developer s Guide
5. add sp Run as an application public static void main String argv throws Exception int args argv length String SOIFOutputFile null if args 1 amp amp args 2 amp amp args 3 System out println args RDMServer query soif_output_file_name return String rdm argv 0 rdm search server eg http portal siroe com 2222 ps search SimpleSearch ss new SimpleSearch rdm if args 3 args ss setSOIFfile argv 2 dump raw soif results to this file if args 1 run from a search box Frame f new Frame SearchPanel sp new SearchPanel ss f add sp f pack f show else run from command line String query argv 1 ss doSearch query 246 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Using Java To Access the Search Server Database There is a helper class called SearchPanel which handle the applet GUI It sets up a search panel with a text box to enter a query and a submit button to run the query See the source file for more details Define the SimpleSearch Class Notice the private helper class SimpleSearch This is where the search is set up and executed and we will look at it in more detail here The applet command line class SearchDemo sets up the arguments for SimpleSearch using either applet or command line parameters It then calls the SimpleSearch doSearch String scope method to execute the sea
6. lt Channel name CustomXML provider CustomXMLProvider gt lt Properties gt lt String name refreshTime value 600 advanced true gt lt String name title value XML Test Channel gt lt String name description value This is a test of the CustomXMLProvider gt lt String name url value gt lt String name xslFileName value html_stockquote xsl gt lt Properties gt lt Channel gt 4 Use the dpadmin command to upload the display profile fragments for this provider For the CustomXMLProvider use the dpadmin command to upload the CustomXMLProvider xml and CustomXMLChannel xml file XML fragments in the display profile That is type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomXMLProvider xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomXMLChannel xml Chapter 4 Using Leaf Providers 111 XMLProvider 5 Include the new channel in one of the existing containers The CustomXMLProvider channel will be displayed in JSPTableContainer To add the channel in the JSPTableContainer from the administration console follow instructions in the Sun ONE Portal Server 6 2 Administrators Guide To add the channel in the JSPTableContainer manually a Develop the CustomXMLProvider channel XML fragment in the CustomxMLContainer xml file for the JSPTableContainer The CustomXMLProvide
7. Code Example 4 10 CustomURLScraperProvider java File import import import import import import public package custom java util List java util Hashtable java util Random com sun portal providers urlscraper URLScraperProvider com sun portal providers ProviderException com sun portal providers context ProviderContextException class CustomURLScraperProvider extends URLScraperProvider protected String getURL throws ProviderException List urlList getListProperty urlPool int size urlList size if size 1 return String urlList get 0 Random rand new Random 104 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 4 10 URLScraperProvider CustomURLScraperProvider java File Continued int r rand nextInt size 1 return String urlList get r Code Example 4 11 Compile the class and put it in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory To compile the Cust omURLScraperProvider java file type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar CustomURLScraperProvider java Dev
8. Code Example 5 23 Sample Modifications to makeNewTab jsp File Si Copyright 2001 Sun Microsystems Inc All rights reserved PROPRIETARY CONFIDENTIAL Use of this product is subject to license terms 6 lt makeNewTab jsp gt lt page import custom CustomTabContainerProvider 55 lt table border 0 cellspacing 2 cellpadding 2 width 50 gt lt tr gt lt td align right gt lt font face lt fontFacel gt size 0 gt lt b gt Tab Name lt b gt lt font gt lt td gt lt td gt lt font face lt fontFacel gt size 0 gt lt input type text name JSPTabContainer tabName size 30 gt lt font gt lt td gt lt tr gt lt tr gt lt td align right gt lt font face lt fontFacel gt size 0 gt lt b gt Tab Description lt b gt lt font gt lt td gt lt td gt lt font face lt fontFacel gt size 0 gt lt input type text name JSPTabContainer tabDesc size 30 gt lt font gt lt td gt lt tr gt lt tr gt lt td align right gt lt font face lt fontFacel gt size 0 gt lt b gt Tab Topics lt b gt lt font gt lt td gt lt td gt lt start tab topic radios gt lt table border 0 cellpadding 2 cellspacing 2 gt lt String checked Ss lt tab tabContainerProvider gt lt CustomTabContainerProvider ctcp CustomTabContainerProvider pageContext getAttribute JSPProvider List tabTopics ctcp getTabTopics for int i 0 i lt tabTop
9. See chapters 2 through 4 for more information December 2003 Overview of the APIs The PAPI defines the interface for implementing the provider A provider is the programmatic entity responsible for generating channels on the Desktop at runtime The channel properties are read from the display profile by the provider code to dynamically generate the channel content There is not necessarily a one to one mapping between providers and channels a single provider can generate one or more channels depending on how you configure it Building Blocks At the next level of Figure 1 3 on page 18 are the building block providers Building block providers are those providers that are public and that you can extend to create new providers The other providers such as bookmark and mailcheck are not public and are not extensible The building block providers in the figure are all the specific content providers leaves and specific container presentation providers that Sun ONE Portal Server software supplies All these public building block classes are based upon the base PAPI classes As a developer you can extend the Java classes for some of the building block providers An administrator can then use your extended classes to define channels for end user consumption See the Sun ONE Portal Server 6 2 Desktop Customization Guide for more information on the out of the box content providers Desktop Servlet At the top of Figure 1 3 on
10. XMLProvider 108 Index 3 Section X 4 Sun ONE Portal Server 6 2 Developer s Guide December 2003
11. catalog service id 41 x catalog budgie siroe com 6714 budgie rdm version 3 1 0 rdm type 11 rd response rdm response interpret 51 20 results out of 36281 hits across 88985 documents DOCUMENT http fury sesta com 999 it newsref pr newsrelease417 html content type 9 text html score 3 100 title 17 Comunicato stampa DOCUMENT http fury sesta com 999 it newsref pr newsrelease374 html content type 9 text html score 3 100 title 17 Comunicato stampa You can pipe the output of sendrdm which is a SOIFSt ream to another program to print the results of the query API Reference The remaining sections in this chapter describe the RDM API located in directory portal server install root SUNWps sdk rdm include rdm h Chapter 9 Using the RDM API to Access the Search Engine and Database inC 233 Example of Submitting a Query Finding the RDM Version RDM_Version NSAPI_PUBLIC const char RDM_Version void Returns the version of the RDM library Creating and Freeing RDM Structures For most RDMxX structures such as RDMRequest RDMQuery and so on there are two or more creation functions There is usually an RDMX_Parse function which takes SOIF arguments and an RDMX_Create function which takes non SOIF arguments There is also an RDMX_Free function which releases the object Several RDM structures also have an RDMX merge function which merges data f
12. December 2003 Chapter 11 Localizing Sun ONE Portal Server This chapter provides instructions for localizing the customizeable parts of Sun ONE Portal Server software It contains the following sections e Templates and JSPs e Resource Bundles e Display Profile Properties e Localization Support in PAPI Templates and JSPs This section addresses the Desktop templates and JavaServer Pages JSP in the Sun ONE Portal Server software that can be translated to support localization Desktop Templates Template Files The etc opt SUNWps desktop desktoptype directory contains templates that are used to generate the Desktop pages For each directory contained in this directory a new directory for the locale must be created The directory name must contain the existing directory with an underscore and the name of the locale for example etc opt SUNWps desktop default is translated to etc opt SUNWps desktop default_ locale 257 Templates and JSPs NOTE The desktoptype refers to the Desktop type attribute which is now a comma separated list The usage of this attribute is described in Chapter 1 of the Sun ONE Portal Server 6 2 Desktop Customization Guide All of the file names can remain the same Only files that require translation must be created in the locale specific directory If a file is not found in the locale specific directory it is automatically taken from the directory that does not have the locale s
13. example3 example3 o CC o 0 SDKLIB example4 example4 o CC o 0 SDKLIB 4 From the portal server install root SUNWps sdk rdm examples directory build the example as follows Solaris gmake 5 From the portal server install root SUNWps sdk rdm examples directory run the example4 c program to generate the RDM file example4 c gt rdm soif The file ram soif will look like the following example RDMHEADER catalog service id 40 x catalog budgie siroe com 6714 budgie rdm version 3 1 0 rdm type 10 rd request rdm query language 6 search RDMQUERY view attributes 18 title content type scope 5 varrius The file ram soif created in must be placed into the server instance directory 6 Send the SOIF contained in rdm soi f to the program sendrdm For example type 232 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Example of Submitting a Query run cs cli sendrdm u portal search rdm soif The current directory should be the server instance directory If ram soi f is not in the server instance directory reference the file from where is was created For example a Change directories to server_instace_dir b Type run cs cli sendrdm u portal search sdk_dir rdm soif c The results of the sendrdm program will be a SOIF stream containing the results of the query such as the following example RDMHEADER
14. fileProviderAdapter getStringProperty key maps to PortletPreferences getValue key default fileProviderAdapter getListProperty key maps to PortletPreferences getValues key default Chapter 6 Developing and Deploying Portlets 175 Converting Providers to Portlets Compile the Portlet When compiling a portlet include the classpath Ensure that portlet jar file is in your classpath when compiling the portlet For example to compile type javac classpath portal server install root SUNWps lib portlet jar HelloWorldPortlet java Create a Portlet Web Application Assemble the portlet class file and the XML fragments into a portlet web application A portlet web application must be packaged as a WAR file The portlet xml file must be placed into the same location as the web xml file To create a portlet web application 1 Create a portlet xml file that includes the declaration for all the portlets Code Example 6 5 contains the port let xml file that includes the declaration for the sample HelloWorldPortlet Code Example 6 5 portlet xml File for the HelloWorldPortlet lt xml version 1 0 encoding UTF 8 gt lt portlet app xmlns http java sun com xml ns portlet xmlns xsi http www w3 0rg 2001 XMLSchema instance xmlns portlet http java sun com xml ns portlet xsi noNamespaceSchemaLocation http java sun com xml ns portlet version 1 0 gt lt portlet gt lt portlet name gt Hell
15. gt name contentPage value toptable jsp gt name description value This is a test for front table containers gt name Desktop fontFacel value Sans serif gt Chapter 5 Using the Container Providers 127 JSPContainerProviderAdapter Code Example 5 7 CustomTCChannel xml File Continued lt Collection lt String lt String lt String lt Collectio lt Collection lt String lt String lt String lt String lt Collectio lt Collection lt String lt String lt Collectio lt Collection lt String lt Collectio lt Collection lt String lt String lt String lt String lt String lt Collectio lt Collection lt Boolea lt Collectio lt Collection lt String lt String lt String lt String lt Collectio lt Collection lt String lt String lt String lt String lt Collectio lt Properties gt lt Available gt lt Reference Reference Reference Reference Reference Reference Reference Reference lt Available gt lt Selected gt lt Reference lt Reference A A A A A A A name categories gt value Personal Channels gt value Sample Channels gt value News Channels gt n gt name Personal Channels gt value UserInfo gt value MailCheck gt value Bookmark gt value App gt n gt name Sample Channels gt value SampleJSP gt value SampleXML gt n gt name News Channels gt value SampleRSS gt n gt name
16. 100 VALIGN TOP gt lt CENTER gt lt BR gt lt FONT SIZE 2 FACE tag fontFacel gt lt B gt Edit tag title lt B gt lt FONT gt lt BR gt tag contentOptions lt CENTER gt lt TD gt lt TR gt lt TABLE gt FONT SIZE 0 FACE tag fontFacel gt lt INPUT TYPE SUBMIT NAME Submit VALUE Finished CLASS button gt INPUT TYPE BUTTON OnClick location tag desktop url VALUE Cancel tag menubar 86 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Extending the ProfileProviderAdapter Class Code Example 3 18 HelloWorldProviderPPA2 editTemplate template File Continued lt font gt lt BODY gt lt HTML gt 10 Create the channel directory under the template root directory By default the template root directory is etc opt SUNWps desktop desktoptype For this example create a HelloWorldPPA2 directory under etc opt SUNWps deskt op desktoptype directory Copy the templates for the provider into the channel directory under the templates root directory For example cp content template etc opt SUNWps deskt op desktoptype HelloWorldPPA2 cp edit template etc opt SUNWps desktop desktoptype HelloWorldPPA2 cp editTemplate template etc opt SUNWps deskt op desktoptype HelloWorldPPA2 Access the channel from a browser To access type the following URL in your browser http hostname port portal dt provider HelloWorldPPA2 To display t
17. Chapter 4 Using Leaf Providers 105 URLScraperProvider Code Example 4 11 CustomURLSProvider xml File Continued lt Collection name cookiesToForwardList gt lt Collection gt lt Integer name timeout value 100 gt lt Properties gt lt Provider gt Code Example 4 12 CustomURLSChannel xm1 File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Channel name CustomURLScraper provider CustomURLScraperProvider gt lt Properties gt lt String name refreshTime value 600 advanced true gt lt Collection name urlPool gt lt String value http localhost port filel html gt lt String value http localhost port file2 html gt lt Collection gt lt Properties gt lt Channel gt 4 Use the dpadmin command to upload the display profile fragments for this provider For the CustomURLScraperProvider use the dpadmin command to upload the CustomURLSProvider xml and CustomURLSChannel xml file XML fragments in the display profile That is type portal server install root SUNWps bin dpadmin add u dn_amadmin w password d distinguishedname CustomURLSProvider xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomURLSChannel xml 5 Include the new channel in one of the existing containers The CustomURLScraperProvider channel
18. List pflist new List pflist add getProviderContext getLocalePropertiesFilter en true String filter com acme filters DateLaterThanPropertiesFilter pflist add getProviderContext getPropertiesFilter filter 02 02 2003 true pflist add getProviderContext getClientPropertiesFilter nokia true getStringProperty getName foo pflist o Code Example 3 22 on page 92 includes an implementation that will return en nokia Chapter 3 Extending the Base Providers 91 Ex tending the PropertiesFilter Class Code Example 3 22 Provider Implementation for DateLaterThanPropertiesFilter List pflist new List pflist add getProviderContext getLocalePropertiesFilter en true String filter com acme filters DateLaterThanPropertiesFilter pflist add getProviderContext getPropertiesFilter filter 04 04 2003 false this filter is optional pflist add getProviderContext getClientPropertiesFilter nokia true getStringProperty getName foo pflist 92 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Chapter 4 Using Leaf Providers A portal provider is a generic connector to the resource in a channel and is the programmatic entity responsible for generating channels on the Desktop A single provider can be used to create multiple channel instances The leaf providers are tools for building channels for the portal Out of t
19. RDMs that processes can use to exchange resource descriptions across a network The SOIF API provides routines for creating and modifying SOIF objects in C The SOIF API is defined in the soif h file in the following directory in your search engine installation directory portal server install root SUNWps sdk rdm include This chapter is restricted to discussing the use of C functions that come with the search engine SOIF API Therefore it is strongly recommended that you have a basic understanding of the C programming language NOTE To correctly support all languages it is important that all SOIF data should use the UTF 8 character set Note that UTF 8 is fully backward compatible with 7 bit ASCII SOIF This chapter contains the following sections e What is SOIF and Using the SOIF API with An Introductory Example e Getting Search Server Database Contents as a SOIFStream e SOIF API 183 What is SOIF What is SOIF SOIF stands for Summary Object Interchange Format It is a syntax that can be used in numerous situations In particular it is used to describe resource descriptions RDs in the search engine database The SOIF format is a basic attribute value format SOIF files look like text but should be treated as binary data and edited with care SOIF files contain tabs and many editors will convert tabs to spaces and corrupt the file You can use SOIF manipulation functions to create and modify SOIF objects
20. directory as shown in Code Example 5 4 Code Example 5 4 Modifications to single jsp File Copyright 2001 Sun Microsystems Inc All rights reserved PROPRIETARY CONFIDENTIAL Use of this product is subject to license terms gt s3 single jsp 35 lt taglib uri tld desktop tld prefix dt 55 lt taglib uri tld desktopSingle tld prefix dtsingle 55 lt page import custom CustomSingleContainerProvider gt lt 5 page session false 55 lt jsp include page header jsp flush true gt lt dt obtainContainer container JSPProvider gt lt dtsingle singleContainerProvider gt lt dtsingle obtainSelectedChannel gt lt img src lt dt scontent gt desktop images nothing gif height 8 width 0 border 0 alt gt lt br gt lt CustomSingleContainerProvider csp CustomSingleContainerProvider pageContext getAttribute JSPProvider S gt lt img src lt dt scontent gt desktop images nothing gif height 8 width 0 border 0 alt gt lt br gt lt String selected csp getSelectedChannel request out println csp getContainerProviderContext getContent request response null selected SI lt dtsingle obtainSelectedChannel gt lt dtsingle singleContainerProvider gt lt dt obtainContainer gt lt jsp include page menubar jsp flush true gt lt 5 include file footer html gt Chapter5 Using the Container Providers 123 JSPCo
21. false gt lt Collection gt lt Collection name amList gt lt String value UserInfo gt lt String value MailCheck gt lt String value App gt lt String value Bookmark gt lt Collection gt lt Collection name pmList gt lt String value MyFrontPageTabPanelContainer Bookmark2 gt lt String value MailCheck gt lt String value SampleXML gt lt String value SampleRSS gt lt Collection gt lt Properties gt lt Available gt lt Reference value UserInfo gt lt String name description value This is a test for front table containers gt 146 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 5 19 JSPContainerProviderAdapter CustomJSPTCChannel xml File Continued lt Selected gt AA A A A A lt Reference value MailCheck gt lt Reference value App gt lt Reference value Bookmark gt lt Reference value MyFrontPageTabPanelContainer Bookmark2 gt lt Reference value SampleJSP gt lt Reference value SampleRSS gt lt Reference value SampleXML gt lt Available gt lt Reference value UserInfo gt Reference value MailCheck gt Reference value App gt Reference value Bookmark gt Reference value MyFrontPageTabPanelContainer Bookmark2 gt Reference value SampleJSP gt Reference value SampleRSS gt lt Reference value SampleXML gt lt Selected gt lt Channe
22. file Code Example 5 30 Sample tableheader jsp File lt Copyright 2001 Sun Microsystems Inc All rights reserved PROPRIETARY CONFIDENTIAL Use of this product is subject to license terms gt lt 5 tableheader jsp gt lt HTML gt lt CENTER gt lt TABLE BORDER 0 CELLPADDING 0 CELLSPACING 0 WIDTH 100 gt lt TR gt lt td bgcolor CC0000 colspan 2 gt lt img src lt dt scontent gt images spacer gif width 1 height 3 alt gt lt td gt lt TR gt lt TR gt lt td gt lt a href dt action edit amp provider JSPRouterContainer onMouseOver over banner home onMouseQutz out banner home gt lt img name banner home src lt dt scontent gt images blueBullet gif width 13 height 9 border 0 alt gt lt a gt lt td gt lt td gt lt a href dt action edit amp provider JSPRouterContainer onMouseOver over banner_home onMouse0ut out banner_ home class noUnderline gt lt span class banner links gt Desktop Preference lt span gt lt a gt lt td gt lt TR gt lt TABLE gt lt img src lt dt scontent gt desktop images nothing gif height 8 width 0 border 0 alt gt lt br gt 9 Opena browser and log in to the administration console The URL to access the administration console is http hostname port amconsole 164 Sun ONE Portal Server 6 2 Developer s Guide December 2003 10 11 12 13 Creating a Custom
23. in the Desktop For example consider a portal application that uses two providers one for a container and the other for several leaf channels Call these providers HeadlineContainerProvider and HeadlineProvider The container provider performs some common processing for the leaf channels and then the leaf channels access the container object to get the results of that processing One way to implement this would be to have the HeadlineContainerProvider put a reference to itself into the request object For example in the HeadlineContainerProvider getContent do request setAttribute HeadlineContainer this Then in the HeadlineProvider getContent method do HeadlineContainerProvider hcp HeadlineContainerProvider request getAttribute HeadlineContainer This example will compile but when the desktop loads and runs this code the HeadlineProvider will cause a ClassCastException on this second statement The reason is that the HeadlinerContainerProvider object is loaded by one provider class loader object and the HeadlineProvider object is loaded by a different class loader object The class loader for HeadlineProvider also loads HeadlineContainerProvider because HeadlineProvider references HeadlineContainerProvider So we have e containerl of type HeadlineContainerProvider loaded by loader1 e channell of type HeadlinerProvider loaded by loader2 Chapter 2 Using Provider API PAPI 59 Overview of Implementing a
24. no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name CustomTableContainerProvider class custom CustomTableContainerProvider gt lt Properties gt lt String name contentPage value toptable jsp gt lt Integer name timeout value 1800 gt lt Integer name layout value 1 gt lt Boolean name showExceptions value false gt lt Boolean name parallelChannelsInit value false gt lt String name title value Table Container Provider gt lt String name description value DESCRIPTION gt lt String name refreshTime value 0 gt lt String name width value thin gt lt String name fontFacel value Sans serif gt lt String name Desktop fontFacel value Sans serif gt lt String name productName value Sun ONE Portal Server gt lt String name presetThemeChannel value JSPPresetThemeContainer gt lt String name customThemeChannel value JSPCustomThemeContainer gt lt Boolean name refreshParentContainerOnly value false advanced true gt lt Boolean name isEditable value true gt lt String name editType value edit_complete gt lt String name editContainerName value JSPEditContainer gt lt Integer name thin_popup_height value 200 gt lt Integer name thin_popup_width value 500 gt lt Integer name thick_popup_height value 300 gt lt Integer name thick_popup_width value 600 gt lt Int
25. 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name RouterContainerProvider class com sample providers containers router RouterContainerProvider gt lt Properties gt lt String name contentPage value router jsp gt lt String name editPage value routeredit jsp gt lt String name processPage value gt lt Boolean name showExceptions value false gt lt String name title value Router Container Provider gt lt String name description value DESCRIPTION gt lt String name refreshTime value advanced true gt lt String name width value thin advanced true gt lt String name fontFacel value Sans serif gt 158 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating a Custom ContainerProvider Code Example 5 25 RCProvider xml File Continued lt String name productName value Sun ONE Portal Server gt lt Boolean name isEditable value true advanced true gt lt String name editType value edit_complete advanced true gt lt String name editContainerName value JSPEditContainer advanced true gt lt String name preset ThemeChannel value JSPPresetThemeContainer advanced true gt lt String name customThemeChannel value JSPCustomThemeContainer advanced true gt lt Properties gt lt Provider gt The sample Route
26. 1 t t 1 conten e oo Gets di content for i top level Gets i getProvider for contained provider container contained i channel content getContent lta ap 1 Bs u 1 u g a L L L Figure 2 4 The Provider Lifecycle Logout Request Chapter 2 Using Provider API PAPI 35 Overview of the Provider API and Desktop Servlet The Browser Desktop PC CPC Logout Service Logout request action logout Validates SSO Token Gets container provider context getLogoutURL Redirect the UR SSO Token Destroyed Release CPC The DesktopServlet This section provides an overview of the DesktopServlet and discusses the relationship between the DesktopServlet and the PAPI It provides information on how the DesktopServlet uses the various methods in the PAPI to perform the various actions such as content edit process and logout 36 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Overview of the Provider API and Desktop Servlet Introduction The DesktopServlet coordinates the drawing of the Desktop dispatches the process to the target channel based on the information stored in the underlining services and validates the user with the Sun ONE Identity Server software In this sense the DesktopServlet is a router of requests It catches requests for content and processing and passes them on to the specific pr
27. Code Example 5 29 Sample tabheader jsp File lt Copyright 2001 Sun Microsystems Inc All rights reserved PROPRIETARY CONFIDENTIAL Use of this product is subject to license terms gt lt 5 tabheader jsp gt lt HTML gt lt CENTER gt lt TABLE BORDER 0 CELLPADDING 03 CELLSPACING 0 ALIGN right HEIGHT 29 gt lt TR gt lt td gt lt a href dt action edit amp provider JSPRouterContainer onMouseOver over banner home onMouseOut out banner home gt lt img name banner_home src lt dt scontent gt images blueBullet gif width 13 height 9 border 0 alt gt lt a gt lt td gt lt td gt lt a href dt action edit amp provider JSPRouterContainer onMouseOver over banner_home onMouseOut out banner_home class noUnderline gt lt span class banner links gt Desktop Preference lt span gt lt a gt lt td gt lt TR gt lt TABLE gt lt img src lt dt scontent gt desktop images nothing gif height 8 width 0 border 0 alt gt lt br gt Chapter 5 Using the Container Providers 163 Creating a Custom ContainerProvider 8 Modify the header jsp file in etc opt SUNWps desktop default JSPTableContainerProvider to add the text from tableheader jsp file as shown in Code Example 5 30 The HTML code to add a link to the edit page of the router container provider is shown in bold in the tableheader jsp see Code Example 5 30 on page 164
28. CustomXMLProvider properties Access the CustomXML Provider channel inside the JSPTableContainer To access log in to the Desktop and type the following URL in your browser http hostname port portal dt provider JSPTableContainer Chapter 4 Using Leaf Providers 113 XMLProvider 114 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Chapter 5 Using the Container Providers Containers are simply channels that include in their output the content of one or more other channels The container providers present containment metaphors for channel aggregation including single table tab and framed This chapter discusses the out of the box extensible set of container providers that implement various metaphors for aggregating content and includes instructions for e Extending the building block Container Providers e Creating a Custom ContainerProvider This chapter also contains the following sections e The ContainerProvider Architecture e Overview of the ContainerProviders e JSPContainerProviderAdapter The ContainerProvider Architecture Figure 5 1 on page 116 shows the relationship between the various interfaces and classes discussed in this chapter The JSPProvider see Chapter 4 Using Leaf Providers for more information and ContainerProviderAdapter classes extend ProfileProviderAdapter see Chapter 2 Using Provider API PAPI for more information The ContainerProvider interface defines the interf
29. Implementing a Custom Provider default locale clientPath default locale default channelname default provider default clientPath default templateroot The root of the search directory default value of etc opt SUNWps desktop can be changed by modifying the templateBaseDir property in the desktopconfig properties file NOTE If the channel display profile is defined inside a container display profile definition the lookup for the channel will be desktoptype containername channelname client Path Provider specific Properties In the display profile properties contain configuration information for the provider and the provider s channels A provider can define any number of specific properties See Properties in Display Profile and Sun ONE Portal Server 6 2 Desktop Customization Guide for more information Also a provider can have more than one properties file which is actually a Java resource bundle file that enables localization of on screen images or text See Properties in Resource bundle on page 57 for more information Properties in Display Profile Provider specific properties are defined in the display profile Provider specific properties are defined in the display profile within the lt Properties gt lt Properties gt tag for the provider The following is the structure of the properties in the display profile lt Properties gt lt Collection gt subset of property defin
30. ONE Portal Server 6 2 Developer s Guide December 2003 Using Java To Access the Search Server Database int viewHits String database String ssoToken String queryLanguage String RDMServer The arguments for the constructor are outlined in the following table String scope String viewAttributes String viewOrder nt firstHits pi nt viewHits H String queryLanguage wn tring database String RDMServer The query string or scope that is the string being searched for A comma delimited list of the SOIF attributes to be retrieved from the database such as URL Author Description For example score url title description classification The order by which to sort the results This is a comma delimited list of attributes Use the minus sign to indicate descending order and a plus sign to indicate ascending order For example score ttitle The hit number of the first result to return A typical value is 1 Maximum number of results to return A typical value is 10 The Search Server query language You should use search for a normal query The logical name of a database or collection you wish to search A typical value is null which will search the server s default database The URL of the search engine servlet This argument has the form http hostname domain com port portal search For example if the search server is installed on www yourcompany com o
31. Providers 89 Extending the PropertiesFilter Class Code Example 3 19 DateLaterThanPropertiesFilter java File Continued public String getCondition return dateLaterThan public boolean match String condition String value throws PropertiesFilterException if condition equals dateLaterThan return false Date cdate null try cdate dateFormat parse value catch ParseException pe throw new PropertiesFilterException DateLaterThanPropertiesFilter match pe return cdate after date 2 Compilethe class file To compile the DateLaterThanPropertiesFilter java file type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar DateLaterThanPropertiesFilter java 3 Create the provider display profile XML fragment for the conditional properties Code Example 3 20 contains the sample display profile XML fragment for the DateLaterThanPropertiesFilter Code Example 3 20 DateLaterThanPropertiesFilter xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Properties gt lt String name foo value bar gt lt ConditionalProperties condition locale value en gt lt String name foo value bar gt lt ConditionalProperties condition dateLaterThan value 03 03 2
32. RD RD RD RD RD RD RD RD RD RD RD RD RD RD_REQ RD_RES SD REQ SD RES SCH REQ SCH RES TAX REQ TAX RES STAT REQ STAT RES MSGTYPE UNKNOWN RD UPD REQ RD DEL REQ RD UPD RES RD DEL RES Undefined or unknown message type Requesting an RD update Requesting an RD update same as RDM RD UPD REQ Requesting an RD delete Responding to an RD update request Responding to an RD update request same as RDM RD UPD RES Responding to an RD delete request Requesting a server description Responding to a server description request Requesting a schema description Responding to a schema description request Requesting a taxonomy description Responding to a taxonomy description request Requesting a status Responding to a status description request You can use the following macros to get and set the string values of the attributes RD RD RD RD RD RD RD eader_Ge eader_Ge eader_Ge Header_Ge ader_G eader_Ge eader_Ge tType RDMHeader returns RDMType tVersion RDMHeader tQueryLanguage RDMHeader tCSID RDMHeader ResponseInterpret RDMHeader ErrorMessage RDMHeader ErrorNumber RDMHeader Using the RDM API to Access the Search Engine and Database inC 235 Example of Submitting a Query RD RD RD RD RD RD RD Header Se Header Se Heade
33. SUBSET the edit container s content is displayed and it wraps around the channel s edit content Figure 2 6 DesktopServlet Legacy edit Action Start process y Determine Provider from Parameter Is Provider Null Yes Get Default Channel Name Get Channel p Is Channel Editable Desktop Exception Get Edit Type Page 2 of the flowchart 42 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Legacy Edit Action Page 2 of the flowchart Edit Type EDIT SUBSET Yes y Overview of the Provider API and Desktop Servlet Call channel getEdit method Y Display Edit Page Get Default Desktop Edit Container y Call Edit Container s getEdit method y Get Channel Name from request parameter Is Channel No Editable NG Get Channel s Edit Type EDIT SUBSET Call Channel s getEdit method Y Provider Exception Call Channel s getEdit method Y Display Edit Page Display Edit Container s content and wrap around the channel s edit content Chapter 2 Using Provider API PAPI 43 Overview of the Provider API and Desktop Servlet 44 DesktopServletURL action edit amp provider editContainer amp targetprov
34. See Code Example 6 2 on page 170 for a sample portlet xml file sun web xml Include a sun web xml file in the WEB INF directory if you use Sun ONE Application Server software as your web container for the portlet application and if your portlet application e Contains servlets JSPs or other resources that will be accessed directly by the browser instead of accessed via the portal server e Requires session support Code Example 6 7 Sample sun web xml File lt sun web app gt lt session config gt lt cookie properties gt lt property name cookiePath value gt lt cookie properties gt lt session config gt lt sun web app gt 178 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Files Used by Portlets The session cookie property cookiePath in Code Example 6 7 on page 178 specifies the pathname that is set when the cookie is created The browser sends the cookie if the pathname for the request contains this pathname If set to forward slash the browser sends cookies to all URLs served by the Sun ONE Application Server software You can set the path to a narrower mapping to limit the request URLs to which the browser sends cookies By default the cookiePath property contains the context path at which the web module is installed The cookiePath property must be changed only if necessary The application server reclaims old sessions based on it s own schedule If you i
35. The program must be run in a search enabled Sun ONE Portal Server software instance directory such as the default var opt SUNWps serverinstance portal directory You should also change the definitions for My CSID MY SCOPE and MY_ATTR_VIEW to suit your needs The following table describes the RDMHeader and RDMQuery object parameters in the first left column and provides a description of the corresponding parameter in the second right column MY_CSID ID of the search engine instance This parameter specifies the specific search engine that you created in the search engine Administration Interface You can find the exact value in var opt SUNWps serverinstance portal config s earch conf For SSL enabled server instances use x catalogs instead of x catalog in the CSID MY_SCOPE Query string The default is to search for documents containing the string varrius For example if you want to search for all documents containing the string style_sheets then set MY_SCOPE to style_sheets Chapter 9 Using the RDM API to Access the Search Engine and Database inC 229 Example of Submitting a Query MY_ATTR_VIEW Attributes to be printed such as URL title and description Code Example 9 1 generates an RDM for querying a search engine database You can pipe the output of the sample program to a temporary file and then use the sendrdm program to post it to the search engine Code Example 9 1 RDM API to Submit a Query Example
36. Type request getResponseContentType PrintWriter writer response getWriter writer write Hello salutation prompt the user for the salutation PortletURL actionURL response createActionURL response setContent Type request getResponseContentType PrintWriter writer response getWriter writer write lt form method post action actionURL toString writer write gt lt TABLE WIDTH 100 gt lt TR gt lt TD ALIGN RIGHT response setContent Type request getResponseContentType try response setContent Type request getResponseContentType PrintWriter writer response getWriter writer write Pref Portlet Help lt p gt lt p gt catch IOException e throw new PortletException PrefPortlet doHelp exception e Compile the Portlet When compiling a portlet include the classpath Ensure that portlet jar is in your classpath when compiling the portlet For example to compile type javac classpath portal server install root SUNWps lib portlet jar PrefPortlet java NOTE This compiled class file must be included in the WAR file that will be deployed on the Portal Server using the pdeploy command Chapter6 Developing and Deploying Portlets 169 Extending the GenericPortlet Abstract Class Create a Portlet Web Application Assemble the portlet class file and the XML fragments into a portlet web application A portlet web application mu
37. Value Pair Routines Attribute Value Pair Routines 188 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Table 7 1 Alphabetized Functions and Objects Defined in the soif h File Continued SOIF AP SOIF function or object Category Attribute Value Pair Routines SOIF_ReplaceMV SOIF_ReplaceStr SOIF_SqueezeMV SOIFAVPair Create SOIFAVPair Free SOIFAVPair_IsMV SOIFAVPair_NthValid SOIFAVPair_NthValue SOIFAVPair_NthVsize SOIFBuffer_Create SOIFBuffer_Free SOIFStream_Finish SOIFStream_GetAllowed SOIFStream_GetDenied SOIFStream_IsAllowed SOIFStream IsEOS SOIFStream_IsParsing SOIFStream_IsPrinting SOIFStream_Parse SOIFStream_Print SOIFStream_SetAllowed SOIFStream_SetDenied SOIFStream_SetFinishFn Attribute Value Pair Routines Attribute Value Pair Routines Attribute Value Pair Routines Attribute Value Pair Routines Multi valued Attribute Routines Multi valued Attribute Routines Multi valued Attribute Routines Multi valued Attribute Routines Memory Buffer Management Memory Buffer Management Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing an
38. Who Should Read This Book You should read this book if you are responsible for customizing and extending the Sun ONE Portal Server software APIs What You Need to Know This book assumes that you are familiar with the following products e Sun ONE Directory Server e Sun ONE Identity Server e Sun ONE Web Server e Sun ONE Application Server This book assumes you already know the basics of e The Solaris Operating Environment and UNIX command line utilities and administrative tasks e One or more of the following programming languages Java JavaScript C XML and HTML How This Book is Organized This book contains the following chapters About This Guide this chapter Chapter 1 Introduction to the APIs This chapter provides an introduction to the Sun ONE Portal Server APIs Chapter 2 Using Provider API PAPI This chapter provides an introduction to the base PAPI interfaces classes and exceptions and includes instructions for implementing a custom provider by extending the PAPI Chapter 3 Extending the Base Providers This chapter provides instructions for implementing a custom provider by extending the PAPI base classes Chapter 4 Using Leaf Providers This chapter provides an introduction to the leaf providers and includes sample customizations to methods in the leaf provider classes Chapter 5 Using the Container Providers This chapter provides an introduction to the
39. XML fragment in file HelloProviderPPA2 xml is shown in Code Example 3 14 Code Example 3 14 HelloProviderPPA2 xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name HelloWorldProviderPPA2 class custom helloworld HelloWorldProviderPPA2 gt lt Properties gt lt String name title value TITLE gt lt String name presetThemeChannel value JSPPresetThemeContainer advanced true gt lt String name customThemeChannel value JSPCustomThemeContainer advanced true gt lt String name description value DESCRIPTION gt lt String name refreshTime value 0 gt lt Boolean name isEditable value true gt lt String name editType value edit_subset gt lt Collection name aList gt lt String value i m aList gt lt Collection gt lt Collection name aMap gt lt String name title value Ramag gt lt String name desc value My Map gt lt Boolean name removable value true gt lt Boolean name renamable value true gt lt Collection gt lt String name message value Hello World Test Provider gt lt Properties gt lt Provider gt The HelloWorldProvider channel display profile XML fragment in file HelloChanne1PPA2 xm1 is shown in Code Example 3 15 on page 84 Chapter 3 Extending the Base Providers 83 Extending the ProfileProviderAdapter
40. XMLProvider getXML pr if xmlbuf null Chapter4 Using Leaf Providers 109 XMLProvider Code Example 4 14 CustomXMLProvider java File Continued return xmlbuf else throw new ProviderException XMLProvider getXML Getting XML failed from source else Open database connection Read the XML contents into a stringbuffer xmlbuf Close the database connection return xmlbuf 2 Compile the class and put it in the provider class base directory That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes To compile the CustomXMLProvider java file type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar CustomXMLProvider java 3 Develop the display profile XML fragment for this provider and this provider s channel The display profile fragment for the CustomXMLProvider s provider is saved in CustomXMLProvider xml file see Code Example 4 15 and the display profile fragment for the CustomXMLProvider s channel is saved in CustomXMLChannel xml file see Code Example 4 16 on page 111 Code Example 4 15 CustomXMLProvider xml File lt xml version 1 0 encoding
41. a filter in the filter list is required then it must match for the overall conditional lookup to succeed If a filter is not required then it can fail to match without causing the overall lookup to fail A chain of non required filters can be used to implement a progressively less specific filter lookup similar to the semantics of Java resource bundle lookup For instance an optional filter would be useful in a case where a locale lookup is followed by a date lookup Given the filter locale en locale US date 03 03 2003 you can get it to successfully match a property with the qualifier locale en date 03 03 2003 even though it does not exactly match the filter specification This can be accomplished by setting the locale filter to be optional The locale property type is deprecated e The match method returns true if this filter object agrees with or matches the condition and value that are passed in given the information that was used to create the object Out of the box the Portal Server software includes filters based on locale and client The locale and client filter extend the PropertiesFilter abstract class and includes an implementation of the getCondition and match methods in the PropertiesFilter class See the Javadoc for more details Exceptions The Desktop expects a provider to only throw ProviderException or a subclass of the ProviderException For correct operation a provider must only throw expected exception ty
42. a single rule change affects both tasks filterrules conf Contains the starting points also referred to as starting point URLs and rules used by the filterrules process function classification conf Contains rules used to classify RDs generated by the robot Use the administration console to edit these configuration files The Filtering Process The robot uses filters to determine which resources to process and how to process them When the robot discovers references to resources as well as the resources themselves it applies filters to each resource in order to enumerate it and to determine whether or not to generate a resource description to store in the search engine database The robot examines one or more starting point URLs applies the filters and then applies the filters to the URLs spawned by enumerating the starting point URLs and so on Note that the starting point URLs are defined in the filterrules conf file A filter performs any required initialization operations and applies comparison tests to the current resource The goal of each test is to either allow or deny the resource A filter also has a shutdown phase during which it performs any required cleanup operations Chapter 8 Search Engine Robot 205 Search Engine Robot Overview Table 8 1 Metadata If a resource is allowed it continues its passage through the filter If a resource is denied then the resource is rejected No further action is taken by the fil
43. advanced true gt name isEditable value true gt name editType value edit_complete gt name editContainerName value JSPEditChannel gt name thin_popup_height value 200 gt name thin_popup_width value 500 gt name thick_popup_height value 300 gt name thick_popup_width value 600 gt name fullwidth_popup_height value 500 gt 144 Sun ONE Portal Se rver 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter Code Example 5 18 CustomJSPTCProvider xml File Continued lt Integer name fullwidth_popup_width value 600 gt lt Collection name categories gt lt String value Personal lt String value Sample C lt String value News Channels gt lt String value Search C lt Collection gt lt Collection lt String value UserInfo lt String value MailChec lt String value Bookmark gt lt String value App gt lt Collection gt lt Collection name Sample Channels gt lt String lt String value SampleJSP gt lt String value SampleXML gt lt String lt Collection gt lt Collection name News Channels gt n n name Personal Channels gt K value SampleSimpleWebService gt value SampleURLScraper gt lt String value SampleRSS gt lt String value Postit gt h Channels gt hannelIsMinimizable value true gt hannelIsMinimized value false advanced true gt hannelIsDetached value fals
44. be thrown from Provider getEdit Type method if an unknown or undefined edit type is encountered The Provider Life Cycle This section describes the lifecycle of the provider per user session Figure 2 2 on page 33 Figure 2 3 on page 35 and Figure 2 4 on page 35 shows how the Desktop handles each user session A session is created at the time the user logs in to the portal Desktop and ends when they logout The session also ends when the user session is idle or when the session times out For authless logins a single session is shared amongst all clients accessing the Desktop in authless mode and the authless session never dies Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of the Provider API and Desktop Servlet For each request the DesktopServlet will validate the user session if it is a valid session the DesktopServlet will start to process the request If a session does not exist the DesktopServlet will create a session The creation of the provider context is equivalent to the creation of a session The container provider context object see ContainerProviderContext on page 118 is generated and maintained one per session So each time a request comes in the cached container provider context object is used For example in Figure 2 2 on page 33 when the first initial request comes in the container provider context is created and initialized and when the subsequent requests come in as i
45. channels are the table containers that are considered active on the Desktop Available channels are those that are available to be activated on the Desktop 148 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter The TabContainer interface defines the interface for implementing a TabContainerProvider A TabContainerProvider must implement this interface This interface contains methods to query information about a TabContainer and to set the properties of a TabContainer See the Javadocs for more information on the methods in this interface UnmodifiableTab The UnmodifiableTab interface represents a tab that cannot be modified This interface includes methods to e Get the name getName the display name get Displayname the HTML encoded name get EncodedName and description getDesc of the tab as a string e Get the properties get TabMap of the tab as a map e Determine whether or not the tab is removable isRemovable and renamable isRenamable by returning true or false e Determine if the tab was created by the user or was predefined for the user isPredefined by returning true or false A value of true indicates that the tab was predefined and a value of false indicates that the tab was created by the user ModifiableTab The ModifiableTab interface represents an instance of the tab that can be modified It extends UnmodifiableTab and all modifiab
46. channelsRow advanced true gt name MailCheck value 4 gt name App value 5 gt name Bookmark value 3 gt name SampleRSS value 2 gt name SampleXML value 2 gt n gt name channelsIsRemovable gt n name UserInfo value false gt n gt name amList gt value UserInfo gt value MailCheck gt value App gt value Bookmark gt n gt name pmList gt value MyFrontPageTabPanelContainer Bookmark2 gt value MailCheck gt value SampleXML gt value SampleRSS gt n gt value UserInfo gt value MailCheck gt value App gt value Bookmark gt value MyF rontPageTabPanelContainer Bookmark2 gt value SampleJSP gt value SampleRSS gt value SampleXML gt value UserInfo gt value MailCheck gt 128 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 5 7 JSPContainerProviderAdapter CustomTCChannel xml File Continued lt Reference value App gt lt Reference value Bookmark gt lt Reference value MyFrontPageTabPanelContainer Bookmark2 gt lt Reference value SampleJSP gt lt Reference value SampleRSS gt lt Reference value SampleXML gt lt Selected gt lt Channels gt lt Channels gt lt Container gt 4 Use the dpadmin command to upload the display profile fragments for this provider For CustomTableContainerProvider use the dpadmin command to upload the
47. container providers and includes instructions for developing a custom ContainerProvider Chapter 6 Developing and Deploying Portlets This chapter provides instructions for developing portlets Chapter 7 Using the SOIF API to Work with SOIF Objects This chapter describes the use of the search engine SOIF API to work with SOIF objects in C 8 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Chapter 8 Search Engine Robot This chapter describes the Search Engine Robot and the application programming interface API used to create plug in robot application functions RAFs Chapter 9 Using the RDM API to Access the Search Engine and Database in C This chapter describes the use of the Search Engine RDM API to access the Search Engine and its database Chapter 10 Using Java to Access the Search Engine Database This chapter describes how to submit queries and add entries to the Search Engine database by using the Java programming language Chapter 11 Localizing Sun ONE Portal Server This chapter provides instructions for localizing the customizable parts of Sun ONE Portal Server software Document Conventions Used in This Guide Monospaced Font Monospaced font is used for any text that appears on the computer screen or text that you should type It is also used for file names distinguished names functions and examples Bold Monospaced Font Bold monospaced font is used to represe
48. data typically that of the channel s edit form When the DesktopServlet receives a request where the action is process to perform the process action it takes the following URL parameters DesktopServlet URL act ion process amp provider channelName Or DesktopServletURL action process amp provider editContainerstargetprovider channelNa me DesktopServletURL action process amp provider channelName When the DesktopServlet receives a request where the action is process see Figure 2 8 the DesktopServlet 1 Looksatthe parameters to identify which provider will handle the action through the provider s processEdit method The processEdit method is called to process the edit page generated from the getEdit method The request passed in contains the parameters 2 Re directs to the URL returned from the provider s processEdit method If there is an InvalidEditFormDataException the DesktopServlet will redirect the browser back to the channel s edit page and include a URL parameter error so that the channel may display the cause of the exception to the user That is the DesktopServlet will get the error message and generate a new request as follows DesktopServletURL act ion edit amp provider channelNameserror errormessnge DesktopServlet Legacy process Action Chapter 2 Using Provider API PAPI 47 Overview of the Provider API and Desktop Servlet Start process y Determine Provider from P
49. description 37 Reference to HTML tags and attributes A CSResource structure has a url field which contains the URL for the SOIF It also has an rd field whose value is the SOIF for the resource Once you get the SOIF for the resource you can use the functions for working with SOIF that are defined in portal server install root SUNWps sdk rdm include soif h file to get more information about the resource The file robot api h includes soif h For example the macro SOIF_Findval soif attribute gets the value of the given attribute in the given SOIF Code Example 8 2 uses this macro to print the value of the META attribute if it exists for the resource being processed Code Example 8 2 SOIF_Findval Macro Example int my_new_raf libcs_pblock pb CSFilter csf CSResource csr char metavalue if metavalue char SOIF Findval csr gt rd meta printf The value of the META tag in the resource is s metavalue rest of function It is recommended that you review the csResource structure in the file robotapi h for more information on other fields and macros For more information about the routines to use with SOIF objects see Chapter 9 Using the RDM API to Access the Search Engine and Database in C Returning a Response Status Code When your robot application function has finished processing it must return a code that tells the server how to proceed with the request Th
50. directive identifies the class of function that is being called Functions should not be called from the wrong directive e fn function identifies the function to be called using the function s unique character string name These two parameters are mandatory In addition there may be an arbitrary number of function specific parameters each of which is a name value pair You will need to specify your function in the directive for which it was written For example the following line uses a plug in function called wordcount that can be used in the Data stage This function counts the words in a resource and assigns the count to a destination specified by a parameter called dst Data fn wordcount dst word count Chapter 8 Search Engine Robot 223 Creating New Robot Application Functions 224 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Chapter 9 Using the RDM API to Access the Search Engine and Database in C This chapter describes the use of the search engine Resource Description Manager RDM API to access the search engine and its database The RDM API provides routines to parse modify and create resource description messages RDMs using C The robot generates RDs and saves them to the search engine database You can retrieve the RDs in SOIF format use the RDM API to modify them and then have the search engine import them back The RDM API is defined in the ram h file in the following directory in your se
51. following URL in your browser http hostname port portal dt provider CustomTCProvider Customizing the Column Widths The getWidths int column method throws ProviderException it returns the column width for the column the width is requested for By default the column widths for left right columns in layout 1 and layout 2 are defined as 30 70 and for layout 3 they are defined as 25 50 25 To customize the column widths extend the JSPTableContainerProvider and override the getWidths int column method to return different widths 1 Extend the JSPTableContainerProvider and develop the CustomJSPTableContainerProvider class file The CustomJSPTableContainerProvider class file in Code Example 5 17 on page 143 overrides the get Widths method in the JSPTableContainerProvider and returns 40 for left and 60 for right columns and 30 40 30 for layout 3 changes are shown in bold 142 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 5 17 CustomJSPTableContainerProvider java File JSPContainerProviderAdapter package custom import com sun portal providers import com sun portal providers ProviderException import com sun portal providers ProviderWidths import com sun portal providers Provider import com sun portal providers util Layout containers jsp table JSPTableContainerProvider public class CustomJSPTableContainerProvider extends JSPTableContainerProvider public int get
52. for writing information to log files 212 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating New Robot Application Functions pblock h Contains functions that manage parameter passing and robot internal variables It also contains functions to get values from a user via the server Writing Robot Application Functions When you write robot application functions you must make sure that the file that defines your robot application functions includes robotapi h You will also find many useful functions in csinfo h All Robot Application Functions use parameter blocks pblocks to receive and set parameter values A parameter block stores parameters as name value pairs A parameter block is a hash table that is keyed on the name portion of each parameter it contains In this section the following topics are described e RAF Prototype e Writing Functions for Specific Directives e Passing Parameters to Robot Application Functions e Working with Parameter Blocks e Getting Information on the Processed Resource e Returning a Response Status Code e Reporting Errors to the Robot Log File e RAF Definition Example RAF Prototype All robot application functions have the following prototype int RobotAPIFn pblock pb CSFilter csf CSResource csr pb is the parameter block containing the parameters for this function invocation csf is the pointer to an enumeration or generation filter Chapter 8 Search Eng
53. fullTopList fullBottomList based on width and as required by your new layout Map columnMap new HashMap columnMap put new Integer LEFT leftList columnMap put new Integer RIGHT rightList columnMap put new nteger CENTER centerList columnMap put new Integer TOP fullTopList columnMap put new Integer BOTTOM fullBottomList return columnMap public int getWidths int column throws ProviderException int centerWidth 1 int leftWidth 1 int rightWidth 1 modify this method as shown in the customizing column widths section according to your layout specifications or keep this method as is return the corresponding width based on the column switch column case LEFT return leftWidth case RIGHT return rightWidth case CENTER return centerWidth default return 1 2 Compile the class and put it in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory To compile the CustomTCProvider java file enter Chapter 5 Using the Container Providers 139 JSPContainerProviderAdapter javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server instal
54. handle the processing of layout 5 that you have created Add the display profile for CustomLayoutContainer as shown in Code Example 5 16 CustomLayoutContainer xml File lt Container name CustomLayoutContainer provider JSPSingleContainerProvider advanced true gt lt Properties gt lt String name title value JSP Custom Layout Channel gt lt String name description value This is the JSP Layout Channel gt Chapter 5 Using the Container Providers 141 JSPContainerProviderAdapter Code Example 5 16 CustomLayoutContainer xml File Continued lt Container gt lt Available gt lt Available gt lt Selected gt lt Selected gt lt Channels gt lt Channels gt lt String name contentPage value merge replace lock false propagate false gt lt String name editPage value layoutedit jsp gt lt String name processPage value layoutdoedit jsp gt lt Boolean name isEditable value true advanced true gt lt String name editType value edit_complete advanced true gt lt Properties gt 14 15 Upload the display profile XML fragment for CustomLayoutContainer using the dpadmin command For example to upload CustomLayout Container xml file fragments type portal server install root SUNWps bin dpadmin add u dn_amadmin w password d distinguishedname CustomLayoutContainer xml Access CustomTCProvider from your browser To access type the
55. hostname port portal dt provider Cust omTableContainer Example 2 Figure 5 2 shows a sample layout for a Thin_Wide_Thin_Span column The table Desktop layout in Figure 5 2 has three columns with the full_bottom spanning two left and center columns Figure 5 2 Sample Table Column Span To achieve the layout shown in Figure 5 2 1 Extend JSPTableContainerProvider and develop the SpanTableContainerProvider class file The SpanTableContainerProvider class is implemented by extending the JSPTableContainerProvider class as shown in Code Example 5 8 on page 130 Code Example 5 8 SpanTableContainerProvider java File package custom import com sun portal providers containers jsp table JSPTableContainerProvider import com sun portal providers ProviderException import com sun portal providers ProviderWidths 130 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter Code Example 5 8 SpanTableContainerProvider java File Continued import com sun portal providers Provider import com sun portal providers context ContainerProviderContext import javax servlet http HttpServletRequest import java util List public class SpanTableContainerProvider extends JSPTableContainerProvider public int getRowSpan HttpServletRequest req throws ProviderException int rowSpan 1 List selected getSelectedChannels for int i 0 i lt selected size i Str
56. message tatic String NO_CACHE noCache tatic String NO CACHE TEMPLATE noCache template tatic String PARENT CONTAINER NAME parentContainerName a an a a a a a a a a a a a a a a Am a a a Am a a a Mm Mm NV private final static String PRODUCT NAME productName private final static String THEME_CHANNEL theme_channel private final static String TITLE_BAR_COLOR titleBarColor private final static String TOOLBAR_ROLLOVER toolbarRollover private final static String TOOLBAR_ROLLOVER_JS toolbarRollovers js Implement the getContent method public StringBuffer getContent HttpServletRequest req HttpServletResponse res throws ProviderException Hashtable tags getStandardTags req if bundle null bundle getResourceBundle tags put welcome bundle getString welcome tags put message getStringProperty message StringBuffer b getTemplate content template tags return b 80 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Extending the ProfileProviderAdapter Class Code Example 3 13 HelloWorldProviderPPA2 java File Continued Implement the getEdit method public StringBuffer getEdit HttpServletRequest req HttpServletResponse res throws ProviderException String containerName req getParameter containerName String providerName req getParameter targetprovider String editChannelNam
57. nbsp lt td gt lt tr gt lt tr gt lt td align center gt lt SELECT NAME desktop gt lt jx forEach var channel items SavailableChannel gt lt dtcpc obtainChannelFromContainer channel Schannel gt lt jx declare id channel type java lang String gt lt dt getTitle id title scope request silentException true gt lt String title String pageContext getAttribute title PageContext REQUEST SCOPE String selected Chapter 5 Using the Container Providers 161 Creating a Custom ContainerProvider Code Example 5 28 Sample routeredit jsp File Continued if selectedChannel equals channel selected selected Ss lt OPTION lt selected gt VALUE lt channel gt gt lt title gt lt OPTION gt lt dtcpc obtainChannelFromContainer gt lt jx forEach gt lt SELECT gt lt td gt lt tr gt lt table gt lt CENTER gt lt br gt lt font size 0 face lt fontFacel gt gt lt input type SUBMIT name Submit value Finished CLASS button gt lt input type BUTTON onClick location lt dtpc getDesktopURL gt value Cancel CLASS button gt lt font gt lt br gt lt p gt lt form gt lt br gt lt jsp include page menubar jsp flush true gt lt 5 include file footer html gt lt dtpc providerContext gt lt dt obtainContainer gt 6 Make a directory for the files in etc opt SUNWps deskt op desktoptype direct
58. portal dt provider HelloWorldP Extending the ProviderAdapter Class As the ProviderAdapter class has implemented many of the methods of the Provider interface the custom provider can extend ProviderAdapter and can override some of the methods or define any new methods The advantage of extending this class versus implementing the Provider interface directly is that you will maintain forward compatibility as additions are made to the PAPI Existing code will by default call the methods in this class Also the ProviderAdapter contains default implementations of methods in the Provider interface that you can use To create a custom provider by extending the ProviderAdapter class NOTE This section provides the instructions for creating a custom provider by extending the ProviderAdapter class The process described here includes creating a sample HelloWorldProvider that prints Hello World on the provider s channel 1 Create a new java class which extends the ProviderAdapter class For the sample HelloWorldProvider create the class file as shown in Code Example 3 4 on page 70 Chapter 3 Extending the Base Providers 69 Extending the ProviderAdapter Class Code Example 3 4 HelloWorldProviderPA java File package custom import import import import public javax servlet http HttpServletRequest javax servlet http HttpServletResponse com sun portal providers ProviderAdapter com sun portal providers Provi
59. to be not editable an exception is thrown on the Desktop If the channel can be edited the DesktopServlet also checks the editType for that channel The editType is a channel property that can be retrieved via the Provider getEditType method The provider s getEdit Type method is invoked to determine the type of edit page to return on the Desktop If the channel s edit type is o EDIT COMPLETE the provider s get Edit method is invoked and the Edit page for the channel is returned on the Desktop o EDIT SUBSET the edit container s provider name will be detected via the default Desktop Edit Container attribute and then the edit container s getEdit method will be invoked Also I The edit container s provides a common look and feel of the edit page for all the channels that it contains After it generates the markup for the common look and feel it detects the channel name from the request parameter and determines whether the target channel is editable Chapter 2 Using Provider API PAPI 41 Overview of the Provider API and Desktop Servlet If the target channel is not editable it throws a provider exception If the target channel is editable it gets the channel s edit type and delegates the process to the target channel s get Edit method ll If the channel s edit type is EDIT COMPLE H E the Edit page is displayed e EDIT
60. to implement an arbitrary filter to selectively look up properties with certain criteria and or to store properties that are specific to certain setting can extend the PropertiesFilter class This section provides the instructions for creating a custom filter by extending the PropertiesFilter class 1 Create the Java class which will implement the filter The class file for the sample DateLaterThanPropertiesFilter is shown in Code Example 3 19 Code Example 3 19 DateLaterThanPropertiesFilter java File import import import import import import import import public private static final DateFormat dateFormat DateFormat getDateInstance DateFormat SHORT private Date date null public DateLaterThanPropertiesFilter protected void init String value boolean required throws PropertiesFilterException com acme filters DateLaterThanPropertiesFilter susu 2 java util Iterator java util Date java text DateFormat java text ParseExcept ion com sun portal providers context PropertiesFilter com sun portal providers context PropertiesFilterException com sun portal providers context ProviderContext class DateLaterThanPropertiesFilter extends PropertiesFilter super super init value required try date dateFormat parse value catch ParseException pe throw new PropertiesFilterException DateLaterThanPropertiesFilter pe Chapter 3 Extending the Base
61. utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name CustomXMLProvider class custom CustomXMLProvider gt lt Properties gt lt String name title value XML Provider gt lt String name description value DESCRIPTION gt lt String name width value thick gt lt String name refreshTime value 0 advanced true gt 110 Sun ONE Portal Server 6 2 Developer s Guide December 2003 XMLProvider Code Example 4 15 CustomXMLProvider xml File Continued lt Boolean name isEditable value false advanced true gt lt String lt String lt String lt String lt String name helpURL value desktop xmlchann htm advanced true gt name fontFacel value Sans serif gt name productName value Sun ONE Portal Server gt name url value gt name xslFileName value html_stockquote xs1 gt lt Integer name timeout value 100 gt lt String lt String name inputEncoding value iso 8859 1 gt name urlScraperRulesetID value default_ruleset gt lt Boolean name cookiesToForwardA11 value true gt lt Collection name cookiesToForwardList gt lt Collection gt lt Properties gt lt Provider gt Code Example 4 16 CustomXMLChannel xm1 File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt
62. value true gt name defaultChannelIsMinimized value false advanced true gt name defaultChannelIsDetached value false advanced true gt name defaultChannelIsDetachable value true gt name defaultChannelIsRemovable value true gt name defaultChannelHasFrame value true advanced true gt name defaultChannelIsMovable value true gt name defaultBorderlessChannel value false advanced true gt lt String name defaultChannelColumn value 1 advanced true gt lt String name defaultChannelRow value 1 advanced true gt ion name channel ion name channel ion name channel ion name channel ion name channel ion name channel ion name channel ion name channel ion name channel ion name borderl gt Channels gt Channels gt sIsMinimized advanced true gt sIsDetached advanced true gt sHasFrame advanced true gt sIsMinimizable gt sRow advanced true gt sColumn advanced true gt sIsMovable gt sIsDetachable gt sIsRemovable gt essChannels gt Code Example 5 7 CustomTCChannel xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name CustomTableContainer provider CustomTableContainerProvider gt lt Properties gt lt String lt String lt String lt String name title value Front Table Container Channel
63. will be displayed in JSPTableContainer To add the channel in the JSPTableContainer from the administration console follow instructions in Sun ONE Portal Server 6 2 Administrator s Guide To add the channel in the JSPTableContainer manually 106 Sun ONE Portal Server 6 2 Developer s Guide December 2003 URLScraperProvider a Add the CustomURLScraperProvider channel XML fragment in the CustomURLSContainer xml file for the JSPTableContainerProvider The CustomURLScraperProvider container XML fragment is shown in Code Example 4 13 Code Example 4 13 CustomURLSContainer xm1 File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name JSPTableContainer provider JSPTableContainerProvider gt lt Properties gt lt Collection name Personal Channels gt lt String value CustomURLSC gt lt Collection gt lt Collection name channelsRow gt lt String name CustomURLSC value 3 gt lt Collection gt lt Properties gt lt Available gt lt Reference value CustomURLSC gt lt Available gt lt Selected gt lt Reference value CustomURLSC gt lt Selected gt lt Channels gt lt Channels gt lt Container gt b Use the dpadmin modify sub command to add the channel to a container If you do not specify a parent object with the p option the channel is added at the root level portal serv
64. 003 gt lt ConditionalProperties condition client value nokia gt lt String name foo value en 03 03 2003 nokia gt lt ConditionalProperties gt 90 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Extending the PropertiesFilter Class Code Example 3 20 DateLaterThanPropertiesFilter xml File lt ConditionalProperties gt lt ConditionalProperties condition client value nokia gt lt String name foo value en nokia gt lt ConditionalProperties gt lt ConditionalProperties gt lt Properties gt 4 Load the display profile using the dpadmin command For example to load the DateLaterThanPropertiesFilter xml into the provider display profile type portal server install root SUNWps bin dpadmin modify m p channelName u dn_amadmin w password d distinguishedname DateLaterThanPropertiesFilter xml Alternatively you can also use the administration console to add and or modify conditional properties See Sun ONE Portal Server 6 2 Administrator s Guide for more information 5 Implement the code to access the filter in your custom provider class file where you wish to implement this filter For example in your provider you can access the sample DateLaterThanPropertiesFilter by doing one of the following o Code Example 3 21 includes an implementation that will return en 03 03 2003 nokia Code Example 3 21 Provider Implementation for DateLaterThanPropertiesFilter
65. 5 An Introductory Example This example assumes that you have already created a file containing a SOIF stream which is available on stdin For example you could have created a SOIF stream containing one or more RDs from the search engine database which you would do by using the routines in RDM nh This example uses SOIF_ParseInitFile to create a SOIF stream from the standard input Code Example 7 1 Simple SOIF Stream Parsing Example Example 1 Simple SOIF Stream Parsing include lt stdio h gt include lt stdlib h gt include soif h int main int argc char argv Define a SOIFStream and SOIF SOIFStream ss SOIF s char titleptr Open a SOIF stream that gets its SOIF from stdin ss SOIF_ParselInitFile stdin SOIFStream_IsEOS checks if this is the end of the stream while SOIFStream ISEOS ss if s SOIFStream Parse ss Exit the loop if the SOIF is invalid break Print the URL for each SOIF will be if there is no URL printf URL Ss n s gt url Print the title if it exists titleptr SOIF_Findval s title printf Title 5s1n titleptr titleptr none Print the number of attributes in the SOIF printf of Attributes d n SOIF GetAttributeCount s release the memory used by the SOIF SOIF Free s Close the SOIFStream and exit SOIFStream Finish
66. Access the Search Engine Database 241 Using Java To Access the Search Server Database If you have installed the browser Java plugin then the instructions are similar to those for appletviewer except that you must make the classes available for download to the client browser To do this 1 Copy SearchDemo html searchsdk jar and the directory hierarchy created above including the SearchDemo classes to a location that is in the content path of your web server You can also add the search demo classes to searchsdk jar to make the applet available in a single download 2 The searchsdk jar file must be named as the archive attribute of the applet tag in SearchDemo html For example enter jar uf com sun portal search demo class searchsdk jar Using Java To Access the Search Server Database 242 You can use the search engine Java SDK to write Java programs that interface with the sendrdm program to retrieve information from the search engine database The main steps are e Creating a Search Object e Executing A Query and Getting the Results Creating a Search Object The entry point for submitting searches is the Search class You need to create a new Search object then call doQuery on it to execute the search query The first thing you need to do is create a new Search object The full constructor syntax is public Search String scope String viewAttributes String viewOrder int firstHit Sun
67. CRIPTION i If there is a SOIF output if sos null try sos writeBytes soif catch Exception el output file el break if firstPageSOIF null attributes URL is special n n n n search getResultStream Examine the results of the search The following code loops through the stream of SOIF i soif instances soif null For illustration dump out the entire SOIF on the first page only firstPageSOIF write soif toByteArray method to get requested and has title description score do something with the results file write the SOIF data there too toString System out println Error failed to write to SOIF r Break if the largest requested hit has been displayed if search getHitCount lt firstHit pagesize 1 System out println No matching documents found Chapter 10 Using Java to Access the Search Engine Database 251 Using Java To Add Entries to the Search Engine Database Using Java To Add Entries to the Search Engine Database The program rdmgr is used to add data to the database from the command line This section describes how to create input data for rdmgr so that it can be added to the database The rdmgr utility can add new data as well as replace modify or retrieve existing data All data input and output is done using SOIF with UTF 8 character
68. Chapter 8 Search Engine Robot 211 Creating New Robot Application Functions The following table describes the header files in the include directory in the first left column and a brief description of the corresponding directory in the second right column csinfo h Contains functions for object typing specifically for mapping files to MIME types csmem h Contains memory related definitions robotapi h Contains the type definitions for structures and the return code definitions for robot API functions filterrules h Contains type definitions for structures needed by filter rules The following table describes the header files in the base directory in the first left column and a brief description of the corresponding directory in the second right column systems h Contains functions that handle system information The following table describes the header files in the 1ibcs directory in the first left column and a brief description of the corresponding directory in the second right column adt h Contains type definitions and function prototypes for utilities needed by the robot such as linked lists queues and hash tables cs h Contains a library of common functions used by the Search Engine csidcf h Contains configuration definitions for Search Engine getopt h Contains routines to get options from the command line for example command line prog n argl p arg2 to get arg1 and arg2 log h Contains routines
69. Class Code Example 3 15 HelloChannelPPA2 xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Channel name HelloWorldPPA2 provider HelloWorldProviderPPA2 gt lt Properties gt lt String name title value Hello World Channel gt lt String name fontFacel value sans serif gt lt String name productName value Sun ONE Portal Server gt lt String name editType value edit_complete gt lt String name description gt This is a test of the hello world provider lt String gt lt String name width value thin gt lt String name message value Hello World Test non localized gt lt Locale language en country US gt States gt lt String name message value Hello World I am speaking English in the United 84 lt Locale gt lt Properties gt lt Channel gt 4 Load the provider and channel display profile definitions using the dpadmin command To load the sample HelloProviderPPA2 provider and channel definitions type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname HelloProviderPPA2 xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname HelloChannelPPA2 xml 5 Create the resource bundle properties file for the HelloWorldProvider HelloWorldProviderPPA2 properties and include th
70. Container advanced true gt name isEditable value true advanced true gt name editType value edit_complete advanced true gt name editContainerName value JSPEditContainer advanced true gt hin_popup_height value 200 gt name thin_popup_width value 500 gt name thick_popup_height value 300 gt name thick_popup_width value 600 gt name fullwidth_popup_height value 500 gt name fullwidth_popup_width value 600 gt name defaultChannelIsMinimizable value true gt name defaultChannelIsMinimized value false advanced true gt name defaultChannelIsDetached value false advanced true gt name defaultChannelIsDetachable value true gt name defaultChannelIsRemovable value true gt name defaultChannelHasFrame value true advanced true gt Chapter 5 Using the Container Providers 151 JSPContainerProviderAdapter Code Example 5 21 CustomTabCProvider xml File Continued lt Boolean name defaultChannelIsMovable value true gt lt Boolean name defaultBorderlessChannel value false advanced true gt lt String name defaultChannelColumn value 1 advanced true gt lt String name defaultChannelRow value 1 advanced true gt lt Collection name channelsIsMinimized advanced true gt lt Collection name channelsIsDetached advanced true gt lt Collection name channelsHasFrame advanced true gt lt Collection name channelsIsMi
71. Container with CustomLayoutContainer 8 Create a new directory for CustomLayoutContainer under etc opt SUNWps desktop desktoptype For example type mkdir etc opt SUNWps desktop desktoptype CustomLayoutContainer 140 Sun ONE Portal Server 6 2 Developer s Guide December 2003 10 Code Example 5 15 JSPContainerProviderAdapter Copy files from etc opt SUNWps desktop default JSPLayoutContainer to etc opt SUNWps deskt op desktoptype CustomLayoutContainer For example type cp etc opt SUNWps desktop default JSPLayoutContainer etc opt SUNWps deskt op desktoptype CustomLayoutContainer Modify layoutedit jsp to display your new layout in the layout page Modify the layoutedit jsp file at etc opt SUNWps desktop desktoptype CustomLayoutContainer as shown in Code Example 5 15 Sample layoutedit jsp lt jx choose gt lt jx when gt lt jx when gt lt jx when gt lt jx when gt lt jx choose gt lt jx when test Slayout 1 gt lt 5 include file layout1 jsp lt jx when test layout 2 gt lt 5 include file layout2 jsp lt jx when test Slayout 3 gt lt 5 include file layout3 jsp lt jx when test layout 5 gt lt include file layout5 jsp gt ae Vv oe Vv ao Vv 11 12 13 Code Example 5 16 Create a new layout 5 jsp which gets displayed on the layout page when the user selects layout 5 Modify layoutdoedit jsp to
72. ContainerProvider Change the default channel name to your ContainerProvider To specify the default channel name select Services from the View pull down menu for your organization and select Portal Desktop For the sample RouterContainerProvider change the default channel name to JSPRouterContainer Save the settings and log out of the administration console Log in as the default user into the portal Desktop Select the Desktop Preference Link from the menubar The sample RouterContainerProvider provides the page to select Tabbed or Table Desktop Chapter5 Using the Container Providers 165 Creating a Custom ContainerProvider 166 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Chapter 6 Developing and Deploying Portlets The Sun ONE Portal Server software includes an implementation of the Portlet Specification as defined by the JSR168 Expert Group This chapter includes the following sections e What is a Portlet e Overview of Developing and Deploying Portlets e Extending the GenericPortlet Abstract Class e Converting Providers to Portlets e Files Used by Portlets What is a Portlet Portlet refers to pluggable web components that process requests and generate content within the context of a portal In the Sun ONE Portal Server software portlets are managed by the Portlet Container Conceptually portlets they are equivalent to the Providers Overview of Developing and Deploying Portlets To devel
73. ContentContainer JSPLayoutContainer JSPEditContainer Extending the JSPSingleContainerProvider In the following example the CustomSingleContainerProvider getSelectedChannel HttpServletRequest req method overrides the JSPSingleContainerProvider getSelectedChannel method to return the first channel from the list whose width is full_top 1 Extend the JSPSingleContainerProvider and develop the CustomSingleContainerProvider class file The CustomSingleContainerProvider class overrides the JSPSingleContainerProvider getSelectedChannel method as shown in Code Example 5 1 Code Example 5 1 CustomSingleContainerProvider java File package custom import com sun portal providers containers jsp single JSPSingleContainerProvider import com sun portal providers ProviderException import com sun portal providers Provider import com sun portal providers ProviderWidths import com sun portal providers context ContainerProviderContext import javax servlet http HttpServletRequest import java util List public class CustomSingleContainerProvider extends JSPSingleContainerProvider public String getSelectedChannel HttpServletRequest req throws ProviderException List selectedChannels getSelectedChannels for int i 0 i lt selectedChannels size i String channel String selectedChannels get i Provider p getContainerProviderContext getProvider req getName channel if p getWidth Pr
74. Custom Provider The HeadlineContainerProvider class is also loaded by loader2 because of the reference to it in the HeadlineProvider code The cast is from the object container1 loaded by loader1 to the variable hcp of type HeadlineContainerProvider loaded by loader2 Thus the cast fails because the class loaders are not the same To understand a case where the classes could actually be different consider the case where container1 is loaded at time 0 and channel is loaded at time 10 but the HeadlineContainerProvider class files was updated on disk at time 5 This means that channel will be running with a different version of the HeadlineContainerProvider class than that being used for container1 The case must fail because the class versions are different To implement this type of application an alternate solution is to pass an object as a request or session property that has a class that is not in the etc opt SUNWps desktop classes directory such as String Set or Hashmap These classes are never reloaded except when the server restarts The data that you store in that object becomes a contract between different versions of the classes that use that object Creating XML Fragments for Display Profile A provider must be defined in the display profile before it can be used This definition associates the provider with its class file implementation and includes the provider s properties That is the provider s display profile fragm
75. CustomTCProvider xml file and CustomTCChannel xml file fragments in the display profile That is type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomICProvider xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomTCChannel xml 5 Create a new directory for the provider in etc opt SUNWps desktop desktoptype directory The directory for the provider is typically named after the channel For the sample CustomTableContainerProvider create a directory called CustomTableContainer in etc opt SUNWps deskt op desktoptype 6 Develop and copy the JSP files for the provider in the newly created directory For CustomTableContainerProvider copy files from etc opt SUNWps desktop default JSPTableContainerProvider to the etc opt SUNWps deskt op desktoptype CustomTableContainer directory 7 Copy the resource file for the provider into etc opt SUNWps desktop classes directory For example for the CustomTableContainerProvider a Change directories to webcontainer portal WEB INF classes directory Chapter5 Using the Container Providers 129 JSPContainerProviderAdapter b Type cp JSPTableContainerProvider properties etc opt SUNWps desktop classes CustomTableContainerProvider properties 8 Access CustomTableContainerProvider from your browser To access log in to the Desktop and type the following URL in your browser http
76. Developer s Guide Sun ONE Portal Server Version 6 2 816 6758 10 December 2003 Copyright 2003 Sun Microsystems Inc 4150 Network Circle Santa Clara California 95054 U S A All rights reserved Sun Microsystems Inc has intellectual property rights relating to technology embodied in the product that is described in this document In particular and without limitation these intellectual property rights may include one or more of the U S patents listed at http www sun com patents and one or more additional patents or pending patent applications in the U S and in other countries THIS PRODUCT CONTAINS CONFIDENTIAL INFORMATION AND TRADE SECRETS OF SUN MICROSYSTEMS INC USE DISCLOSURE OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SUN MICROSYSTEMS INC U S Government Rights Commercial software Government users are subject to the Sun Microsystems Inc standard license agreement and applicable provisions of the FAR and its supplements This distribution may include materials developed by third parties Parts of the product may be derived from Berkeley BSD systems licensed from the University of California UNIX is a registered trademark in the U S and in other countries exclusively licensed through X Open Company Ltd Sun Sun Microsystems the Sun logo Java Solaris JDK Java Naming and Directory Interface JavaMail JavaHelp J2SE iPlanet the Duke logo the Java Coffee Cup logo the Solari
77. Error failed to create output file el SOIFBuffer firstPageSOIF for pagenum lt 5 pagenumt int firstHit pagenum 1 pagesizet1 null sos new DataOutputStream new FileOutputStream SOIFOutputFile new SOIFBuffer Chapter 10 Using Java to Access the Search Engine Database 249 Using Java To Access the Search Server Database 250 try search doQuery firstHit pagesize catch Exception ex ex printStackTrace break i Check the result count 1 indicates an error if search getResultCount lt 0 break The results are stored in the Search object Now do something with the results The functions doSomethingWithResults and displayHTMLResults will be defined in this file They each show a different way of extracting the results from the Search object Display the Results The example application displays the query results to standard output or to a named file In reality you would do more with the results than just print them like this but once you know how to get the results out of the Search object it is up to you what you do with them You can use standard Java functionality to process the results in any way you like The Search object has a method called getResultStream that returns a SOIFInputStream object Each result is read from this SOIF stream in turn Note that the client server connection uses an efficient streamed protocol it is con
78. Facel value Sans serif gt lt Collection name categories gt lt String value Personal Channels gt lt String value Sample Channels gt lt String value News Channels gt lt Collection gt lt Collection name Personal Channels gt lt String value UserInfo gt lt String value MailCheck gt lt String value Bookmark gt lt String value App gt lt Collection gt lt Collection name Sample Channels gt lt String value SampleJSP gt lt String value SampleXML gt Chapter 5 Using the Container Providers 133 JSPContainerProviderAdapter Code Example 5 10 SpanTCChannel xml File Continued lt Collectio lt Collection lt String lt Collectio lt Collection lt String lt String lt String lt String lt String lt Collectio lt Collection lt Boolea lt Collectio lt Collection lt String lt String lt String lt String lt Collectio lt Collection lt String lt String lt String lt String lt Collectio lt Properties gt lt Available gt lt Reference Reference Reference Reference Reference Reference Reference Reference lt Available gt lt Selected gt lt Reference Reference Reference Reference Reference Reference Reference lt Reference lt Selected gt lt Channels gt lt Channels gt lt Container gt AA AA A A A A A A A A A n gt name News Channels gt value SampleRSS gt n gt name channelsRow ad
79. Is allow you to create new providers for delivering portal content to users Conceptually the Desktop APIs consist of Java interfaces in a stack as shown in Figure 1 3 on page 18 Chapter 1 Introduction to the APIs 17 Overview of the APIs Figure 1 3 Desktop APIs Desktop Servlet Building Blocks Containers JSPSingleContainerProvider JSPTableContainerProvider Leaves TabContainer toy eee JSPTabContainerProvider rovider URLScaperProvider a ModifiableTab PAPI Interfaces Context Interfaces Provider ProviderContext ContainerProvider ContainerProviderContext ProviderWidths ProviderEditTypes ProviderWindowStates Exceptions ProviderException 18 Base Classes ProviderAdapter ProfileProviderAdapter ContainerProviderAdapter JSPContainerProviderAdapter PropertiesFilter ClientPropertiesFilter LocalePropertiesFilter PropertiesFilterFactory Theme UnknownEditTypeException InvalidEditFormDataException AsciiForminputExpectedException ProviderContextException UnsupportedWindowStateException PropertiesFilterException Sun ONE Portal Server 6 2 Developer s Guide Provider API At the bottom of Figure 1 3 is the Provider Application Programming Interface PAPI a foundation that contains the interfaces base classes provider context and exception classes As a developer use the PAPI and extend the base classes to create new providers
80. L Tommy I I SOIFAVPair_IsMV define SOIFAVPair IsM avp Use this to determine if the avpair has multiple values or not SOIFAVPair NthValid define SOIFAVPair_NthValid avp n Use this to determine if the Nth value is valid or not SOIFAVPair NthValue define SOIFAVPair NthValue avp n avp gt values n Use this to access the Nth value For example for i 0 i lt avp gt last_slot i if SOIFAVPair_NthValid avp i printf s s n avp gt attribute SOIFAVPair_NthValue avp i SOIFAVPair_NthVsize define SOIFAVPair NthVsize avp n avp gt vsizes n Use this to get the size of the Nth value SOIF_Contains NSAPI_PUBLIC boolean_t SOIF_Contains SOIF s char a char v int vsz 196 Sun ONE Portal Server 6 2 Developer s Guide December 2003 SOIF API Indicates if the given attribute contains the given value It returns B_TRUE if the value matches one or more of the values of the attribute a in the given SOIF s Stream Routines for Parsing and Printing SOIFs A SOIFStream contains one or more SOIF objects The general approach is that you use SOIF streams to create and process streams of many SOIF objects Given a SOIF stream you can parse it to get the SOIF objects from it Use the parse routine to get the next SOIF object in a SOIF stream You can use SOIFStream_IsEOS to check whether the last object has been parsed You can use filter
81. OIF_Findval csr return REQ PROCEED Now insert the string s into t Classification field of the RD Deal with possibility that the already has one or more values if mv libcs_pblock_findval ds sprintf mvp s s mv s src pb dst pb destination available ot have a META tag whose name t return otherwise put the attribute is defined gets the value of the resource soif that describes the resource gt rd Src y he KJ classification field xy t cSr gt sources NULL mvp malloc strlen mv strlen s 2 append the new value to the classification field separa libcs_pblock_nvinsert dst mvp do some clean up free mvp if no values already exist do existing values in the ted by z esr gt sources a simple value insert Chapter 8 Search Engine Robot 221 Creating New Robot Application Functions Code Example 8 3 Robot Application Function Example Continued else libcs_pblock_nvinsert dst s csr gt sources We re all done Return a status code return REQ PROCEED 222 Compiling and Linking your Code You can compile your code with any ANSI C compiler See the makefile in the portal server install root SUNWps sdk robot example directory for an example The makefile assumes the use of gmake This section lists the linking options you need to use to create a s
82. RDM header section begins with a SOIF object whose schema name is RDMHEADER which must contain as least the attributes listed in the following table rdm version A string identifying the version of the message specification for example 1 0 rdm type A string identifying the nature of this message rdm query language A string which identifies which query language is required only for used in the given request Request messages catalog service id A cs1D identifying the catalog to which the optional request response applies for example x catalog siroe budgie com 80 finance If not present the RDM server will use its default catalog 226 Sun ONE Portal Server 6 2 Developer s Guide December 2003 What is an RDM The following example shows two RDM headers and their attributes RDMHEADER rdm version 3 1 0 rdm type 14 status request RDMHEADER rdm version 3 1 0 rdm type 10 rd request rdm query language 6 search catalog service ID 39 x catalog budgie siroe com 80 finance RDM Body The RDM message body contains any data needed to carry out the request For example if the header is rd request which indicates a query request the body must contain the query criteria or scope For example if you are sending a request to find all documents that contain the string varrius then the body must be SOIF object whose schema name is RDMQuery and whose scope attribute is varri
83. TableContainerProv ider properties to etc opt SUNWps desktop classes SpanTableContainerProvider prope rties file 9 Atleastone of the selected channels should be of width full_bottom and the selected layout should be thin_wide_thin for the layout described in Figure 5 2 on page 130 to be displayed 10 Access SpanTableContainerProvider from your browser To access type the following URL in your browser http hostname port portal dt provider SpanTableContainerChannel Example 3 This section provides some sample extensions to the JSPTableContainerProvider class file and its associated JSP files for enabling a customized Desktop layout Chapter5 Using the Container Providers 137 JSPContainerProviderAdapter Customizing the Row Layout 1 Create a new custom table container provider by extending JSPTableContainerProvider as shown in Code Example 5 14 Override the get Layout setUpColumns and getWidths methods as shown in Code Example 5 14 in the CustomTCProvider java file You can also add any new logic to arrange the channels into rows and columns according to your new layout Code Example 5 14 CustomTCProvider java File package custom import com sun portal providers containers jsp table JSPTableContainerProvider import com sun portal providers ProviderException import com sun portal providers ProviderWidths import com sun portal providers Provider import com sun portal providers util Layout im
84. The URLs that it starts crawling from e Server access delays e Passwords e User agent string e Certificates for SSL e Proxy setup In addition the robot API enables you to write custom content parsers and summarizers for special URL handling requirements You can also use the robot API to remove advertisements generate alerts when certain pages are found and perform specialized logging Search Database The Search database consists of Summary Object Interchange Format SOIF objects The search API creates reads modifies and writes the Search database entries Assisting APIs create buffers set and get attribute value pairs used to define content and metadata for the objects in the database handle exceptions create a SOIF output stream and read a SOIF input stream Normally the Search database can be accessed by using the SOIF API but the database can also be accessed through command line utilities You can also add RDs that you create or import RDs from another database An RD is a description of some object to include into the system SOIF is the format used to represent RDs Chapter 1 Introduction to the APIs 21 Portal Environment Authentication APIs The Sun ONE Portal Server software uses the Sun ONE Identity Server software APIs for authentication single sign on session profile and logging In general most development work for a portal developer in the Sun ONE Identity Server software area will be to cus
85. This Guide zere nnn igs veen eden a UNAG ade E dee wre RA 7 Who Should Read This Book sss ars aaan 269698494 des ETA 7 What You Need to KNOW vr licia es ee eas oe seaweed ede Madea 7 How This Book is Organized ili RE ee OEE Ra eee eet 8 Document Conventions Used in This Guide aas i Le na 9 Monospaced FORE iii Pe ete teen weed 9 Bold Monospaced BORE on iii al wate eee 9 Italicized Font a RT E ana 9 Command Line Prompts ui veren I ia 10 Where to Find Related Information sss 04 60600465 der des danser ea niiata 10 Whereto Find This Guide Online gt voe iride Bee ps ila 10 Chapter 1 Introduction to the APIS cece eee eee eee e eee eee 11 OENE derne dn rasa es etna ls his agra a aa se aie eG 11 WharlsaPortal ele eee eed ee Saba AA 12 Desktopand Desktop Flierateh i dei 12 Display Profile opus edhe liebe AN 13 el AAP AA APA AA 14 Sotware SeMVICES ic as PAA PRA bee La Ep tee Re aa tee ane ta de 14 Applicaton Development gt oren denten TA ADA e ia 15 Software Architectite nn ici riad Aahh ad pba Ph Dh 15 Oyeryiew of De APIS AA AP 17 Deskop APIS isolato ele 17 Search API ile lhi era 20 Authentication APIS ari ili iii dla bk tea hie 22 Portal AA AA 22 Web CON MEE iii KA a ea Bane ND Ho beaten teelden eet 22 I AAP PAA AA 23 4 Chapter 2 Using Provider API PAPI eect eee rene eee eens 25 Overview of the Provider APL and Desktop Servlet vernemen sar nege
86. To access log in to the Desktop and type the following URL in your browser http hostname port portal dt provider JSPTableContainer Chapter 4 Using Leaf Providers 101 JSPProvider Deploying JSP Tags and Tag Libraries To make custom JSP tags refer to a document to write custom tag libraries for example see http java sun com products jsp tutorial TagLibrariesTOC htm1 and use this section to deploy the customized tag library into Sun ONE Portal Server software 1 Code Example 4 8 Copy the class files or JAR files that are required by the tag library under providerClassBaseDir where providerClassBaseDir is the directory defined in etc opt SUNWps desktop desktopconfig properties file Make the custom tag library For example see the custom t1d shown in Code Example 4 8 custom tld Custom Tag Library lt taglib gt lt tag gt lt tag gt lt taglib gt lt xml version 1 0 encoding ISO 8859 1 gt lt DOCTYPE taglib PUBLIC Sun Microsystems Inc DTD JSP Tag Library 1 1 EN http java sun com j2ee dtds web jsptaglibrary_1_1 dtd gt lt tlibversion gt 0 1 lt tlibversion gt lt jspversion gt 1 1 lt jspversion gt lt shortname gt customname lt shortname gt lt name gt MyCustomTag lt name gt lt tagclass gt com iplanet portalserver myTags MyCustomTag lt tagclass gt lt bodycontent gt empty lt bodycontent gt The shortname can be anything The name must be the sa
87. Topics method that returns only the predefined tabs from the list of available tabs Code Example 5 20 CustomTabContainerProvider java File package custom import com sun portal providers containers jsp tab JSPTabContainerProvider import com sun portal providers containers jsp tab UnmodifiableTab import com sun portal providers ProviderException import java util List import java util ArrayList public class CustomTabContainerProvider extends JSPTabContainerProvider public List getTabTopics throws ProviderException List availtabs new ArrayList List tabs super getAvailableTabs for int i 0 i lt tabs size i UnmodifiableTab tab UnmodifiableTab tabs get i if tab isPredefined availtabs add tab return availtabs 150 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 5 21 JSPContainerProviderAdapter Compile the class and put it in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory To compile the Cust omTabContainerProvider java file enter javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar CustomTabConta
88. Widths int column throws ProviderException int centerWidth 1 int rightWidth 1 int leftWidth 1 int layout getLayout switch layout case Layout LAYOUT THIN THICK leftWidth 40 rightWidth 60 break case Layout LAYOUT THICK THI rightWidth 40 leftWidth 60 break case Layout LAYOUT THIN THICK THIN rightWidth 30 centerWidth 40 leftWidth 30 break default rightWidth 40 leftWidth 60 break switch column case LEFT return leftWidth case RIGHT return rightWidth case CENTER return centerWidth default return 1 Chapter 5 Using the Container Providers 143 JSPContainerProviderAda pter Compile the class and put it in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory To compile the Cust omJSPTableContainerProvider java file enter javac d etc opt SUNWps desktop classes classpath BaseDir SUNWps sdk desktop desktopsdk jar BaseDir SUNWam lib servlet ja r CustomJSPTableContainerProvider java Develop the display profile XML fragments for this provider and this provider s channel The display profile fragment for the CustomJSPTableContainerProvider s provider is saved in CustomJSPTCProvider xml f
89. a Custom Provider Action logout The logout action ends the user session When the DesktopServlet receives a request where the action is logout to perform the logout action it takes the following parameters DesktopServletURL dt Pact ion logout When the DesktopServlet receives a request for the logout action it redirects the browser to a URL defined by the Sun ONE Identity Server software iplanet am platform logout url attribute in the Platform service By default this attribute has the value amserver logout But If this is set to something that does not terminate the user s session such as a static HTML page then portal dt action logout will not terminate the user session Overview of Implementing a Custom Provider This section describes the development process for a Sun ONE Portal Server provider It touches on the public APIs available for integrating an application with the Sun ONE Portal Server software Desktop via the provider Before developing a custom provider determine whether there is an existing Provider that can access the type of content you are targeting For example if you are trying to fetch content from a JSP page you can create a channel based on the the pre built JSP provider and configure it to access your JSP page If none of the APIs can be used as is determine whether or not the content can be presented by authoring a new provider by extending a provider base class such as the ProviderAdapter or ProfilePr
90. a ele TabContainer ProfileProviderAdapter ContainerProviderAdapter JSPContainerProviderAdapter JSPProvider JSPTabContainerProvider Legend A TARA implements i Pewee extends i egg Seca depends Overview of the ContainerProviders To support the container providers the PAPI includes three APIs the ContainerProvider interface the ContainerProviderAdapter class and the ContainerProviderContext interface This section provides an overview of these three APIs ContainerProvider The ContainerProvider interface defines the interface for implementing a container provider and is the programmatic entity for generating container channels A container provider has a selected and available channels list and allows getting and setting of these lists Selected channels are those that are considered active on the Desktop Available channels are those that are available to be activated on the Desktop That is selected channels are those that are available and selected for display on the Desktop by the user available channels are those that are available for display on the Desktop but not selected for display on the Desktop by the user Chapter5 Using the Container Providers 8117 Overview of the ContainerProviders 118 The Desktop container providers such as JSPSingleContainerProvider JSPTableContainerProvider and JSPTabContainerProvider discussed in this chapter extend the JSPContainerProviderAda
91. ace for implementing a container provider A container provider is a provider that generates its views primarily by being a client of other provider objects 115 The ContainerProvider Architecture Figure 5 1 The ContainerProviderAdapter provides default implementations of the following methods in the ContainerProvider get setSelectedChannels get setAvailableChannels get setWindowState and get SupportedWindowStates For more information on all the methods in this class see the Javadocs The ContainerProviderContext extends ProviderContext and adds container functionality to the ProviderContext interface The ContainerProviderAdapter uses the ContainerProviderContext object as the persistent store The JSPContainerProviderAdapter extends the JSPProvider see Chapter 4 Using Leaf Providers for more information and provides implementations of methods in the ContainerProvider interface to facilitate the execution of JavaServer Pages JSP The JSPTabContainerProvider extends the JSPContainerProviderAdapter and provides default implementation for methods in the TabContainer interface The JSPSingleContainerProvider and the JSPTableContainerProvider also extend the JSPContainerProviderAdapter The ContainerProvider Architecture 116 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of the ContainerProviders ContainerProvider ProviderContext A T ContainerProviderContext ide
92. ad the SOIF hit objects Each SOIF object read from the stream corresponds to one result public int getHitCount The function Search getHit Count returns the number of hits that matched the query Sun ONE Portal Server 6 2 Developer s Guide December 2003 Using Java To Access the Search Server Database public int getResultCount The function Search getResultCount returns the number of results that were returned by the server The result count will be equal to the number requested by the viewHits argument whenever there are enough results available public int getDocumentCount The function Search getDocument Count returns the total number of documents searched across This will usually equal the total number of documents in the searched database Working Through An Example Search Application This section discusses the SearchDemo example application provided with the Java search SDK The purpose of this example is to show how to use a Search object to submit a query to the search server and how to extract the results from the Search object The example application is very simple and limits use of Java to achieving the goals of the example It creates a Java applet that presents the user with a text field in which to enter a search query and a Search button to initiate the search The results of the query are read from a SOIFInput St ream returned by the Search object The query results are displayed to standa
93. ader files that help you create your own robot application functions to use with the directives in robot configuration files Use this API to create the built in functions for the directives used in filter conf the robot filter configuration file When you become familiar with this API you will be able to override add or customize robot functionality For example you will be able to create functions that use a custom database for access control or you can create functions that create custom log files with special entries In general most developers will write RAF functions in C However you can define the functions in any language as long as it can build a shared library If you use C you will need to modify the provided C header files to be used by C files The following steps are a brief overview of the process for creating your own plug in functions 1 Compile your code to create a shared object so file 2 In the Setup directives at the top of filter conf you tell the robot to load your shared object file or dynamic link library 3 Write directives that use your plug in functions in the robot configuration file filter conf The portal server install root SUNWps sdk robot include directory contains all the header files you need to include when writing your plug in functions The portal server install root SUNWps sdk robot examples directory contains sample code the header files and a makefile You should famil
94. ainerProviderAdapter Code Example 5 19 CustomJSPTCChannel xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name CustomJSPTableContainerChannel provider CustomJSPTableContainerProvider gt lt Properties gt lt String name title value Front Table Container Channel gt lt String name contentPage value toptable jsp gt lt String name Desktop fontFacel value Sans serif gt lt Collection name categories gt lt String value Personal Channels gt lt String value Sample Channels gt lt String value News Channels gt lt Collection gt lt Collection name Personal Channels gt lt String value UserInfo gt lt String value MailCheck gt lt String value Bookmark gt lt String value App gt lt Collection gt lt Collection name Sample Channels gt lt String value SampleJSP gt lt String value SampleXML gt lt Collection gt lt Collection name News Channels gt lt String value SampleRSS gt lt Collection gt lt Collection name channelsRow advanced true gt lt String name MailCheck value 4 gt lt String name App value 5 gt lt String name Bookmark value 3 gt lt String name SampleRSS value 2 gt lt String name SampleXML value 2 gt lt Collection gt lt Collection name channelsIsRemovable gt lt Boolean name UserInfo value
95. alizing Sun ONE Portal Server eee eee eee 257 Templates and JSPS8 vr cc retains i ER ERR dea PALA DANE al tole es 257 Desktop Templates cile e ee dee E i 257 File Lookup Mechanism 3 26 04 ea pans ct eee iwi paged ni 259 Resource Bundles 2 4 a secede ER ER 259 File Naming Convention NAN Baan DAG otek ton Bey ea eae eee ee lee 260 File Installation Location 2 4 sossen Ta dake 260 Pile Entes AA AA 260 Resource Bundle Access s sn oons en senen NYA NLNG DING GRE LEI GANG des Be ae CEES Eee 261 Display Profile Properties scene rek NAT oe ea bey eee eRe tee eee KANG 261 To Localize the User Information Channel 262 Localization Support in PAPI 2a a oa 263 6 Sun ONE Portal Server 6 2 Developer s Guide December 2003 About This Guide This guide explains how to use the Sun ONE Portal Server 6 2 software APIs Sun ONE Portal Server software provides a platform to create portals for your organization s integrated data knowledge management and applications The Sun ONE Portal Server software platform offers a complete infrastructure solution for building and deploying all types of portals including business to business business to employee and business to consumer This preface includes the following sections e Who Should Read This Book e What You Need to Know e How This Book is Organized e Document Conventions Used in This Guide e Where to Find Related Information e Where to Find This Guide Online
96. alse merge replace lock false propagate true gt lt Collection gt merge lt Collection name SamplesTabPanelContainer advanced false merge fuse lock false propagate true gt lt String name title value Samples advanced false merge replace lock false propagate true gt lt String name desc value Sampless Tab advanced false merge replace lock false propagate true gt lt Boolean name removable value true advanced false merge replace lock false propagate true gt lt Boolean name renamable value true advanced false merge replace lock false propagate true gt lt Boolean name predefined value true advanced false merge replace lock false propagate true gt lt Collection gt lt Collection name JSPTabCustomTableContainer advanced false merge fuse lock false propagate true gt lt String name title value Make My Own Tab advanced false merge replace lock false propagate true gt lt String name desc value Make from Scratch advanced false merge replace lock false propagate true gt lt Boolean name removable value true advanced false merge replace lock false propagate true gt lt Boolean name renamable value true advanced false merge replace lock false propagate true gt lt Boolean name predefined value false advanced false merge replace lock false propagate true gt lt C
97. alse merge replace lock false propagate true gt lt String name makeTabProvider value JSPTabCustomTableContainerProvider advanced true merge replace lock false propagate true gt lt String name makeTabChannel value JSPTabCustomTableContainer advanced true merge replace lock false propagate true gt lt Integer name channelNumber value 0 advanced false merge replace lock false propagate true gt lt String name contentChannel value JSPContentContainer advanced false merge replace lock false propagate true gt 152 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter Code Example 5 22 CustomTabCChannel xml File Continued lt Collection name TabProperties advanced false merge fuse lock false propagate true gt lt Collection name MyFrontPageTabPanelContainer advanced false merge fuse lock false propagate true gt lt String name title value My Front Page advanced false merge replace lock false propagate true gt lt String name desc value Your front page advanced false replace lock false propagate true gt lt Boolean name removable value false advanced false merge replace lock false propagate true gt lt Boolean name renamable value true advanced false merge replace lock false propagate true gt lt Boolean name predefined value true advanced f
98. ame and URL SOIF_Free NSAPI PUBLIC void SOIF_Free SOIF Frees the given SOIF structure SOIF_GetTotalSize NSAPI_PUBLIC int SOIF_GetTotalSize SOIF s Gets the estimated total size of the SOIF in bytes SOIF_GetAttributeCount NSAPI_PUBLIC int SOIF_GetAttributeCount SOIF s Gets the number of attributes in the SOIF 190 Sun ONE Portal Server 6 2 Developer s Guide December 2003 SOIF API SOIF_GetAttributeSize NSAPI_PUBLIC int SOIF_GetAttributeSize SOIF s Gets the size of the attributes only SOIF_GetValueSize NSAPI_PUBLIC int SOIF_GetValueSize SOIF s Gets the size of the values only SOIF_GetValueCount NSAPI PUBLIC int SOIF GetValueCount SOIF s Gets the number of values only SOIF Merge NSAPI PUBLIC int SOIF Merge SOIF dst SOIF src Use this function to merge two SOIF objects perform a Union of their attribute values It returns non zero on error otherwise returns zero and the dst SOIF object contains all the attribute value pairs from the src SOIF object If the dst object contains the same attribute as src then the attribute becomes a multi valued attribute and all of the values are copied over to dst Only multi valued attributes are copied over For single value attributes discard the value in ast Currently only classification is a multi valued attribute SOIF_Find define SOIF_Find soif attribute name retrieves the AvPair for the given attrib
99. amples and type the following command jar cvf examples war Deploy the Application The Sun ONE Portal Server software includes a deployment tool which will take your WAR and deploy it into the portal server Before deploying the WAR file determine where to place the portlets inside the organization With the following command the sample portlets can be deployed into the organization Chapter 6 Developing and Deploying Portlets 171 Converting Providers to Portlets pdeploy deploy u uid w amAdminPassword g d distinguishedName p ContainerAdminPassword examples war For more information on the pdeploy command see Sun ONE Portal Server 6 2 Administrator s Guide Create Channels from the Deployed Portlets Once the portlet is deployed the portal server is aware of the portlet defined in the application You can start to create channels based on the portlet To create channels see Sun ONE Portal Server 6 2 Administrator s Guide for more information Converting Providers to Portlets This section includes instructions for converting the providers to JSR168 compatible portlets using a sample set of instructions for converting the HelloWorldProviderPA in Chapter 3 Extending the Base Providers into a portlet called HelloWorldPortlet Develop the Class File Code Example 6 4 contains the HelloWorldPortlet class file The HelloWorldPortlet similar to the HelloWorldProviderPA prints Hello World on the c
100. and put it in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory To compile the SimpleUserInfoProvider java file type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar SimpleUserInfoProvider java Develop the display profile XML fragment for this provider and this provider s channel The display profile fragment for the SimpleUserInfoProvider s provider is saved in SimpleUIProvider xml file see Code Example 4 6 on page 100 and the display profile fragment for the SimpleUserInfoProvider s channel is saved in SimpleUIPChannel xml file see Code Example 4 7 on page 100 Chapter 4 Using Leaf Providers 99 JSPProvider Code Example 4 6 SimpleUIProvider xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name SimpleUserInfoProvider class custom SimpleUserInfoProvider gt lt Properties gt lt String name title value Simple User Information Provider gt lt String name description value My UserInformation gt lt String name refreshTime value 0 advanced true gt lt Boolean name
101. annelName from the Desktop service will be used The action and provider parameters are not required if they are absent the default action is content and provider is the value set in the Desktop service for the default channel Chapter 2 Using Provider API PAPI 37 Overview of the Provider API and Desktop Servlet 38 The content edit and process actions map directly to method calls into the PAPI For Desktop actions that map to PAPI method calls the servlet passes an HTTP request and response object to the respective provider method These objects are not the same objects passed into the servlet The request and response objects passed to provider objects from the servlet are wrappers around the original request and response passed into the servlet This is because there is certain functionality that is available from request and response objects that is not applicable to a provider See the Javadocs for the Provider interface for more information The HTTP parameters in the original request object are processed before they are copied to the wrapper servlet request and response objects As part of this processing the parameters are decoded from the character set encoding used to represent the page into Unicode that is used in Java String objects Therefore the parameters that are passed to the providers are all stored as Unicode and the provider does not have to do any decoding of its own related to the character encoding for the pag
102. annels contains channel newList add channel return newList else List pmList List getListProperty pmList for int i 0 i lt pmList size i String channel String pmList get i if selectedChannels contains channel newList add channel return newList 2 Compile the class and put it in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory To compile the Cust omTableContainerProvider java file enter Chapter5 Using the Container Providers 125 JSPContainerProviderAdapter javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar CustomTableContainerProvider java 3 Develop the display profile XML fragments for this provider and this provider s channel The display profile fragment for the CustomTableContainerProvider s provider is saved in CustomTCProvider xml file see Code Example 5 6 and the display profile fragment for the CustomTableContainerProvider s channel is saved in CustomTCChannel xml file see Code Example 5 7 on page 127 Code Example 5 6 CustomTCProvider xml File lt xml version 1 0 encoding utf 8 standalone
103. ansformation is stored as value of the string property xs1FileName The value for the attribute can be either the absolute path such as export home xs1 abc xs1 or just the file name If just the file name has been specified the provider will use the File Lookup API to locate the XSL file If the absolute path is specified it takes precedence and file lookup will not be performed to locate the XSL file If both the XML and the XSL files are present the XMLProvider does the transformation using the XSLT engine The generated contents are displayed in the channel In order to transform the XML file the provider uses JAXP 1 1 The XMLProvider 1 Takes the fully qualified path name of the XML file and returns the file specified by the argument as a StringBuffer It returns null if the file does not exists or cannot be read 2 Gets the XSL file If just an XSL filename has been specified the get XSL method locates the XSL file using the File Lookup API 3 Takes the XML and XSL files and does the transformation 108 Sun ONE Portal Server 6 2 Developer s Guide December 2003 XMLProvider 4 Gets the XML contents after converting the XML file according to the specified XSL stylesheet In order to do this it takes the HttpServletRequest and returns an HttpServletResponse with the XML file contents as a buffer 5 Gets and displays the XML file contents in the channel using the getContent method Extending the XMLProvid
104. arameter Is Provider Yes Get Default Channel Name Null Get Channel eat Desktop Exception Get Error from Exception Get targetProvider from Parameter Generate and Redirect to New URL Return Control to the Web Container DesktopServletURL action process amp provider editContainer amp targetprovider channel Name In this URL the provider parameter specifies the edit container for the container and the targetprovider parameter is the leaf channel inside the container When the DesktopServlet receives a request where the action is process see Figure 2 9 on page 49 the DesktopServlet 48 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Figure 2 9 Overview of the Provider API and Desktop Servlet Determines whether the edit container is editable If the edit container is not editable an exception is thrown on the Desktop and control is returned to the web container If the edit container is editable it calls the edit container processEdit method and determines the channel s name from the request parameter Once the channel name is determined it determines whether the channel is editable If the channel is not editable it throws a provider exception If the channel is determined to be editable it calls the channel s processEdit method Re directs to the URL returned from the provider s proces
105. arch engine installation directory portal server install root SUNWps sdk rdm include This chapter is restricted to discussing the use of C functions that come with the search engine RDM API Therefore it is strongly recommended that you have a basic understanding of the C programming language This chapter contains the following sections e What is an RDM e About the RDM API e Example of Submitting a Query 225 What is an RDM What is an RDM A Resource Description Message RDM is a messaging format which two processes can use to exchange resource descriptions across a network In RDM one process a client or agent sends a request RDM message to a remote server which processes the request then sends a response RDM message similar to the HTTP 1 0 request response model For more information about RDM see http www w3 org TR NOTE rdm html For example you can send an RDM request to a search engine database to request RDs that match certain criteria The search engine will send back an RDM response that contains the requested RDs for example all documents containing the string style_sheet s RDM Format Syntax Each RDM message contains a header and a body The header identifies the nature of the RDM message while the body contains any data required to carry out the needed request for example scoping criteria Both the header and body of the RDM message is encoded using SOIF RDM Header The
106. ase A comma delimited list of the attributes to be used to sort the results A minus sign indicates descending order a plus sign indicates ascending order In this case sort the results by decreasing numerical score value and use alphabetical order of the title as the secondary sort order The hit number of the first returned result The maximum number of results to return The search server query language Use search for normal searches The URL of the remote search engine specified as an argument to the SimpleSearch constructor Sun ONE Identity Server software single sign on token Not used in this case implying anonymous search Execute the Search Query An output stream is created to hold the search results and paginate through the search results for a fixed number of pages in this case five pages in total where each page has viewHits 20 results The first page starts with the first hit firstHit 1 The search is executed again for each page of results It is possible to cache the results for all pages with a single search of course but it is often easier to simply resubmit the search each time This is equivalent to a user clicking a next button in a search user interface try int pagenum 1 int pagesize 10 Execute the query System out println nSearch results for scope DataOutputStream sos if SOIFOutputFile null catch Exception el System out println
107. ava 1 2 plugin You must also edit SearchDemo htm1 to pass the information about your search engine to the SearchDemo applet The command line version takes the server information as a command line argument To Install and Run the Search Demo Command Line Program 1 Compile the SearchDemo java file Make sure the class path includes the SDK JAR file searchsdk jar For example type javac classpath searchsdk jar SearchDemo java 2 Create a directory hierarchy that reflects the Java package structure for these classes to use the compiled classes directly and move the classes into the demo package of this hierarchy For example type mkdir p com sun portal search demo cp class com sun portal search demo 3 Invoke the search demo from the command line and supply the address of the search server and the query string as arguments For example type java classpath searchsdk jar com sun portal search demo SearchDemo http portal server host name port portal search search query The codebase parameter indicates the directory containing the main class and the ancillary classes for the applet You can specify this in the form 240 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Running the Sample Applications http host name compass server port java To Install and Run the Search Demo Applet To run the search demo as an applet use the JDK appletviewer or a browser with the Java 1 3 1 plugin You m
108. be written to implement all of the methods in this interface You will not have access to the ProviderContext and the properties in the display profile cannot be accessed If you are implementing this interface it s up to the provider implementation to get the properties For more information on this interface see the Javadocs at http hostname port portal javadocs To create a custom provider by implementing the Provider Interface 65 Implementing the Provider Interface NOTE This section provides the instructions for creating a custom provider by implementing the Provider interface The process described here includes creating a sample HelloWorldProvider that prints Hello World on the provider s channel 1 Create a new Java class which implements the Provider interface For the sample HelloWorldProvider create the class file as shown in Code Example 3 1 Code Example 3 1 HelloWorldProviderP java File package custom import import import import import import public java net URL javax servlet http HttpServletRequest javax servlet http HttpServletResponse com sun portal providers Provider com sun portal providers ProviderException com sun portal providers UnknownEditTypeException class HelloWorldProviderP implements Provider public void init String name HttpServletRequest req throws ProviderException public StringBuffer getContent HttpServletRequest
109. butes RDMQuery_Get Scope query RDMQuery_GetViewAttr query RDMQuery_GetViewHits query RDMQuery GetViewOrder query RDMQuery GetViewTemplate query RDMQuery SetScope query value RDMQuery SetViewAttr query value list RDMQuery SetViewHits query value RDMQuery SetViewOrder query value list RDMQuery SetViewTemplate query value RDMQuery Parse SAPI PUBLIC RDMQuery RDMQuery_Parse SOIFStream ss RDMQuery Create SAPI PUBLIC RDMQuery RDMQuery_Create const char scope RDMQuery_Free SAPI_PUBLIC int RDMQuery_Free RDMQuery RDMQuery_Merge SAPI_PUBLIC int RDMQuery_Merge RDMQuery SOIF Other RDM Structures In addition to RDMHeader and RDMQuery the file ram h provides definitions and functions for the following auxiliary objects See the file rdm h in portal server install root SUNWps sdk rdm include for details RDMRequest RDMResponse RDMServer Chapter 9 Using the RDM API to Access the Search Engine and Database inC 237 Example of Submitting a Query DMView DMViewHits DMViewOrder DMTaxonomy DMClassification DH DB J DO Xd F DMSchema 238 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Chapter 10 Using Java to Access the Search Engine Database This chapter describes how to submit queries and add entries to the search engine database by using the Java programming language To do so you ne
110. ceivable that the server is still returning later results while the client is processing the first results For each SOIF object read from the result stream you can use the getValue method to get the value of a particular field for example getValue title gets the title of a SOIF object First print out some general result information System out println z gt z gt z gt zzzz 2222222202 System out println page pagenum hits search getFirstHit to search getFirstHit search getResultCount 1 out of search getHitCount across search getDocumentCount documents System out print1n l System out println Sun ONE Portal Server 6 2 Developer s Guide December 2003 Using Java To Access the Search Server Database Now retrieve each search hit from the result stream as SOIF objects and print its URL title description and score to the output stream either the Java console standard output or a named output file SOIFInputStream resultStream SOIF soif for soif resultStream readSOIF resultStream readSOIF if pagenum Now we use the getValue the values of each of the its own accessor method String u soif getURL String t soif getValue String d soif getValue String sc soif getValue System out println TITLE URL SCORE DES
111. ch public void doSearch String scope throws IOException The Search class encapsulates the search It s parameters are the search string the attributes you want returned comma delimited sort order comma delimited descending ascending kk 1 xk 2 kk 3 kk 4 kk 5 kk 6 kk 7 xk 8 first number hit of hits query language eg search taxonomy basic schema basic etc database to search The RD 9 Access Management Edition session id 3f Search searc scope score url title description score 1 20 search null RDMServer null server URL eg http portal siroe com 2222 ps search token null for anonymous access or valid iPlanet Directory Server Access h new Search The Search constructor arguments used here are scope The search scope is the actual query run by the search server It is the scope argument to doSearch and ultimately derives from either the applet input panel or a command line argument to the main program viewAttributes The requested attribute set shown here will result in score url title descri the server returning the score url title and ption description of all documents that match the query 248 Sun ONE Portal Server 6 2 Developer s Guide December 2003 viewOrder score firstHit 1 viewHits 20 queryLanguage search RDMServer ssoToken null Using Java To Access the Search Server Datab
112. ck frame WIDTH THICK e The provider can be displayed in a thin frame WIDTH THIN e The provider can be displayed in a full top frame at the top WIDTH FULL TOP e The provider can be displayed in a full bottom frame at the bottom WIDTH FULL BOTTOM See the Javadocs for more information on the methods in this interface ProviderEditTypes The ProviderEditTypes interface defines the edit types that can be returned from the Provider getEditType method The edit type informs a client of a provider object what it can expect to be returned from the provider s get Edit method The edit type can be EDIT COMPLETE or EDIT SUBSET EDIT SUBSET Indicates that the edit page is not a complete document This value is potentially returned from getEditType to signify that the buffer returned is only a subset of a document The edit type if subset means that the JSP edit container is used to wrap the content from the container This is useful for providing a common look and feel for a set of common portal pages That is it allows the channel s edit page to look and feel according to the container that it exists within although the same channel might appear in two different containers that have very different look and feel In this case the form that wraps the edit content generated by the provider is drawn by the edit container EDIT COMPLETE Indicates that the edit page is a complete docu
113. com 80 default submit type 23 persistent submit operation 29 merge submit view 30 title author description DOCUMENT http www best com jocelyn resdogs index html title 35 Saving English Springer Spaniels author 37 Jocelyn Becker description 39 English Springer Spaniels in need of homes When this input is processed by rdmgr it will result in the RD shown being added to the database and indexed The rdmgr utility supports other types of requests too Code Example 10 4 rdmgr Submit submit header fields String SUBMIT_CSID submit csid String SUBMIT_TYPE submit type String SUBMIT_OPER submit operation String SUBMIT_VIEW submit view String SUBMIT DB submit database String SUBMIT MESSAGE message String SUBMIT ERRCR error submit types String SUBMIT PERSISTENT persistent String SUBMIT NONPERSISTENT nonpersistent String SUBMIT MERGED merged submit operations String SUBMIT RETRIEVE retrieve String SUBMIT INSERT insert String SUBMIT DELETE delete String SUBMIT UPDATE update The submit operations are as follows retrieve Retrieves the requested fields the submit view for the requested RDs In this case the data is a list of RDs that can be specified by their URLs only The server will return the requested fields for these RDs 254 Sun ONE Portal Server 6 2 Developer s Guide December 2003
114. create resource descriptions RDs for documents that are available in the intranet and stores these resource descriptions in an indexed database Resource descriptions can also be imported from another server or from a backup SOIF Summary Object Interchange Format file The search engine includes Java and C APIs for submitting resource descriptions and for searching the database The search engine database can also be used for storing other arbitrary content such as a shared content cache for other content providers Software Services Portal applications and resources use Sun ONE Identity Server software to provide services such as authentication single sign on logging profile and session management See the Sun ONE Identity Server Administrator s Guide for more information 14 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview Application Development As a developer you can provide access to portal resources through the Sun ONE Portal Server software and Sun ONE Identity Server software APIs For example you can develop channel content to define aggregation of both those channels as well as channels built from the predefined set into your site s portal In extending Sun ONE Portal Server software you use the APIs in the following functional areas e Desktop Using the Provider API you can create new providers e Search service Search APIs enable you to customize the search robot behavior and man
115. cription value View Edit User Information gt lt Properties gt lt Channel gt To Localize the User Information Channel 1 To localize the user information channel title and description the conditional properties tag for the locale must be added For example the following modifications must be included modifications are shown in bold lt Channel name UserInfo provider UserInfoProvider gt lt Properties gt lt String name refreshTime value 60 advanced true gt lt String name title value User Information gt lt String name description value View Edit User Information gt lt ConditionalProperties condition locale value fr gt lt String name title value User Information in French gt lt String name description value View Edit User Information in French gt lt ConditionalProperties gt lt Properties gt lt Channel gt 2 To add this the following sample display profile fragment stored in file dp locale xml is needed lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt ConditionalProperties condition locale value fr gt lt String name title value User Information in French gt lt String name description value View Edit User Information in French gt lt ConditionalProperties gt 3 To upload the XML display profile fragment using dpadmin
116. d Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs SOIF Structure A SOIF has a schema name and it associates a URL with a collection of attribute value pairs The schema name identifies how to interpret the attribute value pairs SOIF supports text and binary data and attributes can have multiple values An example SOIF is the following Chapter 7 Using the SOIF API to Work with SOIF Objects 189 SOIF API DOCUMENT http www siroe com title 17 Welcome to Siroe author 13 Dot Punchcard A SOIF object has URL and schema name fields to store its URL and schema name char url The URL char schema_name The Schema Name such as document or RDMHeader A SOIF object contains a collection of SOIFAVPair objects which each contain an attribute and one or more values To access attribute values in a SOIF use SOIF_find to retrieve the AvPair for the given attribute or use SOIF_findval to retrieve the value string for a given attribute You must use all lowercase for attribute names for find since only exact attribute name lookups are supported You can create SOIF objects by using the soIF_create function You can also read SOIF objects from a SOIF stream SOIF_Create NSAPI_PUBLIC SOIF SOIF_Create char schema_name char url Creates a SOIF structure with the given schema n
117. defaultChannelHasFrame value true advanced true gt lt Boolean name defaultChannelIsMovable value true gt lt Boolean name defaultBorderlessChannel value false advanced true gt lt String name defaultChannelColumn value 1 advanced true gt lt String name defaultChannelRow value 1 advanced true gt lt Collection name channelsIsMinimized advanced true gt lt Collection name channelsIsDetached advanced true gt lt Collection name channelsHasFrame advanced true gt lt Collection name channelsIsMinimizable gt lt Collection name channelsRow advanced true gt lt Collection name channelsColumn advanced true gt lt Collection name channelsIsMovable gt lt Collection name channelsIsDetachable gt lt Collection name channelsIsRemovable gt lt Collection name borderlessChannels gt lt Properties gt lt Provider gt Code Example 5 10 SpanTCChannel xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name SpanTableContainerChannel provider SpanTableContainerProvider gt lt Properties gt lt String name title value Front Table Container Channel gt lt String name contentPage value toptable jsp gt lt String name description value This is a test for spanning table containers gt lt String name Desktop font
118. derException class HelloWorldProviderPA extends ProviderAdapter public java lang StringBuffer getContent HttpServletRequest request HttpServletResponse response throws ProviderException return new StringBuffer Hello world 2 Compile the class and put it in the user defined class directory The default directory for the class file is etc opt SUNWps desktop classes To compile the HelloWorldProviderPA java file type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar HelloWorldProviderPA java 3 Define the new provider and provider s channel definition in a temporary XML file The sample HelloWorldProvider XML fragment for the provider in the HelloProviderPA xml is shown in Code Example 3 5 Code Example 3 5 HelloProviderPA xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name HelloWorldProviderPA class custom HelloWorldProviderPA gt lt Properties gt lt String name title value TITLE gt lt String name description value DESCRIPTION gt lt String name refreshTime value 0 gt lt Boolean name isEditable value true gt lt String name editType value edit_subset gt lt String name width value thin advanced true gt lt Con
119. derException public class RouterContainerProvider extends JSPSingleContainerProvider public URL processEdit HttpServletRequest req HttpServletResponse res throws ProviderException String selectedDesktop req getParameter desktop setSelectedChannel selectedDesktop return null Chapter5 Using the Container Providers 157 Creating a Custom ContainerProvider Code Example 5 24 RouterContainerProvider java File Continued Sets the selected channel name param the selected channel name lt code gt String lt code gt exception ProviderException if the selected channel cannot be set public void setSelectedChannel String channel throws ProviderException List selectedChannels new ArrayList selectedChannels add channel setSelectedChannels selectedChannels 2 Compile the class file and put it in the provider class base directory To compile the sample RouterContainerProvider type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar RouterContainerProvider java 3 Define the ContainerProvider provider and container channel XML fragments in the display profile The sample RouterContainerProvider provider XML fragment in the RCProvider xml file is shown Code Example 5 25 Code Example 5 25 RCProvider xml File lt xml version
120. ditionalProperties condition locale value en gt lt String name helpURL value desktop HelloWorld htm advanced true gt lt ConditionalProperties gt 70 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example Extending the ProviderAdapter Class 3 5 HelloProviderPA xml File Continued lt String name helpURL value desktop HelloWorld htm advanced true gt lt String name fontFacel value Sans serif gt lt String name productName value Sun ONE Portal Server gt lt Collection name aList gt lt String value i m aList gt lt Collection gt lt String name message value Sample Hello World Provider gt lt Properties gt lt Provider gt Code Example 4 Upload the provider and channel XML fragments using the dpadmin command For the sample HelloWorldProvider upload the HelloProviderPaA xml XML fragments using the dpadmin command That is for example type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname HelloProviderPA xml 5 Include the new channel in one of the existing containers The sample HelloWorldProvider will be displayed only in a Table Desktop layout To add the channel in the JSPTableContainer from the administration console follow instructions in section Sun ONE Portal Server 6 2 Administrator s Guide To add the channel in the JSPTableContainer manually a Add the He
121. docs Figure 2 1 The Provider Application Programming Interface PAPI 25 Overview of the Provider API and Desktop Servlet Leva rele dare e a Gea Provider Interface UnknownEditTypeException EHH ProviderWidths Interface t gt y ProviderEditTypes Interface i i i i ProviderContext 77777 ProviderAdapter en DesktopServlet LA i i CRESTA ATE TA ProfileProviderAdapter v i ie gt 1 Se tes oye ST gt ProviderException Sca m yl i AsciiFormInputExpectedException 26 InvalidEditFormDataException Ri eo eee een implements zE LSS extends Sun ONE Portal Server 6 2 Developer s Guide December 2003 pur Py AG depends gt Overview of the Provider API and Desktop Servlet The Provider API This section provides an overview of the interfaces see Provider ProviderWidths and ProviderEditTypes base classes see ProviderAdapter ProfileProviderAdapter context see ProviderContext exceptions see Exceptions and the lifecycle of the provider Provider The Provider interface clearly defines the communication channel between a container and a provider The container may be the DesktopServlet or another provider object The methods defined in the Provider interface supply the basic handshaking required for a container to display the content from a provider object A pr
122. down stage the filter has completed its processes and shuts down Although functions written for this stage can use the same data sources as those available at the Data stage shutdown functions typically restrict their operations to shutdown and clean up activities Passing Parameters to Robot Application Functions You must use parameter blocks pblocks to pass arguments into Robot Application Functions and to extract data from them For example the following directive in the filter conf file invokes the filter by exact function Data fn filter by exact src type deny text plain Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating New Robot Application Functions The fn parameter indicates the function to invoke which in this case is filter by exact The src and deny arguments are parameters used with the function They will be passed to the function in a parameter block and the function should be defined to extract its parameters and their values from the parameter block The three structures that are used to hold parameters are libcs pb param libcs_pb_entry and libcs_pblock These structures are defined in the header file portal server install root SUNWps sdk robot include libcs pblock h file libcs pb param This structure holds a single parameter It records the name and value of the parameter typedef struct char name value libcs_pb_param libcs pb entry This structure creates lin
123. e Action content When the action is content the DesktopServlet gets the named channel s main content When the DesktopServlet receives a request where the action is content to perform the content action on the channel it takes the following parameters DesktopServletURL act ion content amp provider ChannelName amp last false The content action maps directly to the following method calls in the PAPI ProviderContext getDefaultChannelName Provider isPresentable and Provider getContent The flowchart in Figure 2 5 on page 39 shows the various methods executed in the back end to process the content action When the client makes a request for content say after login the DesktopServlet 1 Determines the provider responsible for generating the requested content If provider is null it uses the default channel name stored in the DefaultChannelName attribute to get the provider The default channel name is an Sun ONE Identity Server software attribute Default ChannelName in the Desktop service which is set to the top most container that represents the whole Desktop view The default channel name is set to the current target provider value when the request parameter last equals to true If the provider is not null the DesktopServlet gets the provider responsible from the HTTP parameter in the URL for generating the requested content Sun ONE Portal Server 6 2 Developer s Guide December 2003 Figure 2 5 Over
124. e pc BORDER WIDTH tags put FONT FACE Theme getAttribute getName pc FONT_FACE if Theme getSelectedName getName pc equals Theme CUSTOM_THEME tags put THEME CHANNEL getStringProperty customThemeChannel else tags put THEME CHANNEL getStringProperty presetThemeChannel catch ProviderContextException pce throw new ProviderException TemplateContainerProvider getStardardTags failed to obtain theme related attribute pce return tags GetHelpLink for the Help button in the banner and footer of the edit page protected String getHelpLink String key HttpServletRequest reg throws ProviderException try URL helpLink getHelp req key if helpLink null return helpLink toString else return catch Throwable t throw new ProviderException HelloWorldProvider getHelpLink could not get help URL for key t 82 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Extending the ProfileProviderAdapter Class 2 Compile the class file To compile the HelloWorldProviderPPA2 java file type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar HelloWorldProviderPPA2 java 3 Create the provider and chamnel definition for the display profile The HelloWorldProvider provider display profile
125. e req getParameter provider Get the standard tags which will include the menubar footer etc Hashtable tags getStandardTags req tags put help link getHelpLink editPage req Provider specific tags tags put MESSAGE getStringProperty MESSAGE tags put title getTitle tags put providerName providerName tags put contentOptions getTemplate edit template tags toString if containerName null tags put FRONT_CONTAINER_NAME containerName StringBuffer b getTemplate EDIT PROVIDER TEMPLATE tags return b Implement Process Edit Method public URL processEdit HttpServletRequest req HttpServletResponse res throws ProviderException String message req getParameter MESSAGE if message null if message equals getStringProperty MESSAGE setStringProperty MESSAGE message return null else setStringProperty MESSAGE return null HelloWorld Provider supports edit_type edit_complete which means the provider is responsible for generating a complete edit form with header footer and html buttons getStandardTags method populates the hashtable with all the standard tags protected Hashtable getStandardTags HttpServletRequest reg throws ProviderException Hashtable tags new Hashtable ProviderContext pc getProviderContext String property null property FONT_FACE1 tags put FONT_FACE1 ge
126. e advanced true gt hannelIsDetachable value true gt hannelIsRemovable value true gt hannelHasFrame value true advanced true gt hannelIsMovable value true gt lt Collection gt lt Collection name Searc lt String value Search gt lt Collection gt lt Boolean name defaultC lt Boolean name defaultC lt Boolean name defaultC lt Boolean name defaultC lt Boolean name defaultC lt Boolean name defaultC lt Boolean name defaultC lt Boolean name defaultBorderlessChannel value false advanced true gt lt String name defaultChannelColumn value 1 advanced true gt lt String name defaultChannel lt Collection name channel lt Collection name channel lt Collection name channel lt Collection name channel lt Collection name channel lt Collection name channel lt Collection name channel lt Collection name channel lt Collection name channel lt Collection name borderl lt Properties gt lt Provider gt lists sIs sHa SIS sRo LsCo sIs sIs eis ess Channels gt annels gt annels gt gt Wes Row value 1 advanced true gt inimized advanced true gt Detached advanced true gt sFrame advanced true gt inimizable gt w advanced true gt lumn advanced true gt ovable gt Detachable gt Removable gt Channels gt Chapter5 Using the Container Providers 145 JSPCont
127. e value single jsp gt lt Boolean name showExceptions value false gt lt String name title value Single Container Provider gt lt String name description value DESCRIPTION gt lt String name refreshTime value 0 gt lt String name width value thin gt lt String name fontFacel value Sans serif gt lt String name productName value Sun ONE Portal Server gt lt Boolean name isEditable value true gt lt String name editType value gt lt String name editContainerName value JSPEditContainer gt lt String name presetThemeChannel value JSPPreset ThemeChannel gt lt String name customThemeChannel value JSPCustomThemeChannel gt lt Properties gt lt Provider gt Chapter 5 Using the Container Providers 121 JSPContainerProviderAdapter Code Example 5 3 CustomSCChannel xml File lt Properties gt containers gt lt Available gt lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name CustomSingleContainer provider CustomSingleContainerProvider advanced false gt lt String name title value JSP custom single container Channel gt lt String name description value This is a test for single lt String name contentPage value single jsp gt lt Properties gt lt Reference value Search gt lt Reference value Book
128. e 3 7 Code Example 3 7 HelloWorldProviderPPA1 java File import import import import import import import import package custom public class HelloWorldProviderPPAl extends ProfileProviderAdapter private ResourceBundle bundle null public StringBuffer getContent throws ProviderException Implement the getEdit method public StringBuffer getEdit throws ProviderException java net URL java util Hashtable java util ResourceBundle javax servlet http HttpServletRequest javax servlet http HttpServletRequest javax servlet http HttpServletResponse com sun portal providers ProfileProviderAdapter com sun portal providers ProviderException Implement the getContent method HttpServletRequest req HttpServletResponse res Hashtable tags new Hashtable if bundle null bundle getResourceBundle tags put welcome bundle getString welcome tags put message getStringProperty message true tags put properties getMapProperty aMap true StringBuffer b getTemplate content template tags return b HttpServletRequest req HttpServletResponse res Hashtable tags new Hashtable tags put message getStringProperty message tags put properties Chapter 3 Extending the Base Providers 73 Extending the ProfileProviderAdapter Class Code Example 3 7 HelloWorldProviderPPA1 java File Continued StringBu
129. e JSP based container providers which can extend the JSPContainerProviderAdapter For example the sample template based Desktop container providers are developed based on this class The ContainerProviderAdapter class provides default implementations of methods in the ContainerProvider interface implemented using a ContainerProviderContext object as the persistent store This class also has the getContainerProviderContext method which gets the container provider context in addition to the get setAvailableChannels and get setSelectedChannels methods Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter JSPContainerProviderAdapter To extend container functionality for JSP based container providers a JSPContainerProviderAdapter class is included with the software This class extends the JSPProvider The JSPContainerProviderAdapter can be used as the base class for any JSP based ContainerProvider and is similar in functionality to the ContainerProviderAdapter For example the JSPSingleContainerProvider extends from this class The JSPContainerProviderAdapter class provides default implementations of methods in the ContainerProvider interface implemented using a ContainerProviderContext object as the persistent store and extends JSPProvider to facilitate the execution of JSPs It includes interfaces to get setAvailableChannels get setSelectedChannels and getContainerProviderContext Thr
130. e following string welcome Welcome to Hello World 6 Copy the resource bundle properties file HelloWorldProviderPPA2 properties into etc opt SUNWps desktop classes directory 7 Develop the template files for the provider The HelloWorldProvider requires the following template files o content template see Code Example 3 16 on page 85 o edit template see Code Example 3 17 on page 85 This file generates the editable fields in the form Sun ONE Portal Server 6 2 Developer s Guide December 2003 Extending the ProfileProviderAdapter Class o editTemplate template see Code Example 3 18 on page 86 This file generates a complete form Code Example 3 16 HelloWorldProviderPPA2 content template File lt head gt lt head gt lt body bgcolor white gt tag welcome lt br gt lt br gt tag message lt br gt lt br gt lt body gt lt html gt Code Example 3 17 HelloWorldProviderPPA 2 edit template File lt p gt lt table border 0 cellpadding 2 cellspacing 0 width 100 gt lt tr gt lt td colspan 3 bgcolor 333366 gt lt font size 1 face tag fontFacel color FFFFFF gt lt b gt Welcome lt b gt lt font gt lt td gt lt tr gt lt tr gt lt td gt lt br gt lt br gt lt br gt lt td gt lt tr gt lt tr gt lt td width 20 align RIGHT NOWRAP gt lt font face tag fontFacel color 000000 gt lt label for message gt lt b gt Greeting lt b g
131. e second parameter is the log level When the log level is less than or equal to the log level setting in the file process conf the error message is written in the robot log The third parameter is the error message to print and it has the same form as the argument to the standard printf function For example cslog error 1 1 fn extract html text Out of memory n This invocation of cslog_error would generate the following error message in the robot log file Chapter 8 Search Engine Robot 219 Creating New Robot Application Functions 220 22 Jan 1998 15 57 31 8270 0 ERROR fn extract html text Out of memory For another example eslog error 1 1 lt URL s gt Error 5d 5d s n ep gt eo gt key urls gt server_status status s cslog_linestr urls gt error_msg This invocation of cslog_error would generate the following error message in the robot log file 22 Mar 2002 15 57 31 8270 0 ERROR lt URL http budgie siroe com 80 gt Error 0 240 Can t connect to server RAF Definition Example This section shows an example definition for a robot application function This function copies a specified source data to a multi valued field in an RD For example the search engine stores category or classification information in the classification field of an RD The copy_mv function allows the robot to get the value of an HTML lt META gt
132. eContainerProvider properties etc opt SUNWps desktop classes CustomJSPTableContainerProvid er properties 8 Access CustomJSPTableContainerProvider from your browser To access log in to the Desktop and type the following URL in your browser http hostname port portal dt provider CustomJSPTableContainerChannel TabContainer A tab container aggregates the output of channels providing a tabbed user interface to switch between them A tab container s configuration can be modified at runtime to vary which leaf channel is displayed A tab container provider generates its views primarily by being a client of table container objects The TabContainer displays one of its contained channels at a time It allows containers to be arranged onto virtual pages The container can then switch between these pages allowing them to be physically viewed one at a time It allows the user to switch logically separate row column displays From the container perspective each page is a table container The tab container then contains multiple table containers one for each page By default each tab in a tab container corresponds to a table container The tab container can contain any number of table single or tab containers theoretically Having a tab container inside a tab container is not advisable A tab container provider is a container provider that has a selected and available channels list and allows getting and setting of these lists Selected
133. ecember 2003 Resource Bundles Images If image files referenced by the existing templates are inappropriate for a locale the references can be changed to refer to new files The new file must be placed in the document root of the web container at portal server install root SUNWps web src directory and then deploy it with the portal server install root SUNWps bin deploy redeploy command Or you can deploy a new WAR file into the location of your choice File Lookup Mechanism Desktop content can be customized based on the following factors e Desktop type e Locale e Client type The DesktopServlet performs a search for a localized file before selecting a default In order to perform the search the DesktopServlet uses the user s locale attribute in the user s directory entry or preferredLocale attribute in the Sun ONE Identity Server and searches for the file For more information on the search order see Presentation Method on page 53 Locales are searched from more to less specific For example for a locale setting of en US WE the search order would be en US WE en_US en If the locale specific property is not found then the non locale specific version is returned if it exists Resource Bundles Resource bundles contain locale specific objects When your program needs a locale specific resource a String for example your program can load it from the resource bundle that is appropriate for the current u
134. ed by Portlets If this file in not included in the WAR file then default values are used by the portlet container Code Example 6 8 sun portlet xml File Sample lt xml version 1 0 encoding UTF 8 gt lt portlet app extension xmlns http www sun com software xml ns portal_server xmlns xsi http www w3 0rg 2001 XMLSchema instance xmlns sunportal http www sun com software xml ns portal_server xsi noNamespaceSchemaLocation http www sun com software xml ns portal_server version 1 0 gt lt save preferences in render permission gt l lt save preferences in render permission gt lt portlet gt lt portlet name gt JSPPortlet lt portlet name gt lt deployment extension gt lt extension element gt lt session enabled gt 0 lt session enabled gt lt extension element gt lt deployment extension gt lt portlet gt lt portlet gt lt portlet name gt BookmarkPortlet lt portlet name gt lt deployment extension gt lt extension element gt lt session enabled gt 0 lt session enabled gt lt extension element gt lt deployment extension gt lt portlet gt lt portlet gt lt portlet name gt NotepadPortlet lt portlet name gt lt deployment extension gt lt extension element gt lt session enabled gt 0 lt session enabled gt lt extension element gt lt deployment extension gt lt portlet gt lt portlet app extension gt The sun portlet xml file includes the following configuratio
135. ed to use the search engine Java Software Development Kit SDK which is available at portal server install root SUNWps sdk search The Java SDK includes the Java classes needed for interacting with the search engine database and a sample search application which can be run as an applet or as a stand alone program This chapter contains the following sections e The Search Engine Java SDK e Running the Sample Applications e Using Java To Access the Search Server Database e Using Java To Add Entries to the Search Engine Database The Search Engine Java SDK The classes in the search engine Java SDK provide a Java interface for interacting with the search server to access the search engine database Using the Java SDK you can build Java programs applets and your own interfaces that submit searches to the search engine 239 Running the Sample Applications The search engine database contains resource descriptions for the indexed resources such as documents Each resource description is described in SOIF format where SOIF stands for Summary Object Interchange Format For a discussion of SOIF see http www w3 org TR NOTE rdm html soif Running the Sample Applications The search engine Java SDK contains sample Java and HTML files SearchDemo java is an example Java program which can be run as an applet or as a stand alone program To run the applet version use the JDK appletviewer or a browser with the J
136. ee sample extensions namely JSPSingleContainerProvider JSPTableContainerProvider and JSPTabContainerProvider to the JSPContainerProviderAdapter API are included JSPSingleContainerProvider A single container wraps the content of a single channel The single container enables a channel to take over an entire browser page For example this can be used to provide the front page or can be used to display a single channel whose name is passed in the request parameter Typically the front page consists of some banners and the output of another channel The purpose of the single channel is to allow these banners menu bars and the like to be wrapped around the content of the included channel Another purpose of the single container is that the decorational elements such as banners and menu bars which wrap around the channel can be easily changed without changing the channel itself Using the JSPSingleContainerProvider The JSPSingleContainerProvider class extends JSPContainerProviderAdapter A single container simply displays a single leaf channel or a container It must be a JSP that wraps a container or leaf channel The JSPSingleContainerProvider class 1 Gets the selected channel name 2 Returns the selected channel name as a String If more than one channel is defined it displays the first channel in the list Chapter5 Using the Container Providers 119 JSPContainerProviderAdapter Some examples of single container include JSP
137. eger name fullwidth_popup_height value 500 gt lt Integer name fullwidth_popup_width value 600 gt lt Collection name categories gt lt String value Personal Channels gt lt String value Sample Channels gt lt String value News Channels gt lt String value Search Channels gt lt Collection gt lt Collection name Personal Channels gt lt String value UserInfo gt lt String value MailCheck gt lt String value Bookmark gt 126 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 5 6 JSPContainerProviderAdapter CustomTCProvider xml File Continued lt Collec lt Collect Str Str lt Str lt Str lt Collec lt Collec lt Collect lt Collec lt Boolean lt Boolean lt Boolean lt Boolean lt Boolean lt Boolean lt Boolean lt Boolean lt Collect lt Collect lt Collect lt Collect lt Collect lt Collect lt Collect lt Collect lt Collect lt Collect lt Properties lt Provider gt lt String value App gt tion gt ion name Sample ing value SampleSimpleWebService gt ing value SampleURLScraper gt ing value SampleJSP gt ing value SampleXML gt tion gt lt Collection name News Channels gt lt String value SampleRSS gt lt String value Postit gt tion gt ion name Search lt String value Search gt tion gt name defaultChannelIsMinimizable
138. elop the display profile XML fragment for this provider and this provider s channel The display profile fragment for the CustomURLScraperProvider s provider is saved in CustomURLSProvider xml file see Code Example 4 11 and the display profile fragment for the CustomURLScraperProvider s channel is saved in CustomURLSChannel xml file see Code Example 4 12 on page 106 CustomURLSProvider xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name CustomURLScraperProvider class custom CustomURLScraperProvider gt lt Properties gt lt String name title value Custom UrlScraper Channel gt lt String name description value This channel displays the urls at random gt lt Boolean name isEditable value false advanced true gt lt String name urlScraperRulesetID value default_ruleset gt lt String name width value thick gt lt String name refreshTime value 0 advanced true gt lt Collection name urlPool gt lt String value http localhost port filel html gt lt String value http localhost port file2 html gt lt Collection gt lt String name fontFacel value Sans serif gt lt String name productName value Sun ONE Portal Server gt lt Boolean name cookiesToForwardAll value true gt lt String name inputEncoding value UTF 8 gt
139. em in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build a JAR and copy the JAR into the provider class base directory Or just copy the class files into the provider class base directory 4 Develop the display profile XML fragment for this provider and this provider s channel The display profile fragment for the AddressBookProvider s provider is saved in AddressBookProvider xml file see Code Example 4 2 and the display profile fragment for the AddressBookProvider s channel is saved in AddressBookChannel xml file see Code Example 4 3 on page 97 Code Example 4 2 AddressBookProvider xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name AddressBookProvider class custom AddressBookProvider gt lt Properties gt lt S lt S lt S tring name title value Address Book Provider gt tring name description value My Addressbook gt tring name refreshTime value 0 advanced true gt lt Boolean name isEditable value false advanced true gt lt S tring name editType value edit_subset advanced true gt lt String name width value thin advanced true gt lt String name helpURL value desktop usedesk htm advanced true gt lt String name fontFacel value Sans serif gt lt String name productNa
140. en place l interface d utilisation graphique OPEN LOOK et qui en outre se conforment aux licences crites de Sun Les produits qui font l objet de ce manuel d entretien et les informations qu il contient sont regis par la legislation americaine en matiere de controle des exportations et peuvent etre soumis au droit d autres pays dans le domaine des exportations et importations Les utilisations finales ou utilisateurs finaux pour des armes nucleaires des missiles des armes biologiques et chimiques ou du nucleaire maritime directement ou indirectement sont strictement interdites Les exportations ou reexportations vers des pays sous embargo des Etats Unis ou vers des entites figurant sur les listes d exclusion d exportation americaines y compris mais de maniere non exclusive la liste de personnes qui font objet d un ordre de ne pas participer d une facon directe ou indirecte aux exportations des produits ou des services qui sont regi par la legislation americaine en matiere de controle des exportations et la liste de ressortissants specifiquement designes sont rigoureusement interdites LA DOCUMENTATION EST FOURNIE EN L ETAT ET TOUTES AUTRES CONDITIONS DECLARATIONS ET GARANTIES EXPRESSES OU TACITES SONT FORMELLEMENT EXCLUES DANS LA MESURE AUTORISEE PAR LA LOI APPLICABLE Y COMPRIS NOTAMMENT TOUTE GARANTIE IMPLICITE RELATIVE A LA QUALITE MARCHANDE A L APTITUDE A UNE UTILISATION PARTICULIERE OU A L ABSENCE DE CONTREFACON Contents About
141. encoding for character fields Note that SOIF also supports binary valued fields and they can be added or retrieved too For more information on rdmgr see Sun ONE Portal Server 6 2 Administrator s Guide In the simplest case rdmgr can be used to add a file containing multiple SOIF objects to the database This is as simple as creating a SOIF file and adding the data with the command rdmgr soif_input_file The search robot calls rdmgr in this manner to index data it collects from its crawling runs In the general case though rdmgr accepts a complete resource description submit request as input The RD submit input must be in SOIF format with a request header and a body consisting of the SOIF data to be added or retrieved to or from the database A SOIF object consists of a schema name such as REQUEST or DOCUMENT a URL and a list of attribute value pairs The com sun portal search soif package in the Search Server Java SDK is used to build SOIF objects and write them to a file You can use the SOIF classes to create a RD submit request for input to rdmgr Here is an example of constructing a request that can be used as a second argument to rdmgr SOIF req new SOIF REQUEST Write the header part of the RDM to send to the database SOIF objects of type Request do not have an associated URL An update request to the search engine has the following attribute value pairs 252 Sun ONE Portal Server 6 2 Develo
142. ent should include default values for all the properties that are used in the provider java file For example if the provider java file contains get StringProperty color the provider s display profile fragment should include a default value for color The provider s XML fragment in the display profile must adhere to the following structure lt DisplayProfile gt lt Providers gt lt Provider name providername class provider class name gt lt Properties gt lt Properties gt lt Provider gt lt Providers gt lt DisplayProfile gt See Sun ONE Portal Server 6 2 Desktop Customization Guide for more information on the display profile provider definitions 60 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Overview of Implementing a Custom Provider The provider definition is the template that decides the properties for the provider s channels However the display profile definition for the channel ultimately decides the values for the channel s properties When a channel sets a property the property is set in the channel and not in the provider s properties When defining channel properties in the display profile include only those properties where the provider defaults are not applicable The provider s channel XML fragment in the display profile must adhere to the following structure lt DisplayProfile gt lt Channels gt lt Channel name channelname provid
143. er In the following example the XMLProvider get XML method is overridden to get the content out of a database In the CustomXMLProvider the XML content is retrieved from a database To accomplish this 1 Develop the CustomXMLProvider class file and override the get XML method in the CustomXMLProvider s class file The CustomXMLProvider class file see Code Example 4 14 extends the XMLProvider and includes only the overriding get xML method Code Example 4 14 CustomXMLProvider java File package custom import com sun portal providers ProviderException import com sun portal providers context ProviderContext import com sun portal providers xml XMLProvider import javax servlet http HttpServletRequest import javax servlet http HttpServletResponse public class CustomXMLProvider extends XMLProvider protected StringBuffer getXML HttpServletRequest req HttpServletResponse res throws ProviderException String xmlURL getURL StringBuffer xmlbuf new StringBuffer It must be http https or file i e http lt url gt https lt url gt or file lt path gt if xmlURL null amp amp xmlURL length 0 String proto xmlURL substring 0 xmlURL index0f if proto equalsIgnoreCase http proto equalsIgnoreCase https proto equalsIgnoreCase file try xmlbuf super getXML req res catch ProviderException pr getProviderContext debugError
144. er providername gt lt Properties gt lt Properties gt lt Channel gt lt Channels gt lt DisplayProfile gt See Sun ONE Portal Server 6 2 Desktop Customization Guide for more information on the display profile channel definitions The channel definition in the display profile need not have the lt container gt tag unless the channel is defined within a container Channel definitions in the display profile can be encapsulated inside a container The advantage of this is that it provides name scoping so that channels with the same name do not collide Unless a channel is referenced directly from the DesktopServlet URL in which case it need not be encapsulated inside a container you must reference a channel from some container in order to see it The container within which the channel will operate must adhere to the following structure lt DisplayProfile gt lt Channels gt lt Container gt lt Properties gt lt Properties gt lt Available gt lt Available gt lt Selected gt lt Selected gt lt Channel gt lt Channel gt lt Container gt lt Channels gt lt DisplayProfile gt Chapter 2 Using Provider API PAPI 61 Overview of Implementing a Custom Provider 62 To upload display profile changes type e dpadmin add u dn amadmin w password a distinguishedname provider xml if the display profile XML fragment was stored in a separate file e Apadmin modify u d
145. er install root SUNWps bin dpadmin modify m u dn_amadmin w password A distinguishedname CustomURLSContainer xml 6 Change directories to etc opt SUNWps desktop classes and copy the properties file for the provider into this directory For example for the CustomURLScraperProvider a Change directories to WebContainer portal web apps WEB INF classes b Type cp URLScraperProvider properties etc opt SUNWps desktop classes CustomURLScraperProvider prop erties Chapter 4 Using Leaf Providers 107 XMLProvider 7 Access the CustomURLScraperProvider channel inside the JSPTableContainer To access log in to the Desktop and type the following URL in your browser http hostname port portal dt provider JSPTableContainer XMLProvider The XMLProvider can be used to convert and display an XML file according to the specified style sheet Retrieving XML Content The XMLProvider first determines if content is available for the requesting client This is determined by checking on the availability of the XSL stylesheet for the requesting client via the File Lookup API The path to the XML content can be specified as HTTP HTTPs or file URL The path to the XML source is stored as a value of the property ur1 If the path is HTTP or HTTPs the provider uses the super getContent method to fetch the XML content If the path is a file URL the provider reads the file into a StringBuffer The value for XSL file name to use for tr
146. erAdapter is a subclass of the ProviderAdapter that includes convenience wrappers around some commonly used methods in the ProviderContext interface like get set Property exists Property get setStringAttribute and getTemplate The advantages of using the wrapper methods in the ProfileProviderAdapter class as opposed to using the methods in the ProviderContext interface are the following e For example the ProviderContext getStringProperty accepts the channel name as an argument Since the ProfileProviderAdapter knows the channel name it can use ProfileProviderAdapter getStringProperty method without providing the channel name e All of the methods in ProviderContext throw a ProviderContextException The analogous methods in ProfileProviderAdapter throw a ProviderException For example when implementing the get Content method since this method is already defined to throw a ProviderException when a client calls ProfileProviderAdapter getStringProperty inside the getContent method you need not implement a t ry cat ch block However if you use ProviderContext getStringProperty you must catch the ProviderContextException See the Javadocs for more information on the methods in this class ProviderContext The ProviderContext object provides information pertaining to the environment that a provider object is executing within Such information may be specific to the user to the web container or be gl
147. ertMV s classification 3 web crawler strlen web crawler inserts classification 3 10 web crawler SOIF_ReplaceMV NSAPI_PUBLIC int SOIF_ReplaceMV SOIF s char a int slot char v int vsz int useval SOIF DeleteMV NSAPI PUBLIC int SOIF_DeleteMV SOIF s char a int slot Deletes the value at the index slot in the attribute a For example SOIF_DeleteMV s classification 3 deletes classification 3 SOIF FindvalMV NSAPI PUBLIC const char SOIF_FindvalMV SOIF s const char a int slot Finds the value at the index slot in the attribute a For example SOIF_FindvalMV s classification 3 returns web crawler using the previous example SOIF_SqueezeMV NSAPI PUBLIC void SOIF SqueezeMV SOIF s Chapter 7 Using the SOIF API to Work with SOIF Objects 195 SOIF API Forces a renumbering to ensure that the multi value indexes are sequentially increasing for example 1 2 3 This function can be used to fill in any holes that might have occurred during SOIF_InsertMV invocations For example to insert values explicitly for the multivalue attribute author SOIF_InsertMV author Ss 1 John 4 0 SOIF_InsertMV s author 2 s 6 9 i Kevin 5 0 SOIF_InsertMV author d Darren 6 ne SOIF_InsertMV s author 9 Tommy 5 0 SOIF_FindvalMV s author 9 Tommy SOIF SqueezeMV s SOIF_FindvalMV s author 9 SOIF_FindvalMV s author 4 NUL
148. erty getSessionID getUserID encodeURL isAuthless o Data functions pertaining to per client properties get setClientProperty o Data functions pertaining to the debug service isDebugEnabled isDebugErrorEnabled isDebugWarningEnabled isDebugMessageEnabled debugMessage debugWarning debugError o Data functions pertaining to template access get Template getTemplatePath getTemplateMostSpecificPath o Data functions pertaining to channel properties get ProviderName getClassName getNames get set Property exists Property getProviderVersion o Data functions pertaining to config properties getStaticContentPath getConfigProperty e Data Functions pertaining to ClientTypeFilters getClientPropertiesFilters getLocalePropertiesFilters getClientAndLocalePropertiesFilters e Data Functions pertaining to URLEncoding encodeURLParameter See the Javadocs for more information on the methods in this interface Chapter 2 Using Provider API PAPI 29 Overview of the Provider API and Desktop Servlet ProviderWidths The ProviderWidths interface defines the widths that can be returned from the Provider getWidth method The width is a suggestion to a client of a provider object as to how much screen real estate should be given to display the provider s default view e The provider can be displayed in a thi
149. es that are allowed 200 Sun ONE Portal Server 6 2 Developer s Guide December 2003 SOIF API SOIFStream_GetDenied NSAPI PUBLIC char SOIFStream_GetDenied SOIFStream ss Returns an array of all the attributes that are denied Memory Buffer Management You can use SOIF buffers in parsing or printing routines They take care of memory allocation for inserting and appending They are basically memory blocks that are easy for SOIF routines to use A SOIF Buffer is represented in a SOIFBuffer structure that is created with the SOIFBuffer_Create function and freed with the SOIFBuffer Free function The SOIFBuffer structure provides the append increase and reset functions for manipulating the data in the buffer SOIFBuffer_Create NSAPI PUBLIC SOIFBuffer SOIFBuffer Create int default sz The SOIFBuf fer is used in SOIF PrintInitStr SOIFBuffer memory Before you can print SOIF to memory you need to create a buffer for output SOIFBuffer_Free NSAPI PUBLIC void SOIFBuffer_Free SOIFBuffer sb Releases the memory buffer created by SOIFBuffer_Create append void append SOIFBuffer sb char data int n Copies n bytes of data into the buffer increase void increase SOIFBuffer sb int add n Increases the size of the data buffer by addn bytes reset void reset SOIFBuffer sb Resets the size of the data buffer and invalidates all currently valid data A buffer can be reused by resett
150. ese codes are defined in the header file portal server install root SUNWps sdk robot include robotoapi h The following table describes the response status codes after the robot has completed processing in the first left column and includes a description of the corresponding status code in the second right column 218 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating New Robot Application Functions REQ PROCEED The function performed its task so proceed with the request REQ_ABORTED The entire request should be aborted because an error occurred REQ NOACTION The function performed no task but proceed anyway REQ EXIT End the session and exit REQ RESTART Restart the entire request response process Reporting Errors to the Robot Log File When problems occur robot application functions should return an appropriate response status code such as REQ ABORTED and they should also log an error in the error log file To use the error logging functionality you must include the file log h in the portal server install root SUNWps sdk robot include libcs directory After you have ensured that log h exists in the correct place you can use the cslog error macro to report errors The prototype is in the following format cslog error int n int loglevel char errorMessage The first parameter is not currently used may be used in the future You can pass this as any integer Th
151. essionProperty maps to or can use PortletSession getAttribute PortletSession setAttribute Example 3 The ProviderContext getDesktopURL maps to or can use PortletURL RenderResponse createRenderURL RenderResponse createActionURL Dispatching to a JSP PortletRequestDispatcher dispatcher pContext getRequestDispatcher test jsp dispatcher include request response 174 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Converting Providers to Portlets Help getHelp In Provider returns this method returns a hel pURL which can be pointing to a static help file doHelp For portlets this method has to be implemented for writing out the help content dynamically Title getTitle For ProviderAdapter this method returns the title from the Display Profile title property For portlets the title is returned by the portlet implementation editType For a provider the edit Type display profile property can be specified to determine whether the provider implementation will draw the complete edit page or a subset of it For portlets the edit Type is always EDIT COMPLETE and the complete page including the form the Finish and the Cancel buttons have to be generated by the portlet Only the banner and footer are drawn by the PortletEdit jspin Jet c opt SUNWps desktop default directory PortletPreferences The Pro The Pro
152. ffer b ge return b Implement the processEdi public URL processEdit HttpServletRequest req throws ProviderException String message req ge if message null tTemplate edit template tags t method HttpServletResponse res tParameter message if message equals getStringProperty message Set the new message setStringProperty message message return null else setStringProperty message return null Compile the class and put it in the user defined class directory The default directory for the class file is etc opt SUNWps desktop classes To compile the HelloWorldProviderPPA1 java file type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar HelloWorldProviderPPA1 java Define the new provider and provider s channel definition in a temporary XML file The sample HelloWorldProvider XML fragment for the provider in the HelloProviderPPA1 xml file and the XML fragment for the channel in the HelloChannelPPA1 xml file are shown in Code Example 3 8 and Code Example 3 9 on page 75 respectively Code Example 3 8 HelloProviderPPA1 xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt Provider name HelloWorldProviderPPA1 class custom He
153. filter 203 206 GenericPortlet 168 image files 259 InvalidEditFormDataException 32 J Java SDK 242 Section L JavaServer Pages 257 JSPContainerProviderAdapter 116 118 119 124 JSPProvider 94 95 98 115 JSPSingleContainerProvider 116 118 119 120 JSPTabContainerProvider 116 118 119 149 150 JSPTableContainerProvider 116 118 119 124 138 L 142 locale 257 localizing Sun ONE Portal Server 257 ModifiableTab 149 P PAPI 12 25 36 69 93 portlets 167 ProfileProviderAdapter 27 28 72 79 115 118 263 PropertiesFilter 31 89 Provider 27 65 69 72 Provider Application Programming Interface see PAPI 12 ProviderAdapter 27 28 69 72 173 ProviderContext 27 28 72 116 118 263 ProviderContextException 28 ProviderEditTypes 27 30 ProviderException 28 31 32 142 ProviderWidths 27 30 R RDM API 225 233 2 Sun ONE Portal Server 6 2 Developer s Guide December 2003 rdmgr 187 introduction 252 types of requests 254 RDMs 183 225 Resource bundles 259 Resource Description Messages see RDMs 183 robot 21 RouterContainerProvider 157 S Search engine introduction 14 sendrdm 233 242 Service 29 Servlet 29 Session 29 SOIF 21 183 184 Summary Object Interchange Format see SOIF 21 T TabContainer 116 148 149 TabContainerProvider 149 templates 257 U UnknownEditTypeException 32 UnmodifiableTab 149 URLScraperProvider 103 104 Section W W WAR file 259 X
154. following example the JSPProvider getContent method is overridden to make a connection to the database to get the address book from the database and use a JSP to display the content of the address book for each user To accomplish this 1 Code Example 4 1 Extend the JSPProvider and develop the AddressBookProvider class The AddressBookProvider class overrides the JSPProvider s get Content method which reads the user s address book The get Content method gets the address book for the user who is logged in to the Desktop AddressBookProvider java File package custom import javax servlet http HttpServletResponse import javax servlet http HttpServletRequest import com sun portal providers ProviderException import com sun portal providers jsp JSPProvider public class AddressBookProvider extends JSPProvider public StringBuffer getContent HttpServletRequest req HttpServletResponse res Chapter 4 Using Leaf Providers 95 JSPProvider Code Example 4 1 AddressBookProvider java File Continued throws ProviderException AddressBook addrBook new custom AddressBook getProviderContext getUserID req setAttribute addressBook addrBook return super getContent req res 2 Develop the AddressBook class The class AddressBook is responsible for making a connection to the database and getting the user s address book from the database 3 Compile both classes and put th
155. g the SOIF API to Work with SOIF Objects 187 SOIF API Table 7 1 Alphabetized Functions and Objects Defined in the soif h File Continued SOIF function or object SOIF_AttributeCompare SOIF_AttributeCompareM V SOIF_Contains SOIF_Create SOIF_DeleteMV SOIF_Find SOIF Findval SOIF FindvalMV SOIF Free SOIF GetAttributeCount SOIF GetAttributeSize SOIF GetTotalSize SOIF_GetValueCount SOIF_GetValueSize SOIF_Insert SOIF_InsertAVP SOIF_InsertMV SOIF InsertStr SOIF IsMVAttribute SOIF Merge SOIF MVAttributeParse SOIF_ParseInitFile SOIF_ParseInitStr SOIF_PrintInitFile SOIF_PrintInitFn SOIF_PrintInitStr SOIF_Remove SOIF_Rename SOIF_Replace Category Attribute Value Pair Routines Multi valued Attribute Routines Multi valued Attribute Routines SOIF Structure Multi valued Attribute Routines SOIF Structure SOIF Structure Multi valued Attribute Routines SOIF Structure SOIF Structure SOIF Structure SOIF Structure SOIF Structure SOIF Structure Multi valued Attribute Routines SOIF Structure Multi valued Attribute Routines Attribute Value Pair Routines Multi valued Attribute Routines SOIF Structure Multi valued Attribute Routines Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs Stream Routines for Parsing and Printing SOIFs SOIF Structure Attribute
156. ge replace lock false propagate true gt lt Reference value SamplesTabPanelContainer advanced false merge replace lock false propagate true gt lt Reference value SearchTabPanelContainer advanced false merge replace lock false propagate true gt lt Selected gt lt Channels gt lt Channels gt lt Container gt 4 Use the dpadmin command to upload the display profile fragments for this provider For CustomTabContainerProvider use the dpadmin command to upload the CustomTabCProvider xml file fragments in the display profile That is type portal server install root SUNWps bin dpadmin add u dn_amadmin w password d distinguishedname CustomTabCProvider xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomTabCChannel xml 154 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter 5 Create anew directory called customTabContainerProvider under etc opt SUNWps desktop desktoptype 6 Copy all the required JSP files from etc opt SUNWps desktop sampleportal JSPTabContainerProvider to etc opt SUNWps desktop desktoptype CustomTabContainerProvider 7 Modify the makeNewTab jsp file in etc opt SUNWps desktop desktoptype CustomTabContainerProvider to call getTabTopics That is replace the makeNewTab jsp file with the makeNewTab jsp file in Code Example 5 23
157. gments for the provider the provider s channels and the container within which the channels will operate if any Transporting Using the par Utility Utilize the par utility for deploying channels and providers The par command enables you to transfer or move providers or channels from one Sun ONE Portal Server software host to another The par utility creates a specialized packaging mechanism called a par file for transport of channels and providers into and out of the server A par file is an extended form of the jar file format with added manifest information to carry the deployment information and an XML document intended for integration into the Sun ONE Portal Server software display profile on the target server The use of par files is optional You can just as well copy all files into their correct locations The par utility makes deployment easier if you have to install the files on multiple servers To create a par file from scratch use the jar or export subcommand of the par utility To export an existing provider use the export subcommand of the par utility For example if you have the provider associated files in the development environment ready for deployment into the production environment use the following command to build the channel and provider into a par file which can then be deployed on the system par export r dn amadmin p password v provider par dn exportfile To deploy the par file into the system u
158. gt lt INPUT TYPE BUTTON OnClick location tag desktop_url VALUE Cancel CLASS button gt lt font gt lt br gt lt P gt lt FORM gt lt BR gt tag menubar lt font gt lt BODY gt lt HTML gt 7 Create the channel directory under the template root directory By default the template root directory is etc opt SUNWps desktop desktoptype For this example create a Hel loWorldPPA1 directory under etc opt SUNWps deskt op desktoptype directory 8 Copy all the template files over to the newly created directory in Step 7 For example cp content template etc opt SUNWps deskt op desktoptype HelloWorldPPA1 cp edit template etc opt SUNWps desktop desktoptype HelloWorldPPA1 78 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Extending the ProfileProviderAdapter Class 9 Create a resource bundle properties file The sample HelloWorldProvider includes a HelloWorldProviderPPAl properties file a Create a HelloWorldProviderPPAl properties properties file b Include the following property in the file welcome Welcome to Hello World 10 Copy the resource bundle to the user defined class directory By default the class directory to copy the resource bundle into is etc opt SUNWps desktop classes 11 Access the HelloWorld channel inside the JSPTableContainer To access log in to the Desktop and type the following URL in your browser http hostname port
159. gt name fullwidth_popup_height value 500 gt name fullwidth_popup_width value 600 gt lt String value Personal Channels gt lt String value Sample Channels gt lt String value News Channels gt lt String value Search Channels gt lt Collection gt lt Collection name Personal Channels gt lt String value UserInfo gt lt String value MailCheck gt lt String value Bookmark gt lt String value App gt lt Collection gt lt Collection name Sample Channels gt lt String value SampleSimpleWebService gt lt String value SampleJSP gt lt String value SampleXML gt lt String value SampleURLScraper gt lt Collection gt lt Collection name News Channels gt lt String value SampleRSS gt lt String value Postit gt lt Collection gt lt Collection name Search Channels gt lt String value Search gt 132 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter Code Example 5 9 SpanTCProvider xml File Continued lt Collection gt lt Boolean name defaultChannelIsMinimizable value true gt lt Boolean name defaultChannelIsMinimized value false advanced true gt lt Boolean name defaultChannelIsDetached value false advanced true gt lt Boolean name defaultChannelIsDetachable value true gt lt Boolean name defaultChannelIsRemovable value true gt lt Boolean name
160. ha 1S SOME RR RR RA Elke eae hee ae cme a eS 184 Using the SOIR API lie ieee thine Sarda ae tae E 184 An Introductory Example snars sars ep ipid vee Ripa i 185 Getting Search Server Database Contents as a SOIFStream LL 187 SOIFAPRI iii nie alal NAG Seek bee Bath ha 187 SOIF Structure oase vende ERI SI ea 189 Attmbute Value Pair ROUTES a det uien len BE eeh tule 192 Multi valued Attribute Routines an enen eeen 194 Stream Routines for Parsing and Printing SOUPS sr seur aman ee taan eee eh es 197 Memory Buffer Management iscr pa naa NENA BIRD idg ee ed 201 Chapter 8 Search Engine Robot 22262 KANE ene oare enn enne ee NANANG 203 Search Engine Robot OVEIMIEW sin neer en vrint bedie aa belki bet ra ee 203 How me Robot Works AE 204 Robot Comhsurahion Files picciolo eagle eee eas 205 The Filterme Process oes aiea insa ella AA ES 205 Stages in the Filter Process 2 5 cdc piaceri a Sedat ake nt UG BADA DA GA 206 Robot Completion Sanpete er naa an nA An poi Meee EE ee GE 207 Monitoring emdFiook Execufiohi 2 224 10 nre cea tae teas 208 Preparing Your Completion Script to Appear in the Administration Interface 208 Creating New Robot Application Functions cirie ria 209 Robot Pinpin API OVERGOW rar isda DING Na cee sek Gd pele alii ee 210 The Robot Application Function Header Piles rar NANG Kan lea 210 Writing Robot Application Functions 2 Paa anG GT otedi dda avast dard ine chun a 213 Com
161. hannel Code Example 6 4 HelloWorldPortlet java File package custom import import import import import import public java io IOException java io PrintWriter javax portlet GenericPortlet javax portlet PortletException javax portlet RenderRequest javax portlet RenderResponse class HelloWorldPortlet extends GenericPortlet public void doView RenderRequest request RenderResponse response throws PortletException IOException response setContentType request getResponseContentType PrintWriter writer response getWriter writer write Hello World 172 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Converting Providers to Portlets Mapping ProviderAdapter to GenericPortlet When developing the class file use the following table comparing GenericPortlet to ProviderAdapter Table 6 1 Mapping ProviderAdapter to GenericPortlet ProviderAdapter GenericPortlet public void init String n HttpServletRequest req public URL processEdit HttpServletRequest request HttpServietResponse response public StringBuffer getContent HttpServietRequest request HtipServletResponse response public StringBuffer getEdit HttpServletRequest request HttpServletResponse response public URL getHelp HttpServletRequest req String key public String getName public String getTitle public ResourceBundle getResourceBundle String base public ResourceBundle getRes
162. hannel is added at the root level portal server install root SUNWps bin dpadmin modify u dn amadmin w password d distinguishedname HelloChannelPA xml 6 Access the HelloWorld channel inside the JSPTableContainer To access type the following URL in your browser http hostname port portal dt 7provider JSPTableContainer HelloWorldPA Extending the ProfileProviderAdapter Class 72 ProfileProviderAdapter has the default implementation of the Provider interface and extends the ProviderAdapter class It includes some convenient methods that allow the providers to get the channel data from the ProviderContext object Developers who wish to create a new provider can take advantage of this by extending the ProfileProviderAdapter class and create their customized provider class To create a provider by extending the ProfileProviderAdapter Class Sun ONE Portal Server 6 2 Developer s Guide December 2003 Extending the ProfileProviderAdapter Class Example 1 This section provides the instructions for creating a custom provider by extending the ProfileProviderAdapter class The sample HelloWorldProvider reads a string property from the user s display profile and allows the user to edit the string This sample also includes an example about using the resource bundle 1 Create a new Java class which extends the ProfileProviderAdapter class For the sample HelloWorldProvider create the class file as shown in Code Exampl
163. hared object that the robot can be instructed to load by commands in the filter conf configuration file Note that you can link object files into a shared object In Table 8 2 the compiled object files t o and u o are linked to form a shared object called test so Table 8 2 Options for linking System Compile options Solaris ld G t o u o o test so Loading Your Shared Object The robot uses the filters defined in filter conf to filter resources that it encounters If the file filter conf uses your customized robot application functions it must load the shared object that contains the functions To load the shared object add a line to filter conf Init fn load modules shlib path filename so funcs functionl function2 functionN This initialization function opens the given shared object file and loads the functions function1 function2 and so on You can then use the functions functionl and function in the robot configuration file filter conf Remember to use the functions only with the directives you wrote them for as described in the following section Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating New Robot Application Functions Using your New Robot Application Functions When you have compiled and arranged for the loading of your functions you need to provide for their execution All functions are called as follows Directive fn function namel valuel nameN valueN e
164. he etc opt SUNWps desktop classes directory For each X properties file create a X_locale properties file that contains the translation The translated file must be installed into the same directory as the English version File Entries Format Each line of the properties file uses the format key value Lines can be continued using a backslash at the end of the line The properties files are encoded using Java Unicode encoding where non ASCII characters are represented using uxxxx notation Here the uxxxx is the hexidecimal representation of the Unicode value for the character This type of file can be created from a native file using the Java native2ascii program available in the JDK 1 3 1 package that is installed in the JDK_DIR directory specified in etc opt SUNWps PSConfig properties file 260 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Display Display Profile Properties The messages represented by the value part of the line are formatted using the conventions of the Java java text Message format class See the Javadocs for this class for more details on how to express parameters within messages Parameters are enclosed in curly braces Resource Bundle Access The ProviderAdapter getResourceBundle method loads the correct resource bundle for the user s locale and if the specified locale is not found it loads the default resource bundle That is it will look for the providerName_locale propertie
165. he cmdHook is run For example if the onComplet ion parameter is set to idle the robot log output would look like the following 12 45 57 Run cmd opt SUNWps bin cmdHook1 12 45 58 Complete cmd opt SUNWps cmdHook1 12 45 58 Robot is idle if the onCompletion parameter is set to shutdown the robot log output would look like 12 45 57 Run cmd opt SUNWps bin cmdHook1 12 45 58 Complete cmd opt SUNWps bin cmdHook1 12 46 33 Workload complete if the onCompletion parameter is set to loop the robot log output would look like 12 52 04 Run cmd opt SUNWps bin cmdHook1 12 52 05 Complete cmd opt SUNWps bin emdHook1 12 52 05 Restart Robot if the onCompletion parameter is set to loop there will be an additional entry in filter log like this 12 54 41 Filter log started loop 15 Preparing Your Completion Script to Appear in the Administration Interface If you want your cmdHook script to display as an option on the search engine Administration page you should follow these guidelines Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating New Robot Application Functions 1 Because the search engine Administration Interface does not scan binary files when it looks for cmdHook scripts write your script in a run time evaluated language instead of C or another compiled language 2 Place the file in portal server install root SUNWps bin directory 3 Name the file cmdHook f
166. he box the software includes the following building block leaf providers e JSPProvider Serves JavaServer Pages JSP e URLScraperProvider Serves data from a URL HTTP or file path e XMLProvider Enables XSL transformation of an XML document These providers are public and you can extend the Java class to provide customized functionality based on these providers This chapter includes detailed instructions for e Extending the building block leaf providers e Deploying JSP Tags and Tag Libraries Introduction Figure 4 1 on page 94 shows the relationship between the PAPI base class and the leaf providers discussed in this chapter The JSPProvider and URLScraperProvider extend the ProfileProviderAdapter to include support for retrieving content from JavaServer Pages and URLs respectively The XMLProvider extends the URLScraperProvider s functionality to scrape XML content from the named source and translate it into the markup language supported by the requesting client The XML Provider uses the URLScraperProvider s built in functionality to fetch the XML contents from HTTP HTTPs and file URLs 93 JSPProvider Figure 4 1 The Building Block Providers ProfileProviderAdapter JSPProvider URLScraperProvider XMLProvider Legend extends JSPProvider A JSPProvider is a content provider that can use JavaServer Pages to create the content for a channel on the Desktop Invoking a JSP The following is a de
167. he edit template file for the HelloWorldProvider The contents of edit template file is shown in Code Example 3 12 Code Example 3 12 HelloWorldProviderPPA1 edit template File lt DOCTYPE HTML PUBLIC W3C DTD HTML 3 2 EN gt lt HTML gt lt HEAD gt tag noCache lt TITLE gt tag productName lt TITLE gt lt HEAD gt lt BODY BGCOLOR FFFFFF gt lt FONT SIZE 0 FACE tag fontFacel gt lt LINK REL stylesheet TYPE text css HREF surl desktop css style css TITLE fonts gt lt CENTER gt tag bulletColor tag banner lt FORM ACTION dt NAME edit_form METHOD POST ENCTYPE application x www form urlencoded gt lt INPUT TYPE HIDDEN NAME action SIZE 1 VALUE process gt lt INPUT TYPE HIDDEN NAME provider SIZE 1 VALUE tag providerName gt tag inlineError Chapter 3 Extending the Base Providers 77 Extending the ProfileProviderAdapter Class Code Example 3 12 HelloWorldProviderPPA1 edit template File Continued lt TABLE BORDER 0 CELLPADDING 0 CELLSPACING 3 WIDTH 100 gt lt TR gt lt TD WIDTH 100 VALIGN TOP gt lt CENTER gt lt BR gt lt FONT SIZE 2 FACE tag fontFacel gt lt B gt Edit tag title lt B gt lt FONT gt lt BR gt tag contentOptions lt CENTER gt lt TD gt lt TR gt lt TABLE gt lt BR gt lt FONT SIZE 0 FACE tag fontFacel gt lt INPUT TYPE SUBMIT NAME Submit VALUE Finished CLASS button
168. he provider s channel as one of the leaf channels for a container you have to add the channel into the container s available and selected list To accomplish this 1 Add it to the Available and Selected list for the container For example to add the HelloWorldProvider to the TemplateTableContainer type the following o To add to the Available list type the following portal server install root SUNWps bin SUNWps bin dpadmin modify m p TemplateTableContainer u dn_amadmin w password a distinguishedname lt lt EOF lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Available gt lt Reference value HelloWorldPPA2 gt lt Available gt EOF Chapter 3 Extending the Base Providers 87 Extending the ProfileProviderAdapter Class 88 o To add to the Selected list type the following portal server install root SUNWps bin SUNWps bin dpadmin modify m p TemplateTableContainer u dn amadmin w password ad distinguishedname lt lt EOF lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Selected gt lt Reference value HelloWorldPPA2 gt lt Selected gt EOF 2 Access the HelloWorld Channel inside the Template TableContainer To access log in to the Desktop and type the following URL in your browser http ho
169. iarize yourself with the code and samples The Robot Application Function Header Files This section discusses the header files needed for creating robot application functions The following topics are described e Header File Hierarchy e Header File Contents 210 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating New Robot Application Functions Header File Hierarchy The hierarchy of robot plug in API header files is directories are shown in bold robot include cscinfo h csmem h filterrules h robotapi h base systems h libcs adt h cs h csidcf h getopt h log h pblock h The robot and its header files are written in ANSI C Header File Contents This section describes the header files you can include when writing your plug in functions This section is intended as a starting point for learning the functions included in the header files Most of the header files are stored in the following directories BaseDir SUNWps sdk robo Contains header files that define general purpose t include data structures and function prototypes BaseDir SUNWps sdk robo Contains the systems h header files that handle t include base low level platform independent functions such as memory file and network access BaseDir SUNWps sdk robo Contains header files of functions that handle robot t include libcs and HTTP specific functions such as handling access to configuration files and HTTP
170. ibute to the given new name SOIF_AttributeCompare NSAPI_PUBLIC int SOIF_AttributeCompare const char al const char a2 Compares two attribute names Returns 0 zero if they are equal or non zero if they are different Case upper and lower and trailing s are ignored when comparing attribute names The following table illustrates the results of comparing some attribute names Table 7 2 AttibuteA AttributeB Does SOIF_AttributeCompare consider them to be the same title Title yes title Title yes Chapter 7 Using the SOIF API to Work with SOIF Objects 193 SOIF API Table 7 2 AttibuteA AttributeB Does SOIF_AttributeCompare consider them to be the same title title yes title title page no title title no author title no Multi valued Attribute Routines A SOIF attribute can have multiple values SOIF supports the convention of using NNN to indicate a multivalued attribute For example Title 1 Title 2 Title 3 and so on The NNN do not need to be sequential positive integers The Search Engine supports searching on multi valued attributes such as the classification attribute In SOIF representation it is represented using classification 1 classification 2 and so on For example classification 1 5 robot classification 2 5 siroe classification 3 10 web crawler SOIF_AttributeCompareMV NSAPI PUBLIC int SOIF AttributeCompareMV const char al const char a2 Compares two attribute
171. ics size i UnmodifiableTab tab UnmodifiableTab tab get i oe Vv Chapter 5 Using the Container Providers 155 JSPContainerProviderAdapter Code Example 5 23 Sample Modifications to makeNewTab jsp File Continued lt TR gt lt TD gt lt INPUT TYPE radio NAME JSPTabContainer tabTopic VALUE lt tab getEncodedName gt _ lt checked gt gt lt TD gt lt TD gt lt FONT SIZE 1 FACE sans serif gt lt B gt lt tab getDisplayname gt lt B gt lt BR gt lt FONT SIZE 1 FACE sans serif gt lt tab getDesc gt lt FONT gt lt FONT gt lt TD gt lt TR gt lt do V lt checked CHECKED Ss lt tab getMakeTab id makeTab gt lt tab obtainTab tab SmakeTab gt lt include file makeTopic jsp gt lt tab obtainTab gt lt tab tabContainerProvider gt lt table gt lt end tab topic radios gt lt input type hidden name JSPTabContainer make value make gt lt td gt lt tr gt lt table gt 8 Copy the resource file for the provider into etc opt SUNWps desktop classes directory For example for the CustomJSPTableContainerProvider a Change directories to WebContainer portal web apps WEB INF classes directory b Type cp JSPTabContainerProvider properties etc opt SUNWps desktop classes CustomTabContainerProvider pr operties 9 Access CustomTabContainerProvider from your browser To access log in to the Deskto
172. ide December 2003 Portal Environment e JavaMail 1 2 e Java Activation Framework 1 0 1 e JNDI 1 1 2 e SOAP2 2 e JAXP11 File System The Portal Server product uses opt SUNWps opt is a default that can be changed during installation etc opt SUNWps and var opt SUNWps for installing Portal Server specific packages and other files into the file system Most Portal Server Java classes are defined in packages under the com sun portal package name The Sun ONE Portal Server software installs all of its web applications code into a single web application By default this web application is installed on the portal URI in the web container Chapter 1 Introduction to the APIs 23 Portal Environment 24 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Chapter 2 Using Provider API PAPI This chapter provides an overview of the Sun ONE Portal Server software Provider Application Programming Interface PAPI and includes instructions for developing a custom provider This chapter contains the following sections e Overview of the Provider API and Desktop Servlet e Overview of Implementing a Custom Provider Overview of the Provider API and Desktop Servlet Figure 2 1 shows the relationship between the various interfaces classes and exceptions discussed in this chapter For detailed information on these interfaces classes and exceptions see the Javadocs at http hostname port portal java
173. ider refreshTime Time interval for cached content isEditable Can the Provider be edited editType Type of edit form to use width Width of the Provider helpURL URL of a help page for this Provider See Sun ONE Portal Server 6 2 Desktop Customization Guide for detailed information on the Display Profile properties Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of Implementing a Custom Provider Channel definitions that use a provider can overwrite the properties of that provider At runtime channel property values can be affected by the display profile merge process See Sun ONE Portal Server 6 2 Administrator s Guide for detailed information on the display profile merge process Properties in Resource bundle Strings defined in the provider s resource bundle properties file are displayed on the user s Desktop and they are not the channel s properties such as the channel title Strings are defined in the resource bundle to enable localization Typically resource bundle includes properties that do not need to be customized by the administrator or the end user For example properties that need to be localized are read only at runtime and properties that do not change per channel should be included in a resource bundle Properties that need to be localized are settable and properties that change per channel should be in the display profile By default a provider s resource bundle properties file is st
174. ider ChannelNam e The flowchart in Figure 2 7 on page 45 shows the various methods executed in the back end to process the edit action This flowchart shows how the DesktopServlet processes the edit action for a container In this URL the provider parameter specifies the edit container for the container and the targetprovider parameter is the leaf channel inside the container When the client makes a request to process this edit action the DesktopServlet 1 Determines the provider responsible for generating the requested content If provider is null it uses the default channel name to get the provider Default or last accessed channel is not assumed when action equals edit Otherwise the DesktopServlet gets the provider responsible specified in the URL 2 Once the provider is determined the edit container s isEditable method is invoked to determine if the edit container is editable The DesktopServlet gets the named edit container s isEditable property If the edit container is determined to be not editable an exception is thrown on the Desktop If the edit container can be edited the DesktopServlet also checks the edit Type for that edit container The editType is a property that can be retrieved via the Provider getEditType method The provider s getEdit Type method is invoked to determine the type of edit page to return on the Desktop 3 If the edit container s edit type is o EDIT COMPLETE
175. ides a mechanism for extending and aggregating content through the Provider Application Programming Interface PAPI The PAPI is a Java API that enables you to construct the basic building blocks for creating channels Usually though not always channels contain content You can also have channels of channels that is a container channel that aggregates other channels A channel can also be the entire Desktop page The container channels define the layout of the Desktop See Figure 1 1 for a simple representation of a portal Desktop and its providers and containers In this figure the Desktop front page is a tab container with two tabs Each tab contains a table container with various channels Notice how one provider in this case URLScraperProvider is serving more than one channel Providers can have a one to many relationship with channels Desktop Hierarchy and Building Block Providers 12 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview Desktop Providers ge mg 5 Front Channel a TabContainerProvider Tab 2 Tab 1 Ch 12 a ablecontainerProvider B Channel 1 Content ag Content eg C URLScraperProvider TableContainerProvider Channel 3 Content ug C XMLProvider Display Profile The display profile is a set of XML documents used to define and configure provider
176. ike void caller data hook to be used by caller Use SOIFStream Parse to get the SOIF objects from the SOIF stream and use SOIFStream_Print to write SOIF objects to the SOIF stream When you ve finished with the stream close it by using SOIFStream Finish Use SOIFStream SetFinishFn to trigger the given finish_fn function The following example code takes a SOIF stream in stdin and prints each SOIF in the stream to stdout Notice that this code uses SOIF_ParseInitFile to create the SOIFStream to parse the input file and uses SOIF PrintInitFile to create the stream to print the SOIFs to stdout SOIFStream soifin SOIF_ParseInitFile stdin SOIFStream soifout SOIF PrintInitFile stdout SOIF s while SOIFStream_IsEOS soifin if s SOIFStream_Parse soifin SOIFStream print soifout s SOIF Free s SOIF PrintlnitFile NSAPI PUBLIC SOIFStream SOIF PrintInitFile FILE file Creates a disk based stream ready for printing SOIF PrintlnitStr NSAPI PUBLIC SOIFStream SOIF_PrintInitStr SOIFBuffer memory Creates a memory based stream ready for printing SOIF PrintlnitFn NSAPI PUBLIC SOIFStream SOIF PrintInitFn int write fn void data char buf int bufsz void data 198 Sun ONE Portal Server 6 2 Developer s Guide December 2003 SOIF API Creates a generic application defined stream ready for printing The given write_fn is used to print the stream This func
177. ile That is type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname AddressBookProvider xml portal server install root SUNWps bin dpadmin modify m u dn_amadmin w password d distinguishedname AddressBookChannel xml 6 Develop the JSP file for the provider For the sample AddressBookProvider the JSP in Code Example 4 4 on page 98 can be used to display the content of the address book for each user However the details of displaying the address book are not shown in Code Example 4 4 Chapter 4 Using Leaf Providers 97 JS Code Example 4 4 PProvider addressBook jsp File lt addressBook jsp gt lt S page import custom AddressBookProvider gt lt S page import custom AddressBook gt lt AddressBookProvider addressBookProvider AddressBookProvider pageContext getAttribute JSPProvider AddressBook addrBook AddressBook pageContext getAttribute addressBook PageContext REQUEST_SCOPE gt lt 5 Display the address book gt 98 Create a channel directory under the template root directory By default the template root directory is etc opt SUNWps desktop desktoptype For this example create an AddressBook directory under etc opt SUNWps deskt op desktoptype directory Copy all the JSP files over to the newly created directory in Step 7 For example type cp addressBook jsp etc opt SUNWps deskt op de
178. ile see Code Example 5 18 and the display profile fragment for the CustomTableContainerProvider s channel is saved in Cust omJSPTCChannel xml file see Code Example 5 19 on page 146 Code Example 5 18 8 CustomJSPTCProvider xml File lt xml version 1 lt DOCTYPE Displa lt Provider name class custom Cu lt Properties gt lt String lt Integer lt Integer lt Boolean lt Boolean lt String lt String lt String lt String lt String lt String lt String lt String lt String lt Boolean lt Boolean lt String lt String lt Integer lt Integer lt Integer lt Integer lt Integer 0 encoding utf 8 standalone no gt yProfile SYSTEM jar resources psdp dtd gt CustomJSPTableContainerProvider stomJSPTableContainerProvider gt name contentPage value toptable jsp gt name timeout value 1800 gt name layout value 1 gt name showExceptions value false gt name parallelChannelsInit value false gt name title value Table Container Provider gt name description value DESCRIPTION gt name refreshTime value 0 gt name width value thin gt name fontFacel value Sans serif gt name Desktop fontFacel value Sans serif gt name productName value Sun ONE Portal Server gt name preset ThemeChannel value JSPPresetThemeContainer gt name customThemeChannel value JSPCustomThemeContainer gt name refreshParentContainerOnly value false
179. ine Robot 213 Creating New Robot Application Functions 214 NOTE The pb parameter is read only and any data modification should be performed on copies of the data Doing otherwise is unsafe in threaded server architectures and will yield unpredictable results in multiprocess server architectures Writing Functions for Specific Directives You should write each function for a particular stage in the filtering process setup metadata data enumeration generation and shutdown The function should only use the data sources that are available at the relevant stage See the section Sources and Destinations in the Sun ONE Portal Server 6 2 Administrator s Guide for a list of the data sources available at each stage At the Setup stage the filter is preparing for setup and cannot get information about the resource s URL or content At the MetaData stage the robot has encountered a URL for a resource but has not downloaded the resource s content Consequently information is available about the URL and the data that is derived from other sources such as the filter conf file At this stage information is not available about the content of the resource At the Data stage the robot has downloaded the content of the URL so information is available about the content such as the description the author and so on At the Enumeration and Generation stages the same data sources are available as for the Data stage At the Shut
180. inerProvider java Develop the display profile XML fragments for this provider and this provider s channel The display profile fragments for the Custom TabContainerProvider s provider and channel are saved in CustomTabCProvider xml see Code Example 5 21 and CustomTabCChannel xml see Code Example 5 22 on page 152 files respectively CustomTabCProvider xml File lt xml version 1 lt DOCTYPE Displa lt Provider name lt Properties gt lt String lt Boolean lt String lt String lt String lt String lt String lt String lt String lt String lt Boolean lt String lt String lt Integer name t lt Integer lt Integer lt Integer lt Integer lt Integer lt Boolean lt Boolean lt Boolean lt Boolean lt Boolean lt Boolean 0 encoding utf 8 standalone no gt yProfile SYSTEM jar resources psdp dtd gt CustomTabContainerProvider class custom CustomTabContainerProvider gt name contentPage value tab jsp gt name showExceptions value false gt name title value Tab Container Provider gt name description value DESCRIPTION gt name refreshTime value advanced true gt name width value thin advanced true gt name fontFacel value Sans serif gt name productName value Sun ONE Portal Server gt name preset ThemeChannel value JSPPresetThemeContainer advanced true gt name customThemeChannel value JSPCustomTheme
181. ines URLs and their associated network resources Each resource is tested by both the enumerator and the generator If the resource passes the enumeration test the robot checks it for additional URLs If the resource passes the generator test the robot generates a resource description that is stored in the search engine database Figure 8 1 How the Robot Works Spawn New URL filterrules conf filter conf classification conf robot conf Engine Database Enumerator Setup Metadata Retrieval Data Enumerate Shutdown RDM 204 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Generator Setup Metadata Retrieval Data Generate Shutdown Register Resource Description Search Engine Robot Overview Robot Configuration Files Robot configuration files define the behavior of the search engine robots These files reside in the directory webcontainer portal config The following table lists the configuration file in the first left column and provides a description of the corresponding robot configuration file in the second right column robot conf Defines most of the operating parameters for the robot In addition this file points the robot to applicable filters in the file filter conf filter conf Contains all of the functions used by the Search Engine robot during the enumeration and generation filtering tasks Including the same functions for both enumeration and generation ensures that
182. ing channel String selected get i Provider p getContainerProviderContext getProvider reg getName channel if p getWidth ProviderWidths WIDTH_ FULL BOTTOM rowSpan rowSpant return rowSpan 2 Compilethe class and put it in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory To compile the SpanTableContainerProvider java file enter javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar SpanTableContainerProvider java 3 Develop the display profile XML fragments for this provider and this provider s channel The display profile fragment for SpanTableContainerProvider s provider is saved in SpanTCProvider xml file see Code Example 5 9 on page 132 and the display profile fragment for SpanTableContainerProvider s channel is saved in SpanTCChannel xml file see Code Example 5 10 on page 133 Chapter5 Using the Container Providers 131 JSPContainerProviderAdapter Code Example 5 9 SpanTCProvider xml File lt S lt S lt S lt S lt S lt S lt S lt S lt S lt S lt S tring tring tring tring tring tring tring tring t
183. ing functions for a SOIF stream to specify that certain SOIF attributes are allowed or denied If an attribute is allowed you can parse and print that attribute for SOIF objects in the stream If it is denied you cannot parse or print that attribute of SOIF objects in the stream SOIF streams can be disk or memory based When you create a SOIFSt ream you need to specify if you will be printing or parsing the SOIF stream and if you will be using a memory or disk based stream The functions you need to use will depend on what you will be doing with the SOIF stream For creating a SOIF streams into which you will be printing SOIFS the functions are the following SOIF_PrintInitFile creates a disk based stream ready for printing SOIF_PrintInitStr creates a memory based stream ready for printing SOIF_PrintInitFn creates a generic application defined stream ready for printing The given write_fn is used to print the stream To create SOIF stream from a file or a string containing SOIF use the following functions SOIF_ParseInitFile creates a disk based stream ready for parsing The stream is created from an input containing SOIF syntax Chapter 7 Using the SOIF API to Work with SOIF Objects 197 SOIF API SOIF_ParseInitStr creates a memory based stream ready for parsing The stream is created from an input containing SOIF syntax SOIFStream objects have a caller data field which you can use as you l
184. ing it this way Chapter 7 Using the SOIF API to Work with SOIF Objects 201 SOIF API 202 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Chapter 8 Search Engine Robot This chapter describes the search engine robot and the application programming interface API used to create plug in robot application functions RAFs NOTE For more information on the Search Engine Robot see the Sun ONE Portal Server 6 2 Administrator s Guide This chapter covers the following topics e Search Engine Robot Overview e Robot Completion Scripts e Creating New Robot Application Functions Search Engine Robot Overview A search engine robot is an agent that identifies and reports on resources in its domains it does so by using two kinds of filters an enumerator filter and a generator filter The enumerator filter locates resources by using network protocols It tests each resource and if it meets the selection criteria it is enumerated For example the enumerator filter can extract hypertext links from an HTML file and use the links to find additional resources The generator filter tests each resource to determine if a resource description RD should be created If the resource passes the test the generator creates an RD which is stored in the search engine database 203 Search Engine Robot Overview How the Robot Works Figure 8 1 illustrates how the search engine robot works In Figure 8 1 the robot exam
185. ion set by the user in the edit mode String salutation request getParameter SALUTATION try PortletPreferences pref request getPreferences pref setValue salutation salutation pref store catch Exception e throw new PortletException e getMessage return the user back to the view mode and normal state response setPortletMode Port letMode VIEW response setWindowState WindowState NORMAL 168 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Extending the GenericPortlet Abstract Class Code Example 6 1 PrefPortlet java File Continued public void doView RenderRequest request RenderResponse response throws PortletException IOException public void doEdit RenderRequest request RenderResponse response throws PortletException IOException VALIGN TOP gt salutation lt TD gt lt TID ALIGN LEFT gt lt INPUT TYPE TEXT NAME SALUTATION gt lt TD gt lt TR gt lt TR gt lt TD ALIGN RIGHT gt amp nbsp lt TD gt lt TD ALIGN LEFT gt lt INPUT TYPE SUBMIT NAME SUB1 VALUE Submit gt lt TD gt lt TR gt lt TABLE gt lt form gt public void doHelp RenderRequest request RenderResponse response throws PortletException displays the salutation stored in the preference PortletPreferences pref request getPreferences String salutation pref getValue salutation response setContent
186. ipulate the Search database itself e Sun ONE Identity Server software There are five APIs packaged with Sun ONE Identity Server software authentication debugging logging client detection and Single Sign on SSO You can extend the authentication and client detection APIs The other APIs that can be used include the functional areas of SSO debugging and logging This guide does not describe the Sun ONE Identity Server software APIs in detail but instead provides a general overview See the Sun ONE Identity Server Programmer s Guide for more information on programming with those APIs Software Architecture Figure 1 2 on page 16 shows the Sun ONE Portal Server software architecture In this figure the Sun ONE Portal Server software components consist of e Applications such as NetMail e Services such as search made up of the search engine and robot discussions and subscriptions e Content delivery and presentation on the Desktop The Java Developers Kit JDK provides the Java run time environment for all Java software in Portal Server and its underlying components The Sun ONE Web Server software or the Sun ONE Application Server software or the BEA WebLogic Server or the IBM Websphere Application Server provides the web container The application server provides the Portal Server with a robust highly scalable web container for the Portal Server web applications It also provides Portal Server with compatibility for o
187. is 1 That is if a portlet does not define the session enabled element in the sun portlet xml file it is session enabled The session enabled element allows the portlet container to optimize the loading of portlets for performance improvement PDConfig properties Some of the default setting used by the pdeploy command to deploy portlet application are available in PDConfig properties file The PDConfig properties file is installed into etc opt SUNWps portlet directory When the pdeploy command deploys the portlet application it prepares the portlet application by consulting the following parameters logger log level SEVERE By default the log level is set to SEVERE Valid values for this parameter are ALL OFF INFO WARNING SEVERE logger file dir var op This parameter indicates the directory to which the t SUNWam debug log file for the deployed portlet application is stored validate_schema t rue This parameter indicates whether or not schema validation should be performed during deployment Chapter6 Developing and Deploying Portlets 181 Files Used by Portlets 182 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Chapter 7 Using the SOIF API to Work with SOIF Objects This chapter describes the use of the search engine SOIF API to work with SOIF objects in C Resource descriptions in the search engine database are described in SOIF and so are Resource Description Messages
188. isEditable method e Preconfigured for the user by the administrator but editable by the end user determines the logistics of the getEdit method If editable determine o What will and what will not be editable That is determine the parameters that will be configurable and those that will not be editable o The type of edit form to present EDIT_SUBSET or EDIT_COMPLETE The advantage of using EDIT_SUBSET is that the EditContainer provides a common look and feel for all providers that have EDIT_SUBSET edit type Using EDIT_COMPLETE edit type provides more control over the overall look and feel for the edit page This will determine the logistics of the getEditType and the processEdit methods e Determine the theme requirements for the content made available via this provider A theme is a collection of visual elements such as background color font face and so on to be used when displaying the provider s content The themes are stored as global properties in the organization level s display 52 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of Implementing a Custom Provider profile Providers can use these properties in their templates or JSPs to achieve a global look and feel of the presentation For use with JSP theme properties can be accessed from a series of tag libraries Non JSP channels can access theme proper
189. isEditable value false advanced true gt lt String name editType value edit_subset advanced true gt lt String name width value thin advanced true gt lt String name helpURL value desktop usedesk htm advanced true gt lt String name fontFacel value Sans serif gt lt String name productName value Sun ONE Portal Server gt lt String name contentPage value simpleUserInfoContent jsp gt lt String name editPage value simpleUserInfoEdit jsp gt lt Properties gt lt Provider gt In Code Example 4 7 note that the SimpleUserInfoProvider channel definition is embedded inside JSPTableContainer thus making the channel only visible via the container Code Example 4 7 SimpleUIPChannel xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name JSPTableContainer provider JSPTableContainerProvider gt lt Properties gt lt Collection name Personal Channels gt lt String name SimpleUserInfo gt lt Collection gt lt Collection name channelsColumn gt lt String name SimpleUserInfo value 3 gt lt Collection gt lt Properties gt lt Available gt lt Reference value SimpleUserInfo gt lt Available gt lt Selected gt lt Reference value SimpleUserInfo gt lt Selected gt lt Channels gt lt Channel name SimpleUserInfo provider Simp
190. it pourront tre d riv es des syst mes Berkeley BSD licenci s par l Universit de Californie UNIX est une marque d pos e aux Etats Unis et dans d autres pays et licenci e exclusivement par X Open Company Ltd Sun Sun Microsystems le logo Sun Java Solaris JDK Java Naming and Directory Interface JavaMail JavaHelp J2SE iPlanet le logo Duke le logo Java Coffee Cup le logo Solaris le logo SunTone Certified et le logo Sun tm ONE sont des marques de fabrique ou des marques d pos es de Sun Microsystems Inc aux Etats Unis et dans d autres pays Toutes les marques SPARC sont utilis es sous licence et sont des marques de fabrique ou des marques d pos es de SPARC International Inc aux Etats Unis et dans d autres pays Les produits portant les marques SPARC sont bas s sur une architecture d velopp e par Sun Microsystems Inc Le logo Netscape Communications Corp est une marque de fabrique ou une marque d pos e de Netscape Communications Corporation L interface d utilisation graphique OPEN LOOK et Sun TM a t d velopp e par Sun Microsystems Inc pour ses utilisateurs et licenci s Sun reconnait les efforts de pionniers de Xerox pour la recherche et le d veloppement du concept des interfaces d utilisation visuelle ou graphique pour l industrie de l informatique Sun d tient une license non exclusive de Xerox sur l interface d utilisation graphique Xerox cette licence couvrant galement les licenci s de Sun qui mettent
191. ition in the display profile Extending the JSPTableContainerProvider This section includes some sample providers that extend JSPTableContainerProvider and override methods in the JSPTableContainerProvider API Example 1 The following is an example of a container provider that selects channels dynamically based on the time of the day 124 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter 1 Extend JSPTableContainerProvider and develop the provider class file For CustomTableContainerProvider the CustomTableContainerProvider class is implemented by extending the JSPTableContainerProvider class as shown in Code Example 5 5 Code Example 5 5 CustomTableContainerProvider java File package custom import import import import import public private Calendar rightNow Calendar getInstance com sun portal providers containers jsp table JSPTableContainerProvider com sun portal providers ProviderException java util List java util ArrayList java util Calendar class CustomTableContainerProvider extends JSPTableContainerProvider public List getSelectedChannels throws ProviderException List selectedChannels super getSelectedChannels List newList new ArrayList if rightNow AM_PM rightNow AM List amList List getListProperty amList for int i 0 i lt amList size i String channel String amList get i if selectedCh
192. itions lt Collection gt lt Integer gt lt Integer gt Chapter 2 Using Provider API PAPI 55 Overview of Implementing a Custom Provider 56 lt String gt lt String gt lt Boolean gt lt Boolean gt lt Properties gt Typically the custom provider will not modify the required properties When properties are updated they are set in the user s display profile by the administrator via the administration console However values can only be set on existing properties If the provider class does not extend the ProfileProviderAdapter and implements the Provider interface then the get Property methods cannot be used directly and the display profile properties are not accessible If the provider class implements the Provider interface directly then no properties are required Properties must be hardcoded return values or can come from another source such as a database However some provider properties are required if the provider implementation extends ProviderAdapter or ProfileProviderAdapter The following is a list of the mandatory properties for a provider The mandatory properties described below are for a provider extending the ProviderAdapter or the ProfileProviderAdapter classes If you are implementing the Provider interface directly you can avoid the use of the display profile and the required properties outlined below title Title of the Provider description Description of the Prov
193. ked lists of 1libcs parameter structures struct libcs pb entry libes pb param param struct libcs pb entry next bi libcs pblock This structure is a hash table containing an array of libcs pb entry structures typedef struct int hsize struct libcs_pb_entry ht libes pblock Chapter 8 Search Engine Robot 215 Creating New Robot Application Functions Working with Parameter Blocks A parameter block stores parameters and values as name value pairs There are many pre defined functions you can use to work with parameter blocks to extract parameter values to change parameter values and so on For example libcs pblock findval paramname returnPblock uses the given return pblock to return the value of the named parameter in the RAF s input pblock For an example see RAF Definition Example When adding removing editing and creating name value pairs for parameters your robot application functions can use the functions in the pblock h header file in portal server install root SUNWps sdk robot include libcs directory The names of these functions are all prefixed by libcs The following table contains the parameter manipulation functions in the first left column and a description of the corresponding function in the second right column See the portal server install root SUNWps sdk robot include libcs pblock h header file for full function signatures with return type and arg
194. l root S UNWam lib servlet jar CustomICProvider java 3 Develop the display profile XML fragment for this provider and this provider s chamnel a The display profile fragment for the CustomTCProvider s provider and chamnel must be saved in separate XML files b Add lt Integer name layout value 5 gt in the display profile fragment for the CustomTCProvider s provider 4 Use the dpadmin command to upload the display profile fragments for this provider For Custom TCProvider use the dpadmin command to upload the CustomTCProvider xml file and CustomTCChannel xml file fragments in the display profile That is type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomICProvider xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomTCChannel xml 5 Create a new directory for the provider in etc opt SUNWps desktop desktoptype The directory for the provider is typically named after the provider For the sample CustomTCProvider create a directory called CustomTCProvider in etc opt SUNWps desktop desktoptype 6 Copy files from etc opt SUNWps desktop default JSPTableContainerProvider to the newly created directory 7 Modify the HTML in toptable jsp file in etc opt SUNWps desktop desktoptype CustomTCProvider Rearrange the channels into rows and columns as per your specifications Replace JSPLayout
195. l root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname SpanTCChannel xml 5 Create anew directory for the provider in etc opt SUNWps desktop desktoptype directory The directory for the provider is typically named after the channel For the sample SpanTableContainerProvider create a directory called SpanTableContainerChannel in etc opt SUNWps deskt op desktoptype directory 6 Copy files from etc opt SUNWps desktop default JSPTableContainerProvider to the newly created directory 7 Modify the JSP files in etc opt SUNWps desktop desktoptype SpanTableContainerChannel as shown in Step a Step b and Step c modifications to the file are shown in bold a Add the following to toptable jsp Chapter5 Using the Container Providers 135 JSPContainerProviderAdapter Code Example 5 11 Changes to toptable jsp File lt BEGIN FULL TOP CHANNELS gt lt dttable getColumns id channels column top scope request gt lt jsp include page tabletopbottom jsp flush true gt lt jsp param name columnName value top gt lt jsp include gt lt END TOP CHANNELS 5 lt BEGIN FULL BOTTOM CHANNELS 5 lt dttable getColumns id channels column bottom scope request gt lt jsp include page tabletopbottom jsp flush true gt lt jsp param name columnName value bottom gt lt jsp include gt lt END BOTTOM CHANNELS gt Here tcp is an instance of S
196. language en country US gt lt String name message value Hello World I am speaking English in the United Upload the provider and channel XML fragments using the dpadmin command For the sample HelloWorldProvider upload the Hel1oProviderPPA1 xml file and HelloChannelPPA1 xml file XML fragments using the dpadmin command That is for example type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname HelloProviderPPAl xml Chapter 3 Extending the Base Providers 75 Extending the ProfileProviderAdapter Class portal server install root SUNWps bin dpadmin add u dn_amadmin w password d distinguishedname HelloChannelPPA1 xml 5 Include the provider s channel in one of the existing containers The sample HelloWorldProvider will be displayed in a Table Desktop layout To add the channel in the JSPTableContainer from the administration console follow instructions in the Sun ONE Portal Server 6 2 Administrators Guide To add the channel in the JSPTableContainer manually a Add the HelloWorldProvider channel XML fragment in the HelloContainerPPA1 xml file for the JSPTableContainer as shown in Code Example 3 10 Code Example 3 10 HelloContainerPPA1 xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name JSPTableContainer provider JSPTableContainerProvider gt
197. ld test lt keywords gt lt portlet info gt lt portlet preferences gt lt preference gt lt name gt name lt name gt lt value gt World lt value gt lt preference gt lt portlet preferences gt lt portlet gt lt portlet app gt 170 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Extending the GenericPortlet Abstract Class 2 Create the web xml file A web application also requires a web xml file If you have servlets for your portlet web application then the servlet definition can be incorporated in the web xml file Code Example 6 3 contains the web xml file for the sample portlet Code Example 6 3 web xml File for PrefPortlet lt xml version 1 0 encoding ISO 8859 1 gt lt DOCTYPE web app PUBLIC Sun Microsystems Inc DTD Web Application 2 3 EN http java sun com dtd web app_2_3 dtd gt lt web app gt lt display name gt Portlet Examples lt display name gt lt web app gt 3 Package everything into a WAR file For the sample portlets create an examples directory where all the files of the WAR will be placed Then within the examples directory create the WEB INF directory All the portlet files will be placed into the WEB INF directory For example your directory hierarchy may look like this examples WEB INF web xml portlet xml classes examples PrefPortlet class 4 Create the WAR file That is change directories to ex
198. le tabs inherit the characteristics of the UnmodifiableTab This interface provides methods to allow the user to reset the display name setDisplayname and description setDesc of the predefined tab JSPTabContainerProvider The JSPTabContainerProvider includes the functionality to enable display of JSPs in the TabContainer environment It provides methods that allow the associated JSP files to use these methods and generate a view that aggregates the output of channels providing a tabbed user interface to switch between them The JSPTabContainerProvider class extends JSPContainerProviderAdapter and implements the TabContainer interface Chapter 5 Using the Container Providers 149 JSPContainerProviderAdapter Extending the JSPTabContainerProvider This section includes a sample extension to the JSPTabContainerProvider class In this example a new method called get TabTopics is added to the JSPTabContainerProvider The get TabTopics method returns only the predefined tabs from the list of available tabs This method is then called from the makeNewTab jsp so that the Make New Tab page of the customTabContainer will only display the Predefined tab topics instead of displaying all the available tabs predefined and user created To accomplish this 1 Extend the JSPTabContainerProvider and develop the CustomTabContainerProvider class file The CustomTabContainerProvider class file in Code Example 5 20 includes a get Tab
199. leUserInfoProvider gt 100 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 4 7 JSPProvider SimpleUIPChannel xml File Continued lt Properties gt lt String name processPage value simpleUserInfoDoedit jsp gt lt Properties gt lt Channel gt lt Channels gt lt Container gt Use the apadmin command to upload the display profile fragments for this provider For the SimpleUserInfoProvider use the dpadmin command to upload the SimpleUIProvider xml file and SimpleUIPChannel xml file XML fragments in the display profile That is type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname SimpleUIProvider xml portal server install root SUNWps bin dpadmin modify m u dn_amadmin w password d distinguishedname SimpleUIPChannel xml Create a channel directory under the template root directory By default the template root directory is etc opt SUNWps deskt op desktoptype For this example create an SimpleUserInfo directory under etc opt SUNWps deskt op desktoptype directory Develop and copy all the JSP files over to the newly created directory in Step 5 For example develop the simpleUserInfoContent jsp and simpleUserInfoEdit jsp files and copy them over to the newly created etc opt SUNWps deskt op desktoptype SimpleUserInfo directory Access the SimpleUserInfo channel inside the JSPTableContainer
200. lloWorldProvider channel XML fragment in the HelloChanne1PA xml file for the JSPTableContainer as shown in Code Example 3 6 3 6 HelloChannelPA xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name JSPTableContainer provider JSPTableContainerProvider gt lt Properties gt lt Collection name Personal Channels gt lt Collection gt lt Col lt Co lt Col lt Co lt String value HelloWorldPA gt lection name channelsRow gt lt String name HelloWorldPA value 3 gt llection gt lection name channelsColumn gt lt String name HelloWorldPA value 3 gt llection gt Chapter 3 Extending the Base Providers 71 Extending the ProfileProviderAdapter Class Code Example 3 6 HelloChannelPA xml File Continued lt Properties gt lt Available gt lt Reference value HelloWorldPA gt lt Available gt lt Selected gt lt Reference value HelloWorldPA gt lt Selected gt lt Channels gt lt Channel name HelloWorldPA provider HelloWorldProviderPA gt lt Properties gt lt String name message value Hello World Test non localized gt lt Properties gt lt Channel gt lt Channels gt lt Container gt b Use the dpadmin modify subcommand to add the channel to a container If you do not specify a parent object with the p option the c
201. lloWorldProviderPPA1 gt lt Properties gt 74 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Code Example 3 8 Extending the ProfileProviderAdapter Class HelloProviderPPA1 xml File Continued lt String name title value TITLE gt lt String name description value DESCRIPTION gt lt String name refreshTime value 0 gt lt Boolean name isEditable value true gt lt String name editType value edit_subset gt lt Collection name aMap gt lt String name title value Ramag gt lt String name desc value My Map gt lt Boolean name removable value true gt lt Boolean name renamable value true gt lt Collection gt lt String name message value Hello World Test Provider gt lt Properties gt lt Provider gt Code Example 3 9 HelloChannelPPA1 xml File lt Properties gt States gt lt Locale gt lt Properties gt lt Channel gt lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Channel name HelloWorldPPA1 provider HelloWorldProviderPPA1 gt lt String name title value Hello World Channel gt lt String name description gt This is a test of the hello world provider lt String gt lt String name width value thin gt lt String name message value Hello World Test non localized gt lt Locale
202. ls gt lt Channels gt lt Container gt 4 Use the dpadmin command to upload the display profile fragments for this provider For CustomJSPTableContainerProvider use the dpadmin command to upload the CustomTCProvider xml file and CustomTCChannel xm1 file fragments in the display profile That is type portal server install root SUNWps bin dpadmin add u dn_amadmin w password d distinguishedname CustomJSPTCProvider xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomJSPTCChannel xml 5 Create anew directory for the provider in etc opt SUNWps desktop desktoptype The directory for the provider is typically named after the provider For the sample CustomJSPTableContainerProvider create a directory called CustomJSPTableContainerChannel in etc opt SUNWps desktop desktoptype Chapter5 Using the Container Providers 147 JSPContainerProviderAdapter 6 Develop and copy the JSP files for the provider in the newly created directory For CustomJSPTableContainerProvider copy files from etc opt SUNWps desktop default JSPTableContainerProvider to the etc opt SUNWps desktop desktoptype CustomJSPTableContainerChannel directory 7 Copy the resource file for the provider into etc opt SUNWps desktop classes directory For example for the CustomJSPTableContainerProvider a Change directories to WebContainer portal web apps WEB INF classes directory b Type cp JSPTabl
203. lt Properties gt lt Collection name Personal Channels gt lt String value HelloWorldPPA1 gt lt Collection gt lt Collection name channelsRow gt lt String name HelloWorldPPA1 value 3 gt lt Collection gt lt Properties gt lt Available gt lt Reference value HelloWorldPPA1 gt lt Available gt lt Selected gt lt Reference value HelloWorldPPA1 gt lt Selected gt lt Channels gt lt Channels gt lt Container gt 76 b Usethe dpadmin modify subcommand to add the channel to a container If you do not specify a parent object with the p option the channel is added at the root level portal server install root SUNWps bin dpadmin modify m u dn_amadmin w password d distinguishedname HelloContainerPPA1 xml Sun ONE Portal Server 6 2 Developer s Guide December 2003 Extending the ProfileProviderAdapter Class 6 Create the template files if the new provider requires template files The sample HelloWorldProvider requires content template and edit template files a Create the content template file for the HelloWorldProvider The contents of content template file is shown in Code Example 3 11 Code Example 3 11 HelloWorldProviderPPA1 content template File lt html gt lt head gt lt head gt lt body bgcolor white gt tag welcome lt br gt lt br gt tag message lt br gt lt br gt tag properties lt body gt lt html gt b Create t
204. lt String name title value Hello World Channel gt lt String name description gt This is a test of the hello world provider lt String gt lt String name width value thin gt lt Properties gt lt Provider gt Code Example 3 3 HelloChannelP xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Channel name HelloWorldP provider HelloWorldProviderP gt lt Properties gt lt String name message value Hello World Test non localized gt lt Locale language en country US gt lt String name message value Hello World I am speaking English in the United States gt lt Locale gt lt Properties gt lt Channel gt 68 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Extending the ProviderAdapter Class 4 Upload the provider and channel XML fragments using the dpadmin command For the sample HelloWorldProvider upload the HelloProviderP xml and HelloChannelP xml XML fragments using the dpadmin command That is for example type portal server install root SUNWps bin dpadmin add u dn_amadmin w password d distinguishedname HelloProviderP xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname HelloChannelP xml 5 Access the channel from a browser To access type the following URL in your browser http hostname port
205. mark gt lt Available gt lt Selected gt lt Reference value Search gt lt Selected gt lt Channels gt lt Channels gt lt Container gt 4 Use the dpadmin command to upload the display profile fragments for this provider For the CustomSingleContainerProvider use the dpadmin command to upload the CustomSCProvider xml file and CustomSCChannel xm1 file XML fragments into the display profile That is type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomSCProvider xml portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname CustomSCChannel xml 5 Create a new directory for the provider in etc opt SUNWps desktop desktoptype directory The directory for the provider is typically named after the provider s channel For the sample CustomSingleContainerProvider create a directory called CustomSingleContainer in etc opt SUNWps desktop desktoptype directory 122 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter 6 Develop and copy the JSP files for the provider in the newly created directory For the CustomSingleContainerProvider copy files from etc opt SUNWps desktop default JSPSingleContainerProvider to the etc opt SUNWps desktop desktoptype CustomSingleContainer directory a Modify single jsp file in the etc opt SUNWps desktop desktoptype CustomSingleContainer
206. me value Sun ONE Portal Server gt lt String name contentPage value addressBook jsp gt lt Properties gt lt Provider gt 96 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPProvider In Code Example 4 3 note that the AddressBookProvider channel definition is embedded in an existing table container JSPTableContainer Code Example 4 3 AddressBookChannel xm1 File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name JSPTableContainer provider JSPTableContainerProvider gt lt Properties gt lt Collection name Personal Channels gt lt String name AddressBook gt lt Collection gt lt Collection name channelsColumn gt lt String name AddressBook value 3 gt lt Collection gt lt Properties gt lt Available gt lt Reference value AddressBook gt lt Available gt lt Selected gt lt Reference value AddressBook gt lt Selected gt lt Channels gt lt Channel name AddressBook provider AddressBookProvider gt lt Properties gt lt Properties gt lt Channel gt lt Channels gt lt Container gt 5 Use the dpadmin command to upload the display profile fragments for this provider For the AddressBookProvider use the dpadmin command to upload the AddressBookProvider xml file and AddressBookChannel xml file XML fragments in the display prof
207. me as your custom tag name and the tagclass must point to the correct class Copy the t1d file in templateBaseDir default tld where templateBaseDir is the directory defined in etc opt SUNWps desktop desktopconfig properties file Modify the JSP files to use the custom tags For example 102 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 4 9 URLScraperProvider Sample Tag Usage in JSPs lt taglib uri tld custom tld prefix custom gt lt HTML gt lt HEAD gt lt TITLE gt My custom jsp lt TITLE gt lt HEAD gt lt BODY gt Here is the result of MyCustomTag lt custom MyCustomTag gt lt BODY gt lt HTML gt URLScraperProvider The URLScraperProvider can retrieve and display content from a given URL Scraping Content from the URL The following is a step by step description of how the URLScraperProvider retrieves and displays content from the specified URL 1 2 Gets the timeout property for the provider Gets the ur1 property for the provider This is the URL source for the content to be fetched The ur1 property is fetched from the conditional property of display profile based on the user s clientType and locale if defined Otherwise the default value is returned Gets the urlscraperRuleset ID to be used by Rewriter as a string Determines if the cookieName can be forwarded To determine it checks the value of cookiesToForwardA11 attrib
208. ment This value is potentially returned from Provider getEdit Type to signify that the buffer returned is a complete document The container of the provider uses this information to determine if it needs to wrap it s edit page output to form a complete document This is done with something called an edit container Containers use edit containers to provide a container specific look and feel to otherwise heterogenous providers It allows the channel s edit page to look and feel according to the container that it exists within although the same channel might appear in two different containers that have very different look and feel 30 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Overview of the Provider API and Desktop Servlet See the Javadocs for more information on the methods in this interface PropertiesFilter The PropertiesFilter abstract class when extended can describe a specific filter criteria To implement a specific filter one must minimally implement the getCondition and match methods in the PropertiesFilter abstract class e The getCondition method must return the condition on which the PropertiesFilter should operate e The getValue method must return the value that corresponds to the given condition e The isRequired method can be implemented to specify whether you want this to be a required filter or not A conditional property lookup involves one or more property filters If
209. mmands create a SOIF like the following example document http varrius doc htm title 22 All About Style Sheets author 12 Robin Styles description 38 All you need to know about style sheets Each SOIF object contains attribute value pairs which are each represented as SOIFAVPair objects Using the SOIF API you can get and set values of attributes you can create and delete attribute value pairs you can change the values of attributes and you can add values to existing attributes Some attributes can have multiple values Multiple SOIF objects can be grouped together into SOIF streams which are represented by SOIFSt ream objects A SOIFSt ream object provides functionality for handling a stream of SOIF objects For example you can use the stream to filter attributes and print the desired attributes for every SOIF in the stream Thus the relevant data structures when using the SOIF API include e soIir aSOIF object e SOIFAVPair an attribute value pair e SOIFStream a stream of SOIF objects An Introductory Example You will find several examples of the use of the SOIF API in portal server install root SUNWps sdk rdm examples This section discusses an example that is similar to but not necessarily identical to examplel c It shows how to iterate through a SOIF stream and print the URL and number of attributes of each SOIF in the stream Chapter 7 Using the SOIF API to Work with SOIF Objects 18
210. n ean isEditable throws ProviderException ean isPresentable ean isPresentable HttpServletRequest reg tTitle throws ProviderException turn HelloWorld Channel tName tDescription throws ProviderException turn This is a sample HelloWorld channel L getHelp javax servlet http HttpServletRequest req throws long getRefreshTime throws ProviderException int getWidth throws ProviderException Chapter 3 Extending the Base Providers 67 Implementing the Provider Interface 2 Compile the class and put it in the user defined class directory The default directory for the class file is etc opt SUNWps desktop classes To compile the HelloWorldProviderP java file type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar HelloWorldProviderP java 3 Define the new provider and channel definition in a temporary XML file The sample HelloWorldProvider provider and channel definitions are in the HelloProviderP xml see Code Example 3 2 and HelloChannelP xml see Code Example 3 3 files Code Example 3 2 HelloProviderP xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name HelloWorldProviderP class custom HelloWorldProviderP gt lt Properties gt
211. n amadmin w password d distinguishedname provider xml if an existing display profile document was directly edited where provider xm1 contains the display profile XML fragment for the provider See Sun ONE Portal Server 6 2 Administrator s Guide for more information on the dpadmin command and on administering Sun ONE Portal Server software display profile Installing the Provider This section provides information on e Installing a provider into a portal server instance o Manually without using the par utility o Transporting using the par utility e Provider Class Loader Installing a provider This section includes instructions for installing the provider using the par utility and manually Installing Manually To install the provider manually 1 Compile the provider class file and copy the file to the provider class base directory which by default is etc opt SUNWps desktop classes Or copy the file to the location specified in the etc opt SUNWps desktop desktopconfig properties file 2 Copy the resource bundle files if any to etc opt SUNWps desktop classes directory 3 Develop the JSPs and templates for the provider and copy the files to the template root directory for the provider which by default is etc opt SUNWps deskt op desktoptype providerName Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Overview of Implementing a Custom Provider 4 Develop and upload the display profile XML fra
212. n information Portlet Application Extension Definition This is defined using the portlet app extension element The portlet app extension element is the root of the deployment extension descriptor for a portlet application This is a required element if the sun port let xml file is included in your WAR file 180 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Files Used by Portlets Permission to Save Preferences In Render Method This is defined using the save preferences in render permission element The value for this element indicates whether or not the portlet application allows preferences value to be saved in the render method A value of 1 means it is allowed and a value of 0 means it is not allowed By default the value is 0 Portlet Definition This is defined using the port let element The portlet element contains the declarative data of a portlet Each portlet element must contain the portlet name element and zero or more deployment extension elements The portlet name element contains the portlet name and the deployment extension element contains zero or more extension element elements In this release there is only one extension element defined which is the session enabled element The session enabled element indicates whether or not a portlet uses session A value of 1 means the portlet uses session a value of 0 means the portlet does not use a session The default value of the session enabled
213. n port 80 the value would be http www yourcompany com 80 portal search Chapter 10 Using Java to Access the Search Engine Database 243 Using Java To Access the Search Server Database 244 String ssoToken An Sun ONE Identity Server software single sign on token used when doing secure searches There is also a simpler convenience constructor with the following syntax public Search String scope String RDMServer When this constructor is used the following values are used for the unspecified arguments viewAttributes null Return all attributes viewOrder null Use the server default sort order sorted by relevance firsthit 1 Start hits at hit number 1 viewhits 10 Return 10 hits only query language search Search for documents using the normal query language database null Search the server s default database ssoToken null Use anonymous search Executing A Query and Getting the Results You submit a query by calling the doQuery method public void doQuery The results from Search doQuery can be obtained as a SOIF stream using Search getResultStream The next search will replace the previous result stream reference so you must process the results or save a reference to the result stream after each query There are also methods for checking the number of results public SOIFInputStream getResultStream The function get Result Stream returns a SOIFInput Stream which is used to re
214. n the Sun ONE Portal Server software is used to load the classes Each channel and each container is loaded with a separate provider class loader object This enables on the fly reloading of classes when they change In order to upload a new version of a custom provider class without restarting the server e Ifthe original class existed in a JAR file rebuild the JAR with the new version of the class file and copy the JAR into the provider class base directory Or Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of Implementing a Custom Provider e Just copy the new version of the class as a file into the provider class base directory In order to reload a property file that is being used by a custom provider with a modified property inside a resource bundle in the provider class base directory without restarting the server change the last modified time on the custom provider class If the custom provider class exists e InaJAR file use the command touch JAR file name jar e Asa file use the command touch class file name The presence of the provider class loader has an impact on the design of a multi channel application in the Desktop When an object reference is cast from one type to another not only does the class of the variable need to match the class of the object the two associated class loaders have to be the same too This constraint can show up when objects are being passed between different channels
215. n the reload and logout requests shown in Figure 2 3 on page 35 and Figure 2 4 on page 35 respectively the cached container provider context is returned The container provider context maintains a list of its contained provider objects and their cached content locally Contained providers are created and initialized once per session and their content is cached in the provider context object Subsequent requests access the cached provider objects that live inside the provider context object The contentChanged and allcontentChanged methods signify that either the content for one channel or all channels has changed respectively This is used to remove all the cached content for the channels as well as to clear the cached provider objects When the requested action is logout as shown in Figure 2 4 on page 35 the DesktopServlet will redirect the request to the logout URL and the session will be destroyed At this point the provider context object is removed from the cached list and ready for garbage collection Also if the session expires or timesout the provider context object is removed from the cached list Figure 2 2 on page 33 and Figure 2 4 on page 35 shows a sample of how the content and logout actions are processed For detailed information on how the DesktopServlet and the back end providers handle each action including content and logout see The DesktopServlet Figure 2 2 The Provider Life Cycle Initial Request for A
216. names Returns 0 zero if they are equal or non zero if they are different If neither of the attributes is multi valued then use above routine SOIF_AttributeCompare If one or both of the attributes are multi value use the base name of the multi valued attribute for comparison The base name of a multi valued attribute is the name portion before For example the base name of classification 3 is classification SOIF MVAttributeParse NSAPI PUBLIC int SOIF MAttributeParse char a Returns the multi valued number of the given attribute and strips the attribute string of its NNN indicator otherwise returns zero in the case of a normal attribute name For example classification 3 returns the number 3 SOIF IsMVAttribute NSAPI PUBLIC char SOIF IsMVAttribute const char a 194 Sun ONE Portal Server 6 2 Developer s Guide December 2003 SOIF API Returns NULL if the given attribute is not a multi valued attribute otherwise returns a pointer to where the multi valued number occurs in the attribute string For example for the multi valued attribute classification 3 it will return the pointer to 3 SOIF_InsertMV NSAPI_PUBLIC int SOIF_InsertMV SOIF s char a int slot char v int vsz int useval Inserts a new value v at index slot for the given attribute a in non multivalue form If set the useval flag tells the function to use the given value buffer rather than creating its own copy For example SOIF_Ins
217. nclude HttpSession setMaxInactiveInterval or PortletSession setMaxInactiveInterval in your code then ensure that the following entries appear in the sun web xml file The value associated with the reapIntervalSeconds should be smaller than the inactive time you have set in the code lt sun web app gt lt session config gt lt session manager gt lt manager properties gt lt property name reapIntervalSeconds value 5 gt lt manager properties gt lt session manager gt lt session config gt lt sun web app gt For further information about how to configure the sun web xml file please see Sun ONE Application Server 7 Developer s Guide to Web Applications sun portlet xml Besides the port let xml file the Sun ONE Portal Server software includes a sun portlet xml file The sun portlet xml file includes some configuration data which is needed by the portlet container implementation but is not included in JSR 168 v1 0 release s deployment descriptor This file is packaged and deployed at the same location as the portlet xm1 file in the WAR file This file must be included in the portlet application WAR file if you wish to make use of the extensions This file includes two extensions to e Support saving of preference in render e Declare a portlet as session enabled because the granularity of this setting is per portlet and not per application Chapter6 Developing and Deploying Portlets 179 Files Us
218. nde es 25 The Provider API 2 verwenden eee eater ede eb an das desde de Re ee OS 27 The DesktopServlek sciita o 36 Overview of Implementing a Custom Provider ici aa 51 Defining Specific Requirements and Functionality a veur venen eon i 52 Developing the Provider Class File cesis soeurs DUO KANINA aan ennen bl dee re 57 Creating XML Fragments for Display Profile gt BABAE IND ii 60 Installing the Provider illa desiderat tonen 62 Chapter 3 Extending the Base Providers cece eee eee eee 65 lnviplemienting the Provider INA iii erva dade tel bes ia dee ieee 65 Extending the ProviderAdapter Class ian a 69 Extending the ProfileProviderAdapter Class anr enerverende bh KAL bedtime 72 Example AA 73 8b 02 1na 2 AA ile eh 79 Extending the Properties Fiker Clase in Naa ANDONG KAYE NANA Mla NAAN ens GO oes 89 Chapter 4 Using Leaf Providers saai senen mensne NAE KAR eee eee 93 MatroductiOn aan arn EE PDE AEN deed pee Sees EA e 93 TSBPFOVBE gt KA ARA ile RESA eee LANA NET DARA ee wale oes 94 Invoking a JSP c c eas eae ee 94 Extending the JSPPrOvidet a a KAG bend ewan DID NAL hak tie leas 95 Deploying JSP Tags and Tag Libraries aas itsi GN ave itin i a had 102 URLSEFAperProvider 2 20002 NAAN REA pe Rea ee 103 scraping Content trom the URL i061 2a feces se ie te vee iiee at 103 Extending the URLScrapsrProvidet ili eci 104 XMLPEOWiIder i ERE ana 108 Retrieving XML Content iii ete
219. nimizable gt lt Collection name channelsRow advanced true gt lt Collection name channelsColumn advanced true gt lt Collection name channelsIsMovable gt lt Collection name channelsIsDetachable gt lt Collection name channelsIsRemovable gt lt Collection name borderlessChannels gt lt Properties gt lt Provider gt Code Example 5 22 CustomTabCChannel xm1 File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name CustomTabContainer provider CustomTabContainerProvider merge replace lock false advanced false gt lt Properties advanced false merge fuse lock false name _properties propagate true gt lt String name title value JSP Tab Container Channel advanced false merge replace lock false propagate true gt lt String name description value This is a test for tab containers advanced false merge replace lock false propagate true gt lt String name contentPage value tab jsp advanced false merge replace lock false propagate true gt lt String name editPage value tabedit jsp advanced false merge replace lock false propagate true gt lt String name startTab value MyFrontPageTabPanelContainer advanced false merge replace lock false propagate true gt lt Integer name maxTabs value 4 advanced f
220. nnel s name from request parameters and calls get Edit on that channel and wraps the channel s content before returning it to the servlet See the legacy edit action for EDIT_SUBSET in page 41 for more information Figure 2 7 DesktopServlet edit Action Start process y Determine Provider from Parameter Is Provider Null Get Default Channel Name Get Channel Page 2 of the flowchart Chapter 2 Using Provider API PAPI 45 Overview of the Provider API and Desktop Servlet Page 2 of the flowchart Is Edit Container Editable Desktop Exception No Call Container Channel s getEdit method Y EDIT_SUBSET Get Leaf Channel s name from request parameter Legacy Edit Action Is Leaf channel Editable Yes Get Leaf channel s Edit type Call Leaf Channel s getEdit method Y 7 ys Display Edit Page Call Leaf Channel s getEdit method y Container s Edit Container wraps around the channel s edit content y Display Edit Page EDIT_SUBSET 46 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Figure 2 8 Overview of the Provider API and Desktop Servlet Action process The process action allows the named channel to process URL parameters and form
221. nt text within a code example that you should type For example you might see something like this portal server install root SUNWps bin dpadmin add p parent u amadmin dn w password d node dp locale xml Italicized Font Italicized font is used to represent text that you enter using information that is unique to your installation for example variables It is used for server paths and names and account IDs About This Guide 9 Command Line Prompts Command line prompts for example for a C Shell or for a Korn or Bourne shell are not displayed in the examples Depending on which operating system environment you are using you will see a variety of different command line prompts However you should enter the command as it appears in the document unless specifically noted otherwise Where to Find Related Information In addition to this guide SunTM ONE Portal Server comes with supplementary information for administrators as well as documentation for developers Use the following URL to see all the Sun ONE Portal Server software documentation http docs sun com prod slportalsrv Use this book in conjunction with the Javadocs at http hostname port URI javadocs Listed below are the additional documents that are available Sun ONE Portal Server 6 2 Deployment Guide Sun ONE Portal Server 6 2 Installation Guide Sun ONE Portal Server 6 2 Migration Guide Sun ONE Portal Server 6 2 Administrator s Guide Sun ONE Por
222. ntInitStr SOIFStream IsParsing define SOIFStream IsParsing s Returns 1 true if the SOIF has been setup in a stream by SOIF_ParseInitFile Or SOIF ParselnitStr Filtering SOIF Objects To support targeted parsing and printing you can use the attribute filtering mechanisms in the SOIF stream For each SOIF stream object you can associate a list of allowed attributes When printing a SOIF stream only the attributes that match the allowed attributes will be printed When parsing a SOIF stream only the attributes that match the allowed attributes will be parsed SOIFStream IsAllowed and SOIFStream_SetAllowed allow attributes while SOIFStream_IsDenied and SOIFStream_SetDenied deny attributes You can allow or deny an attribute but not both SOIFStream IsAllowed NSAPI PUBLIC boolean t SOIFStream_IsAllowed SOIFStream ss char attribute Indicates that the given attribute is allowed that is it can be printed or parsed SOIFStream_SetAllowed NSAPI PUBLIC int SOIFStream_SetAllowed SOIFStream ss char allowed_attrs Sets all the attributes in the allowed_attrs array to allowed SOIFStream_SetDenied NSAPI_PUBLIC int SOIFStream_SetDenied SOIFStream ss char denied attrs Sets all the attributes in the allowed attrs array to be denied that is they cannot be parsed or printed SOIFStream_GetAllowed NSAPI_PUBLIC char SOIFStream GetAllowed SOIFStream ss Returns an array of all the attribut
223. ntainerProviderAdapter b Adda FULL_TOP channel to the container provider before testing the container provider For example for the CustomSingleContainerProvider add the Search channel via the administration console 7 Access the CustomSingleContainerProvider from your browser To access log in to the Desktop and type the following URL in your browser http hostname port portal dt provider CustomSingleContainer JSPTableContainerProvider A table container aggregates the content of other channels into rows and columns It can be thought of as a bucket for the content of other channels The JSPTableContainerProvider class extends JSPContainerProviderAdapter The table container facilitates the aggregation of multiple channels into a single display That is the JSPTableContainerProvider aggregates channels into HTML rows and columns Using the JSPTableContainerProvider A JSPTableContainerProvider provides methods that allow the associated JSP files to use these methods and generate a view that arranges the contained channels to be displayed in a HTML table By the nature of the container provider the JSPTableContainer has a list of available channels and a list of selected channels Available channels are the channels that are available to be activated in the Desktop and selected channels are the channels that are displayed in the Desktop Selected and available channels list is defined in the table container channel defin
224. oWorldPortlet lt portlet name gt lt portlet class gt custom HelloWorldPortlet lt portlet class gt lt expiration cache gt 0 lt expiration cache gt lt supports gt lt mime type gt text html lt mime type gt lt portlet mode gt VIEW lt portlet mode gt lt supports gt lt portlet info gt lt title gt HelloWorldPortlet lt title gt lt portlet info gt lt portlet gt lt portlet app gt 2 Create the web xml file A web application also requires a web xml file If you have servlets for your portlet web application then servlet definition can be incorporated in the web xm1 file Code Example 6 6 contains the web xml file for the sample HelloWorldPortlet 176 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Converting Providers to Portlets Code Example 6 6 web xml File for HelloWorldPortlet lt xml version 1 0 encoding ISO 8859 1 gt lt DOCTYPE web app PUBLIC Sun Microsystems Inc DTD Web Application 2 3 EN http java sun com dtd web app_2_3 dtd gt lt web app gt lt display name gt Portlet Examples lt display name gt lt web app gt 3 Package everything into a WAR file For the sample portlets create an examples directory where all the files of the WAR will be placed Then within the examples directory create the WEB INF directory All the portlet files will be placed into the WEB INF directory For example your directory hierarchy may look like this
225. obal shared between multiple users This interface does not define what information falls into each of these categories this is left up to the implementation Provider developers can obtain a handle to a ProviderContext object by extending ProviderAdapter and then calling ProviderAdapter getProviderContext The ProviderContext forms the layer between the services used by the provider and the provider implementation thus isolating the provider code from specific service interfaces and implementations It defines the service interface for the Desktop and allows different implementation to access the actual data The following are some of the methods in the ProviderContext Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of the Provider API and Desktop Servlet e Service data functions pertaining to the Desktop service getDeskt opURL getLocaleString getLocale getDesktopType get LogoutURL getStringAttribute setStringAttribute getDefaultChannelName getLoginURL getRoles e Servlet data functions pertaining to the servlet getRequestServer getServletConfig e Client type data functions pertaining to the client device type getClientTypeProperty getDefaultClientType getClientType getCharset getClientPath getContentType getClientTypeProperties e Session o Data functions pertaining to the user s session get setSessionProp
226. ollection gt lt Collection name SearchTabPanelContainer advanced false merge fuse lock false propagate true gt lt String name title value Search advanced false merge replace lock false propagate true gt Chapter 5 Using the Container Providers 153 JSPContainerProviderAdapter Code Example 5 22 CustomTabCChannel xml File Continued lt String name desc value Search Tab advanced false merge replace lock false propagate true gt lt Boolean name removable value true advanced false merge replace lock false propagate true gt lt Boolean name renamable value true advanced false merge replace lock false propagate true gt lt Boolean name predefined value true advanced false merge replace lock false propagate true gt lt Collection gt lt Collection gt lt Properties gt lt Available advanced false merge fuse lock false gt lt Reference value MyFrontPageTabPanelContainer advanced false merge replace lock false propagate true gt lt Reference value SamplesTabPanelContainer advanced false merge replace lock false propagate true gt lt Reference value SearchTabPanelContainer advanced false merge replace lock false propagate true gt lt Available gt lt Selected advanced false merge fuse lock false gt lt Reference value MyFrontPageTabPanelContainer advanced false mer
227. ollowed by an alphanumeric character string for example cmdHook0 cmdHookAlpha cmdHook12a 4 Adda description string to the file and comment it so that it does not affect the execution of the script For example description My menu choice string Creating New Robot Application Functions Typically you might modify the behavior of a search engine robot filter by using the search engine administration interface or the predefined robot application functions RAFs NOTE For more information on the search engine administration interface and on the predefined robot application functions RAFs see the Sun ONE Portal Server 6 2 Administrator s Guide When you want to modify the behavior of the search engine robot filters in a way that is not accommodated by the standard filter functions you will need to create your own robot application functions RAFs Robot filters are defined in the file filter conf Filter definitions consist of filter directives which each specify a robot application function This section describes the following topics e Robot Plug in API Overview e The Robot Application Function Header Files e Writing Robot Application Functions e Compiling and Linking your Code e Loading Your Shared Object e Using your New Robot Application Functions Chapter 8 Search Engine Robot 209 Creating New Robot Application Functions Robot Plug in API Overview The robot plug in API is a set of functions and he
228. on Overview Figure 1 1 What Is a Portal A portal is a doorway or entry point to a set of resources that an enterprise wants to make available to the portal s users For some consumer portals the set of resources includes the entire World Wide Web For most enterprise portals the set of resources includes information applications and other resources that are specific to the relationship between the user and the enterprise The primary purpose of Sun ONE Portal Server software is to give end users a portal Desktop which provides access to resources and applications In addition a search engine infrastructure enables intranet content to be organized and accessed from the portal Desktop Desktop and Desktop Hierarchy The Desktop uses an aggregation of a variety of separate web applications channels within a common framework The common framework provides multiple levels and styles of aggregation presented to end users through a container metaphor In the Desktop leaf channels are the basic unit of content displaying a specific type of information To the end user a channel is a distinct unit of content in the Desktop usually but not always set off with a border and header row of icons that enables users to configure the channel to their preference A provider is a Java class responsible for converting the content in a file or the output of an application or service into the proper format for a channel The Desktop prov
229. op and deploy portlets 1 Develop the portlet class file 2 Create the portlet specific XML fragments and package it into a WAR file 3 Deploy the Portlet web application 167 Extending the GenericPortlet Abstract Class 4 Create and view the Portlets Extending the GenericPortlet Abstract Class This section includes instructions for extending the GenericPortlet abstract class It includes instructions to create a sample portlet named PrefPortlet In the view mode this portlet displays a salutation In the edit mode of PrefPortlet the user can change that salutation The modified salutation is saved into the preference to be used for subsequent requests to the portlet Develop the Class File Code Example 6 1 contains the class file for the sample PrefPortlet Code Example 6 1 PrefPortlet java File package examples import javax portlet GenericPortlet import javax portlet ActionRequest import javax portlet RenderRequest import javax portlet ActionResponse import javax portlet RenderResponse import javax portlet PortletException import javax portlet PortletURL import javax portlet PortletMode import javax portlet PortletPreferences import javax portlet WindowState import java io IOException import java io PrintWriter public class PrefPortlet extends GenericPortlet public void processAction ActionRequest request ActionResponse response throws PortletException process the salutat
230. operty for the channel getStringProperty java lang String key boolean localized and getStringProperty java lang String key java lang String def boolean localized which gets a localized string property for the channel If localized is true then this method will attempt to find a localized version of the map string named by the key The locale for the user who this object is executing is read from the ProviderContext object associated with this provider object getStringProperty String channel String name List pflist getStringProperty String channel String name String def List pflist getMapProperty String key List pflist getMapProperty String key Map def List pflist to support conditional properties Chapter 11 Localizing Sun ONE Portal Server 263 Localization Support in PAPI See the Javadocs for more information on these methods 264 Sun ONE Portal Server 6 2 Developer s Guide December 2003 A AsciiFormInputExpectedException 32 B BookmarkProvider 260 C Client type 29 ClientTypeFilters 29 cmdHook 207 208 ContainerProvider 115 116 117 118 119 ContainerProviderAdapter 115 117 119 ContainerProviderContext 116 117 118 119 D Desktop 16 APIs 17 exceptions 31 Desktop servlet 19 DesktopServlet 33 36 259 actions 37 content 38 Index edit 40 logout 51 process 47 Display profile 13 E EDIT_COMPLETE 30 79 EDIT_SUBSET 30 enumerator filter 203 206 G generator
231. optype_locale channelname clientPath desktoptype locale provider clientPath desktoptype locale channelname desktoptype locale provider desktoptype locale clientPath desktoptype locale desktoptype channelname clientPath desktoptype provider clientPath desktoptype channelname desktoptype provider desktoptype Chapter 2 Using Provider API PAPI 53 Overview of Implementing a Custom Provider 54 defaul defaul defaul defaul defaul defaul defaul defaul defaul defaul default t_locale channelname clientPath t locale provider clientPath t locale channelname t locale provider t locale t channelname clientPath t provider clientPath t channelname t provider t clientPath templateroot Where desktoptype is the value of the desktopType property locale is the user s locale channelname is the name of the channel provider is the provider name clientPath is an optional file path containing client specific templates templateroot is by default etc opt SUNWps desktop If there is no clientPath specified then the directory search order is as follows desktoptype locale channelname desktoptype locale provider desktoptype locale desktoptype channelname desktoptype provider desktoptype clientPath desktoptype default_locale channelname default_locale provider Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of
232. ored in portal server install root SUNWps web src WEB INF classes directory Note that you can change the file here but you must re deploy the portal web application for the changes to take effect Resource bundles that are needed by the custom providers should be copied into the provider class base directory see Provider Class File for more information Resource bundles should be placed as individual files and cannot exist inside the JAR file under the provider class base directory Resource bundles are given a base name that equals to the name of the display profile provider definition that they are associated with Typically this is the relative non fully qualified class name of the Java class file that implements the provider To get the name of the resource bundle in your custom provider call ProviderContext getProviderName This value can then be used as the baseName argument to ResourceBundle get Bundle If you are extending ProviderAdapter simply call getResourceBundle Developing the Provider Class File This section includes information on the requirements for developing a provider s class file Chapter 2 Using Provider API PAPI 57 Overview of Implementing a Custom Provider 58 Provider Class File Location The provider classes must be deployed in the provider class base directory specified in the file etc opt SUNWps desktop desktopconfig properties By default the provider class ba
233. ory and copy the files over to the newly created directory For the sample RouterContainerProvider type mkdir etc opt SUNWps desktop desktoptype ISPRouterContainer cp router jsp etc opt SUNWps deskt op desktoptype ISPRouterContainer cp routeredit jsp etc opt SUNWps desktop desktoptype JSPRouterContainer The RouterContainerProvider also requires header jsp to display the header on routeredit page and menubar jsp to display the menubar on the routeredit page Copy these files from etc opt SUNWps desktop default JSPSingleContainerProvider directory 162 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating a Custom ContainerProvider cp etc opt SUNWps desktop sampleportal JSPSingleContainerProvider header jsp etc opt SUNWps deskt op desktoptype JSPRouterContainer cp etc opt SUNWps desktop sampleportal JSPSingleContainerProvider menubar jsp etc opt SUNWps deskt op desktoptype JSPRouterContainer 7 Modify the header jsp file in etc opt SUNWps desktop sampleportal JSPTabContainer to add the text from tabheader jsp file as shown in Code Example 5 29 The HTML code to add a link to the edit page of the router container provider is shown in bold in the tabheader jsp see Code Example 5 29 file Add this HTML code to etc opt SUNWps desktop sampleportal JSPTabContainer header jsp and etc opt SUNWps desktop sampleportal JSPTableContainerProvider h eader jsp files
234. ourceBundle public int getEditType public int getWidth public boolean isEditable public boolean isPresentable public ProviderContext getProviderContext public void init PortletConfig config public void processAction ActionRequest request ActionResponse response public void render RenderRequest request RenderResponse resposne protected void doView RenderRequest request RenderResponse response protected void doEdit RenderRequest request RenderResponse response protected void doHelp RenderRequest request RenderResponse response public String getPortletName protected String getTitle RenderRequest request public java util ResourceBundle getResourceBundle java util Locale locale public PortletConfig getPortletConfig public PortletContext getPortletContext public String getlnitParameter java lang String name public java util Enumeration getInitParameterNames public void destroy Chapter 6 Developing and Deploying Portlets 173 Converting Providers to Portlets Sample Code Fragments for Provider to Portlet Conversion This section includes some sample code fragments for Provider to Portlet conversion Example 1 The ProviderContext getStringAttribute firstname maps to Map ui Map renderRequest getAttribute javax portlet userinfo String firstname String ui get firstname Example 2 The ProviderContext getSessionProperty setS
235. ovider can implement this interface Clients of the Provider interface call the methods in this interface to query information or to perform an action in the provider Such clients include but are not limited to the DesktopServlet and other channels container channels There are essentially two types of methods in this interface Methods that handle actions This includes get Content getEdit and processEdit methods Methods that describe how the provider should be treated by the containing entity This includes all methods that begin with is and get minus the get methods used for handling actions See the Javadocs for more information on the methods in this interface ProviderAdapter The ProviderAdapter class implements aspects of the Provider using the ProviderContext The ProviderAdapter class implements the ProviderWidths interface which defines the provider widths and ProviderEditTypes interface which defines the edit types making the constants defined in these interfaces available to classes that extend ProviderAdapter Developers who wish to implement a provider can extend this class or the ProfileProviderAdapter class for forward compatibility and convenient access to the ProviderContext interface See the Javadocs for more information on the methods in this class Chapter 2 Using Provider API PAPI 27 Overview of the Provider API and Desktop Servlet 28 ProfileProviderAdapter The ProfileProvid
236. ovider object Whenever a provider throws an exception that cannot be handled by the container provider the exception will propagate all the way up to the DesktopServlet and the DesktopServlet will display an error page For detailed information on how the DesktopServlet creates and validates a user session and creates and gets the provider context object see the The Provider Life Cycle The following sections only describe how the DesktopServlet handles the various actions DesktopServlet Actions The DesktopServlet understands several actions Every action has an associated channel or container name and actions are performed on the associated channel or container Actions are passed to the servlet via request parameters The associated channel name is also passed as a parameter For example to perform an action on a channel pass in the following parameters to the servlet DesktopServletURL act ion actionTypesprovider ChannelName Here e action indicates the type of action to take Action can be content edit process or logout e provider indicates the name of the provider to contact The provider argument is named that way for historical reasons the value of the provider argument is really a channel or container name If the provider parameter is absent or null in the request the servlet assumes it is equal to the value of the last request For the initial request if the provider parameter is absent then the defaultCh
237. oviderAdapter See chapters 3 4 and 5 for information on extending a provider base class and building block providers To develop a provider you must start by e Defining Specific Requirements and Functionality that includes defining o Application Specific Requirements o Presentation Method o Provider specific Properties e Developing the Provider Class File and considering o Using the PAPI o Extending the PAPI Chapter 2 Using Provider API PAPI 51 Overview of Implementing a Custom Provider e Creating XML Fragments for Display Profile e Installing the Provider Defining Specific Requirements and Functionality Before beginning to develop a provider determine the application specific requirements content source and properties of the provider Application Specific Requirements Determine the nature of the provider Will this provider be a building block provider or will this be a content provider The content providers are special purpose providers and the building block providers are general purpose providers For example the bookmark channel is special purpose where XMLProvider is general purpose That is the XMLProvider can be used in general to connect to an XML source and translate it via XSLT to some markup language Determine if the content made available via this provider will be e Preset for the user by the administrator thus making it unmodifiable by the end user This will determine the logistics of the
238. oviderWidths WIDTH_FULL_TOP return channel return String selectedChannels get 0 120 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 5 2 JSPContainerProviderAdapter Compile the class and put it in the provider class base directory The default directory for the class file is etc opt SUNWps desktop classes That is build the JAR and copy the JAR into the provider class base directory Or just copy the class as a file into the provider class base directory To compile the Cust omSingleContainerProvider java file enter javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root S UNWam lib servlet jar CustomSingleContainerProvider java Develop the display profile XML fragments for this provider The display profile fragment for the CustomSingleContainerProvider s provider is saved in CustomSCProvider xml file see Code Example 5 2 and the display profile fragment for the CustomSingleContainerProvider s channel is saved in CustomSCChannel xml file see Code Example 5 3 on page 122 CustomSCProvider xml File lt xml version 1 0 encoding ut f 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Provider name CustomSingleContainerProvider class custom CustomSingleContainerProvider gt lt Properties gt lt String name contentPag
239. p and type the following URL in your browser http hostname port portal dt provider CustomTabContainer 156 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating a Custom ContainerProvider Creating a Custom ContainerProvider This section includes detailed instructions for creating a sample RouterContainerProvider A RouterContainerProvider provides the interface for the user to select between a tab and table Desktop layout Use the instructions provided with the sample RouterContainerProvider for developing your custom ContainerProvider by extending any one of the container providers 1 Based on whether the container provider is template based or JSP based container provider create a new class which extends ContainerProviderAdapter or JSPContainerProviderAdapter The new custom container provider can directly extend the container classes For example public class CustomContainerProvider extends Implement the methods See Code Example 5 24 for the sample RouterContainerProvider java file Code Example 5 24 RouterContainerProvider java File package com sample providers containers router import java util List import java util ArrayList import java net URL import javax servlet http HttpServletRequest import javax servlet http HttpServletResponse import com sun portal providers containers jsp single JSPSingleContainerProvider import com sun portal providers Provi
240. page 18 is the Desktop servlet which routes client requests for content and processing and passes them on to the specific provider object The Desktop servlet processes the following actions e content Gets the named channel s main content e edit Gets the named channel s edit content e process Allows the named channel to process form data e logout Ends the user s session The action is performed on the channel for the content edit and process actions The following request parameter names are reserved by the portal Desktop action provider Chapter 1 Introduction to the APIs 19 Overview of the APIs last containerName targetprovider page error container selected editChannelName NOTE You cannot extend the Desktop servlet How Concepts in the Provider API Map to Sun ONE Identity Server Software The Provider API furnishes architectural separation from Sun ONE Identity Server software but the PAPI is implemented in terms of specific Sun ONE Identity Server software APIs within the Sun ONE Portal Server software framework Typically to create a provider you will need to access various software services for provider development For example this might include attribute property access session services and client based property retrieval In the PAPI these services are accessible through the Provider and ContainerProviderContext interfaces The implementation of these interfaces connects to softwa
241. pairs are stored as SOIFAVPair structures The important fields in a SOIFAVPair structure are the following char attribute Attribute string NO terminated char value primary value may be 0 terminated size_t vsize of bytes 8 bits for primary value char values Multiple values for multivalued attributes size_t vsizes the sizes for the values int nvalues number of values associated with attribute int last_slot last valid slot array may contain holes 192 Sun ONE Portal Server 6 2 Developer s Guide December 2003 SOIF API SOIFAVPair_Create NSAPI_PUBLIC SOIFAVPair SOIFAVPair Create char a char v int vsz Creates an AVPair structure with the given attribute a and value v The value v isa buffer of vsz bytes SOIFAVPair_Free NSAPI_PUBLIC void SOIFAVPair_Free SOIFAVPair avp Frees the memory used by the given soIFAVPair structure SOIF_Replace NSAPI_PUBLIC int SOIF_Replace SOIF s char att char val int valsz Replaces the value of an existing attribute att with a new value val of size valsz in the SOIF s SOIF_InsertSir define SOIF_InsertStr soif attribute value Inserts the given attribute with the given value into the soif SOIF_ReplaceSir define SOIF_ReplaceStr soif attribute value Replaces the existing value of the given attribute in the soif with the given value SOIF_Rename NSAPI_PUBLIC int SOIF_Rename SOIF s char old_attr char new_attr Renames the given attr
242. panTableContainerProvider b Add the following to tablecolumn jsp Code Example 5 12 Sample tablecolumn jsp File lt page import custom SpanTableContainerProvider gt lt page session false gt lt SpanTableContainerProvider tcp SpanTableContainerProvider pageContext getAttribute JSPProvider 5 gt lt dt obtainContainer container JSPProvider gt lt String columnName request getParameter columnName lt pageContext setAttribute columnName columnName gt lt if columnName equalsIgnoreCase right S gt lt TD WIDTH lt dttable getColumnWidth column columnName gt VALIGN TOP ROWSPAN lt tcp getRowSpan request gt gt lt else S gt lt TD WIDTH lt dttable getColumnWidth column columnName gt VALIGN TOP gt lt S gt Ss 136 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter c Add the following to tabletopbottom jsp Code Example 5 13 Sample tabletopbottom jsp lt jx if test ShasChannel gt lt TABLE WIDTH 100 BORDER 0 CELLPADDING 2 CELLSPACING 0 gt lt if request getParameter columnName equals bottom gt lt TR COLSPAN 2 gt lt else S gt lt TR gt lt gt lt TD WIDTH 100 VALIGN TOP gt lt jx forEach var channel items Schannels gt 8 Copy the WebContainer portal web apps WEB INF classes JSP
243. pe That is e Minor exceptions can be managed internally for example log a debug message Chapter 2 Using Provider API PAPI 31 Overview of the Provider API and Desktop Servlet 32 e Serious exceptions can be rethrown as an expected exception type Exceptions from providers are logged in var opt SUNWam debug desktop debug file Note that this file is created only if there is an error ProviderException The ProviderException is a generic superclass for all provider related exceptions AsciiFormInputExpectedException The AsciiFormInputExpectedException will be thrown from Provider processEdit method when something other than ASCII only encoded form input is sent to it InvalidEditFormDataException The InvalidEditFormDataException is thrown from the Provider processEdit method when there is an error in the data input by the user If thrown the Desktop will send back the same Edit page and will attach the exception s message as a parameter to the URL For example if the exception is throw new InvalidEditFormDataException Error Error the Desktop will redirect back to the same Edit page adding the error message to the URL error parameter error Error Error The edit page wrapper then looks for the error parameter in the URL and if present displays the message or the value of the error parameter at the top of the page in red UnknownEditTypeException The UnknownEditTypeException may
244. pecifier Template files are mostly markup text with embedded tags that specify substitutions to be performed at runtime The tags have the form The tags should not be modified during the translation process Each template file is encoded using Java Unicode encoding where non ASCII characters are represented with uxxxx notation Here the uxxxx is the hexidecimal representation of the Unicode value for the character This type of file can be created from a native file using the Java native2ascii program available in the Java Development Kit JDK 1 3 1 package that is shipped with the Sun ONE Portal Server JSPs JSP files end with the jsp suffix The encoding for each top level JSP file is specified using a header at the top of the file The header must look like the following lt page contentType text html charset encoding Ss where encoding is the desired encoding such as UTF 8 or EUC JP Note that this is only for top level JSP files JSPs that are statically included by other JSPs must use the encoding of the including JSP That is JSPs that are statically included by other JSPs using lt include file relativeURL 55 must use the encoding of the including JSP JSPs that are dynamically included using lt jsp include page relativeURL lt expression gt flush true gt must have their own page directive that contains the encoding 258 Sun ONE Portal Server 6 2 Developer s Guide D
245. per s Guide December 2003 Using Java To Add Entries to the Search Engine Database submit csid submit type submit operation submit view Add values for each of these attributes to the request header req insert submit csid x catalog nikki boots com 80 default reg insert submit type persistent reg insert submit operation merge reg insert submit view title author description Now we create the body part of the submit request We ll be saving a resource description for a document whose URL is http www sesta com jocelyn resdogs index htm whose title is Saving English Springer Spaniels whose author is Jocelyn Becker and whose description is English Springer Spaniels in need of homes SOIF data new SOIF DOCUMENT http www sesta com jocelyn resdogs index htm n data insert title Saving English Springer Spaniels data insert author Jocelyn Becker data insert description English Springer Spaniels in need of homes Now the request is saved to a file for input to rdmgr SOIFOutputStream sos new SOIFOutputStream filename sos write req sos write data sos close At this point soif_file should contain Chapter 10 Using Java to Access the Search Engine Database 253 Using Java To Add Entries to the Search Engine Database REQUEST submit csid 20 x catalog nikki boots
246. pes Description Example The location of a resource http home siroe com The access portion of the URL http ftp file The address portion of the URL www siroe com Numeric version of the host 198 95 249 6 The path portion of the URL index html Number of links from the starting point URL 5 206 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Robot Completion Scripts Data Filters the resource based on its data Data filtering is done once per resource after it is retrieved over the network Data that can be used for filtering includes e content type e content length e content encoding e content charset e last modified e expires Enumerate Enumerates the current resource in order to determine if it points to other resources to be examined Generate Generates a resource description RD for the resource and saves it for adding it to the search engine database Shutdown Performs any needed termination operations Occurs once in the life of the robot Robot Completion Scripts After the robot has finished with all the entries in the enumeration pool and has finished all outstanding processing you can specify additional programs to execute by enabling the cmdHook parameter The cmdHook is provided as a way for you to extend the shutdown phase of the robot For example you might want the robot to send email after it completes one run start another process analyze its own log files write a small report and
247. pilingand Linking four Code pA NAGA debet beh bak banh haarden a 222 Loading Your Shared OBR sc a nakaka nka okra totaan Rai ee il 222 Using your New Robot Application Functions userscore KULAM Pha nsa 223 Contents 5 Chapter 9 Using the RDM API to Access the Search Engine and Database in C 225 Whatisan RID ci oen St ke a Md oa cae Aes agate ag aria a 226 RDM Format Syntax roses en ia PNG 226 About the RDM ARI eerie oer meren brakken det E ve Bae Ae 228 Example of Submitting a Query renten neske genere u ver bedekt 229 Running ihe Example 2a Sieg de LNG DA dn ed ene de 231 API Reference verwendet RR deden bad dede 233 Finding the RDM Version nns sensoren a 234 Creating and Freeing RDM Structures a iii see werende vr be 234 NBA iti attend en EN e ek ide 234 RDMOQUGEY oaren treten edie e ene dd de kat a a ra 236 Other ROM Structures rina oi nea alt ed eel 237 Chapter 10 Using Java to Access the Search Engine Database 239 The search Engine Jaya SDK oren denten DER ned a 239 Running the Sample Applications lc cupido elen etende 240 To Install and Run the Search Demo Command Line Program ooo 240 To Install and Run the Search Demo Applet ctr deter 241 Using Java To Access the Search Server Database sooo eee 242 CHEAP SEREEN GA eene Elba dn ee iedeen 242 Executie A Query and Getting the Results os one eneen tenen eten 244 Using Java To Add Entries to the Search Engine Database sove 252 Chapter 11 Loc
248. port com sun portal providers context ContainerProviderContext import javax servlet http HttpServletRequest import java util List import java util ArrayList import java util Map import java util HashMap import java util Iterator public class CustomTCProvider extends JSPTableContainerProvider public int getLayout throws ProviderException int layout getIntegerProperty layout return layout public Map setupColumns HttpServletRequest req throws ProviderException int layout getLayout List leftList new ArrayList List centerList new ArrayList List rightList new ArrayList List fullTopList new ArrayList List fullBottomList new ArrayList if layout gt Layout LAYOUT_THIN_THICK amp amp layout lt Layout LAYOUT THIN THIN THIN return super setupColumns req else List selectedChannels getSelectedChannels for Iterator i selectedChannels iterator String providerName String i next Provider p null p getContainerProviderContext getProvider req getName providerName r r i hasNext 138 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 5 14 CustomTCProvider java File Continued JSPContainerProviderAdapter int width try width i p getWidth catch NumberFormatException e catch Throwable e add the channel to leftList centerList rightList
249. portal dt provider JSPTableContainer Example 2 This section provides the instructions for creating a custom provider by extending the ProfileProviderAdapter The process includes creating a sample provider that prints Hello World on the provider s channel The following sample HelloWorldProvider reads a string property from the user s display profile and allows the user to edit the string The sample HelloWorldProvider described here will also support EDIT_COMPLETE which means this provider is responsible for generating the complete edit form with header footer and handling of the form submit actions To accomplish this 1 Create the Java class which will generate the content for the channels backed by this provider For the sample HelloWorldProvider create the class file as shown in Code Example 3 13 Code Example 3 13 HelloWorldProviderPPA2 java File package custom helloworld import java util Hashtable import java util ResourceBundle import java net URL Chapter 3 Extending the Base Providers 79 Extending the ProfileProviderAdapter Class Code Example 3 13 8 HelloWorldProviderPPA2 java File Continued import import import import import import import public javax servlet http HttpServletRequest javax servlet http HttpServletResponse com sun portal providers ProfileProviderAdapter com sun portal providers ProviderException com sun portal providers contex
250. pter that implements the ContainerProvider interface The ContainerProvider includes interfaces to get setAvailableChannels and get setSelectedChannels See the Javadocs for more information ContainerProviderContext The ContainerProviderContext interface provides an environment for container provider execution More formally this class adds container channel functionality to the ProviderContext interface see Chapter 2 Using Provider API PAPI for more information That is where provider object can obtain access to a ProviderContext object container providers obtain access to a ContainerProviderContext object A ContainerProviderContext object has a superset of the functionality exposed in ProviderContext The additions are related to managing contained providers For example container channel functionality includes getting provider objects fetching content content caching adding clients creating channels and containers and getting and setting selected and available channels list The ContainerProviderContext is the object to get the container channel properties from the store at run time The ContainerProviderContext can also be used to getProvider on another channel or container and get Content on another channel or container ContainerProviderAdapter The ContainerProviderAdapter class extends ProfileProviderAdapter ContainerProviderAdapter can be used as the base class for any container provider except for th
251. r Se Header Se Header S Type RDMHeader RDMType Version RDMHeader stringvalue QueryLanguage RDMHeader stringvalue CSID RDMHeader stringvalue Header Se Header Se PI PUBLIC PI PUBLIC PI PUBLIC RDMHeader Parse SAPI PUBLIC Create _CreateRequest _CreateResponse ResponseInterpret RDMHeader stringvalue ErrorMessage RDMHeader stringvalue tErrorNumber RDMHeader stringvalue RDMHeader RDMHeader_Parse SOIFStream ss RDMHeader RDMHeader Create RDMType t RDMHeader RDMHeader CreateRequest RDMType char q1 CSID RDMHeader RDMHeader_CreateResponse RDMType char ri CSID RDMHeader Free NSAPI PUBLIC int RDMHeader Free RDMHeader r RDMHeader Merge NSAPI PUBLIC int RDMHeader Merge RDMHeader SOIF Merges data from a SOIF object into the RDMHeader object RDMQuery An RDMQuery represents the body of an RDM An RDMQuery structure has one public field soif which is a SOIF containing a collection of attribute value pairs The allowable attribute names of the attribute value pairs in the SOIF are scope required view attributes optional view hit optional view order optional 236 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Example of Submitting a Query e view template optional You can use the following macros to get and set the string values of these attri
252. r container fragment is shown in Code Example 4 17 Code Example 4 17 CustomXMLContainer xm1 File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name JSPTableContainer provider JSPTableContainerProvider gt lt Properties gt lt Collection name Personal Channels gt lt String value CustomXML gt lt Collection gt lt Collection name channelsRow gt lt String name CustomXML value 3 gt lt Collection gt lt Properties gt lt Available gt lt Reference value CustomXML gt lt Available gt lt Selected gt lt Reference value CustomXML gt lt Selected gt lt Channels gt lt Channels gt lt Container gt b Usethe dpadmin modify sub command to add the channel to a container If you do not specify a parent object with the p option the channel is added at the root level portal server install root SUNWps bin dpadmin modify m u dn_amadmin w password d distinguishedname CustomXMLContainer xml 6 Change directories to etc opt SUNWps desktop classes and copy the properties file for the provider into this directory For example for the CustomXML Provider 112 Sun ONE Portal Server 6 2 Developer s Guide December 2003 XMLProvider a Change directories to WebContainer portal web apps WEB INF classes b Type cp XMLProvider properties etc opt SUNWps desktop classes
253. r install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname RCChannel xml Develop the templates or JSP files for the ContainerProvider The sample RouterContainerProvider requires the following JSP files o router jsp see Code Example 5 27 on page 160 This file includes the logic for displaying the tab or the table Desktop based on the user s selcetion o routeredit jsp Code Example 5 28 on page 160 This file has the logic for displaying the form where the user can select a tab or table Desktop Sample router jsp File lt router jsp lt Ss gt lt 5 page import com sample providers containers router RouterContainerProvider gt RouterContainerProvider rcp RouterContainerProvider pageContext getAttribute JSPProvider lt rcp getContainerProviderContext getContent request response null rcp getSelectedChannel gt Code Example 5 28 Sample routeredit jsp File So lt routeredit jsp 35 lt page import com sample providers containers router RouterContainerProvider com sun portal providers Provider java util List java util Map java util ArrayList lt 5 page session false 55 160 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating a Custom ContainerProvider Code Example 5 28 Sample routeredit jsp File Continued lt taglib uri tld jx tld prefix jx gt lt taglib u
254. rContainerProvider channel XML fragment in the RCChannel xml file is shown in Code Example 5 26 Code Example 5 26 RCChannel xml File lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt lt Container name JSPRouterContainer provider RouterContainerProvider advanced true gt lt Properties gt lt String name title value Router Container gt lt String name description value Router container gt lt Boolean name isEditable value true advanced true gt lt String name editType value edit_complete advanced true gt lt String name contentPage value router jsp gt lt Properties gt lt Available gt lt Reference value JSPTabContainer gt lt Reference value JSPTableContainer gt lt Available gt lt Selected gt lt Reference value JSPTabContainer gt lt Selected gt lt Channels gt lt Channels gt lt Container gt Chapter 5 Using the Container Providers 159 Creating a Custom ContainerProvider Code Example 5 27 Use the dpadmin command to upload the display profile fragments for this provider For RouterContainerProvider use the dpadmin command to upload the RCProvider xml file and RCChannel xm file fragments in to the display profile That is type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname RCProvider xml portal serve
255. rch and display the results The SimpleSearch constructor takes the location of the search server as an argument In this way a single SimpleSearch object can be used repeatedly to run searches against the remote search server The SimpleSearch setSOIFfile String filename method is used by the main program to direct search results to a file when running in command line mode Code Example 10 2 SimpleSearch Class Performs a simple search and displays its results class SimpleSearch String RDMServer String SOIFOutputFile xx x SimpleSearch constructor x param rdm the rdm search server eg http portal siroe com 2222 portal search Kij public SimpleSearch String rdm System out println Sun ONE Search Java Demo RDMServer rdm xx x param filename a file to dump raw SOIF results into only x use if running from the comand line or an applet with file x system access kf public void setSOIFfile String filename SOIFOutputFile filename Execute a search public void doSearch String scope throws IOException see Code Example 10 3 Before submitting the search SimpleSearch needs to create a Search object The constructor for the Search class takes several arguments as discussed previously Chapter 10 Using Java to Access the Search Engine Database 247 Using Java To Access the Search Server Database Code Example 10 3 doSearch Class Execute a sear
256. rd output as plain text Import the Necessary Classes In your favorite editor or Java development environment view the search SDK file SearchDemo java This demo runs as a stand alone application or as an applet The soif package is provided as part of the Search Server Java SDK while java applet java awt and java io are standard Java packages package com sun portal search demo import com sun portal search soif import java applet Applet import java awt import java io Define the SearchDemo Class The class SearchDemo is an applet so it extends the class Applet SearchDemo defines init and main methods which allow it to run as an applet or as a stand alone command line program Chapter 10 Using Java to Access the Search Engine Database 245 Using Java To Access the Search Server Database Code Example 10 1 SearchDemo example for those who want to create their own java interface This example demonstrates search only Browse determining the schema of the search server and obtaining the taxonomy of the search server will be demonstrated in other examples Pak Applet application for simple query interface Can be used as an public class SearchDemo extends Applet Run as an applet public void init String rdm getParameter RDMServer SimpleSearch ss new SimpleSearch rdm SearchPanel sp new SearchPanel ss setLayout new FlowLayout FlowLayout CENTER
257. re services in an implementation independent manner The actual implementation of the software services for the most part is located in another layer the context interfaces simply pull these features together into a common interface to simplify provider development Search APIs The Sun ONE Portal Server software Search service provides e CAPI for customizing the way the robot crawls URLs and generates resource descriptions e Java APIs for searching the database for submitting data and for manipulating SOIF objects such as RDs RDM and SOIF APIs C versions of these APIs are also available e Search provider taglib and helper beans to write customized search JSPs 20 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of the APIs Search Robot The robot examines a set of selected URLs and searches for documents For each found document the robot then creates a resource description RD of the document using a predefined schema The schema defines what pieces of information about the document are put in the RD For example the RD could contain a date the author the title the URL and an abstract about the document These RDs can be grouped together or classified according to a given hierarchical taxonomy You can configure the robot through the Sun ONE Identity Server software administration console The robot has many customizeable parameters including the following configuration parameters e
258. reexport to countries subject to U S embargo or to entities identified on U S export exclusion lists including but not limited to the denied persons and specially designated nationals lists is strictly prohibited DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS REPRESENTATIONS AND WARRANTIES INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT ARE DISCLAIMED EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID Copyright 2003 Sun Microsystems Inc 4150 Network Circle Santa Clara California 95054 Etats Unis Tous droits r serv s Sun Microsystems Inc d tient les droits de propri t intellectuels relatifs la technologie incorpor e dans le produit qui est d crit dans ce document En particulier et ce sans limitation ces droits de propri t intellectuelle peuvent inclure un ou plus des brevets am ricains list s a l adresse http www sun com patents et un ou les brevets suppl mentaires ou les applications de brevet en attente aux Etats Unis et dans les autres pays CE PRODUIT CONTIENT DES INFORMATIONS CONFIDENTIELLES ET DES SECRETS COMMERCIAUX DE SUN MICROSYSTEMS INC SON UTILISATION SA DIVULGATION ET SA REPRODUCTION SONT INTERDITES SANS L AUTORISATION EXPRESSE ECRITE ET PREALABLE DE SUN MICROSYSTEMS INC Cette distribution peut comprendre des composants d velopp s par des tierces parties Des parties de ce produ
259. request HttpServletResponse response throws ProviderException return new StringBuffer Hello World public java lang StringBuffer getContent java util Map m throws ProviderException return new StringBuffer Hello world public StringBuffer getEdit HttpServletRequest request HttpServletResponse response throws ProviderException Get the edit page and return it is as a StringBuffer return null public java lang StringBuffer getEdit java util Map m throws ProviderException return null public int getEditType throws UnknownEditTypeException return 0 66 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 3 1 Implementing the Provider Interface HelloWorldProviderP java File Continued re public re public re public re public re public re public re public re re public re public re ProviderException turn null turn null bool turn false bool turn true bool turn true java lang S java lang S java lang S public java net UR ProviderException turn null turn 0 turn 0 tring ge tring ge turn HelloWorld tring ge public URL processEdit HttpServletRequest request HttpServletResponse response throws java net URL processEdit java util Map m throws ProviderExceptio
260. ri tld desktop tld prefix dt gt lt taglib uri tld desktopProviderContext tld prefix dtpc gt lt taglib uri tld desktopContainerProviderContext tld prefix dtcpc gt lt taglib uri tld desktopTheme tld prefix dttheme 55 A oe RouterContainerProvider rcp RouterContainerProvider pageContext getAttribute JSPProvider String selectedChannel rcp getSelectedChannel pageContext setAttribute rep rcp gt ag lt dt obtainContainer container rcp gt lt dtpc providerContext gt lt dtpc getStringProperty key fontFacel id fontFace gt lt jx declare id fontFace type java lang String gt lt String fontFacel String pageContext getAttribute fontFacel PageContext REQUEST_SCOPE S gt lt jsp include page header jsp flush true gt lt form action dt name routeredit_form method POST enctype application x www form urlencoded gt lt input type HIDDEN name action size 1 value process gt lt input type HIDDEN name provider size 1 value JSPRouterContainer gt lt dt getAvailableChannels id availableChannel gt lt CENTER gt lt table border 0 cellspacing 1 cellpadding 0 width 75 align center gt lt tr gt lt td bgcolor 666699 gt lt b gt lt font face lt fontFace S gt color FFFFFF size 1 gt Please select a desktop for your front page lt b gt lt font gt lt td gt lt tr gt lt tr gt lt td gt amp
261. ring tring tring lt Integer lt Integer lt Integer lt Integer lt Integer lt Integer lt Collection name categories gt lt xml version 1 0 encoding utf 8 standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt Provider name SpanTableContainerProvider class custom SpanTableContainerProvider gt lt Properties gt lt String name contentPage value toptable jsp gt lt Integer name timeout value 1800 gt lt Integer name layout value 1 gt lt Boolean name showExceptions value false gt lt Boolean name parallelChannelsInit value false gt name title value Table Container Provider gt name description value DESCRIPTION gt name refreshTime value 0 gt name width value thin gt name fontFacel value Sans serif gt name Desktop fontFacel value Sans serif gt name productName value Sun ONE Portal Server gt name preset ThemeChannel value JSPPresetThemeContainer gt name customThemeChannel value JSPCustomThemeContainer gt lt Boolean name refreshParentContainerOnly value false advanced true gt lt Boolean name isEditable value true gt name editType value edit_complete gt name editContainerName value JSPEditChannel gt name thin_popup_height value 200 gt name thin_popup_width value 500 gt name thick_popup_height value 300 gt name thick_popup_width value 600
262. rom a SOIF object into an existing RDMX structure RDMHeader An RDMHeader represents the header of an RDM An RDMHeader structure has one public field soif which is a SOIF containing a collection of attribute value pairs The allowable attribute names of the attribute value pairs in the SOIF are e rdm version required This is set automatically if you use RDMHeader_CreateRequest Or RDMHeader_CreateResponse to create the RDMHeader e rdm type required e catalog service id recommended This indicates which search engine instance to send the RDM request to e rdm query language required for a request For communicating with the search engine you can specify search Response RDMs also have several attributes and you can find them in rdm h The following statements create an RDMHeader whose RDMType is RDM_RD_REQ and whose query language is search This RDM will be sent to the search engine instance search1 of the search engine at http budgie siroe com 6714 CSID csid CSID_Parse x catalog budgie siroe com 6714 searchl RDMHeader myheader RDMHeader_CreateRequest RDM_RD_REQ search csid 234 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Example of Submitting a Query The following table describes the allowable values for RDM Type in the first left column and a includes a description of the corresponding RDM Type value in the second right column RD RD
263. s file if it is unable to find the specified properties file it will look for providerName properties file and load it Profile Properties The display profile can be modified by using XML files that are input to the dpadmin command The encoding for display profile XML file is specified using the following XML header at the top of the file lt xml version 1 0 encoding encoding gt where encoding is whatever encoding is suitable for the content of the file Typically the encoding is UTF 8 but it can also be other native encodings such as SJIS or ISO 8859 1 The DesktopServlet always converts characters internally to Unicode and stores them in the directory using UTF 8 Every XML fragment must include a XML header and a doctype declaration as shown below lt xml version 1 0 encoding encoding standalone no gt lt DOCTYPE DisplayProfile SYSTEM jar resources psdp dtd gt The display profile contains text strings for items such as channel titles and descriptions These strings can be localized For example the user information channel is defined by the following element in the display profile lt Channel name UserInfo provider UserInfoProvider gt lt Properties gt lt String name refreshTime value 60 advanced true gt lt String name title value User Information gt Chapter 11 Localizing Sun ONE Portal Server 261 Display Profile Properties lt String name des
264. s and channels in Sun ONE Portal Server software The display profile defines the following three items e Providers e Channels e Container channels Chapter 1 Introduction to the APIs 13 Overview A provider s display profile document acts as a template for creating channels They define the set of properties that channels based on this provider will make use of as well as providing default values for these properties where appropriate Channels and container channels must reference a provider and will use their default property values unless the property is redefined in the channel The display profile used to generate a user s Desktop is constructed by merging together multiple display profile documents The display profile is a series of XML documents for storing channel properties The display profile documents are stored in their entirety as a single attribute in the Sun ONE Identity Server software services layer That is the display profile documents are an LDAP attribute residing in an instance of the Sun ONE Directory Server software See the Sun ONE Portal Server 6 2 Administrator s Guide and Sun ONE Portal Server 6 2 Desktop Customization Guide for a complete discussion of the display profile and its administrative tasks Search Engine The Sun ONE Portal Server software provides a search engine service that includes basic and advanced search and browse channels for the Desktop The search engine uses a robot to
265. s logo the SunTone Certified logo and the Sun ONE logo are trademarks or registered trademarks of Sun Microsystems Inc in the U S and other countries All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International Inc in the U S and other countries Products bearing SPARC trademarks are based upon architecture developed by Sun Microsystems Inc Legato and the Legato logo are registered trademarks and Legato NetWorker are trademarks or registered trademarks of Legato Systems Inc The Netscape Communications Corp logo is a trademark or registered trademark of Netscape Communications Corporation The OPEN LOOK and Sun TM Graphical User Interface was developed by Sun Microsystems Inc for its users and licensees Sun acknowledges the pioneering efforts of Xerox in researching and developing the concept of visual or graphical user interfaces for the computer industry Sun holds a non exclusive license from Xerox to the Xerox Graphical User Interface which license also covers Sun s licensees who implement OPEN LOOK GUIs and otherwise comply with Sun s written license agreements Products covered by and information contained in this service manual are controlled by U S Export Control laws and may be subject to the export or import laws in other countries Nuclear missile chemical biological weapons or nuclear maritime end uses or end users whether direct or indirect are strictly prohibited Export or
266. sEdit method If there is an InvalidEditFormDataException the DesktopServlet will redirect the browser back to the channel s edit page and include a URL parameter error so that the channel may display the cause of the exception to the user That is the DesktopServlet will get the error message and generate a new request as follows DesktopServletURL act ion edit amp provider channelNameserror errormessnge If there is no InvalidEditFormDataException the DesktopServlet generates the new URL and returns control to the web container DesktopServlet process Action Chapter 2 Using Provider API PAPI 49 Overview of the Provider API and Desktop Servlet Start process y Determine Provider from Parameter Is Provider Null Yes Get Default Channel Name Get Edit Container Is Edit Container Editable Desktop Exception 50 Call Edit Container s processEdit method Y Get Channel s name from Request Prameter Provider Exception Is Channel Editable Get Error from Exception y Get targetProvider from Parameter y Return Control to the Web Container a Call Channel s processEdit method yNo Generate and Redirect to New URL Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of Implementing
267. scription of the step by step process of the JSPProvider invoking a JSP 1 The JSpProvider getContent method is called and the JSPProvider looks up the JSP to be executed It calls a common private method to service the JSP 2 The provider then creates request and response objects copies information such as cookies from the Desktop request to those objects initializes the session information and checks to see if a servlet wrapper for the JSP already exists If not a servlet wrapper is created The service method is then called on the wrapper 94 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 JSPProvider The servlet wrapper service method loads the JSP Before loading it checks to see if the JSP class file is out of date with the class file If the JSP class file is out of date with the class file it invokes the compiler to compile the JSP into a class file and read the class file into memory and uses the class loader to define the new class Finally the JSP servlet is instantiated and the init method is called on the JSP Once the JSP is loaded the JSP s service method is called by the servlet wrapper service method After the JSP s service method completes the JSPProvider get Content method extracts the response body from the processed JSP file and returns it as a StringBuffer Extending the JSPProvider This sections contains some sample extensions to the JSPProvider Example 1 In the
268. se directory is etc opt SUNWps desktop classes For hot deployment the JAR file has to be dropped in the directory mentioned in providerClassBaseDir variable in the desktopconfig properties file Provider Class File The custom provider classes and all other custom classes that the provider classes reference can be bundled into a JAR file and placed in the provider class base directory They can also exist as class files in the provider class base directory If a class exists in a file and is also present in a JAR file under the provider class base directory the class existing as a file under the provider class base directory is given the first preference Once the class is found as a file no attempt is made to check for its existence in a JAR file If a class file exists in two JAR files under the provider class base directory the class is picked up from one of them at runtime Do not duplicate classes in multiple JAR files When compiling the class file the Servlet API identity server install root SUNWam lib servlet jar and PAPI portal server install root SUNWps sdk desktop desktopsdk jar are required in the CLASSPATH That is when compiling a Provider java file you must type javac d etc opt SUNWps desktop classes classpath portal server install root SUNWps sdk desktop desktopsdk jar identity server install root SUNWa m lib servlet jar Provider java Provider Class Loader The provider class loader i
269. se the following command par import r dn amadmin p password v provider par dn provider providername channel channelname NOTE All providers that ship with Sun ONE Portal Server software are in the service level Desktop display profile There is no command to extract them all See Sun ONE Portal Server 6 2 Administrators Guide for more information on the par utility Chapter 2 Using Provider API PAPI 63 Overview of Implementing a Custom Provider 64 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Chapter 3 Extending the Base Providers This chapter includes instructions for creating a custom provider by e Implementing the Provider Interface e Extending the ProviderAdapter Class e Extending the ProfileProviderAdapter Class e Extending the PropertiesFilter Class Examples are provided for developing a sample HelloWorldProvider that will display a message Hello World This is to illustrate the fundamentals of how the Provider interface works first followed by examples of how ProviderAdapter and ProfileProviderAdapter classes make the implementation easier Use the instructions provided with the sample HelloWorldProvider for developing your custom provider by extending any one of these APIs Implementing the Provider Interface The Provider interface defines the interface for implementing the provider component of a channel If you want to directly implement the Provider interface code should
270. sent attributes in an RDMQuery The RDM API defined in rdm h file provides functions for creating and modifying these structures For example the following statement RDMQuery myquery RDMQuery Create varrius creates an RDMQuery that corresponds to the following SOIF RDMQUERY scope 7 varrius The following statement RDMQuery_SetViewAttr myquery URL Title modifies the RDMQuery so that it corresponds to the following SOIF RDMQUERY 228 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Example of Submitting a Query scope 7 varrius view attributes 30 URL Title Author Last Modified Both the RDMHeader and RDMQuery structures have soif fields which contain the SOIF data for the header or the query To extract SOIF data from RDMHeader or RDMQuery you can access the soif field Thus you can also use the RDM SOIF API to create and modify RDMHeader and RDMQuery objects Example of Submitting a Query To send the RDMHeader and RDMQuery objects to the search engine to perform a query request you can use the pre built sendram program located in portal server install root SUNWps lib directory This program takes an RDM request which is a message in SOIF format sends it to the search engine and outputs the results as a SOIF stream You can also use HTTP to post an RDM stream directly to the server through its URL http server port portal search
271. ser s locale See the documentation on Resource Bundles at http java sun com products jdk 1 2 docs api java util ResourceBun dle html for more information on e The structure of the Resource Bundle e The search look up mechanism of Resource Bundles The Desktop and the Desktop Providers use Java Resource Bundles for the localized on screen text Chapter 11 Localizing Sun ONE Portal Server 259 Resource Bundles Resource bundle for providers store content that is not included in display templates such as error messages and dynamic content The Sun ONE Portal Server software automatically loads the correct resource bundle for the user s locale see Resource Bundle Access for more details File Naming Convention The file name for the resource bundle is usually the provider name that is the name defined in the display profile when the provider class is declared For example lt Provider name Bookmark class com iplanet portalserver providers bookmark BookmarkProvider gt Here for the BookmarkProvider the resource bundle file name is Bookmark properties The provider name will be retrieved via the ProviderContext getProviderName method The provider can also use a different name different from the default name for the resource bundle The name must be passed as a key when calling ProviderAdapter getResourceBundle String key method File Installation Location The resource bundle files must be installed in t
272. sktoptype AddressBook Access the AddressBook channel inside the JSPTableContainer To access log in to the Desktop and type the following URL in your browser http hostname port portal dt provider JSPTableContainer Example 2 In the following example the SimpleUserInfoProvider overrides the processEdit method of the JSPProvider It reads the common name that is input in the edit page JSP and then it is read from the processEdit method The value is set to the backend store To accomplish this 1 Extend the JSPProvider and develop the SimpleUserInfoProvider class The SimpleUserInfoProvider class overrides the JSPProvider processEdit method as shown in Code Example 4 5 on page 99 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 4 5 JSPProvider SimpleUserInfoProvider java File package custom import java net URL import javax servlet http HttpServletResponse import javax servlet http HttpServletRequest import com sun portal providers ProviderException import com sun portal providers jsp JSPProvider public class SimpleUserInfoProvider extends JSPProvider public URL processEdit HttpServletRequest req HttpServletResponse res throws ProviderException get the common name from the request and set it into the backend store getProviderContext setStringAttribute cn String req getParameter cn return null Compile the class
273. so on When the robot has finished all outstanding processing it will call the executable specified in the cmdHook setting If the oncomplet ion parameter is set to idle or quit the script is called once before the robot shuts down or goes idle If the parameter is set to loop the script is called each time the robot restarts See the log samples in Monitoring cmdHook Execution The cmdHook script can be written in any language as a Perl or shell script a C program and so on If you choose to use a C program you ll have to insert the cmdHook parameter in the robot conf file manually as the search engine Administration Interface does not scan binary executables Chapter 8 Search Engine Robot 207 Robot Completion Scripts 208 The cmdHook script is run from the robot s execution environment This means your script will inherit any environment variables set by the robot and will not have access to environment variables that might be set by your search server or the administration server The cmdHook script will be executed from var opt SUNWps serverinstance portal This is important to keep in mind if you are using any relative directory references There are two examples provided in portal server install root SUNWps samples robot They are a simple touch test cmdHook0 and an email upon completion script cmdHook1 Monitoring cmdHook Execution At the default logging level a log message is written in robot log when t
274. so you do not have to write and edit them manually The following sample SOIF describes a document whose title is Rescuing English Springer Spaniels whose author is Jocelyn Becker and whose URL is http www siroe com jocelyn resdogs index html DOCUMENT http www siroe com jocelyn resdogs index html title 34 Rescuing English Springer Spaniels author 14 Jocelyn Becker Each SOIF object has a schema name or template type and an associated URL and it contains a list of attribute value pairs In this case the schema name is DOCUMENT which indicates this resource is a document Title and author are both attribute names and you can see that each attribute has a value Using the SOIF API The SOIF API is defined in the soif h header file in directory portal server install root SUNWps sdk rdm include The SOIF API defines structures and functions for working with SOIF objects For example the following code uses the functions SOIF_Create and SOIF_InsertStr to create a SOIF and add some attribute value pairs to it SOIF mysoif SOIF_Create DOCUMENT http varrius doc htm 184 Sun ONE Portal Server 6 2 Developer s Guide December 2003 An Introductory Example SOIF_InsertStr mysoif title All About Style Sheets SOIF_InsertStr mysoif author Robin Styles SOIF_InsertStr mysoif description All you need to know about style sheets These co
275. ss exit 0 186 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Getting Search Server Database Contents as a SOIFStream Getting Search Server Database Contents as a SOIFStream You can retrieve the entire contents of the search engine database as a SOIF stream by using the rdmgr utility The rdmgr utility must be run in a search enabled Sun ONE Portal Server software instance directory The default is WebContainer portal From the WebContainer portal directory run the following command var opt SUNWps bin rdmgr U Be sure that the environment variable LD_LIBRARY_PATH to portal server install root 1ib This command prints the database contents as a soIFStream You can pipe the output to a program that uses SOIFSt ream routines to parse the SOIFs in the stream SOIF API The functions and objects defined in the soif h header file are listed by category in the following sections e SOIF Structure e Attribute Value Pair Routines e Multi valued Attribute Routines e Stream Routines for Parsing and Printing SOIFs e Memory Buffer Management Table 7 1 on page 187 provides an alphabetized version of the functions and objects for your reference Table 7 1 Alphabetized Functions and Objects Defined in the soif h File SOIF function or object Category O append Memory Buffer Management increase Memory Buffer Management reset Memory Buffer Management SOIF_Apply SOIF Structure Chapter 7 Usin
276. st be packaged as a WAR file The portlet xml file must be placed into the same location as the web xml file To create a portlet web application 1 Create a complete portlet xml file that includes the declaration for all the portlets Code Example 6 2 contains the port let xml file that includes the declaration for the sample portlet In Code Example 6 2 the XML file includes name class and cache information Since the sample portlet also uses preferences the preference setting is also included in the portlet xml file Also PrefPortlet supports the EDIT as well as HELP mode so the supported modes are specified in the portlet xml file Code Example 6 2 portlet xml File for the PrefPortlet lt xml version 1 0 encoding UTF 8 gt lt portlet app xmlns http java sun com xml ns portlet xmlns xsi http www w3 0rg 2001 XMLSchema instance xmlns portlet http java sun com xml ns portlet xsi noNamespaceSchemaLocation http java sun com xml ns portlet version 1 0 gt lt portlet gt lt portlet name gt PrefPortlet lt portlet name gt lt portlet class gt examples PrefPortlet lt portlet class gt lt expiration cache gt 0 lt expiration cache gt lt supports gt lt mime type gt text html lt mime type gt lt portlet mode gt EDIT lt portlet mode gt lt portlet mode gt HELP lt portlet mode gt lt supports gt lt portlet info gt lt title gt PrefPortlet lt title gt lt keywords gt Hello wor
277. stname port portal dt provider TemplateTableContainer Utilize the par utility for transporting channels and providers For example the following command can be used to export the HelloWorld channel and provider into a par file which can be imported to another Sun ONE Portal Server system par export r dn amadmin p password v helloworld par distinguishednode helloworld txt Here helloworld txt contains the following from channel provider HelloWorldPPA2 file providerClassBaseDir HelloWorldProviderPPA2 properties provider class custom helloworld HelloWorldProviderPPA2 directory templateBaseDir HelloWorldPPA2 desc HelloWorld Provider Using the following command the contents of the hel loworld par can be imported to as HelloWorld channel in a different Sun ONE Portal Server software installation par import r dn amadmin p password v helloworld par distinguishednode provider HelloWorldProvider channel HelloWorld avail TemplateTableContaine r selected Sun ONE Portal Server 6 2 Developer s Guide December 2003 Extending the PropertiesFilter Class The above command apart from installing the channel and provider will also include the HelloWorld channel as one of the selected and available channels in the TemplateTableContainer For more information on the par utility and its subcommands see the Sun ONE Portal Server 6 2 Administrator s Guide Extending the PropertiesFilter Class Developers who wish
278. t lt label gt lt font gt lt td gt lt td width 45 gt lt font face tag fontFacel size 0 gt lt input type TEXT name message size 50 maxlength 50 value tag message id message gt lt font gt lt td gt lt tr gt lt tr gt lt td width 20 gt amp nbsp lt td gt lt td width 45 gt amp nbsp lt td gt lt tr gt lt table gt Chapter 3 Extending the Base Providers 85 Extending the ProfileProviderAdapter Class Code Example 3 18 HelloWorldProviderPPA2 editTemplate template File lt lt CLASS bu lt lt lt lt lt lt DOCTYPE HT lt L PUBLIC W3C DTD HTML 3 2 EN gt lt HTML gt lt HEAD gt tag noCache lt TITLE gt tag productName lt TITLE gt lt HEAD gt lt BODY BGCOLOR FFFFFF gt lt FONT SIZE 0 FACE tag fontFacel gt lt LINK REL stylesheet TYPE text css HREF surl desktop css style css TITLE fonts gt lt CENTER gt tag bulletColor tag banner lt FORM ACTION dt NAME edit_form METHOD POST ENCTYPE application x www form urlencoded gt lt INPUT TYPE HIDDEN NAME action SIZE 1 VALUE process gt lt INPUT TYPE HIDDEN NAME provider SIZE 1 VALUE tag providerName gt tag inlineError lt TABLE BORDER 0 CELLPADDING 0 CELLSPACING 3 WIDTH 100 gt lt TR gt BR gt tton gt font gt br P gt FORM gt BR gt lt TD WIDTH
279. t ProviderContext com sun portal providers context ProviderContextException com sun portal providers context Theme class HelloWorldProviderPPA2 extends ProfileProviderAdapter private ResourceBundle bundle null private final private final n tatic String BANNER banner tatic String BANNER_TEMPLATE banner template private final static String BORDER_COLOR borderColor private final static String BORDER_WIDTH borderWidth private final static String BULLET_COLOR bulletColor private final private final private final private final private final private final tatic String BULLET_COLOR_JS bulletColor js tatic String BG_COLOR bgColor tatic String CONTENT_LAYOUT contentLayout tatic String CONTENT LAYOUT TEMPLATE contentLayout template tatic String DESKTOP URL desktop url tatic String EDIT PROVIDER TEMPLATE editTemplate template private final static String ERR MESSAGE errMessage private final static String FONT_COLOR fontColor private final static String FONT_FACE fontFace private final static String FONT FACE fontFacel private final private final private final private final private final private final private final private final tatic String FRONT_CONTAINER_NAME frontContainerName tatic String INLINE_ERROR inlineError tatic String MENUBAR menubar tatic String MENUBAR TEMPLATE menubar template tatic String MESSAGE
280. tStringProperty FONT FACE1 property PRODUCT NAME tags put PRODUCT NAME getStringProperty PRODUCT NAME tags put PARENT CONTAINER NAME pc getDefaultChannelName templates tags put MENUBAR getTemplate MENUBAR_TEMPLATE tags put CONTENT_LAYOUT getTemplate CONTENT_LAYOUT_TEMPLATE Chapter 3 Extending the Base Providers 81 Extending the ProfileProviderAdapter Class Code Example 3 13 HelloWorldProviderPPA2 java File Continued tags put tags put TOOLBAR_ROLLOVER getTemplate TOOLBAR_ROLLOVER_JS NO CACHE getTemplate NO CACHE TEMPLATE tags put DESKTOP URL pc getDesktopURL reg tags put BULLET COLOR getTemplate BULLET COLOR JS tags put BANNER getTemplate BANNER TEMPLATE error tags if any String err req getParameter error if err null tags put ERR_MESSAGE err tags put inlineError getTemplate inlineError template else no error put in dummy tags so lookup doesn t fail tags put ERR_MESSAGE tags put INLINE ERROR theme attributes try tags put BG COLOR Theme getAttribute getName pc BG COLOR tags put TITLE_BAR_COLOR Theme getAttribute getName pc TITLE_BAR_COLOR tags put BORDER_COLOR Theme getAttribute getName pc BORDER_COLOR tags put FONT COLOR Theme getAttribute getName pc FONT COLOR tags put BORDER WIDTH Theme getAttribute getNam
281. tag of any name and store the value in the classification field in the database For example using this function you could instruct the robot to get the content of the lt META NAME topic gt tag and store it as the classification of the resource You would invoke this function with a directive such as the following Generate fn copy_mv src topic dst classification Code Example 8 3 shows a sample function definition Sun ONE Portal Server 6 2 Developer s Guide December 2003 Code Example 8 3 Creating New Robot Application Functions Robot Application Function Example xk x example robot applicati include robotapi h include pblock h include log h include objlog h on function NSAPI Public int copy_mv libcs_pblock pb CSFilter csf CSResource csr char s mv mvp Use the libcs_pblock_findval function to get the values of the src and dst parameters which were specified by the directive that invoked this function char src libcs_pblock_findval char dst libcs_pblock_findval if src dst eslog error 1 1 lt URL s gt Error No source or csr gt url return REQ PROCEED Tf the current document does n matches the src parameter jus src value in the string s The function SOIF_Findval soif in sdk rdm include soif h It given attribute from the given The rd in the CSResource is a Bi if s char S
282. tal Server Secure Remote Access 6 2 Administrator s Guide Sun ONE Portal Server 6 2 Desktop Customization Guide Sun ONE Portal Server 6 2 Release Notes Where to Find This Guide Online You can find the Sun ONE Portal Server 6 2 Developer s Guide online in PDF and HTML formats This book can be found at the following URL http docs sun com prod slportalsrv 10 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Chapter 1 Introduction to the APIs This chapter provides an introduction to customizing the portal to fit the specific needs of your organization It describes the Sun ONE Portal Server software architecture APIs and programming concepts that developers can use This chapter contains the following sections e Overview e Overview of the APIs e Portal Environment See the Sun ONE Portal Server 6 2 Administrator s Guide for information on administering the Sun ONE Portal Server software See the Sun ONE Portal Server 6 2 Desktop Customization Guide for information on customizing the Desktop templates and JavaServer Pages JSP NOTE Detailed information on the Sun ONE Portal Server software APIs is available in the Javadocs The URL to access the Javadocs is http hostname port portal javadocs Overview This section provides a brief description of the Sun ONE Portal Server software See Sun ONE Portal Server 6 2 Administrator s Guide for a complete product architecture descripti
283. ter for resources that are denied If a resource is not denied the robot will eventually enumerate it attempting to discover further resources The generator might also create a resource description for it Note that these operations are not necessarily linked Some resources result in enumeration others result in RD generation Many resources result in both enumeration and RD generation For example if the resource is an FTP directory the resource typically will not have an RD generated for it However the robot might enumerate the individual files in the FTP directory An HTML document that contains links to other documents can produce a generated RD and can lead to enumeration of the linked documents as well Stages in the Filter Process Both enumerator and generator filters have five phases in the filtering process They both have four common phases Setup Metadata Data and Shutdown If the resource makes it past the Data phase it is either in the Enumerate or Generate phase depending on whether the filter is an enumerator or a generator Setup Performs initialization operations Occurs only once in the life of the robot Metadata Filters the resource based on metadata that is available about the resource Metadata filtering occurs once per resource before the resource is retrieved over the network Table 8 1 lists examples of common metadata types Complete URL Protocol Host IP address PATH Depth Common Metadata Ty
284. the DesktopServlet gets the named channel s or edit container s request parameters and starts to process the edit action When the DesktopServlet receives a request where the action is edit to perform the edit action it takes the following parameters Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of the Provider API and Desktop Servlet DesktopServletURL act ion edit amp provider ChannelName for backward compatibility Or DesktopServletURL act ion edit amp provider editContainer amp t argetprovider ChannelName The DesktopServlet checks the edit types based on the values defined in the ProviderEditTypes interface DesktopServletURL action edit amp provider ChannelName The flowchart in Figure 2 6 on page 42 shows the various methods executed in the back end to process the edit action When the client makes a request to edit the channel s editable parameters the DesktopServlet 1 Determines the provider responsible for generating the requested content If provider is null it uses the default channel name to get the provider Default or last accessed channel is not assumed when action equals edit Otherwise the DesktopServlet gets the provider responsible specified in the URL Once the provider is determined the channel s isEditable method is invoked to determine if the channel is editable The DesktopServlet gets the named channel s isEditable property If the channel is determined
285. ther applications written to use application server and for developers that want to use the additional enterprise services that are provided by these application servers Chapter 1 Introduction to the APIs 15 Overview Figure 1 2 The Sun ONE Directory Server software provides the user profile data repository The Sun ONE Identity Server software provides support for core services such as profile session authentication and logging It also provides single sign on services policy management debug utility the administration console and client support interfaces for Portal Server Use the Sun ONE Identity Server software administration console for service profile and user administration See the Sun ONE Identity Server Administrator s Guide and Sun ONE Portal Server 6 2 Administrator s Guide for more information The Sun ONE Portal Server software Search Engine provides the search capability It includes basic and advanced search and browse channels for the Desktop It uses a robot to create resource descriptions for documents that are available in the intranet and stores these resource descriptions in an indexed database Search includes Java and C APIs for submitting resource descriptions and for searching the database Search also includes an administration console module for editing Search service data and for configuring the search engine and the robot The console also lets you edit the contents of the Search database The Desk
286. ties via the Theme class See the Javadocs for more detail Presentation Method Determine whether the provider will fetch content from template files or JSPs This will determine the logistics of the get Template method Channel template files are stored in a directory based on the name of the channel or the name of the provider that is used by the channel The channel directory for the provider is created under the template root directory By default this will be etc opt SUNWps desktop desktoptype channeldirectory templatefiles The JSPs and templates are stored under etc opt SUNWps desktop default and etc opt SUNWps desktop sampleportal directories Storing the files in the etc opt SUNWps desktop default directory allows the files to be shared That is when the Desktop service uses the comma separated string as an ordered Desktop type list in the Desktop type attribute to lookup it starts at the first element in the list and each element represents a sub directory under the Desktop template base directory If a template is not found in the first directory or the first string in the desktop type attribute then it proceeds to the next one in the list This continues until the item is found or not for all Desktop type elements in the list If the default directory is not included in the list it will be added at the end of the list implicitly The directory search order for the template and JSP files is as follows deskt
287. tion allows you to hook up your own routine for printing SOIF_ParselnitFile NSAPI PUBLIC SOIFStream SOIF_ParseInitFile FILE fp Creates a disk based stream ready for parsing The file must contain SOIF formatted data The function reads SOIF data from the file object fp SOIF ParselnitStr NSAPI PUBLIC SOIFStream SOIF ParselnitStr char buf int bufsz Creates a memory based stream ready for parsing The character buffer must contain SOIF formatted data SOIFStream Finish NSAPI PUBLIC int SOIFStream_Finish SOIFStream Closes the stream when you have finished with it SOIFStream SetFinishFn NSAPI PUBLIC int SOIFStream SetFinishFn SOIFStream int finish_fn SOIFStream Allows you to hook up a function for cleaning up after the SOIF stream finishes its business The finish_fn will be called when soIrstream Finish has finished executing SOIFStream_Print define SOIFStream_Print ss s Prints another SOIF object to the SOIF stream ss Returns 0 on success or non zero on error SOIFStream_Parse define SOIFStream Parse ss Parses and returns the next SOIF object in the SOIF stream SOIFStream IsEOS define SOIFStream IsEOS s Returns 1 true if the SOIF stream has been exhausted Chapter 7 Using the SOIF API to Work with SOIF Objects 199 SOIF API SOIFStream IsPrinting define SOIFStream IsPrinting s Returns 1 true if the SOIF has been set up in a stream by SOIF_PrintInitFile Or SOIF Pri
288. tn Lia 108 Extending the XML Provider a npag ee Pra nt 109 Chapter 5 Using the Container Providers 000 cess cece eeen 115 The ContainerProvider Architecture ra oer aar overbeek bot dee ini 115 Overview of the ContainerProviders an eneen eee 117 EG GH a AA 117 ContainerProviderContext a ici evans amd ba BILAN a a dane i 118 ContamerProvider Adapter AA AA AA AA AG 118 JSPContainerProvidetAdapter e nortoe arseen lire 119 JSPSingleContainetProwidet arn aan reren dine ee ian 119 SP TableContaiier Provider i gilera Ka Wa ea 124 TabContamen ieri iaia ed he dees bak iii ie 148 JSPTabContainerProvider lira A AERAZIONE donna aed 149 Sun ONE Portal Server 6 2 e Developer s Guide December 2003 Creating a Custom Container PRO NAE riris rusni eee ls add hae pea bale Rae ea ede es pak 157 Chapter 6 Developing and Deploying Portlets 00 167 Witt isa Portlet is bebe en eee ea bha na 167 Overview of Developing and Deploying Portlets 2 cs siii 167 Extending the GeneriePortlet Abstract Class 05 nG LA NABA bes te Caen DNA PAP has 168 Converting Providers to Portlets gt een sene eene eet GN ONG 172 Piles Used by Panata an BAAL elie DALITA todd mb iride ia 178 POENA AA rai ei ae ER dele ee ne 178 sun wWebail eneen verheven ae ade arena 178 SU MELEE IY En 179 PDCGniie properties eean bpidediehigactid iol web APA AA 181 Chapter 7 Using the SOIF API to Work with SOIF Objects 183 Wi
289. tomize the authentication interfaces Table 1 1 explains the authentication development tasks and where to go for the information Table 1 1 Authentication Development Tasks If you want to Go to Change the look and feel of the Chapter 5 Sun ONE Identity Server Programmer s Guide authentication screen Enable or disable authentication Chapter 5 Sun ONE Identity Server Administrator s Guide modules Add a custom authentication Chapter 5 Sun ONE Identity Server Programmer s Guide By default Sun ONE module Identity Server software supplies authentication modules for the following types of logins Anonymous Certificate LDAP Membership RADIUS SafeWord SecurelD and UNIX Portal Environment This section contains the following e Web Container e File System Web Container The Sun ONE Portal Server software providers run within the Java Virtual Machine provided by the web container which may vary between different web containers The Sun ONE Portal Server software environment in the Sun ONE Web Server software or Sun ONE Application Server software web container is Java Development Kit JDKTM 1 3 1 04 In addition to the standard J2SE environment the following additional Java libraries and capabilities are available to Sun ONE Portal Server software extensions that run within the web container e HTTPS protocol scheme is recognized by the URLConnection class 22 Sun ONE Portal Server 6 2 Developer s Gu
290. top provides the primary end user interface for Portal Server and a mechanism for extensible content aggregation through the Content Provider Interface PAPI The Desktop includes a variety of providers that provide a container hierarchy and the basic building blocks for building some types of channels The Desktop implements a display profile data storage mechanism on top of an Identity Server service for storing content provider and channel data The Desktop also includes an administration console module for editing the display profile and other Desktop service data Sun ONE Portal Server Software Architecture 16 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of the APIs Sun ONE Portal Server Desk Applications Services esrtop Desktop Renderer Search Servlet and JSP Administration NetMail l Console Discussions Display Provid Template Profile roviders Manager NetFile Subscriptions Sun ONE Identity Server Session Profile Logging i Auth Utility Admin Policy Services Module Agent Messaging and Transport JDK Web Container Sun ONE Directory Server Overview of the APIs This section describes the Sun ONE Portal Server software Desktop Search and authentication APIs for extending your portal Desktop APIs The Desktop AP
291. uery SOIFStream_Finish out exit 0 BRK K IK IK IK EOF FOR IK IK IO kk kek Running the Example To run the example described in Code Example 9 1 on page 230 follow these steps 1 Edit the definitions for MY SCOPE MY CSID and MY_ATTR_VIEW as appropriate for your situation For more information see Code Example 9 2 2 Save the file in portal server install root SUNWps sdk rdm examples directory For example save the file as example4 c in portal server install root SUNWps sdk rdm examples directory 3 Create a makefile You can find sample makefiles at portal server install root SUNWps sdk rdm examples directory Edit the makefile to include examp1e4 c Code Example 9 2 shows the makefile with the changes needed for examp1e4 c in bold Code Example 9 2 Makefile for SOIF RDM examples akefile for SOIF RDM SDK examples Use make and cc CC cc SDKDIR Sa SDKLIB S SDKDIR lib librdm a SDKINC 5 SDKDIR include CFLAGS IS SDKINC DXP_UNIX CFLAGS DSOLARIS CFLAGS DIRIX CFLAGS DHPUX CFLAGS DAIX EXAMPLES examplel example2 example3 example4 all EXAMPLES examplel examplel o CC o 0 SDKLIB example2 example2 o Chapter 9 Using the RDM API to Access the Search Engine and Database inC 231 Example of Submitting a Query Code Example 9 2 Makefile for SOIF RDM examples Continued CC o 0 SDKLIB
292. uments libcs param create Creates a parameter with the given name and value If the name and value are not null they are copied and placed into a new pb paran structure libcs param free Frees a given parameter if it is non NULL It returns 1 if the parameter was non NULL and 0 if it was NULL This function is useful for error checking before using the libcs_pblock_remove function libcs_pblock_create Creates a new parameter block with a hash table of a chosen size Returns the newly allocated parameter block libcs_pblock_free Frees a given parameter block and any entries inside it libcs_pblock_find Finds the entry with the given name in a pblock and returns its value otherwise returns NULL libcs_pblock_findval Finds the entry with the given name in a pblock and returns its value otherwise returns NULL libcs_pblock_remove Behaves like the libcs_pblock_find function but in addition it removes the entry from the pblock 216 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Creating New Robot Application Functions libcs_pblock_nninsert These parameters create a new parameter with a and given name and value and insert it into a given libcs_pblock_nvinsert parameter block The libcs_pblock_nninsert function requires that the value be an integer but the libcs_pblock_nvinsert function accepts a string libcs_pblock_pinsert Inserts a parameter into a parameter block libes_pblock_str2pblock Scans the gi
293. us RDMQUERY scope 7 varrius If the RDM message is a query request the body of the message can also indicate which attributes of the resulting RDs are wanted the number of results and sort preference For example the following search criteria in the RDM body specifies the URL title author and last modified attributes The result set contains at most 10 hits and the resulting set is ordered by the title attribute RDMQUERY scope 7 varrius view attributes 30 url title author last modified view hits 2 10 view order 5 title Chapter 9 Using the RDM API to Access the Search Engine and Database inC 227 About the RDM API If the RDM message is another kind of request such as a Schema Description Request a Server Description Request ora Status Request the body of the message should contain appropriate data See the relevant document for more details on RDM bodies About the RDM API The file rdm h defines structures and functions for creating RDMs The intent of these functions is to construct queries and instructions that can be output as RDM and sent via the sendrdm program to a search engine for processing These queries and instructions are created in the C programming language The basic structures are e RDMHeader e RDMQuery To support each of these main structures there are additional structures like RDMViewAttributes RDMViewOrder and RDMViewHit which are used to repre
294. using the add subcommand with the parent option type 262 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Localization Support in PAPI portal server install root SUNWps bin dpadmin add p parent u dn amadmin w password d distinguishedname dp locale xml Localization Support in PAPI The ProviderContext contains localization aware methods such as getCollectionProperty java lang String Channel java lang String name boolean localized and getCollectionProperty java lang String channel java lang String name java util Map def boolean localized which gets the localized version of a collection property getStringProperty java lang String channel java lang String name boolean localized and getStringProperty java lang String Channel java lang String name java lang String def boolean localized which gets the localized version of a String property getCollectionProperty String channel String name List pflist getCollectionProperty String channel String name Map def List pflist getStringProperty String channel String name List pflist getStringProperty String channel String name String def List pflist to support conditional properties The ProfileProviderAdapter contains localization aware methods such as getMapProperty java lang String key boolean localized and getMapProperty java lang String key java lang String def boolean localized which gets the localized version of a map pr
295. ust also edit SearchDemo htm1 to configure the information about your search engine location NOTE The instructions included here are for appletviewer To run the applet in a browser you need Java 1 2 or later browser plugin More information on the Java browser plugin can be found at http java sun com products plugin and http java sun com products plugin 1 3 docs tags html 1 Compile the searchDemo java file Make sure the class path includes the SDK JAR file searchsdk jar For example enter javac classpath searchsdk jar SearchDemo java 2 Createa directory hierarchy that reflects the Java package structure for these classes to use the compiled classes directly and move the classes into the demo package of this hierarchy For example type mkdir p com sun portal search demo cp class com sun portal search demo 3 Enter the server location information by editing the applet parameters in SearchDemo html For example type lt param name RDMServer value http portal_server_host_name port portal search gt Appletviewer can now be run from the command line It will access the java classes from the current location For example enter appletviewer SearchDemo html Search queries are entered into the search bow that appears and results are sent to stdout of the controlling terminal If you are running the applet in a browser the results are displayed in the Java console Chapter 10 Using Java to
296. ute in the given soif For example the following statement gets the AvPair for the title attribute in the soif s SOIFAVpair avp SOIF_Find s title SOIF_Findval define SOIF Findval soif attribute name retrieves the value string for the given attribute in the given soif For example the following statement prints the value of the title attribute of the soif s printf Title s n SOIF Findval s title SOIF Remove define SOIF_Remove soif attribute name Removes the given attribute from the given soif Chapter 7 Using the SOIF API to Work with SOIF Objects 191 SOIF API SOIF_Insert define SOIF Insert soif attribute name value value size Inserts the given attribute and the value of the given size as an AVPair into the soif SOIF_InsertAVP define SOIF InsertAVP soif avpair Inserts the given AVPair into the given soif SOIF Apply define SOIF Apply soif function user date Applies the given function with the given argument user data to each AvPair in the given soif For example void print av SOIF s SOIFAVPair avp void unused printf Ss s n avp gt attribute avp gt value print every attribute and value in the soif s SOIF_Apply s print_av NULL Attribute Value Pair Routines Attribute value pairs contain an attribute and an associated value The value often is a simple null terminated string however the value can also be binary data Attribute value
297. ute value in the display profile If this value is false it checks the cookiesToForwardList attribute value in the display profile Determines if cookies from the request should be forwarded Gets the content by o Retrieving content from the specified URL Chapter4 Using Leaf Providers 103 URLScraperProvider That is it sends an HTTP request that contains information related to this request for content and gets an HTTP response that allows the provider to influence the overall response for the Desktop page besides generating the content Or by o Taking the fully qualified path name of the file and returning StringBuffer containing the data from the specified file or null if file does not exist or cannot be read Extending the URLScraperProvider The following sample extends the URLScraperProvider and overrides the getURL method to get a random URL from a pool of URLs defined in the display profile This sample can be used to display a random image from a pool of images that is the following getURL method selects an URL at random from a pool of URLs where each URL is pointing to a HTML file containing the image 1 Extend the URLScraperProvider and develop the custom class file The CustomURLScraperProvider class file overrides the URLScraperProvider getURL method as shown in Code Example 4 10 The CustomURLScraperProvider gets the URL property for the provider This is the URL from where the contents are fetched
298. uthenticated User Chapter 2 Using Provider API PAPI 33 Overview of the Provider API and Desktop Servlet Top Level Contained Contained HIPON sae oy Pope Provider Provider 1 Provider 2 Initial request PESO soi action is lee a Validates SSO Token Name Le new AA Gets container provider context nd getContent initcreate EE ani i getContent ha ee getContent h ui i Geis getProvider for contained provider contained init i channel Pa content 5 e di for i i getContent top level due Di a container gt Gets i getProvider for contained provider contained channel i init content ka 0 FE l etContent l DA al ey aap 34 Sun ONE Portal Server 6 2 Developer s Guide December 2003 Overview of the Provider API and Desktop Servlet Figure 2 3 The Provider Lifecycle Desktop Reload Request for Authenticated User Top Level Contained Contained The Browser Desktop PC CPC Provider Provider 1 Provider 2 pag Reload request HA URL null Validates SSO Token nd Gets container provider context nd getContent getContent g E nn getContent i i getProvider for contained provider i Gets contained channel 7 getContent
299. vanced true gt name MailCheck value 4 gt name App value 5 gt name Bookmark value 3 gt name SampleRSS value 2 gt name SampleXML value 2 gt n gt name channelsIsRemovable gt n name UserInfo value false gt n gt name amList gt value UserInfo gt value MailCheck gt value App gt value Bookmark gt n gt name pmList gt value MyFrontPageTabPanelContainer Bookmark2 gt value MailCheck gt value SampleXML gt value SampleRSS gt n gt value UserInfo gt value MailCheck gt value App gt value Bookmark gt value MyF rontPageTabPanelContainer Bookmark2 gt value SampleJSP gt value SampleRSS gt value SampleXML gt value UserInfo gt value MailCheck gt value App gt value Bookmark gt value MyF rontPageTabPanelContainer Bookmark2 gt value SampleJSP gt value SampleRSS gt value SampleXML gt 134 Sun ONE Portal Server 6 2 Developer s Guide December 2003 JSPContainerProviderAdapter 4 Use the dpadmin command to upload the display profile fragments for this provider For SpanTableContainerProvider use the dpadmin command to upload the CustomTCProvider xml file and CustomTCChannel xml file fragments in the display profile That is type portal server install root SUNWps bin dpadmin add u dn amadmin w password d distinguishedname SpanTCProvider xml portal server instal
300. ven string for parameter pairs in the format name value Or name value adds them to a pblock and returns the number of parameters added libcs_pblock_pblock2str Places all of the parameters in the given parameter block into the given string Each parameter is of the form name value and is separated by a space from any adjacent parameter Getting Information on the Processed Resource As mentioned in RAF Prototype the prototype for all robot application functions is in the following format int RobotAPIFn pblock pb CSFilter csf CSResource csr where csr is a data structure that contains information about the resource being processed The csResource structure is defined in the header file robotapi h This structure contains information about the resource being processed Each resource is in SOIF syntax Objects in SOIF syntax have a schema name an associated URL and a set of attribute value pairs In the Code Example 8 1 the schema name is DOCUMENT the URL is http developer siroe com docs manuals htmlguid index htm and the SOIF contains attribute value pairs for title author and description Code Example 8 1 SOIF Syntax Example DOCUMENT http developer siroe com docs manuals htmlguid index htm title 18 HTML Tag Reference Chapter 8 Search Engine Robot 217 Creating New Robot Application Functions Code Example 8 1 SOIF Syntax Example Continued author 11 Preston Day
301. view of the Provider API and Desktop Servlet Once the provider is determined the provider s isPresentable method is invoked to determine if the provider can be presented to the requesting client If the provider is determined to be not presentable an error is thrown on the Desktop If the provider can be presented the provider s get Content method fetches the content for display on the client s Desktop When last is set to false the DesktopServlet will not set the last channel to the value of the provider parameter If not specified the default setting is last true and the last accessed channel is set to the value of the provider parameter The next time when the action is content the DesktopServlet provider parameter will be used to fetch the content If the provider parameter is absent in the request URL the DesktopServlet assumes it is equal to the value of the last request DesktopServlet content Action Chapter 2 Using Provider API PAPI 39 Overview of the Provider API and Desktop Servlet 40 Start process Determine Provider Bear aS Get Default Channel Name Null Get Channel mu Is No Channel Send 406 Error Code Presentable Set Default Channel Name Get Content for Channel _ Send Response to Browser lag t Display on the Desktop Action edit When the action is edit

Download Pdf Manuals

image

Related Search

Related Contents

環 境 報 告 書 2005    SERVICE MANUAL Electric wheelchair    Samsung ML-3050 Manual de utilizare  MANUEL D`ENTRETIEN ET DE SUPPORT  

Copyright © All rights reserved.
Failed to retrieve file