Users, Site, Organization and User Group in Liferay and its association

Liferay artifacts are useful in building and organizing a portal. Following liferay artifacts are key building blocks to construct liferay portal.

Liferay artifacts

  • Users
    • Users are key entity in Liferay portal.
    • In Liferay portal, users are associated with site / organization / usergroups. They have different roles
  • Site (Till Liferay 6.0 this was know as Community)
    • Liferay provides provision of Site.
    • Site in Liferay represents web site that has page, content , users and other functionality.
    • Generally any web site is comprises of set of static files (html) or it’s built by some web application. Liferay site provides similar functionality. It allows us to add pages, users, look and feel and other functionalities (portlets) to form a complete web site.
    • Users in site can access different part and functionality of site based on site role associated.
    • To know more about Liferay site, you can refer this
  • Organization
    • Organization in Liferay manages users in hierarchy.
    • Organization can have a site so all functionality of sites are also applicable to organization.
    • You may refer old post on liferay to know what is different between site and organization
  • Role – Permission
    • Role in liferay define privileges to access certain pages or functionality.
    • Permission is resource level priviledge. Group of permissions form a role in Liferay.
  • User Group
    • user groups is used to group set to users with common interest.
Following are possible association between liferay artifacts.
  • Liferay Portal has Users
  • User can be part of Organization
  • User can be part of Site
  • Organization is used to aggregate users in hierarchical manner.
  • Users with common interest can be part of same Site. It’s similar to face book group where people with common interest can collaborate with each other.
  • Organizations can have Site but Site can’t have Organization
  • User can have 
    • Site Specific Roles.
    • Organization specific Roles.
    • Regular (Portal level) Roles.
  • Each Role in Liferay is having set of Permissions.
  • User Groups is collections of Users
  • User Groups can be associated to Site
  • User can be associated to SiteOrganization and User Group
Relation between liferay artifacts (User, Organization, Site and User Group) can be explained by below screen shot.
Liferay artifacts - User Site Organization and Usergroup - Relation_Org_Site_Use_UserGroup
  • User can have role. Roles are further scoped by OrganizationSites or Regular (Portal Level)
  • Ex. User A can have Administrator role for Site-a but for Site-b he is just normal user.
  • Each Role is group of Permissions.
  • For each Site, there will be one role called Site Administrator which has full access for that site(Super User). Similar is applicable for Organization.
  • Apart from Site and Organization Administrator, there is one more role called Site Owner and Organization Owner which is similar to Site / Organization Administrator. 
  • The only different between them is Site / Organization Owner can make other user Administrator for that Site / Organization while simple Administrator can’t do it.
To understand above association in depth, do some hands on by
  • Creating Site Organization
  • Creating User and associate them with Site / Organization
  • Creating User Group and assign some User to it.
  • To associate Site to Organization, Select the check box called ‘Create Site‘ from ‘Organization Site‘ section at right side links in Organization Edit Screen. This check box is available while creating Organization first time.
Feel free to ask Question / give feedback.
 
I would recommend looking at index page ‘A Complete Liferay Guide‘ to browse all topics about liferay.

Share This Post

20 Comments - Write a Comment

  1. HI Nilang,

    How to assign a user to site in Liferay 7 programmatically?
    Any API available for it?

    from control panel, we can assign a user to site.

    SInce I have to make a private page as default landing page, I am trying to write post login hook and there we can assign a user to site programmatically.
    any suggestion

    Thanks
    Bharamani

    Reply
    1. HI Nilang,
      I got API for this.
      User user = PortalUtil.getUser(lifecycleEvent.getRequest());
      System.out.println(“Inside Post Login Action” + user.getFirstName());
      GroupLocalServiceUtil.addUserGroup(user.getUserId(), 20143);

      Now the problem is groupId(20143)
      how to get it using portalUtil.

      Thanks

      Reply
      1. Hello Bharamani,

        Welcome to Tech blog. You can get groupId with following two ways

        1) from PortalUtil.getScopedGroupId(request)
        2) first get ThemeDisplay Object –> ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.ThemeDisplay)
        then scop Group Id (Group Id of current site) as themeDisplay.getScopeGroupId();

        Hope this helpful.

        Feel free to ask questions / give suggestions.

        Regards
        Nilang

        Reply
  2. HI nilang,
    i have a query regarding referencing various services. so is this possible in liferay 7 that we can reference a table in one service to another table in different service . if possible please let me know how??? it would be a great help.

    Reply
    1. Hello Amit,

      Welcome to Techblog. The question that you have asked, I am also finding the solution. You are asking, you have two different service builder modules and you want to make reference of service from SB1 to SB2 correct. Soon I get the solution, I will let you know.

      Regards
      Nilang

      Reply
  3. I have many departments and each department having a manager and employees
    i need to apply workflows for leave request so the emp create leave req then his manager review it and approve it then it goes to HR dept to finalize it

    how can i realize this scenario in liferay portal?
    departments will become groups ? or organizations?

    Reply
  4. Hi Nilang,

    I am facing below mentioned issue. Please help would be much appreciated.

    I have created new site under one organization, assigned the users to it. Is there a way to restrict the same site should not be available to other organization ? I tried to create private/restricted site under org but its still appearing for the org2. Is there a way to restrict the site1 should not be available to Org2.

    Second thing , is there a way to restrict the users existing under org1 should not be available to org2.
    Thanks in advance Nilang.

    Reply
  5. Hi All ,

    I am working on liferay admin console for a application. I have the below query.

    1. How to create common site for organization accessed by all the members of that org
    2. How to create specific site for organization eg: Org1 –> Site 1 Org2 –> site2
    3. How to create users specific to particular organization and site eg: user1 –> site1 –> org1 user2 –> site2 –> org2

    Reply
    1. Hello Rashmi,

      Welcome to Tech blog. Answers to you questions.
      1. How to create common site for organization accessed by all the members of that org
      Ans:- You can create Site for each Organization which is accessed by all member of that Org. Edit Organization, there will be on option called Site and you have to select checkbox while crating organization.
      2. How to create specific site for organization eg: Org1 –> Site 1 Org2 –> site2
      Ans:- Same as Ans-1
      3. How to create users specific to particular organization and site eg: user1 –> site1 –> org1 user2 –> site2 –> org2
      Ans:- This is not an ideal scenario. Ideally user should access Organization’s site pages. You need to develop and deploy portlets on Organization’s site pages in such a way that it will show current user’s data. This way it would simulate that those pages are of that users only.

      Reply
      1. Thanks a lot Nilang for your quick response. Really appreciated.
        I will try out the options suggested by you. I will ping you back if i encounter any new issues.

        Reply
      2. Hi Nilang,
        Still i am facing an issue with Organization users.
        I have created org and added 3 users under that. Out of 3 users one user i have made as org administrator. When org admin logs in he is not able to see admin tab it self. How to enable Admin tab for Org admin?
        I tried to assign Site owner role to Org Admin, and now he is able to see Admin tab. But I want to restrict the users. It should display only the users under his org.
        Also any specific roles need to be added to see only users under that org to which he belongs to?

        Reply
        1. Helo Rashmi,

          You can create private pages for that organization site (which is by default available to members of that site only). So if you are creating Public pages, just delete them and create Private page. You must have just one public page, on which you can put some web content (just static content) and the actual functionality would be on private page so other user won’t have access to those private pages.

          Let me know still issue is persist.

          Regards
          Nilang

          Reply
  6. Hi Nilang,
    First of all great blog, liked it!!

    I am completely new to the portlet technology and have just set hello-world portlet using your blog content.
    Now I want to make role based portlet i.e. want to assign particular portlet to a particular user only.So how can I do that.
    I am completely new so will be helpful if you can give me step by step guide.

    Regards.

    Reply
    1. Hi Ayan,

      Welcome to Tech blog and sorry for late respond. There are multiple things to achieve what you are looking for.

      1) Programatically
      — Liferay provides Role API to perform certain operation base on role. The plus side is you can achieve hide/show portion of portlet based on Role. The minus side is, in case in future if you wish to change the role, you have to modify the code and redeploy your portlet

      2) Configuration
      — Portlet are placed on Liferay page and each page can be configured to be visible based on role. The plus side is, for any future change of role, you can easily re-configure the role to page. The minus side is, whole page can be controlled so if you are planning to place other portlets on same page, the whole page can be either visible or not based or role, all portlets are affected so in case if you are looking for just one portlet, this trick will not help.

      3) Programatically configurable.
      You need to take help of portlet preference. Take the role in preference and perform the operation what you want. This way it will be applicable to that portlet only and also you can change the rule from preference in future so its configurable.

      Feel free to ask qustions..
      Regards
      Nilang

      Reply
    1. Hi Carmen,

      First of all Welcome to Tech blog. If you wish to assign role to user withing organization then you need to first create role. In Liferay you can create role with different scope like Regular(or portal level), Site or Organization. Second, the user to whom you want to assign role must be member of that organization. So follow below steps

      1) Create role with scope Organization (Organization Role)
      2) Go to Organization screen where you will find list of all organization with Action link for each.
      3) On clicking this ‘Action’ button, you will see context menu.
      4) Choose ‘Assign Organization Role’ link.
      5) You will be first asked to specify the role and then user. Click the role you want to choose
      6) Second screen will show list of users. ( you may need to choose Available tab to see what all users are available)
      7) Select the user and click on ‘Update Association’ button.

      And its done.

      Feel free to ask questions / Give suggestions..

      Regards
      Nilang

      Reply
      1. Hi,
        Thanks for your reply and for the clean answer. Is it okey if I ask a question related to workflows? I am trying to make a workflow in which some tasks are send to Organization role users. I think the workflow is okey because I have tested it with regular role users and it works, so I believe there is something wrong with the Organization role users or the way I have enabled the workflow for the organization, I can not understand what. I followed the steps from your post and created the users, but the workflow fails. Can you also enumerate the steps I should follow when creating workflows that include Organization role users? I can provide you with a sample of my code if you want. Thank you.

        Reply
        1. Hi Carmen,

          Sure. You can ask any question and I will try my best to give solution. can you please send me the workflow file (on [email protected]) ? also let me know the liferay version you are using. I will check it from my end and let you know if find any issue.

          Regards

          Reply
    1. Hi Abhinandan,

      Welcome to Tech blog and thanks for writing here. Yes its possible. You can achieve this by following way.

      1) You can define set of categories.
      2) These categories you can show as checkbox (for each category) in portlet config screen.
      3) You can provide user preference screen where you can show same categories with checkbox
      4) while rendering portlet (in render method), you can check the categories choose by user in user preference with categories set for portlet. If atleast one is common in both case, you can show the content else you can show empty content (logic in JSP)

      Let me know if this solution works for you. Feel free to ask questions / give suggestions

      Regards
      Nilang

      Reply

Post Comment