Getting an overview of Liferay Portal Architecture
You are now aware of the Portal basics and Liferay Portal's Dockbar. Before we go ahead with the rest of the chapters of this book, it is important to understand the Portal Architecture of Liferay. When we use the term Portal Architecture, it includes the basic building blocks of the Liferay Portal and relationship between each block.
In this section, we will get an overview of the Liferay Portal Architecture. We will get familiar with different components and understand their role in Liferay. We will, however, discuss these components in detail in Chapter 5, Building Your First Liferay Site.
Understanding the Liferay building blocks
Let's start discussing this topic with a question! We have been talking about Portal since the beginning of this chapter. Whom do we build/develop a portal for? The answer can be content creators, bloggers, content approvers, certain type of admins, visitors, and so on. If we want to use only one word, collectively for all these people, then the word would be users. This means we develop the portal for the user. The user can be anyone from just a visitor to portal admin.
Now, when we say all of the above mentioned people are just the users of the portal, there is a significant difference between each of the users in terms of what they can do in the portal. For example, a visitor would not be able to add any content, content creator would not be able to approve the content, and content approver may not be able to create/edit any users. So each of the users is distinguished by the function he/she can do in the portal. These functions in the portal are associated with the user's role in the portal. There is a certain set of permissions associated with each role. When you assign a user to the role, the user will get all the permissions/privileges associated to the role.
Now, think of a site such as http://www.cnn.com, where you have to deal with a huge amount of content. What happens if you have only one person who creates the content called content creator and only one person who approves the content called content approver for this site? There would be a bottleneck. Also, one user may not be able to create all the content which is required for your site. In that case, you would need more than one person who can perform a similar function, for example creating content or approving content. Yes, you guessed it! Here, we are talking about the User Groups. Users who do the same function or have something in common, can be collected into user groups. To make user management easier, an entire user group can be assigned to a role as well, so all the users who are part of the user group will get the privileges or permission associated with that role.
By keeping the preceding discussion in mind, we can make the following statements:
- Portals are developed for the users and accessed by the users.
- Users having common characteristics can be collected into a user group, for example content creator.
- Users can be assigned to a role, which will give them all the permissions/privileges associated with the role.
- User group can also be assigned to a Role. This will give all the users, members of the user group, all the permissions/privileges associated with the role.
In addition to the preceding components—User, User Group, and Role—Liferay consists of a few more building blocks—Organization, Community, Page, and Team.
The community is a group of people who have common interest. It is very similar to the concept of the community in the social networking world, where people with common interests get connected. In Liferay, you can create different communities and assign users to the communities.
Users can be collected into an Organization, which is a hierarchical collection of users. Organization in Liferay can represent an Organization in real life.
You can create multiple Organizations and Communities in Liferay Portal.
User, User group, and Organization can be members of a community who have common interests.
To understand these concepts, let's have a look at the following diagram. This diagram shows all the components of Liferay Portal and their relationships with one another. The arrows in the diagram mean "can be assigned to" or "can be a member of".
This diagram is a pictorial representation of the Liferay Portal Architecture. The outer square box represents a portal which is a physical Portal Instance. We can extract the following facts from the diagram:
- User is in the heart of the portal, which means all the activities are performed by keeping user in the centre.
- An Organization, a Community, a User, User Group, and Roles are created at a portal level.
- You can create multiple Organizations, Community, Users, User Groups, and Roles within a Portal.
- A user can be assigned to more than one Role, User Group, Organization or a Community.
- A User Group can be assigned to a Role.
- An Organization or a Community can also be assigned to a Role. On doing so, all the members of the Organization or Community will get permissions associated with that role.
- Organization and Community have their own resources—Organization/Community Roles, Pages, and Teams.
- When a User is assigned to an Organization or a Community, the user becomes a member of the Organization or Community. A member can access resources of an Organization or Community.
- A User has to be a member of an Organization or a Community before assigning to an Organization or Community-level role or team created within an Organization or a Community.
- A page in Liferay Portal, is not a separate entity and cannot be created at a Portal level. A page has to be created within an Organization or a Community.
- We can also create a role at an Organization or Community level.
- A team can be created within an Organization or a Community.
Now, as we have taken an overview of the Liferay Portal Architecture, let's talk about each component.
User is a physical entity in Liferay Portal. It represents a real-world user in the portal. Each user except the Guest user has his/her account in Liferay and uses the account to access the portal. A user is always created at a portal level can then can be assigned to an Organization or a Community. Remember, a user is never created within an Organization or a Community.
As displayed in the pictorial representation of the Liferay Portal Architecture, a user can be collected in the following ways:
- User can be assigned to a Role which has specific permissions associated with
- A user can be assigned to a specific user group like content creators
- A user can be a member of one or more Organization which represents an organization in real life
- A user can be a member of one or more Community which is created for the users having some common interest like stamp-collector's community
A user group is a simple, arbitrary collection of users. A user group is created at a portal level and can be created by a Portal Admin only. Users can be assigned to the user group and then the user group can be assigned to a role. On doing so, all the users who are a part of the user group will get the permissions defined for that role. It is not possible to directly assign any permission to the user group. You can also assign the user group to a Community or an Organization. When we do that, all the users in the User Group will become members of the Community or Organization respectively.
User groups make user management simpler and easier.
Role is used to define a permission to do a certain task in the portal. As we have seen earlier, permissions cannot be given to an individual user or a user group. In order to give some permissions to the user, we have to follow a three-step process as follows:
- Create a Role.
- Define permissions for the Role.
- Assign the Role to a User or User Group.
Liferay has a very fine-grained permission system and a Role plays an important part in the permission system. We can create three types of Roles in Liferay:
These types are based on the scope of the role. When we create a role at a portal scope with some pre-defined permissions to perform certain actions, a user having this role can perform those actions in the entire portal—including all the organizations or communities of the portal. If the same role has been created with a community scope, then a user having this role in a community can perform those actions within that community only. Same thing applies to the organization scope as well.
Let's understand this with an example. Let's consider that we have a portal instance and we have created two Communities—C1 and C2—and two Organizations—O1 and O2—in the portal. As mentioned earlier, it is possible to create multiple organizations and communities in one portal instance. We will do this in Chapter 5, Building Your First Liferay Site. We have created a user, John, in the portal.
Now, if the user John has an Admin role at a portal level, then he can perform admin activities in all the communities and organizations across the portal, which includes C1, C2, O1, and O2.
If John has an Admin role in C1 (Community Admin), then he can perform all the admin activities in C1 only and not in C2, O1, and O2.
Similarly, if the user John has Admin role in O2 (Organization Admin), then he can perform all the admin activities only in O2 and not in C1, C2, and O1.
We can assign an individual user, user group, organization or community to the role.
We will do all these activities practically in Chapter 4, Knowing Tips and Tricks—Advanced Configuration, and Chapter 6, Managing Pages, Users, and Permissions.
Community in Liferay is created to group the users having a common interest. These communities are very similar to the communities we are familiar with in the social networking world, where users having a common interest can join or leave at their will. The connection between the user and the community is ad-hoc.
You can create three types of communities in Liferay:
A user can join or leave an open community by will. This can be done using the Liferay control panel or the My Communities portlet of Liferay.
A user needs an approval of the community administrator to join a restricted community. A user has to request for membership of the Restricted community.
A private community is very similar to a restricted community but a user cannot see the private community under the list of communities in the My Communities portlet. The community admin has to add users to the private community. The private community is also sometimes called the hidden community.
In Liferay, a community can behave as a separate site. You can create pages, roles, and teams within a community.
It is also possible to create more than one community in the portal. Each of the community can be assigned a virtual host to behave as a separate site.
An Organization in Liferay can represent an organization in real life. Organizations are hierarchical collections of users. You can create an entire real-world organization structure using Liferay's organization feature. An Organization can have sub-organizations and each sub-organization can have numerous sub-organizations. This can go up to n level.
A user can be a member of more than one organization.
You can create pages, organization roles, or teams within an organization.
Organizations are of two types:
- Regular organization—You can create a sub-organization under a regular organization by default.
- Location—This is a special type of organization. It behaves as a leaf node. It is not possible to create a sub-organization (sub-location) under a location, by default.
It is also possible to define custom-type organizations. This has to be done by extending the portal.properties
file, which is a default configuration file for the portal. You can find it in the portal-impl.jar
file under the WEB-INF/lib
folder of your Tomcat server.
The sub-organization is the same as a normal organization but it has some other organization as a parent organization.
When a user becomes a member of a child organization, he/she automatically becomes the member of the parent organization by default. This can be turned-off if required.
An individual user or a user group can be a member of the organization.
An entire organization can be assigned to a role or a community.
Similar to community, an organization can also behave as a separate site in the portal. It is also possible to create multiple organizations within a portal. We can provide a virtual URL to an Organization to make it behave like a website. We will add multiple organizations in Chapter 5, Building Your First Liferay Site.
Tip
The Portal.properties
file contains all the properties related to Liferay Portal. The properties are set in Key-Value pair. We can add or modify the properties by creating a portal-ext.properties
file in the portal.
To add new Organization types in the portal you need to copy the following property in the portal-ext.properties
file and add new types to the property.
organizations.children.types[regular-organization]=regular-organization,location
To restrict a user from becoming a member of the parent organization by default, set the following property to true
. The default value of the property is false
.
organizations.membership.strict=false
Team is a new concept added in Liferay 6. A team belongs to the organization or community which it was created in. A team can be created by an Organization or Community admin and is a collection of organization or community members. A team is created to assign special tasks to certain members of the organization or community only. For example, we can have a stamp-collector's community which requires a blogger team to update other members by writing new blogs about this hobby.
You may think that the preceding requirement can also be fulfilled by a community role. You're absolutely right! But, when you create a community-scoped role for stamp-collector's community, it also appears in other communities even though it is not required. However, when you create a team, it is visible only within the organization or community it has been created in.
Teams are very useful because they can be created by a community admin or an organization admin. Admins can delegate their work to certain team by creating team and assigning certain permissions to the team.
To become the member of a team, a user first has to be the member of an organization or community. It's pretty obvious! You cannot be a manager of any company without being an employee of the company!
We are yet to discuss when to create an organization versus when to create a community. We also need to discuss when to create user groups in real projects. Well, don't worry about all these questions for the moment. We will discuss them in detail in Chapter 5, Building Your First Liferay Site.
- Which of the following are true?
a. A user can be created within an Organization or Community
b. A user can be created at Portal level only
c. A Page can be created at a Portal level
d. A page can be created within Organization or Community only
- Which of the following can be a member/part of the Organization?
a. User
b. User Group
c. Role
d. Community
- If a team is created in one organization, it also appears in other organizations created in the same Portal.
a. True
b. False
- Which of the following are types of community?
a. Open
b. General
c. Restricted
d. Private
- Which of the following are types of Organization?
a. Location
b. Special Organization
c. Regular Organization
d. Static Organization
- If a user has a community admin role of one community, he/she will become admin of all the communities in the portal.
a. True
b. False
- If a community-scope role is created for one community, the same role will also appear in other communities in the same portal.
a. True
b. False
Before going to the next topic, Control Panel, let's summarize what we have done so far.
In the last topic, we have discussed Liferay Portal Architecture and the basic components of the architecture. You know that a Portal consists of different building blocks like User, Role, User Group, Organization, Community, Page, and Team. We are also aware of what can be created at a Portal level and what can be created at Organization or Community level. We have gone through the portlet concept in Liferay and added a few portlets to the page as well.
We have also discussed different scopes of role, different types of communities, and different types of organizations. You should now be aware of the difference between an organization or community scope role and a team.
Before going through the next topic, go back to the Portal Architecture diagram and look at all the relations between each of the components. The diagram should now make more sense than when you looked at the same for the first time.