How to find the companyId in Liferay.

In liferay many services require comapanyId. In lifeay company means portal instance. You can find this easily.

Get comapanyId in code:

  1. PortalUtil.getDefaultCompanyId(); this give you default companyId.
  2. PortalUtil.getCompanyId(request); here request means HttpServletRequest.
  3. PortalUtil.getCompanyId(portletRequest);here portletRequest means any portletRequest(Render,Action or Resource). 
  4. ThemeDisplay themeDisplay=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);themeDisplay.getCompanyId(); 
  5. Get current companyId from specific thread local storage by:             CompanyThreadLocal.getCompanyId();

Get comapanyId manually:


To find the company ID (portal instance ID), follow these steps:

1/ Sign into portal as admin user

2/ Navigation the Portal Instances admin page

Navigation Path is "Dockbar > Admin > Control Panel > (Configuration) Portal Instances

3/ Review first column  "Instance ID"

The instance ID is the company ID.


Enjoy.......

Comments

Popular posts from this blog

How to run ofbiz as ubuntu Service.

JPA vs Spring JPA vs Spring Data JPA vs Hibernate

Java Array Interview Questions for Entry-Level Developers Part 01