Showing posts with label Theme. Show all posts
Showing posts with label Theme. Show all posts

Friday, June 17, 2016

Create a url to change language on Portal

You can use following code to change the language on Portal.
<portal-navigation:url command="ChangeLanguage">
  <portal-navigation:urlParam name="locale" value="<language>"/>
</portal-navigation:url>
 
There was a problem with this when navigational state is cleared. 
This happens if  bookmarks to friendly URLs are used for navigation or 
the navigational state is cleared intentionally.
 
You can this technique to store language value in cookie temporarily and 
It sets the locale information, if no locale information can be 
found in the navigational state.
 
Configure cookie support language using this 
url: http://www-01.ibm.com/support/docview.wss?uid=swg1PM17679
 

Tuesday, December 18, 2012

Portal v8 Modular Theme : Changing the Theme profile for a page

The default profile for the Portal8 theme is profiles/profile_deferred.json but you can override it at page level by setting the value of resourceaggregation.profile to different profile for example i can set it to profiles/profile_lightweight.json like this

Once you set that and access the page you will see that it does not have page action button any more.


Actually I was looking for this kind of user interface for selecting Theme Profile but with my Portalv8.0 installation without any fixpack this option is not coming for selection in Edit Page properties option



Tuesday, June 26, 2012

Pagebuilder2 theme and skin setup


  1. Download WebDav client - http://www.jscape.com/products/file-transfer-clients/anyclient and setup following url
http://localhost:10039/wps/mycontenthandler/dav/themelist/
http://localhost:10039/wps/mycontenthandler/dav/skinlist/
http://localhost:10039/wps/mycontenthandler/dav/fs-type1/
  1. Connect webdav to http://localhost:10039/wps/mycontenthandler/dav/themelist/
  2. Copy the existing theme pagebuilder2 'csa2.theme' folder to local drive
  3. Rename the csa2.theme folder to folder say csa2.Mytech, the csa2.Mytech will be used as uniqueName for theme
  4. Open the C:\Temp\csa2.Mytech\metadata\localized_en.properties file in the Notepad and change the value of title property
    #
#Fri Feb 24 21:49:19 IST 2012
description=Mytech PageBuilder2 Theme
title=MytechTheme

  1. Now use the WebDav client to upload the csa2.Mytech folder onto WebDav store at /themelist url
  2. Connect webdav to http://localhost:10039/wps/mycontenthandler/dav/skinlist/
  3. Copy the existing skin 'csa2.standard' folder to local drive
  4. Rename the csa2.standard folder to folder say csa2.MyTechSkin, the csa2.MyTechSkin will be used as uniqueName for skin
  5. Open the C:\temp\csa2.MyTechSkin\metadata\localized_en.properties file in the Notepad and change the value of title property
#
#Wed Mar 14 11:26:40 IST 2012
description=MyTech Skin
title=MyTechSkin

  1. Now use the WebDav client to upload the csa2.MyTechSkin folder onto WebDav store at / skinlist url
  2. Now you should able to see the new theme (MytechTheme) new skin (MyTechSkin) in the themes and skins admin portlet. But dynamic resources are still pointing to pageBuilder2 theme.
Note - If you don't see your theme and skin name here then that means the name is cached somewhere you can either restart the server or click on Add New Theme button and create new theme from there to see your theme name.
To customize theme or skin, need to edit the theme or skin files in WebDAV. To perform administrative customization (title, description, metadata) continue to use the /themelist or /skinlist entry point. If you want to customize the templates and static resources, use the /fs-type1/ entry point.
  1. Create war file based on the pagebuilder.war (location is \IBM\WebSphere\PortalServer\theme\wp.mashup.cc.theme\installedApps\wp.mashup.cc.theme.ear\PageBuilder2.war  )
a)      Create a new dynamic project 2.4 named 'MytechTheme'
b)      Copy the contents of the original PageBuilder2 theme from the directory PortalServer/theme/wp.mashup.cc.theme/installedApps/wp.mashup.cc.theme.ear/PageBuilder2.war into a new WAR directory.
c)       Change the name of the PageBuilder2 directory (in ./themes/html/) to a name MytechTheme
d)      Remove the plugin.xml file from the WEB-INF directory but do not remove the decorations.xml file or the tld directory.
e)      Change the display-name in the web.xml file to a name MytechTheme
f)       Change the attribute in the ibm-web-bnd.xmi and the ibm-web-ext.xmi files to match the above name.
g)      Package this directory into a new WAR file and deploy the war file to WebSphere Application Server with your own contextroot (/Mytechtheme) while installing, make sure to start the application after installation.
Note - there will be numerous compilation error on jsps just ignore them and deploy, it will get resolve automatically.
  1. Follow the steps below to connect the theme with context root of installed WAR file
a.       Export the existing themes and skins using the attached xmlaccess script 'ExportAllSkin_Theme.xml '. Use following command ' xmlaccess -url http://localhost:10039/wps/config -in ExportAllSkin_Theme.xml -out ExportSkinTheme.xml '
                                                               i.      Find the new theme and skin created in above steps and change the active='true', context-root and resourceroot attributes to match new WAR file. Add a uniquename and defaultskinref to theme. Find the modified XMLAccess in attachment 'MytechSkin_Theme.xml '.
                                                             ii.      Ensure that the default attribute is set to false.
                                                            iii.      Remove all the other tags from the xml file and import the modified file using xmlaccess.
b.      Change all the dynamic-content spots in csa2.Mytech\theme.html and csa2.Mytech\nls\theme_en.html to point to the dynamic resources in your new WAR file.
                                                               i.      <link rel="dynamic-content" href="dyn-cs:id:head@tl:oid:csa2.theme"> replace with following   <link rel="dynamic-content" href="res:/Mytechtheme/themes/html/MytechTheme/head.jsp">
                                                             ii.      Do the same for the remaining jsp's using following path.
                res:/Mytechtheme/themes/html/MytechTheme/bannerNav.jsp
                res:/Mytechtheme/themes/html/MytechTheme/search.jsp
                res:/Mytechtheme/themes/html/MytechTheme/bannerCommonActions.jsp
                res:/Mytechtheme/themes/html/MytechTheme/status.jsp
                res:/Mytechtheme/themes/html/MytechTheme/tabNav.jsp
                res:/Mytechtheme/themes/html/MytechTheme/pageToolbar.jsp
                res:/Mytechtheme/themes/html/MytechTheme/asa.jsp
                res:/Mytechtheme/themes/html/MytechTheme/config.jsp
c.       Now use the WebDav client to upload the csa2.Mytech folder onto WebDav store at / fs-type1 url
  1. Assign MytechTheme theme to page (page properties-->select this theme)

Troubleshooting
Problem:  The context-root of your new web application can't be found
Solution: Make sure you started the new enterprise application.  Also, if you are accessing the portal via the Web server then make sure you re-generated the plugin file and distributed it to the web servers.  Also, make sure you mapped the WAR module to both your Portal server and your web server.

Problem: Your xmlacces import changed the base PageBuilder2 theme
Solution: Import the XML file from the export of all themes. This should restore all themes to their original state.

Problem: Updating the theme war after initial deployment causes errors (typically with com.ibm.wps.resolver.data.exceptions.URIProcessingIOException: EJCBD0021E)
Solution: Try changing the cache.expiration for themes and skins to 30 seconds on the WP Config Service resource environment provider (stop and restart portal). For example:

filestore.cache.expiration.0.re=themes/.*
filestore.cache.expiration.0.seconds=30

filestore.cache.expiration.0.re=skins/.*
filestore.cache.expiration.0.seconds=30

Sample XML Access for ExportAllSkin_Theme - https://www.box.com/s/948cb6bb4956ad1a4018
and for registering pagebuilder2 theme and skin -  https://www.box.com/s/4a768707faa3d1aaf1c7

WCM search and Integrating with portal search


1.       Creating the WCM search collection
        1) Login to Portal Administration
        2) Goto Search Administration > Manage Search
        3) Click on 'Search Collections' > New Collections and provide following information
                        Location of collection : MytechCollection
                        Name of collection : MytechCollection
                        Description of Collection : MytechCollection
        4) Once saved, click on MytechCollection
        5) Create following Content Sources (MytechContent, BlogContents)
        6) Click on 'New Content Source' and provide following details to create MytechContent content sources
a.       Content Source Type : WCMSITE
b.      Content Source Name : MytechContent
c.       Collect documents linked from this URL : http://portal.Mytech.com:10039/seedlist/myserver?SeedlistId=MytechContent/Internet&Source=com.ibm.workplace.wcm.plugins.seedlist.retriever.WCMRetrieverFactory&Action=GetDocuments
      Note - Replace portal.Mytech.com with your portal server host name and MytechContent/Internet with your wcm sitearea
d.      Levels of links to follow: Unlimited
e.      Number of documents to collect: Unlimited
f.        Force Complete Crawl: true
g.       Stop collecting after (min):60
h.      Stop fetching a document after (sec): 20
i.         Links expire after (days): Unlimited
j.        Remove broken links after (days): 10
k.       Click on Security tab and enter portal admin credentials
                User Name : wpsadmin
                Password : wpsadmin
                Host Name : portal.Mytech.com
                Click on 'Create' button
                Click on Save button
                Note - Provide actual portal host and wpsadmin credentails
l.         Once saved, click on 'Start Crawler' button next to created content source entry
7) Search anonymously - to allow anonymous users to access the portal search collections, you need to Add Anonymous user to your Search Collection
Assign Anonymous Permission to MytechCollection
a)      Login to portal administration
b)      Goto Access > Resource Permissions
c)       Click on PSE Sources
d)      Click on 'Assign Access' button next to MytechCollection entry
e)      Edit User Role
f)       Add ' Anonymous Portal User' and ' All Authenticated Portal Users'
g)      Apply and done

2.       Rendering WCM search component results
WCM search component can also be used to display WCM search results.
There are several reasons you may decide to do this instead of using search center out of box portlet, some reasons:
o   Only WCM results will be displayed, meaning any non WCM assets in the search collection will be filtered out when using WCM search component.
o   Full control over the HTML display of the results.
o   Integration within a WCM site being rendered from the servlet.

To accomplish this, we have to create a piece of content that will hold both the search form and the results of the search. When a search is submitted the form will submit to the page for the results, which the form is also deployed to.

1)      Creating the Authoring Template
First, an authoring template for the content is necessary. Create an authoring template named "AT_Search", and use manage elements to add the following 3 elements:
query_form - a Component Reference
search_results - a Component Reference
text - a Text Componentck
2)      Creating the presentation template
Next we need to set up the presentation template to display the elements. Create a new presentation template named "PT_Search", and in the HTML put the following:
<p>[Element context="current" type="content" key="text"]</p>
<p>[Element context="current" type="content" key="query_form"]</p>
<p>[Element context="current" type="content" key="search_results"]</p>
3)      Creating the WCM search form
Now, we need to create the HTML component that will hold the html for the search form. Create a new HTML component named "HTML - Adv Search form", and enter the following HTML:

<form action='[PathCmpnt type="servlet"]/MytechContent/Internet/Search/Results' method="post" onSubmit="this.search_query.value=addFilter(this.query.value)">
<table>
<tr>
        <td>Search : </td>
        <td>
                        <input type="text" name="query" />
                        <input type="submit" value="Search" />
        </td>
</tr>
</table>
<input type=hidden name="search_query"/>
</form>

What the code does is setting up the form to submit to the MytechContent/Internet/Search/Results content (which we will create later), and puts the search_query in the form. The search_query is what gets processed by the WCM Search component as the search. We also limit results to exclude content that is using a specific authoring template, you would append this to the end of the search_query field. This means that when the search is performed, we limit results based on the content's authoring template.

Constructing search_query can easily be done using Javascript that executes on the form submit.
<script language="Javascript">
function addFilter(queryIn){
return queryIn + ' -AuthoringTemplate::"AT_Banner" -AuthoringTemplate::"AT_Search"';
}
</script>

4)      Creating the WCM search component
Next, we need the WCM search component to be created in order to display the search results. Create a new search component named "Search-Search Results". In the search options, select the MytechCollection for the Search collection: field. Also, use 10 for the results per page, as we will use a page navigation to page through the search results.

In the header field, enter the following:
[Component name="Mytechtechnical/search-result-navigation"]
<table>

In the results field, enter the following:
<tr>
        <td>
                        [AttributeResource attributeName="titleLink" separator=","]
                Date: [AttributeResource attributeName="date" format="MM/dd/yyyy" separator=","]
                        Relevance: ([AttributeResource attributeName="relevance" format="##.#" separator=","])
                        <br>
                        [AttributeResource attributeName="summary" separator=","]
        </td>
</tr>
For the footer:
</table>

For the Separator:
<tr>
        <td bgcolor="#FFFAA" colspand="2" />
</tr>

For No result design:
<div> No result found to display.</div>

5)      Creating the paging component
For the results to be paged, we create a simple paging component. Create a new 'page navigation' element named "Search-result-navigation". Use the following as a guide for the paging design for shuffle, paging, jump to page, and page size values to use.

Use the following as the guide for the value of the design elements of the paging component:


6)      Creating the necessary content and site framework
Now that the pieces are in place for the search components, all we have to do is create the content and site area to hold them. First, create a new site area in your MytechContent library. Name it "Search", and map the presentation and authoring template to the site area that you created.

Save and close the site area.

Secondly, create a new piece of content. Select the AT_Search authoring template, name the content "Results", For the Query Form item, select the HTML - Adv Search form component. For the Search Results, select the Search - Search Results component. In the text field, enter " Please select your search text and click the search button ":


Choose a workflow for your content, save and publish the content. As a last step, go back to the Search site area, and set this new content as the default content for the site area.

7)      Performing the search within the WCM search component
a) The easiest way to see the search in action is to preview the Results content. Click on the preview button, and the content will be displayed.
b) Create a portal page 'Search' and enter value 'wcmsearch' for friendly url. Click on 'Add Web Content Mapping' button and map your main sitearea as Web Content Folder.
Once page is created, click on edit page layout button and add ' Web Content Viewer (JSR 286)' portlet into this page. Configure 'Web Content Viewer (JSR 286)' portlet to wcm content 'Results'  from the edit shared settings option.

3.       Integrate WCM search component results with theme search box

Need to configure theme's themeSearchBox with WCM search component results.
Open the search.jsp of pagebuilder theme and modify ScopeSearchWidget as follows :
<div id="themeSearchBox" dojoType="ibm.portal.search.Enhanced.widgets.ScopeSearchWidget" displayScopes="false" submitUrl="?1dmy&urile=wcm%3apath%3a/MytechContent/Internet/Search/Results" resourceBundle="<portal-fmt:out><searchmenu:resourceBundle bundleName="com.ibm.lotus.search.taglib.ScopeSearchWidget"/></portal-fmt:out>" sourceContentNode="<searchmenu:currentContentNode/>" searchFeedUrl="'<searchmenu:generateSearchFeedUrl/>'" timeStamp="<searchmenu:scopesLastUpdateTime/>"></div>

Following javascript function is added to create search_query hidden input filed dynamically on submit of the themeSearchBox form. This filed store and forward user entered search query to WCM search component.

<script language="Javascript">
dojo.addOnLoad(function(){
        dojo.connect(dojo.byId("themeSearchBox"), "onsubmit", function(event){
                        search_query=dojo.doc.createElement("input");
                        dojo.attr(search_query, "name","search_query");
                        dojo.attr(search_query, "type","hidden");
                        dojo.attr(search_query, "value",addFilter(this.query.value));
                        this.appendChild(search_query);
        });
});
</script>

Friday, June 15, 2012

WebDAV Portal Urls

WebSphere portal exposes following resources over WebDav protocol -
  1. WebDAV for managing pages and static content
    1. Portal pages are represented as folders. They can contain subfolders that represent child pages.
    2. Static pages are placed in a separate folder. The content of static pages is represented as an additional folder named staticcontent.
    3. Updating metadata , globalization information
  2. WebDAV filestore. For example, this is used by mashup integration in the portal.
    1. Accessing public,users, system folders related to mashups.
  3. WebDAV for Web Content Management.
    1. Creating siteareas, components, updating the acl…etc

You can obtain the entry point URL to the WebDAV file store from the service document under the URL http://localhost:10039/wps/mycontenthandler/!ut/p/model/service-document

Different WebDAV entry points in websphere portal and WCM

  1. Entry point to access the Portal Themes


  1. Entry point to access the Portal Skins

 
 
  1. Entry point to access the Static Resources (common-resources, layouts,…etc)


  1. Entry point to access the Portal Pages  :
    1. For default portal installations

    1. For virtual portals
                                                               i.      If host name was specified when the virtual portal was created, the WebDAV URL looks like this

                                                             ii.      If the virtual portal was created with a URL context only and no host name was specified, the WebDAV URL looks like this
 
  1. Entry point to access WCM libraries
http://localhost:10039/portal_context_root/mycontenthandler/dav/content/libraries/



Using WebDAV , we can
  1. browse, changing metadata of portal pages.
  2. create, update, deletion of static pages under staticcontent. Users can access the content of static pages via the subfolder staticcontent
Using WebDAV, we can’t
  1. creating the new pages, updating the uniquename or objectid, copy or moving pages .
  2. updating portal content

WebDAV-Security

The WebDAV entry point requires user authentication via HTTP basic authentication. SSL access is not supported at this time. To use WebDAV, users log in to the portal with their portal user ID. Users can then access and work with portal pages according to their access permissions as set by Portal Access Control.

By default only administrative users can perform write operations on specific folders of the WebDAV file store. This affects public and user owned folders. You can enable write access for all authenticated users on WebDAV file stores folders.

Managing access control for theme and mashup folders:

  1. All users have view access to all resources in these folders. This includes both anonymous users and authenticated users.
  2. You can administer write access to the these folders via the virtual resource THEME MANAGEMENT provided by portal access control.
    1. To give users write access to resources contained in theme folders, for example to create, modify, or delete such resources, assign the users MANAGER role on the virtual resource THEME MANAGEMENT in portal access control.
  3. To enable write access for all authenticated users, add the following property to the WP ConfigService resource environment provider in the WebSphere Application Server administrative console: filestore.writeaccess.allowed. Set the value for the property to true .
    1. There are several WebDAV entry points. However, the property filestore.writeaccess.allowed applies to the filestore entry points for home directories for each user located at: http://server_name:WC_default_host/wps/mycontenthandler/dav/fs-type1/users/user_name
    2. Users can modify only their own directories. You must grant additional permissions for users to modify other directories.

Tuesday, June 14, 2011

Get Current Page Details in theme

1) To get current page title
 <portal-fmt:title varname="${wpsSelectionModel.selectedNode}"/>

2) Get selected page
javax.naming.Context ctx = new javax.naming.InitialContext();
com.ibm.portal.model.NavigationSelectionModelHome navigationSelectionModelHome = (com.ibm.portal.model.NavigationSelectionModelHome) ctx.lookup("portal:service/model/NavigationSelectionModel");
final com.ibm.portal.model.NavigationSelectionModelProvider nsmProvider = navigationSelectionModelHome.getNavigationSelectionModelProvider();
            final com.ibm.portal.navigation.NavigationSelectionModel nsm = nsmProvider.getNavigationSelectionModel(request, response);
            com.ibm.portal.model.ContentModelProvider cmProvider = contentModelHome.getContentModelProvider();
            com.ibm.portal.content.ContentModel contentModel = cmProvider.getContentModel( request, response );
           
            final NavigationNode currentNavNode = (NavigationNode) nsm.getSelectedNode();
            final ContentNode currentContentNode = currentNavNode.getContentNode();

3) ChildrenCount of Specific Page
<% String themeLinksUniqueNameRoot = "com.employeeportal.footer"; %>

<portal-navigation:navigation scopeUniqueName="<%=themeLinksUniqueNameRoot%>"  startLevel="1" stopLevel="1">
    <%
        int pageCount=((com.ibm.wps.model.wrappers.NavigationModelWrapper)wpsNavModel).getChildrenCount(((com.ibm.wps.model.wrappers.NavigationModelWrapper)wpsNavModel).findByUniqueName(themeLinksUniqueNameRoot));
     %>
       </portal-navigation:navigation>

Monday, June 13, 2011

Puma Service/User Details in (Theme, Servlet, Portlet)

a) Get details of User in Theme for loggedIn User
1) Use following tag lib to get basic user attribute value
<%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-fmt" prefix="portal-fmt" %>
<portal-fmt:user attribute="givenName" /> <portal-fmt:user attribute="sn" />
2) To get other info like in which group user belongs to
<%
com.ibm.portal.puma.User portalUser=  (com.ibm.portal.puma.User) request.getAttribute(com.ibm.portal.RequestConstants.REQUEST_USER_OBJECT);
 if(portalUser!=null) {
    java.util.List groups = portalUser.getGroups();
        for (int i=0; i< groups.size() ; i++){
            com.ibm.portal.puma.Group grp = (com.ibm.portal.puma.Group)groups.get(i);
        }
}
%>

b) Get details of User in Servlet for loggedIn User
import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.naming.CompositeName;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibm.portal.um.PumaHome;
import com.ibm.portal.um.PumaLocator;
import com.ibm.portal.um.PumaProfile;
import com.ibm.portal.um.User;
import com.ibm.portal.um.exceptions.PumaAttributeException;
import com.ibm.portal.um.exceptions.PumaMissingAccessRightsException;
import com.ibm.portal.um.exceptions.PumaModelException;
import com.ibm.portal.um.exceptions.PumaSystemException;

public class UserInfo extends HttpServlet {
    private static final long serialVersionUID = 1L;

    private PumaHome pumaHome;

    @Override
    public void init() throws ServletException {
        super.init();

        try {
            Context context = new InitialContext();
            Name pumaJndiName = new CompositeName(PumaHome.JNDI_NAME);
            pumaHome = (PumaHome) context.lookup(pumaJndiName);
        } catch (NamingException e) {
            e.printStackTrace();
        }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        String UIDParam = request.getParameter("uid");

        PumaLocator pLocator = pumaHome.getLocator();
        PumaProfile pProfile = pumaHome.getProfile();

        try {
            List<User> users =pLocator.findUsersByAttribute("uid", UIDParam);

            // get a list of attributes defined for this User
            List attribNames = pProfile.getDefinedUserAttributeNames();
            // Get a map of attribute values for this user
            Map userDetails = pProfile.getAttributes(users.get(0), attribNames);

            String userEmail = (String) userDetails.get("mail");
            System.out.println("UserInfo.doGet()" + UIDParam + ":"+ userEmail + ":" + users.size());
        } catch (PumaSystemException e) {
            e.printStackTrace();
        } catch (PumaAttributeException e) {
            e.printStackTrace();
        } catch (PumaMissingAccessRightsException e) {
            e.printStackTrace();
        } catch (PumaModelException e) {
            e.printStackTrace();
        }
    }

}

c) Get details of User in Portlet for loggedIn User

import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.portlet.ActionRequest;
import javax.portlet.PortletRequest;

import com.ibm.portal.portlet.service.PortletServiceHome;
import com.ibm.portal.um.PumaController;
import com.ibm.portal.um.PumaEnvironment;
import com.ibm.portal.um.PumaLocator;
import com.ibm.portal.um.PumaProfile;
import com.ibm.portal.um.User;
import com.ibm.portal.um.portletservice.PumaHome;
import com.ibm.websphere.security.UserRegistry;

public class UserProfileService {
    // This class uses PUMA SPI to access the LDAP and retrieve user profile information
    private static PumaHome pumaHome;

    // List of all Attribute Names that are defined in LDAP for USER group
    public static final String LAST_NAME = "sn";
    public static final String FIRST_NAME = "givenName";
    public static final String EMAIL = "mail";
    public static final String PASSWORD_USER_PROPERTY = "password";
    public static final String USERID_USER_PROPERTY = "uid";
    public static final String COMMONNAME_USER_PROPERTY = "cn";
   
    // Method to connect and create a PumaHome object
    public UserProfileService() {
        try {
            Context ctx = new InitialContext();
            PortletServiceHome psh = (PortletServiceHome) ctx
                    .lookup("portletservice/com.ibm.portal.um.portletservice.PumaHome");

            if (psh != null) {
                pumaHome = (PumaHome) psh.getPortletService(PumaHome.class);
            }

        } catch (Exception ne) {
            // ne.printStackTrace();
            pumaHome = null;
        }

    }

    public Map getUserProfile(PortletRequest req) {
        Map userDetails = null;
        // Util method that uses PUMA SPI to load user attributes from LDAP into
        // // a domain object (LmsUser)
        if (pumaHome == null) {
            return null;
        } else {
            try {
                // first get a PumaProfile object
                PumaProfile pumaProfile = pumaHome.getProfile(req);
                // get a list of attributes defined for this User
                List attribNames = pumaProfile.getDefinedUserAttributeNames();

                // Get a map of attribute values for this user
                userDetails = pumaProfile.getAttributes(pumaProfile
                        .getCurrentUser(), attribNames);
                System.out.println("userDetails::::::"+userDetails);
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }
        return userDetails;
    }

    public static PumaHome getPumaHome() {
        if (pumaHome == null) {
            try {
                PortletServiceHome psh;
                Context ctx = new InitialContext();
                psh = (PortletServiceHome) ctx.lookup(PumaHome.JNDI_NAME);
                if (psh != null) {
                    pumaHome = (PumaHome) psh.getPortletService(PumaHome.class);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return pumaHome;
    }

    protected static PumaLocator getPumaLocator(PortletRequest portletRequest) {
        PumaLocator pumaLocator = getPumaHome().getLocator(portletRequest);
        return pumaLocator;
    }
    protected static PumaProfile getPumaProfile(PortletRequest portletRequest) {
        PumaProfile pumaProfile = getPumaHome().getProfile(portletRequest);
        return pumaProfile;
    }

    protected static PumaEnvironment getPumaEnvironment() {
        PumaEnvironment pumaEnvironment = getPumaHome().getEnvironment();
        return pumaEnvironment;
    }
    protected static PumaController getPumaController(PortletRequest portletRequest) {
        PumaController pumaController = getPumaHome().getController((ActionRequest) portletRequest);
        return pumaController;
    }
    public static void changePasswordLDAP(ActionRequest actionRequest, String password) {
        final PumaProfile pf = getPumaProfile(actionRequest);
        final PumaController pc = getPumaController(actionRequest);
        final PumaEnvironment pe = getPumaEnvironment();
        final Map userSetAttr = new HashMap();
        final List passwd=new ArrayList();
        passwd.add(password);
        // set AD password attribute in the Map
        userSetAttr.put(PASSWORD_USER_PROPERTY, passwd);
        try {
            pe.runUnrestricted(new PrivilegedExceptionAction() {
                public Object run() {
                    try {
                            User user = pf.getCurrentUser();
                            pc.setAttributes(user, userSetAttr);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}