Integrating IBM WebSphere Portlet Factory V6.0.1 with IBM WebSphere Portal Document Manager

IBM WebSphere Portlet Factory V 6.0.1 provides builders that facilitate creating, retrieving, updating, and deleting content in IBM WebSphere Portal Document Manager. This article describes these new builders and demonstrates their use through a sample application.

Share:

Abhishek Singh, Senior IT Specialist, IBM

Abhishek Singh is a Senior I/T Specialist with IBM Software Services for Lotus and has worked with IBM WebSphere Portal products since 2003. He specializes in WebSphere Portlet Factory and design and development of enterprise J2EE applications. His experience includes designing and developing software products, service-oriented architecture, information systems, telecom applications, and client/server applications.



Georgiana Avram (georgiana@us.ibm.com), IT Specialist, IBM

Georgiana Ivy Avram is an IT Specialist with IBM Global Business Services, in the Business Transformation Center of Excellence, focusing on application consulting and development. Her experience includes Service-Oriented Architecture, business process, and workflow development. She is currently working on the design and implementation of a solution combining content management, data analysis, reporting, and enterprise search functionality.



09 January 2008

Also available in Russian

IBM WebSphere Portlet Factory V6.0.1 gives IBM WebSphere developers a toolset to speed development. Each new version of the product gives you additional builders, many of which are designed to simplify incorporating an expanded set of Web features into your work.

You should have a good understanding of building portlets using WebSphere Portlet Factory using either Eclipse or IBM Rational Application Developer for WebSphere Software. You should also be familiar with the Portal Document Manager in IBM WebSphere Portal.

Introduction

IBM WebSphere Portlet Factory provides a Rapid Application Development toolset for building portlets. It empowers you with new builders to add, view, edit, and remove content to the content repository of Portal Document Manager in IBM WebSphere Portal.

This article provides a basic background on Portal Document Manager and its usage. The article illustrates how to incorporate new WebSphere Portlet Factory builders by describing the process of adding them to the sample portlet application, which allows browsing, creating, updating, and removing content in Portal Document Manager.

To develop the sample application described in this article, you need Eclipse 3.1 (or later) or IBM Rational Application Developer V6 (or later), and WebSphere Portlet Factory V6.0.1. In addition, you need to have WebSphere Portal V6 (or later) installed so that you can use its content repository.

Portal Document Manager overview

Portal Document Manager (PDM) allows users to create and store documents in a centralized repository. A description of all PDM features and capabilities is beyond the scope of this article. Some of the features of PDM are its ability to:

  • Create a folder structure to manage documents
  • Create and edit documents in Portal Document Manager
  • Import existing documents into Portal Document Manager
  • Delete documents from Portal Document Manager
  • Download content from Portal Document Manager

Portal Document Manager is installed by default with WebSphere Portal. You can access the document libraries in Portal Document Manager by using the Document Manager portlet that is installed as part of the Portal Document Manager installation. The Document Manager portlet allows portal users to create libraries, folders, and documents. The Document Manager portlet is an administrative portlet that has all functionality to manage Portal Document Manager. To customize the functionality of Portal Document Manager, you need to write your own portlet.

To manage your documents for the sample portlet, create the folders needed to upload documents for storage in Portal Document Manager. Follow these steps to create a folder structure in Portal Document Manager:

  1. Log into WebSphere Portal.
  2. Launch Portal Document Manager by choosing Launch - Documents - Document Manager. You should now see the Document Manager portlet as shown in figure 1.
    Figure 1. Document Manager portlet
    Document Manager portlet
  3. Create a folder using the Document Manager portlet by clicking New - Folder.
  4. Specify the Folder name and Description (optional) where you intend to keep the documents related to the sample portlet as shown in figure 2. Click the Save button when you are done.
    Figure 2. Creating a new folder using the Document Manager portlet
    Creating a new folder using the Document Manager portlet
  5. To add documents to the folder you created in the previous step, click the Import File button at the top of the Document Manager portlet. Browse the file system to find the files you want to import, and enter a Title and Description (optional) as shown in figure 3.
  6. Click Publish when you are done.
    Figure 3. Uploading documents using the Document Manager portlet
    Uploading documents using the Document Manager portlet
  7. Repeat the preceding steps for all the folders and documents you want to create in Portal Document Manager.

Sample application overview

The sample application uses WebSphere Portlet Factory content builders to build a Training Content portlet that enables you to manage your documents in Portal Document Manager. The intent is to leverage some of the existing functionality of the Document Manager portlet and to extend it through development of a custom portlet. The Document Manager portlet is more like an administration portlet for Portal Document Manager, and hence, the intent is to explain how to implement and customize some of the functionality of this portlet using WebSphere Portlet Factory builders.

The Training Content portlet uses the following Portal Document Manager folder structure as an example:

  • Business Training
  • Technical Training
  • Training Methodologies

You must have these folders created in your Portal Document Manager as outlined in the preceding steps. The Training Content portlet allows you to view the folders you created and the documents within those folders. You also can delete or upload documents. The Training Content portlet appears as shown in figure 4.

Figure 4. Training Content portlet
Figure 4. Training Content portlet

Creating the WebSphere Portlet Factory project

WebSphere Portlet Factory V6.0.1 supports these development IDEs:

  • IBM Rational Application Developer V6 or V7
  • Eclipse 3.1 or higher

To create the training content project, follow these steps:

  1. Choose Window - Open Perspective - Other from the Eclipse or Rational Application Developer menu.
  2. Select the WebSphere Portlet Factory perspective from the list in the Select Perspective dialog box.
  3. Choose File - New - WebSphere Portlet Factory Project after you have opened the WebSphere Portlet Factory perspective.
  4. You are prompted for a project name, and then you are asked to select from a list of feature sets to include in your project. Select the Content Model Extension feature.
  5. Next, you are prompted for a deployment configuration. Enter the details relevant to your testing environment. Select the Auto Deploy option if you want to launch your development changes immediately on a server.
  6. As the New Project wizard processes your request, you see a prompt that asks the following:

    Would you like to add the following jars from the Feature Set
    to the project Java build path?
    WEB-INF/work/lib/ContentModel_builder.jar
    WEB-INF/work/lib/ContentModel_builder_nl1.jar
    Click Yes.

Creating the Training Content service provider model

The first model defined by this project is the TrainingContentProvider model, which defines all the service operations required to access the documents and folders in Portal Document Manager. It also defines the actions needed to upload, download, and delete documents. The following is a list of service operations defined by the TrainingContentProvider model as well as a brief description of their intended purposes.

  • getFolders. Gets the list of folders for the specified path.
  • getDocuments. Gets the list of documents for the specified path.
  • downloadDocument. Downloads a document using the browser.
  • deleteDocument. Deletes the specified document in Portal Document Manager.
  • uploadDocument. Uploads the document to Portal Document Manager.

To create the TrainingContentProvider model, follow these steps:

  1. Choose File - New - WebSphere Portlet Factory Model. Select the WebSphere Portlet Factory project created previously to associate each model with that project. Select an empty model for each, and click Next.
  2. The Service Definition builder is the first step in creating the Service Provider model. Add a Service Definition builder, and use these settings (see figure 5).

    • In the Service Name field, enter TrainingContent.
    • Select the Make Service Public option.
    • Click the Apply button on the builder.
    Figure 5. Adding the Service Definition builder
    Adding the Service Definition builder

Creating the getFolders service operation

To create the getFolders service operation, follow these steps:

  1. Add the Content Model Access builder to the Service Provider model, and enter the name as Folder.

    The Content Model Access builder is your gateway to Portal Document Manager. This builder allows you to retrieve the content from Portal Document Manager based on the document type specified.

    The possible document types on which the builder can operate are these:

    • Document. com.ibm.content.model.Document
    • Folder. com.ibm.content.model.Folder
    • CollaborativeDocument. com.ibm.content.lotus.model.CollaborativeDocument
  2. For the getFolders service, specify the Document Type builder input as com.ibm.content.model.Folder to search for folders. See figure 6.
    Figure 6. Document Type for Content Model Access builder
    Document Type for Content Model Access builder

    You also need to specify the way the folders are accessed. The sample application displays only one level of folders, that is, only direct children for the specified path are displayed. Therefore the Search Depth parameter is set to "Search only direct children of a path." Specify the Max Documents builder input as 1000. See figure 7.
    Figure 7. Search Criteria settings for Content Model Access builder
    Search Criteria settings for Content Model Access builder
  3. Add an Action List builder to operate on the Content Model Access builder with the following specfications.

    • In the Name field, enter getFolders.
    • Under the Arguments section, specify an argument searchCriteria of IXml Data Type.
    • Specify the Return Type as IXml.
    • Next, define Actions for the builder. The first Action assigns the search criteria to the variable created by Content Model Access builder. The next action calls the findDocuments method created by the Content Model Access builder. Finish the Actions builder input by returning the contents of the FolderSearchResults Variable. The following are the inputs to the Actions section of the builder. See figure 8.
      • Assignment!Variables/FolderSearchCriteria/FolderSearchCriteria=
        ${Arguments/searchCriteria}
      • DataServices/Folders/findDocuments
      • Return!${Variables/FolderSearchResults/FolderSearchResults}
    Figure 8. Actions for the getFolders Action List builder
    Actions for the getFolders Action List builder
  4. Add the Service Operation builder with the following settings. See figure 9.

    • In the Data Service field, select TrainingContent.
    • In the Operation Name and Action to Call fields, enter getFolders.
    • For Input Structure Handling, select the Specify input schema option.
    • In the Input Schema field, enter FolderSchema/FolderSearchCriteria.
    • For Result Structure Handling, select the Specify result schema option.
    • In the Result Schema field, enter FolderSchema/FolderSearchResults.
    Figure 9. getFolders Service Operation builder
    Figure 9. getFolders Service Operation builder

This completes the implementation of the getFolders service.

Creating the getDocuments service operation

The steps to create the getDocuments service are similar to those for the getFolders service. The only salient difference is that the Document Type in the Content Model Access builder for this service is com.ibm.content.lotus.model. CollaborativeDocument.

  1. Add the Content Model Access builder with the following inputs:

    • In the Name field, enter Document.
    • In the Document Type field, enter com.ibm.content.lotus.model.CollaborativeDocument.
    • In the Search Depth field, select the "Search only direct children of a path" option.
    • In the Search Type field, select the Match all documents option.
    • In the Max Documents field, enter 1000.
  2. Add an Action List builder with the following inputs:

    • In the Name field, enter getDocuments.
    • Under the Arguments section, specify an argument searchCriteria of IXml Data Type.
    • Specify the Return Type as IXml.
    • In the Actions section, enter the following actions:

      • Assignment!Variables/DocumentSearchCriteria/DocumentSearchCriteria=
        ${Arguments/searchCriteria}
      • DataServices/Document/findDocuments
      • Return!${Variables/DocumentSearchResults/DocumentSearchResults}
  3. Add the Service Operation builder to create the getDocuments Service with the following inputs:

    • In the Data Service field, enter TrainingContent.
    • In the Operation Name and Action to Call field, enter getDocuments.
    • For Input Structure Handling, select the Specify input schema option.
    • In the Input Schema field, enter DocumentSchema/DocumentSearchCriteria.
    • For Result Structure Handling, select the Specify result schema option.
    • In the Result Schema field, enter DocumentSchema/DocumentSearchResults.

This completes the implementation of the getDocuments service.

Creating the downloadDocument service operation

The Content Model Access builder creates a method named downloadDocumentContent that is used to download a document through the browser. Each document in Portal Document Manager has an ID associated with it that uniquely identifies it. The downloadDocumentContent method takes this ID as an input to determine the document to download. Follow these steps:

  1. Add an Action List builder with following inputs:

    • In the Name field, enter getDocumentDownload.
    • Under the Arguments section, enter an argument with Name as ID and Data Type as String.
    • Under the Actions section, enter the following Action items:

      • Assignment!Variables/DocumentGetCriteria/DocumentGetCriteria/DocumentID
        =${Arguments/id}
      • Document.downloadDocumentContent
  2. Add a Service Operation builder with the following inputs:

    • In the Data Service field, enter TrainingContent.
    • In the Operation Name field, enter downloadDocument.
    • In the Action to call field, enter getDocumentDownload.
    • For Input Structure Handling, select the "Use structure from called action" option.
    • For Result Structure Handling, select the No results option.

This completes the implementation of the downloadDocument service.

Creating the deleteDocument service operation

Creating the deleteDocument service is very similar to creating the downloadDocument service described in the previous steps.

  1. Add an Action List builder with following inputs:

    • In the Name field, enter deleteDocument.
    • Under the Arguments section, enter an argument with Name as ID and Data Type as String.
    • Under the Actions section, enter the following Action items:

      • Assignment!Variables/DocumentGetCriteria/DocumentGetCriteria/DocumentID=
        ${Arguments/id}
      • DataServices/Document/deleteDocument
  2. Add a Service Operation builder with the following inputs:

    • In the Data Service field, enter TrainingContent.
    • In the "Operation Name and Action to Call" field, enter deleteDocument.
    • For Input Structure Handling, select the "Use structure from called action" option.
    • For Result Structure Handling, select the No results option.

This completes the implementation of the deleteDocument service.

Creating the uploadDocument service operation

Implementing the uploadDocument service operation requires several builder calls. Each folder inside Portal Document Manager has a unique identifier associated with it; to upload a document to a folder, you first need to get the unique ID for that folder, and then specify other inputs to upload the document.

  1. Add a Method builder call with following inputs as shown in figure 10:

    • In the Name field, enter getIdForPath.
    • In the Arguments section, enter an argument with Name as pathXml and Data Type as IXml.
    • Specify the Return Type as String.
    • In the Method Body, add the Java code shown in listing 1.
    Figure 10. getIDForPath Method builder
    getIDForPath Method builder
Listing 1. Java code for getIDForPath Method builder
{
	String pathStr = pathXml.getText();
	String id = (String)webAppAccess.callMethod("Document.getIdForPath", pathStr);
		
	return id;
}
  1. Add an Action List builder to upload the document, and supply the following inputs:

    • In the Name field, enter uploadDocument.
    • Under the Arguments section, enter an argument with Name as documentDetails and Data Type as IXml.
    • Under the Actions section, enter the following Action items:

      • Assignment!Variables/DocumentWithCreateCriteria/DocumentWithCreateCriteria/
        Document=${Arguments/documentDetails}
      • Assignment!Variables/DocumentWithCreateCriteria/DocumentWithCreateCriteria/
        DocumentCreateCriteria/CollectionPropertyName=documents
      • Assignment!Variables/DocumentWithCreateCriteria/DocumentWithCreateCriteria/
        DocumentCreateCriteria/ParentID=${MethodCall/getIdForPath(${Variables/
        DocumentWithCreateCriteria/DocumentWithCreateCriteria/Document/path})}
      • Variables/DocumentWithCreateCriteria/DocumentWithCreateCriteria/Document/label=
        ${Variables/DocumentWithCreateCriteria/DocumentWithCreateCriteria/Document/title}
      • Assignment!Variables/DocumentWithCreateCriteria/DocumentWithCreateCriteria/
        Document/effectiveDate=2007-02-27T06:00:00.000Z
      • DataServices/Document/createDocumentWithCriteria


    Here is an explanation of the Action steps specified in the Action List builder.

    • The first input of the Action List builder assigns the documentDetails argument to the Document input of the createDocumentWithCriteria method created by the Content Model Access builder.
    • The second action sets the value of the CollectionPropertyName to constant named documents. This lets the method know that a document is to be uploaded to Portal Document Manager.
    • The third action sets the ID for the parent that identifies the folder where the document is to be uploaded. This step calls the method getIdForPath created previously.
    • The next action sets the document title for the document to be uploaded.
    • Next, you need to set the effective date from which the document is visible in Portal Document Manager. You can set it to any past date for the document to be visible immediately.
    • The last action is to call the createDocumentWithCriteria method of the Add a Final Actions builder input to call the createDocumentWithCriteria method of the Content Model Access builder.
  2. Open the Content Model Access builder call named Document, and under the Content Handling section shown in figure 11, enter the value for the File Upload Tag builder input as fileUpload. The other two inputs, Search Results Content Handling and Detail Content Handling, should have their default values. You later add the File Upload builder to the tag specified here in the Consumer model. The Content Model Access builder identifies the File Upload tag and uploads the document into Portal Document Manager as specified by the File Upload builder.
    Figure 11. Content Handling inputs for the Content Model Access builder
    Content Handling inputs for the Content Model Access builder
  3. Add the service operation with the following inputs:

    • In the Data Service field, enter TrainingContent.
    • In the "Operation Name and Action to Call" field, enter uploadDocument.
    • For Input Structure Handling, select the Specify input schema option.
    • In Input Schema, enter DocumentSchema/DocumentWithCreateCriteria/Document.
    • For Result Structure Handling, select the No results option.

This completes the creation of the TrainingContentProvider model. Your next step is to create the Training Consumer model that uses the services you created.

Creating the Training Consumer model

The Training Consumer model defines the user interface needed to view, browse, download, upload, and delete documents in Portal Document Manager through a portlet.

The following steps take you through the process of developing the Training Consumer model:

  1. Begin by adding a new model to the WebSphere Portlet Factory project.
  2. Add a Service Consumer builder to the model to access the services created by the TrainingContentProvider model. Use these settings:

    • In the Provider Model field, enter training/TrainingContentProvider.
    • Select the "Add All Provider Operations" option.
    • Click the Apply button on the builder.
  3. Next, add a Portlet Adapter builder call to add portlet support to the model. The Portlet Adapter builder input defines the name of the portlet in WebSphere Portal. The Portlet Adapter builder has the following inputs:

    • In the Name field, enter TrainingContent.
    • In the Portlet Title field, enter Training Content.
    • In the Portlet Description field, enter Displays Training Content contained in Portal documentManager.
    • In the Default Locale field, enter en.
    Figure 12. Portlet Adapter builder inputs
    Portlet Adapter builder inputs
  4. Add an Action List builder, and set the Name input to main. This is the first builder called when the portlet runs within a page. You add the Action List builder inputs for main in subsequent steps.

Defining common variables and methods

Follow these steps to define variables and methods:

  1. Add the two Variable builders named currentPath and rootPath of type String, respectively. Both variables initially should have the same initial value as /contentRoot/icm:libraries[22], which is the default root library path of Portal Document Manager.
  2. Add a Method builder call to navigate back to the parent folder after the user has drilled down into the folder structure. As the user navigates through the folder structure, the name of the current folder is concatenated to the currentPath variable. This method removes the current folder name from the currentPath variable when returning a path to the parent folder. The Method builder has the following inputs:

    • In the Name field, enter getParentPath.
    • Specify the Return Type as String.
    • Under the Import List section, add com.bowstreet.util.StringUtil to Imports.
    • In the Method Body, add the Java code shown in listing 2.
Listing 2. Java code for getParentPath Method builder
{
    String parentPath = null;
    
    final String rootPath = 
    StringUtil.normalize( webAppAccess.getVariables().getString( "rootPath" ) );
    String currentPath = 
    StringUtil.normalize( webAppAccess.getVariables().getString( "currentPath" ) );

	if( rootPath.equals( currentPath ) || currentPath == 
	null || currentPath.startsWith( rootPath ) == false )
		// If we are already at the root of the path or the 
		current path is null, then just return the root. 
		parentPath = rootPath;
	else
		// Return the current path with the last subpath removed.
	    parentPath = currentPath.substring( 0, currentPath.lastIndexOf( "/" ) );
    return parentPath;
}

Creating the content page

Follow these steps to create a content page:

  1. Add a Page builder to the model, and call it contentPage.
  2. Paste the HTML shown in listing 3 into the Page Contents builder input.
Listing 3. Content Page HTML content
<html>
    <body>
        <!-- As a best practice, change the form name to a unique name -->
        <form name="myForm" method="post">
            <div align="left">
            	<span name="namedTag"></span>
            	<table border="0">
            	      <tr>
            		<td width="90%"><b>Contents of Folder: <
            		span name="currentFolder" /></b></td>
            		<td width="10%"><span name="parent" /></td>
            	      </tr>
           	       <tr><td width="100%"><
           	       span name="folders" /></td></tr>
            	       <tr><td width="100%"> </td></tr>
            	       <tr><td width="100%"><
            	       span name="documents" /></td></tr>
            	       <tr>
            		<td width="90%"> </td>
            		<td width="10%"><
            		span name="uploadDocumentButton" /></td>
            	       </tr>
          	</table> 			
            </div>
        </form>
    </body>
</html>
  1. Add another Action List builder to call the Service Provider to obtain a listing of folders and documents for the current path with the following inputs:

    • In the Name field, enter getFoldersAndDocuments.
    • Under Actions, enter the following:

      • Assignment!Variables/ServiceConsumerGetFoldersInputs/FolderSearchCriteria/
        SearchPaths/Path=${Variables/currentPath}
      • Assignment!Variables/ServiceConsumerGetDocumentsInputs/DocumentSearchCriteria/
        SearchPaths/Path=${Variables/currentPath}
      • DataServices/ServiceConsumer/getFolders
      • DataServices/ServiceConsumer/getDocuments
      • contentPage
  2. Next, reopen the main Action List builder that you created previously, and add a call to the getFoldersAndDocuments Action List in the main builder.

Displaying the folders list

Follow these steps to display the folders list.

  1. Add a Data Page builder to display the list of folders returned by the getFoldersAndDocuments Action List. Configure the Data Page builder call to write its data to the folders' <span> tag of the contentPage created earlier. This builder renders the FolderSearchResults variable that is populated by the call to the getFolders service operation. See figure 13. Use the following inputs:

    • In the Name field, enter foldersDataPage.
    • In the Variable field, enter Variables/ServiceConsumerGetFolderResults/
      FolderSearchResults.
    • In the Page in Model field, enter contentPage.
    • In Location for New Tags field, enter folders.
    • Leave all other fields with their default values.
    Figure 13. Data Page builder inputs to display the folder list on the Content Page
    Data Page builder inputs to display the folder list on the Content Page
  2. Add a Data Column Modifier builder to hide all columns except the title generated by the call to the Data Page builder created in the previous step.
  3. Add an Image builder to display a folder image before the folder title on the portlet. See figure 14. Use the following inputs:

    • In the Name field, enter folderImage.
    • Choose Location Technique as Relative to Named Tag.
    • In the Page field, enter contentPage.
    • In the Tag field, enter title.
    • In the Placement field, enter Before.
    • In the Image Source field, enter /training/images/folder.gif.
    Figure 14. Image builder inputs
    Image builder inputs
  4. Add an Action List builder that creates an action to allow the user to navigate folders in Portal Document Manager on the portlet. The builder has the following inputs:

    • In the Name field, enter navigateFolders.
    • Under the Arguments section, enter an argument with Name as path and Data Type as String.
    • Under Actions, enter the following:

      • Assignment!Variables/currentPath=${Arguments/path}
      • getFoldersAndDocuments
  5. Add a Link builder call to the title tag created by the Data Page builder previously to link-enable each folder title and allow users to navigate to the contents of a folder. This link invokes the navigateFolders Method builder call you created previously, and it passes the folder path to the Action List. See figure 15. . Use following inputs:

    • In the Name field, enter foldersLink.
    • In the Page field, enter contentPage.
    • In the Tag, enter title.
    • In the Link text field, enter ${Variables/FolderLoopVar/Folder/title}.
    • Select Action type as Link to an action.
    • In the Action field, enter navigateFolders.
    • Under the Arguments Section, for input Mappings, enter the following:

      • In the Name field, enter id.
      • In the Value field, enter ${Variables/FolderLoopVar/Folder/path}.
    Figure 15. Link builder inputs
    Link builder inputs
  6. Add an Action List builder call named getParentNode, which enables the user to navigate to the parent folder and view its contents. The builder has following inputs:

    • In the Name field, enter getParentNode.
    • Under Actions, enter the following:

      • Assignment!Variables/currentPath=${MethodCall/getParentPath}
        getFoldersAndDocuments
  7. Add a Button builder call with following settings:

    • In the Name field, enter goOneLevelUpButton.
    • In the Page field, enter contentPage.
    • In the Tag field, enter parent.
    • In the Label field, enter "Go One Level Up."
    • Select the Action Type as Submit form and invoke action.
    • Select Action as getParentNode.

Displaying the document list

So far you have implemented the steps to show folders in Portal Document Manager on your portlet. The following steps add support for displaying a list of documents for a given folder in the portlet.

  1. Add a Data Page builder to display the list of documents and write its data to the documents <span> tag of the contentPage you created earlier. This builder renders the DocumentSearchResults variable, which is generated by WebSphere Portlet Factory as a result of the getDocuments service operation. Figure 16 identifies the settings relevant to this builder.

    • In the Name field, enter documentDataPage.
    • In the Variable field, enter Variables/ServiceConsumerGetDocumentsResults/
      DocumentSearchResults.
    • In the Page in Model field, enter contentPage.
    • In the Location for New Tags field, enter documents.
    • Leave all other fields with their default values.
    Figure 16. Data Page builder inputs to display document list on Content Page
    Data Page builder inputs to display document list on Content Page
  2. Add a Data Column Modifier builder to hide all columns except Document_title and Document_description created by the Data Page added in the last step.
  3. Add an Image builder to display a document image before the document title on the portlet.

Downloading a document

This section outlines the steps required to download a document through a Web browser from your portlet.

  1. Add an Action List builder with following inputs:

    • In the Name field, enter downloadDocument.
    • Under the Arguments section, enter an argument with Name as ID and Data Type as String.
    • Under Actions, enter the following:

      • Assignment!Variables/ServiceConsumerDownloadDocumentInputs/arguments/
        id=${Arguments/id}
      • DataServices/ServiceConsumer/downloadDocument
      • contentsPage
  2. Add a Content Launch Action builder call to enable the user to download the document from Portal Document Manager. Set the Page Location builder input to act on the contentPage Document_title tag. The builder call invokes the downloadDocument Action List builder you created in the previous step. See figure 17.

    • In the Name field, enter downloadDocumentLink.
    • In the Page field, enter contentPage.
    • In the Tag field, enter Document_title.
    • In the Link text field, enter ${Variables/DcoumentLoopVar/Document/title}.
    • Select Page Control Type as Link.
    • Select Action type as Link to an action.
    • In the Content Load Action field, enter downloadDocument.
    • Under the Arguments Section, for input Mappings, enter the following:

      • In the Name field, enter id.
      • In the Value field, enter ${Variables/DocumentLoopVar/Document/id}.
      • Under the Content Response Description section, in the field Content type, enter
        ${Variables/DocumentLoopVar/Document/dataMimeType}.
    Figure 17. Content Launch Action builder inputs
    Content Launch Action builder inputs

Deleting a document

This section outlines the steps required to delete a document through your portlet in Portal Document Manager.

  1. Add an Action List builder with following inputs:

    • In the Name field, enter deleteDocument.
    • Under the Arguments section, enter an argument with Name as ID and Data Type as String.
    • Under Actions, enter the following:

      • Assignment!Variables/ServiceConsumerDeleteDocumentInputs/arguments/
        id=${Arguments/id}
      • DataServices/ServiceConsumer/deleteDocument
      • getFoldersAndDocuments
  2. Add a Delete column to the Document Data Page using the Data Column Modifier you added earlier.
  3. Add an Image Button builder call to the Delete column. This builder call passes the document ID as a parameter and calls the deleteDocument Action List you created earlier.

Uploading a document

This section outlines the steps required to upload a document through your portlet in Portal Document Manager.

  1. Add a Page builder to the model, and call it uploadDocumentPage.
  2. Paste the HTML shown in listing 4 into the Page Contents builder input.
Listing 4. Upload Document Page HTML content
<html>
        	<body>
		<table cellpadding="0" cellspacing="2">
		    <form name="input_form" method="POST">
		    <tr>
            			<td><b>Current Folder: <
            			span name="currentFolder" /></b></td>
           		     </tr>
   		      <tr>	<td><span name="input_data" /></td>
   		             </tr>
    		       <tr><td><span name="submit_button" /><
    		       span name="cancel_button" /></td></tr>
    		       <tr><td> </td></tr>
		    </form>
		</table>
	</body>
         </html>
  1. Add a Button builder call to the uploadDocumentButton <span> tag of the contentPage with action specified as uploadDocumentPage created in the previous step.
  2. Add a Data Page builder call to the uploadDocumentPage with Page Type input as Data Entry that hooks into the inputs of the uploadDocument service in the TrainingContentProvider model. This creates an input form that allows the user to enter the details of a document to be uploaded to Portal Document Manager. See figure 18.

    • In the Name field, enter uploadDocumentDataPage.
    • In the Variable field, enter Variables/ServiceConsumerUploadDocumentInputs/
      Document.
    • In the Page in Model field, enter uploadDocumentPage.
    • Select Page type as Data Entry.
    • In the Location for New Tags field, enter input_data.
    • Leave all other fields with their default values.
    Figure 18. Upload Document Data Page builder inputs
    Upload Document Data Page builder inputs
  3. Add the Document Column Modifier builder call, and configure its inputs to hide all fields except title, description, and the dataMimeType created by the Data Page in the previous step.
  4. Add the File Upload builder call to the uploadDocumentPage to enable the user to upload documents to the Portal Document Manager. Remember that the <span> tag on which you place the File Upload builder call is the same as specified in the Content Model Access builder when creating the uploadDocument Service in the TrainingContentProvider model. See figure 19.

    • In the Name field, enter fileUpload.
    • Select Location Technique as Relative to Named Tag.
    • In the Page field, enter uploadDocumentPage.
    • In the Tag field, enter OuterTable.
    • In the Placement field, enter After.
    • In New Tag Name field, enter fileUpload.
    Figure 19. File Upload builder inputs
    File Upload builder inputsNOTE: For the File Upload builder to work, you need to add the following properties to cluster.properties in the WEB-INF/config folder of your project.

    # File Upload Builder
    bowstreet.upload.enabled=true

    # This determines the maximum file size that can be uploaded KiloBytes.
    bowstreet.upload.maxFileSizeK=5000000
  5. Add an Action List builder with following inputs:

    • In the Name field, enter uploadDocumentAction.
    • Under Actions, enter the following:

      • Assignment!Variables/ServiceConsumerUploadDocumentInputs/Document/
        path=${Variables/currentPath}
      • DataServices/ServiceConsumer/uploadDocument
      • getFoldersAndDocuments
    NOTE: You do not need to explicitly set the other builder inputs that you entered for uploading the document to the uploadDocument service because the Data Page is created from the service inputs variable. When you submit the form, these service inputs are already set as service inputs.
  6. Add two buttons, Submit and Cancel, respectively, to the uploadDocumentPage.

    • The Submit button calls the uploadDocumentAction Action List, which further uploads the document to Portal Document Manager and redirects the user to the contentPage.
    • The Cancel button redirects the user to the contentPage without uploading the document to Portal Document Manager.

This completes the Training Content portlet. Please refer to the sample code that is included with this article to see these models in their entirety.

Conclusion

WebSphere Portlet Factory V6.0.1 gives you new content builders that let you access content in Portal Document Manager and surface it in a portlet. There are a few things to keep in mind when using these builders.

  • The Content Model Access builder can be used only to access content in Portal Document Manager and not in IBM WebSphere Content Management. A separate set of builders will be available for WebSphere Content Management in WebSphere Portlet Factory V6.0.2.
  • The Content Model Access builder will be renamed to Portal Document Manager Access in WebSphere Portlet Factory V6.0.2.

Download

DescriptionNameSize
Code sampleTrainingSampleApplication.zip14KB

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=280786
ArticleTitle=Integrating IBM WebSphere Portlet Factory V6.0.1 with IBM WebSphere Portal Document Manager
publish-date=01092008