Wednesday, November 5, 2014

Liferay Theoretical Architecture /Liferay Layered Architecture


Liferay is open source portal and it provides robust application features and capabilities which full fill real world end user needs.

Liferay support many functions such as Portal Management, Content Management, Work flow Management, Document Management, User Management and Security Management.

All these services liferay already implemented as it core features so that as developer we need not worry about underlaying services only we need to think about end user needs when we develop application.

Layer is also comprised of the inter related service components and features Personalization,Collaboration, Social Networking, Delivery Channels, Virtualization Tunnelling Servlets and these services we can inherited from liferay core features.

Liferay follows a Model Driven Architecture approach

Liferay follows a Model Driven Architecture

Model-driven architecture (MDA) is a software design approach for the development of software systems. It provides a set of guidelines for the structuring of specifications, which are expressed as models. Model-driven architecture is a kind of domain engineering, and supports model-driven engineering of software systems. It was launched by the Object Management Group (OMG) in 2001.


Liferay follows below software engineering models

Platform Independent Model (PIM) :

A Platform-Independent Model (PIM) in software engineering is a model of a software system or business system, that is independent of the specific technological platform used to implement it.


Platform Specific Model (PSM):

A platform-specific model is a model of a software or business system that is linked to a specific technological platform (e.g. a specific programming language, operating system, document file format or database). Platform-specific models are indispensable for the actual implementation of a system.


Domain Specific Model (DSM)

Domain-specific modeling is a software engineering methodology for designing and developing systems, such as computer software. It involves systematic use of a domain-specific language to represent the various facets of a system.



Platform Specific Model (PSM) which constitutes following technologies

EJB’s, Spring Framework, Hibernate Layer, Web Services.

Service Builder Made up with implementation of Platform Specific Model (PSM) technologies such as EJB’s, Spring Framework, Hibernate Layer, Web Services.

The services builder is the Model Driven Transformation (MDT) Tool which will construct and deploy services those are required by liferay portal and portlets.

Liferay already a developed application so if any one wants to extend or add new features then liferay have given following extension frameworks these will be as part of Plugins SDK.

Extension Environment

Plugins Framework

Note:

Before 6.1 version we have separate Extension Environment later version it was added into Plugins Framework.

Extension Environment:

Extension environment is for override existing portal source.Extension environment consist same directory structure i.e. portal follows.

Extension environment override portal source files by placing in appropriate path where it actually in liferay source portal.

Extension environment have different -ext.properties files to override existing portal and other languages propertied files.

Plugins Framework:

Plugin framework is for customize or extend portal and its hot deployable plugins means no need stop sever when we deploy and changes will be applied after successful deployment.

Pluigns frame work consist of following types for different contextual use with respect to liferay such as Portlet,Hook,Theme,Layout and web

Hooks are used to override some source of liferay portal such as portal jsps, portal properties language properties, events and struts actions

We have following types of Hooks

JSP hooks(JSP hook used to modify the existed Liferay JSP Pages)

properties hook(these are used to modify some of portal properties and language properties file in liferay source) 
 
Event hooks(liferay have events action classes we can modify using event hook like post login, pre login events are examples)

Model hooks(Model hooks deal with entity actions in services)

Struts Action Hooks(from liferay 6.1 we have these feature)

Plugins frame work provide following Interfaces in development

Command Line:

Ant Targets so that we can run from command prompt.

IDE:

Eclispe plugin consist GUI based interface to create pluings such as portlet,hook,layout,theme and web

Liferay supports Windows, Mac and Linux OS Operating Systems and Liferay need JVM and its operating system dependent

Liferay Portal Support many Server Environments such as Apache Tomcat, Glassfish, Geronimo, Jetty, JOnAS, JBoss, and Resin and this one of huge advantage so that we can deploy into any of the sported servers.

Each application server provide many services which will be used by application those are deployed in the server.

JNDI (Java Naming and Directory Interface)
JDBC (Java database connectivity)
JTS (Java transaction service)
JMS (Java Message Service)
JAAS (Java Authentication and Authorization Service)
JDO (Java Data Objects)
JWS (java Web Services)
JSP/Servlets
JavaMail

Liferay Architecture Diagram




Note:

Each layer is differentiated by different color and each layer consist one more components.

Layer: 1

Any Software that required Operating System to run.so its base layer for any software. In the diagram is bottom layer represent Operating System.
We already know liferay support Windows,Mac and Linux.

Layer: 2

As we know any software required native run time environment and liferay is java portal so we need Java Virtual Mechine (JVM). If we install Java then we will be ready with JVM.Each OS have its platform depended JVM

Layer: 3

Liferay is java web portal and to run any web application we need application server and application server will be running with help of JVM.
Liferay support many application servers such as Apache Tomcat, Glassfish, Geronimo, Jetty, JOnAS, JBoss, and Resin.

Each application servers by default provide many services which will be used by deployed applications.Liferay Portal Application also used different application server services such as JNDI, JDBC, JTS, JMS, JAAS, JDO, JWS, JSP/Servlets, and JavaMail
This layer we can say Application Server and Its services

liferay also use external services and These services can be deployed into application services and these services can be used by liferay such as SOLR Search engine DROOLS Rule Engine and Tunneling Servlets.When we required then we can deploy these services so that liferay can use.
Search engines(SOLR/Lucene) provide capabilities like clustering, faceted search and filtering.

Layer: 4

This layer is actual liferay core implementation and its technologies.its provide robust capabilities to run and integrate other applications into liferay.

Language adopter provide mechanism to develop and run other language portlet such as PHP, Ruby, Python and Groovy.

Portlet Bridge / JSR 168/286

Liferay implemented Portlet Bridge for deploy JSR 168/286 portlets and supports RIA applications

We can also use Web framework related Portlet Bridges to convert Web work flow into Portlet Work flow

Struts Portlet Bridges:

To run Struts framework based portlet applications.

Spring Portlet Bridge(Spring Portlet MVC):

To run spring frame work based portlets.

JSF Portet Bridge:

For JSF based portlets

JCR ( Java Content Repository):

Liferay use the JCR ( Java Content Repository) based implementation to maintain WCM such as Documents and Files.Liferay used Jackrabbit JCR implementation by default.Liferay also provide easy integration with other JCR implementation such as Alfresco.

BPM(Business Process Management):

Its provide work flow management services in liferay portal. Liferay used Kalio work flow and JBPM(jBoss Business Process Management) these are reference implementation for BPM.

Lucene Engine:

Lucene Engine is inbuilt search engine in Liferay and its also support configurable SOLR search Engine and SOLR Search Engine also implemented based in Lucene.

Liferay use different technologies to provide database relates services and other application services i.e. Spring,Hibernate and EJP are portal service implementation technologies.

Layer: 5

This layer provide defined mechanism such that we can customize or extend liferay features and provide rapid services implementation tools such as service builder.

Liferay Service Builder Tool

Liferay Service Builder Tool provide construct and deploy services and these tool use Spring and Hibernate to implement services.

Portlet plug-in :

The portlet plug-in leverages on the portlet bridge to provide dynamically generated portlets to the end users and enhanced RIA integration.

Hooks plug-in:

The hooks plug-in provide convenient access to intercept and alter the services and functionality of the Liferay instance in a standardized approach

Portal Service/Custom Services:

Portal Service/Custom Services are like core liferay services such as Group,Organization,Site,User and Roles services we can also customize services.

OOTB(Out of Box)/Custom portlets:

Liferay also capable of develop and run OOTB portlets. Liferay provide custom portlet development through plugins SDK and OOTB portlet we can use any other webapplication frameworks such as spring,struts,JSF and vaadin.

Layer 6:

Layer:6 is real world application layer that user can experiences. Liferay used all above services and capabilities and it provide robust core features such as Portal Management, Web Content Management, Enterprise Content Management, Document Management, User Management, Work flow Management, Security Management.

We will use Layer:6 liferay core capabilities and we will turn it into Personalization, Collaboration, Virtualization, Social Networking and integrates Dynamic Delivery Channels, and Tunneling Services


Reference Source Article

Wednesday, October 1, 2014

Working with Liferay User Roles


Liferay  have different types of roles for user. So whenever we develop portlet application we may get need to fetch user roles.
 
The following article will give you more about Liferay Roles


Generally we have following roles in Liferay
  1. Regular Roles/Portal Roles
  2. Organization Roles
  3. Site Roles
  4. Inherited Roles
Portal Role/Regular Roles

Liferay is providing Portal Role/Regular Role for portal level. It’s not specific to anything like Organization, Site or User Group. 

This role can be assigned to any user who belongs to any one of Organization, Community/Site or User Group.

Generally when we associate Portal Role/Regular Role s to any user then the association can be stored in Users_Roles Mapping Table.

To fetch Portal Role/Regular Role we can use RoleLocalServiceUtil.java class and these classes have many service methods which can fetch roles with respect to selected user.

We can use following ways to fetch user Portal Role/Regular Roles

Use RoleLocalSercviceUtil


List<Role> userRoles=RoleLocalServiceUtil.getUserRoles(themeDisplay.getUserId());


Use User Object 
 

List<Role> userRoles1=themeDisplay.getUser().getRoles();


Site Roles 

Site Role is one of the types in liferay which is only associated to Site users. This role only we can associate to site users. When we create site role we can use this site role to any used who belongs to any site liferay.

When we associate any site roles to user then association will be stored in UserGroupRole table.When ever we want get site roles then we have to use respective service class to access those roles like we need use UserGroupRoleLocalService.java class there we can find many service methods.


List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRoles(themeDisplay.getUserId());
List<UserGroupRole> siteRoles = new ArrayList<UserGroupRole>();
for (UserGroupRole userGroupRole : userGroupRoles) {
int roleType = userGroupRole.getRole().getType();
if (roleType == RoleConstants.TYPE_SITE) {
siteRoles.add(userGroupRole);
}
}


Organization Roles

Similar to site role organization role is used for organization users. This role can be associated to any user who belongs to any organization in portal.

When we associate any Organization roles to user then association will be stored in UserGroupRole table.When ever we want get Organization roles then we have to use respective service class to access those roles like we need use UserGroupRoleLocalService.java class there we can find many service methods.


List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRoles(themeDisplay.getUserId());
List<UserGroupRole> organizationRoles = new ArrayList<UserGroupRole>();
for (UserGroupRole userGroupRole : userGroupRoles) {
int roleType = userGroupRole.getRole().getType();
if (roleType == RoleConstants.TYPE_ORGANIZATION) {
organizationRoles.add(userGroupRole);
}
}



Inherited Roles

Inherited roles really not existed in the liferay but we can see these roles in the user my account page roles section .these roles specially appear when the user can be member of user group which is assigned a role.

We can say if any roles which associates with User Group and the user is member of respective user group then role can be visible as part of inherited roles section.

Simply we can say that user directly not associated with role instead of that User Group will be associated with role and the user will be member of User Group then the roles are become as inherited role to users who are belong to User Group.

Understanding inherited roles
  • Create User Group (Photography) and assign Users to Photography User Group
  • Create role called Photography Group Member
  • Assign User Group to Role( associate role to User Group)

Now all users who are belongs to User Group will be get Photography Group Member role as inherited role when we observe here Photography Group Member role is not directly associated with user but role is associated with Photography user group because of this Photography Group Member become as inherited role.

When we want fetch inherited roles first we need to find all User Groups of respective user so that we can fetch all inherited roles.


<%
User selUser=themeDisplay.getUser();
List<Group> allGroups = new ArrayList<Group>();
List<UserGroup> userGroups = selUser.getUserGroups();
List<Group> groups = selUser.getGroups();
List<Organization> organizations = selUser.getOrganizations();
allGroups.addAll(groups);
allGroups.addAll(GroupLocalServiceUtil.
getOrganizationsGroups(organizations));
allGroups.addAll(GroupLocalServiceUtil.
getOrganizationsRelatedGroups(organizations));
allGroups.addAll
(GroupLocalServiceUtil.getUserGroupsGroups(userGroups));
allGroups.addAll(GroupLocalServiceUtil.
getUserGroupsRelatedGroups(userGroups));
for(int i=0;i<allGroups.size();i++){
com.liferay.portal.model.Group group=allGroups.get(i);
List<Role> groupRoles = RoleLocalServiceUtil.getGroupRoles(group.getGroupId());
if (!groupRoles.isEmpty()) {
Role groupRole = groupRoles.get(0);
out.println(ListUtil.toString(groupRoles,
 Role.NAME_ACCESSOR));
}
}
%>


Note:

When we work with above code respective Java classes should be import.

The following is sample code snippets which is in JSP page


<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.liferay.portal.service.GroupLocalServiceUtil"%>
<%@page import="com.liferay.portal.model.Organization"%>
<%@page import="com.liferay.portal.model.User"%>
<%@page import="com.liferay.portal.model.UserGroup"%>
<%@page import="com.liferay.portal.model.Group"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.liferay.portal.model.RoleConstants"%>
<%@page import="com.liferay.portal.service.UserGroupRoleLocalServiceUtil"%>
<%@page import="com.liferay.portal.model.UserGroupRole"%>
<%@page import="com.liferay.portal.model.Role"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.service.RoleLocalServiceUtil"%>
<%@page import="com.liferay.portal.service.UserLocalServiceUtil"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
List<Role> userRoles=RoleLocalServiceUtil.getUserRoles(themeDisplay.getUserId());
List<Role> userRoles1=themeDisplay.getUser().getRoles();
for (Role role : userRoles) {
out.println(role.getName());
}
%>
<%
List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRoles(themeDisplay.getUserId());
List<UserGroupRole> organizationRoles = new ArrayList<UserGroupRole>();
for (UserGroupRole userGroupRole : userGroupRoles) {
int roleType = userGroupRole.getRole().getType();
if (roleType == RoleConstants.TYPE_ORGANIZATION) {
organizationRoles.add(userGroupRole);
out.println(userGroupRole.getRole().getName());
}
}
%>
<%
List<UserGroupRole> userGroupRoles1 = UserGroupRoleLocalServiceUtil.getUserGroupRoles(themeDisplay.getUserId());
List<UserGroupRole> siteRoles = new ArrayList<UserGroupRole>();
for (UserGroupRole userGroupRole : userGroupRoles1) {
int roleType = userGroupRole.getRole().getType();
if (roleType == RoleConstants.TYPE_SITE) {
siteRoles.add(userGroupRole);
out.println(userGroupRole.getRole().getName());
}
}
%>
<%
User selUser=themeDisplay.getUser();
List<Group> allGroups = new ArrayList<Group>();
List<UserGroup> userGroups = selUser.getUserGroups();
List<Group> groups = selUser.getGroups();
List<Organization> organizations = selUser.getOrganizations();
allGroups.addAll(groups);
allGroups.addAll(GroupLocalServiceUtil.
getOrganizationsGroups(organizations));
allGroups.addAll(GroupLocalServiceUtil.
getOrganizationsRelatedGroups(organizations));
allGroups.addAll(GroupLocalServiceUtil.
getUserGroupsGroups(userGroups));
allGroups.addAll(GroupLocalServiceUtil.
getUserGroupsRelatedGroups(userGroups));
for(int i=0;i<allGroups.size();i++){
com.liferay.portal.model.Group group=allGroups.get(i);
List<Role> groupRoles = RoleLocalServiceUtil.getGroupRoles(group.getGroupId());
if (!groupRoles.isEmpty()) {
Role groupRole = groupRoles.get(0);
out.println(ListUtil.toString(groupRoles,
 Role.NAME_ACCESSOR));
}
}
%>


Author

Monday, September 29, 2014

Why we need liferay in real web world / What are the main factors to choose liferay


Liferay is a portal technology which provides many features in the web world. Liferay portal developed in java technologies so that its pure java based portals.

Generally in any web application development we need to do many things when we start development from scratch.
Likewise we need to design system architecture, implement technologies, scalability, reliability, extensibility. So we need to take care all the above.

Assume we have some application already developed and if it requires customization and extensibility to add new features then we almost have application in our hand need to add changes for meeting the requirement, same thing liferay have done.

Liferay already developed portal application which covered almost all generalized webapplication needs so that we can use liferay portal to customize or extends the liferay portal according to our requirements.

As a developer we need to take care about reliability, scalability and security related things. In liferay we no need to worry for these as liferay already implemented all these features so that we can think only about our Customer requirements.

As we already know liferay is developed portlet technology which consists of multiple portlets to complete web page

Here portlet is fragment of dynamic content and each portal page have multiple portlets which loads dynamic content in the web browser to show complete web page.

The following are main reason to choose liferay in Real Web world

  • Ready to use Application
  • Easy customization and extending portal.
  • SAAS Based Portal
  • Robust Community
  • Open source CE and Enterprise Edition
  • Already developed Permission System and Security mechanisms
  • Support Multiple Server Environments and Operating Systems
  • Market Place for new portlet applications and Easy deployment
  • Robust Content Management System
  • Technology Flexibility in Development.


Ready to use Application:

Liferay is already developed potal application so we can simply installed and directly we can use it.
It already have more than 80 portlet applications so we can design our dynamic website with help of those portlet application.

Easy customization and extending portal :

Apart from generalized needs liferay also provides robust and easy mechanism to customize and extending portal so that we can full fill our requirement with help of customization or extending.
Liferay offers plugin mechanism so that we can customize or add new features to portal as per our needs. Customization achieved through liferay hook and ext plugins and extending portal achieved with help of plugin portlets.


SAAS Based Portal :

Liferay offers Software As A Service(SAAS) Mechanism so that we can install one portal instance but we can create any number of websites and each website has its own dynamic content and its own functionality. Liferay offers different ways to provide SAAS using Site, Organization and User Groups. Physically it is deployed in one application servers but virtually it seems to like many web applications. Each website has its own access point called domain so that as end user he always feels its individual website.


Robust Community :

Liferay has robus community so that we can get solutions for any challanges.Liferay providing forum discussion, wikis , blogs and documentation so that we can easyly expect solutions from community.There are many people are in the community.If any open source technologies we are going to use first we need to check community actiness. Liferay community is growing now days very rapidly.


Open source CE and Enterprise Edition :

Liferay is an open source technology so that anyone can use and experience the features. There are many people working for liferay community and releasing new version as per the new features they implemented. Liferay also provide Enterprise Edition, if anyone interested then they can purchase license too.

Already developed Permission System and Secuirty mechanisams :

Sometimes we need dynamic applications have different types of roles and permissions. This is one of the typical part in web application development but liferay already developed elegant permission system so that we can easily use it.

It is role based permission system and each user consist one or more roles and each role defied with set of permissions access the application accessibility against the user access.

Liferay also provides robust security mechanism and it also offer integrating with many of authentication implementation like Central Authentication Service(CAS)(Single Sign On And Single Sing Out) ,SAML(Security Assertion Markup Language) Integration and LDAP integration.


Support Multiple Server Environments and Operating Systems :

Liferay portal support multiple portal environments like Tomcat, Jboss, GlashFIsh, Weblogic and Websphear. And it also support any operating system like Windows and almost all Linux Flavours.


Market Place for new portlet applications and Easy deployment :

Liferay offers market place where we can get new portlet applications as for current needs in real web world. Liferay portal provides Admin Control panel where we can download and install new application from smooth user interface. So here any one can deploy portlet application without have development knowledge.


Robust Content Management System :

Liferay offer CMS features so that we can quickly design web content for page and update it. We have many features in CMS like structures and templates, work flow management.


Technolgy Flexibilty in Develoment :

To develop Liferay application, developer can choose any of the Java-J2EE technologies like Struts, Spring, JSF –etc or even we can implement with other technologies like PHP, vaadin, ruby, groovy –etc.

Note:
Apart from these liferay have many features. Please follow the liferay documentation so that we can understand more about liferay portal

http://www.liferay.com/documentation/liferay-portal/6.2/user-guide


Author



Recent Posts

Recent Posts Widget

Popular Posts