Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • IBM Digital Experience wiki
  • All Wikis
  • All Forums
  • ANNOUNCEMENT: WIKI CHANGE TO READ-ONLY. LEARN MORE...
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
  • API Documentation
Search
Community Articles > WebSphere Portal > PUMA (Portal User Management Architecture) Scenarios
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

Click to view profilesiva r vaka
Contribution Summary:
  • Articles authored: 14
  • Articles edited: 14
  • Comments Posted: 12

Recent articles by this author

Displaying feeds using Digital Data Connector - Yahoo News Demo using DDC

This article demonstrates how to display news feed(yahoo) in portal without any coding required.

PUMA API Scenarios - Portal User Management Architecture

This article talks more about not so frequently discussed PUMA related scenarios with code samples

Adding Personalization (PZN) dynamic attribute using script (xml / .nodes)

This article explains how to create the personalization (PZN) dynamic attribute using the script (XML.nodes) . I couldn't find anything related to this on the infocenter or in product help, so thought to post this here and this can be helpful if anybody looking on same lines.

Clear all websphere portal dyna caches (distributedmap) with one click

This article explains how to clear the all websphere dynacaches with single click by injecting small code piece into JSP

Customize WCM Workflow Notification Email Body

This article explains how to enable, configure and customize WCM workflow emails . Sample code attached in attachment section (Sample code is written for demo purpose only)
Community articlePUMA (Portal User Management Architecture) Scenarios
Added by siva r vaka on December 28, 2014 | Version 1
expanded Abstract
collapsed Abstract
This article talks more about not so frequently discussed PUMA related scenarios with code samples
Tags: IBM PUMA, IBM Portal User Management Architecture (PUMA), WebSphere Portal PUMA, WebSphere Portal User Management API, PUMA API, PUMAHome, PumaLocator.findUsersByQuery
ShowTable of Contents
HideTable of Contents
  • 1 Description
  • 2 Accessing the PUMA from webapp that is deployed on the portal
  • 3 Searching for multiple users by passing the list of uid's without using the wildchars
  • 4 Using Paged Search in PUMA
  • 5 References
  • 6 Author

Description

This article talks more about not so frequently discussed PUMA related scenarios with code samples

1.        Accessing the PUMA from webapp that is deployed on the portal (not part of themes or portlets)

        a.       If user doesn't have the portal security context in request 

        b.      Want to execute the PUMA as system user (where you want to access to all users)

 

2.        Searching for multiple users by passing the list of uid's without using the wildchars ( search using wildchar may returns thousands of results ) 

       a.       Searching the users based on the multiple attributes 

       b.      Retrieving multiple user objects using 'OR' condition like uid='user1' or uid='user2'

       c.       Retrieving users without using the wildcard chards

 

3.        Using Paged Search in PUMA

       a.       To handle large result sets returning from the LDAP.

Accessing the PUMA from webapp that is deployed on the portal


      /*


      * <p>Execute as authenticated admin user(retrieve users without login to portal)</p>



      * <p> You can return the list of users instead of printing them by just uncommenting couple of statement in this method </p>



      */



     //public List<User> getUsersByLastName(final String lastName) throws Exception{



     public String printUsersByLastName(final String lastName) throws Exception{



                 



          final PumaLocator pumaLocator = pumaHome.getLocator();



          final PumaProfile pumaProfile = pumaHome.getProfile();



         



          final List<String> attribList = new ArrayList<String>();



          attribList.add("uid");



          attribList.add("cn");



          attribList.add("sn");



        



          //final List<User> usersList = new ArrayList<User>();



          final StringBuffer sb = new StringBuffer();



   PrivilegedExceptionAction<Void> privilegedAction = new PrivilegedExceptionAction<Void>() {



  



        @Override



        public Void run() {



          try{



            //search users who have the same last name i.e users with last name as "vaka"



            List<User> users = pumaLocator.findUsersByAttribute("sn", lastName);



            //usersList.addAll(users);



            for(User user : users){



            Map<String, Object> attributesMap = pumaProfile.getAttributes(user, attribList);



            for (Map.Entry<String, Object> entry : attributesMap.entrySet()) {



               sb.append(entry.getKey() + " : " + entry.getValue() +" , \t");



            }



            sb.append("\n").append("</br>");



          }



          }catch(Exception ex){



               System.err.println("Error while gettting the users from the PUMA");



          }



              return null;



          }



         };



 



         try {



              PumaEnvironment pumaEnv = pumaHome.getEnvironment();



              pumaEnv.runUnrestricted(privilegedAction);



         } catch (PrivilegedActionException ex) {



              System.err.println("error while executing the previleged action");



              ex.printStackTrace();



         }



        



         //return usersList;



         return sb.toString();



     }


Searching for multiple users by passing the list of uid's without using the wildchars


/*



 * <p> Execute the FindUsersByQuery with or condition(retrieve users without login to portal)</p>



 * <p> You can return the list of users instead of printing them by just uncommenting couple of statement in this method </p>



 */



 //public List<User> getListOfUsers(List<String> userIds) throws Exception{



 public String printListOfUsers(List<String> userIds) throws Exception{



        



          final PumaLocator pumaLocator = pumaHome.getLocator();



          final PumaProfile pumaProfile = pumaHome.getProfile();



         



          final List<String> attribList = new ArrayList<String>();



          attribList.add("uid");



          attribList.add("cn");



          attribList.add("sn");



        



          //final List<User> usersList = new ArrayList<User>();



          final StringBuffer usersDetailsStr = new StringBuffer();



         



          if(null == userIds || 0 == userIds.size()) return "Empty userIds List passed";



          final StringBuilder userIdsListQuery = new StringBuilder();



          int i = 0;



          if( 1 == userIds.size() ){



                userIdsListQuery.append("(uid='"+userIds.get(0)+"*')");



          } else {



               for (String uid : userIds) {



                    if(i == 0) {



                    userIdsListQuery.append("((uid='"+uid+"*') or ");



                    }else if(i == userIds.size()-1)



                    userIdsListQuery.append("(uid='"+uid+"*'))");



                    else



                    userIdsListQuery.append("(uid='"+uid+"*') or ");



                    ++i;



                }



          }



                



   PrivilegedExceptionAction<Void> privilegedAction = new PrivilegedExceptionAction<Void>() {



     @Override



     public Void run() {



       try{



 



        List<User> users = pumaLocator.findUsersByQuery(userIdsListQuery.toString());



        //usersList.addAll(users);



        for(User user : users){



           Map<String, Object> attributesMap = pumaProfile.getAttributes(user, attribList);



           for (Map.Entry<String, Object> entry : attributesMap.entrySet()) {



              usersDetailsStr.append(entry.getKey() + " : " + entry.getValue() +" , \t");



           }



           usersDetailsStr.append("\n").append("</br>");



        }



                



      }catch(Exception ex){



         System.err.println("Error while gettting the users from the PUMA");



      }



         return null;



     }



    };



 



         try {



              PumaEnvironment pumaEnv = pumaHome.getEnvironment();



              pumaEnv.runUnrestricted(privilegedAction);



         } catch (PrivilegedActionException ex) {



              System.err.println("error while executing the previleged action");



              ex.printStackTrace();



         }



        



         //return usersList;



         return usersDetailsStr.toString();



     }



Using Paged Search in PUMA


    /*



      * Print All users (using the paged search)



      * <p> You can return the list of users instead of printing them by just uncommenting couple of statement in this method </p>



      */



     //public List<User> getAllUsers() throws Exception{



     public String printAllUsers() throws Exception{



                



          final PumaLocator pumaLocator = pumaHome.getLocator();



          final PumaProfile pumaProfile = pumaHome.getProfile();



         



          //Page size is 5



          final Map<String, Object> configMap = new HashMap<String, Object>();



          configMap.put(PumaLocator.RESULTS_PER_PAGE, new Integer(5));



         



          final List<String> attribList = new ArrayList<String>();



          attribList.add("uid");



          attribList.add("cn");



          attribList.add("sn");



        



          //final List<User> usersList = new ArrayList<User>();



          final StringBuffer sb = new StringBuffer();



              



          PrivilegedExceptionAction<Void> privilegedAction = new PrivilegedExceptionAction<Void>() {




  @Override


  public Void run() {



  try{



   //you can use findUsersByQuery or findUsersByAttribute



   //PagingIterator<User> users=pumaLocator.findUsersByQuery("uid='*'", configMap);



   PagingIterator<User> users=pumaLocator.findUsersByAttribute("uid", "*", configMap);



   List<User> temp = new ArrayList<User>();



   while(users.hasNextPage()){



      temp = users.getNextPage(temp);



      //usersList.addAll(temp);



      if(null != temp && 0 < temp.size()){



         for (User user : temp) {                                          



 Map<String, Object> attributesMap = pumaProfile.getAttributes(user, attribList);



      for (Map.Entry<String, Object> entry : attributesMap.entrySet()) {



        sb.append(entry.getKey() + " : " + entry.getValue() +" , \t");



      }



      sb.append("\n").append("</br>");



     }



    }



   }                      



                  



  }catch(Exception ex){



     System.err.println("Error while gettting the users from the PUMA");



  }



  return null;



 }



 };



 



         try {



              PumaEnvironment pumaEnv = pumaHome.getEnvironment();



              pumaEnv.runUnrestricted(privilegedAction);



         } catch (PrivilegedActionException ex) {



              System.err.println("error while executing the previleged action");



              ex.printStackTrace();



         }



        



         //return usersList;



         return sb.toString();



 


     }



 

IBM PUMA Scnearios Output

References

To download/browse sample code related to this visit  blog.sivavaka.com

Author

Thanks & Regards
Siva R Vaka
Senior Websphere Portal & WCM Consultant
Siva R Vaka's Blogexternal link

expanded Attachments (0)
collapsed Attachments (0)
expanded Versions (4)
collapsed Versions (4)
Version Comparison     
VersionDateChanged by              Summary of changes
4Dec 28, 2014, 4:33:15 PMsiva r vaka  
3Dec 28, 2014, 4:31:20 PMsiva r vaka  
2Dec 28, 2014, 4:29:11 PMsiva r vaka  
This version (1)Dec 28, 2014, 4:27:54 PMsiva r vaka  
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • FacebookIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkThe Social Lounge
  • Wiki Help
  • Forgot user name/password
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use