FPN - Consumer & Producer favorites on the same window

Found this useful post on SCN Posted by Piyush kumar in SAP NetWeaver Portal: Administration and Development


 This custom application will give access to consumer as well as producer favorites (In FPN Scenario) on the same page in consumer Portal. So in this way we can avoid the two portal favorite windows on consumer portal.
In my case  Enterprise Portal (EP) is the Consumer Portal and the BI Portal is the Producer Portal. 

Note: I assume members who are following this blog, know the Par application development using Abstract Portal Component and reading KM documents from Par file .

Symptom /Problem Details:

When we use a Federated Portal Network where the Enterprise Portal (EP) is the Consumer Portal and the BI Portal is the Producer Portal.  Users access BI Reports from the Enterprise Portal (Consumer Portal) through RRA or RDL.
BI Report’s “Save As" functionality allows us to save a BI report as a   "KM Bookmark” which will be available in Portal Favorite list, But when we save BI reports as favorite it gets saved in Producer Portal  and we do not see the bookmarks in Consumer Portal Favorite list. So if we want to access the BI bookmarks then we need to have two Favorite windows in our Consumer Portal as shown in below picture.


pastedImage_4.png
              Image -1



Because of this we often face issue as Customers are not ready to accept two Favorite windows in Portal.   Even it creates confusion for End Users .

Solution:
This solution is mainly dived in two steps:
  1. WebDAV Repository creation
  2. Par Application development , Which will read the bookmarks from created repository

1. WebDAV Repository creation:
To Create KM repository for Producer Portal in Consumer Portal, we need to created
  1. First we create HTTP System
  2. Then we create Cache for the WebDAV Repository
  3. At last step we create WebDAV Repository Manager

  1. Creating  a Http system  - SAP Help URL
  2. Creating a Cache for the WebDAV Repository - SAP Help URL
  3. Creating a WebDAV Repository Manager - SAP Help URL

2. Par Application development:
This is the final step of proposed solution;in this step we create the par application which will read the bookmarks from created repository.
Note:
  • While creating Par application we select Abstract Portal Component
  • In portalapp.xml we need to use com.sap.portal.htmlb, com.sap.km.application,usermanagement, knowledgemanagement as Sharing Reference.

Development overview:
After creating par project/Object, get the logged in user
  1. IUseruser=request.getUser();  
  2. com.sapportals.portal.security.usermanagement.IUserep5User=  
  3.  WPUMFactory.getUserFactory().getEP5User(user);  
  4. Stringuid=request.getUser().getUniqueName();  

After getting logged in user we need to read the Consumer bookmarks and producer bookmarks (Which is now available in Consumer KM repository, by following step 1 “WebDAV Repository creation”
As we know Portal Bookmarks/Favorites path will be fixed - /userhome/user_id/favorites
So using the uid from above code read the Consumer bookmarks from below path
favLoc = “/userhome/"+uid+"/favorites”;
And suppose we created the WebDAV Repository called “producer_home” in Consumer Portal from Step 1 then read the Producer bookmarks from below path
favLoc = "/producer_home/"+uid+"/favorites";
Code for reading bookmarks from KM:

  1. ResourceContextctxt = null;  
  2. RID resRid = RID.getRID(favLoc);                          
  3. ICollectioncurrentFolder = null;              
  4. currentFolder = (ICollection) com.sapportals.wcm.repository.ResourceFactory.getInstance().  
  5.                             getResource(resRid, ctxt);      
  6.   
  7. if(currentFolder != null)   
  8. {                  
  9.     IResourceList children = null;  
  10.     children = currentFolder.getChildren();                  
  11.     IResourceListIterator it = children.listIterator();  
  12.       while (it.hasNext())   
  13.       {                                                                             
  14.         com.sapportals.wcm.repository.IResourcechildRes = it.next();  
  15.   
  16.         try{                                          
  17.                 IPropertyMaphm = childRes.getProperties();                                      
  18.                 IPropertyIteratoriter = hm.iterator();                                      
  19.                 IPropertyNamepropName = null;                                      
  20.                 String uri = "";  
  21.   
  22.                 while(iter.hasNext())  
  23.                     {  
  24.                         propName = ((IProperty)iter.next()).getPropertyName();  
  25.   
  26.                         if(propName.getName().equalsIgnoreCase("contentlink"))  
  27.                         {  
  28.                             uri = ((IProperty)childRes.getProperty(propName)).getStringValue();  
  29.                             String strFavName = childRes.getDisplayName();  
  30.   
  31.                      //Here uri will hold the url for bookmark and strFavName will hold display name of bookmark  
  32.   
  33.   response.write("Here create the Hyper link -- where href = uri and display name= strFavName");  
  34.                             break;  
  35.                          }  
  36.                     }  
  37.             }      
  38.         catch (Exception e)  
  39.          {                                      
  40.             //response.write(e.getLocalizedMessage());  
  41.             //response.write(e.toString());  
  42.             e.printStackTrace();  
  43.   
  44.          }  

Output:

      Fav_App.png

                                                         Image -2
In above image we can see that BI bookmarks as well as Consumer portal bookmarks are available in same page. We can compare BI bookmarks from Image -1
Functionality which are different from Standard Portal Favorite Application
As Standard Portal Favorite Application is for one Portal only i.e. all the favorite get stored at same server itself and for our scenario Consumer favorite gets stored at Consumer server and BI reports which comes from Producer Portal gets stored at Producer portal.
So here in our custom application we will have two menus for “Organize Favorites” functionality.  One menu will point to Consumer maintenance window and other menu will point to Producer maintenance window (Created KM Repository). Which is shown in above image (Organize Portal Favorites & Organize BI Favorite Reports)
We use below code to add Context Menu Option to Tray
/*
* Tray Menu Option for Consumer
*/
  1.       response.write("<script defer=\"defer\">");  
  2.       response.write("try {");  
  3.       response.write("if (!window.pageSupport) { ");  
  4.       response.write("if (parent.pageSupport) {");  
  5.       response.write("varmyId = parent.pageSupport.getIvuId(self);");  
  6.       response.write("parent.pageSupport.ivuAddTrayOption(myId , \"Organize Portal favourites\" ,   
  7.                      \"addTrayOptionEditFavorite()\");");  
  8.       response.write("} }");          
  9.       response.write("  } catch(e){ }");  
  10.       response.write("</script>");  
  11.       response.write("<script> ");  
  12.       response.write("function addTrayOptionEditFavorite() {window.open('"+manageConsumer+"',   
  13.                       'myFavWin' ,'toolbar=no, status=no, menubar=no,resizable=yes, scrollbars=yes,   
  14.                        width=800, height=600'); }");  
  15.       response.write("</script> ");  

Where
  1. manageConsumer="/irj/go/km/navigation/userhome/"+uid+"/favorites?StartUri=/userhome/"+uid+"/  
  2.                                    favorites&rndLayoutSet=PortalFavoritesMaintenance&layoutSetMode=exclusive";  

/*
* Tray Menu Option for Producer
*/

  1. response.write("<script defer=\"defer\">");  
  2. response.write("try {");  
  3. response.write("if (!window.pageSupport) { ");  
  4. response.write("if (parent.pageSupport) {");  
  5. response.write("varmyId = parent.pageSupport.getIvuId(self);");  
  6. response.write("parent.pageSupport.ivuAddTrayOption(myId , \"Organize BI favourite Reports\" ,   
  7.                 \"addTrayOptionEditFavoritePro()\");");  
  8. response.write("} }");          
  9. response.write("  } catch(e){ }");  
  10. response.write("</script>");  
  11. response.write("<script> ");  
  12. response.write("function addTrayOptionEditFavoritePro() {window.open('"+manageProducer+"',   
  13.                 'myFavWin' ,'toolbar=no, status=no, menubar=no,resizable=yes,   
  14.                  scrollbars=yes, width=800, height=600'); }");  
  15. response.write("</script> ");  

Where
  1. manageProducer="/irj/go/km/navigation/producer_home/"+uid+"/favorites?StartUri=/ producer_home/"  
  2.                   +uid+"/favorites&rndLayoutSet= PortalFavoritesMaintenance&layoutSetMode=exclusive";  



No comments:

Post a Comment