Posts

Points to remember when we write the custom login portlet

Suppose you need to create the custom login portlet, which does not satisfy the default liferay's login portlet. then you need to update the following properties in the portal-ext.properties. 1. If your portlet name is "Custom login" then you need to update this property      auth.login.portlet.name= Custom login. 2. Also we need to mention the Page name(friendly URL) where this login portlet resides.      auth.login.url=/web/guest/ login

Tranaction in Liferay

Following content is Pasted from the below url http://www.liferayaddicts.net/blogs/-/blogs/transaction-management-with-liferay-service Following are the important points that a Liferay Architect must make note of in order to work with Transactions in Liferay The entry point to transaction (start of transaction boundary) in Liferay service is the <Entity>LocalServiceImpl class. Hence, while firing DML oriented methods like update, insert and delete on X Entity from Y do not use make calls to XLocalServiceUtil or XLocalService as this will result in two transaction boundaries - one for entity X and the other for entity Y. Relate the two entities through service.xml file (one to many or many to many based on your domain model) or else refer one entity in the other using <reference... in service.xml file. For e.g. if you want to make call on X entity from YLocalServiceImpl then in service.xml file while configuring Y Entity put <reference entity="X" package...

Difference between InnoDB and MyISAM in MySQL?

InnoDB : is a storage engine for MySQL. MyISAM : is the default storage engine for the MySQL relational database management system versions prior to 5.5 1. The major deficiency of MyISAM is the absence of transactions support . Versions of MySQL 5.5 and greater have switched to the InnoDB engine to ensure referential integrity constraints, and higher concurrency. Ensure that your database supports transactions; yes ! this is needless to say but then if you are using MySQL, the database engine other MyISAM does not support transactions. You must use InnoDB as the database engine for your tables.

sanitizers in liferay

Liferay Uses Stanitizers to escape the XSS elements In Portal-model-hints.xml for blog title <sanitize content-type="text/plain" modes="ALL" /> In Portal.properties sanitizer.impl=com.liferay.portal.sanitizer.DummySanitizerImpl Following Links which explains how to use it 1.http://www.liferay.com/community/forums/-/message_boards/message/12668382 2.https://www.liferay.com/web/juan.fernandez/blog/-/blogs/sanitizers-in-liferay-6 We need antiSamy hook to deploy , to work as excepted.

Checking weather the user has the role Organization Administrator.

Whenever we are creating the Organization we can assign the user to the Organization also we can assign the Organization role to the User. As of now we have 2 roles. 1.Organization Owner. 2. Organization Administrator. User who created the Organization will have the role "Organization Owner". But we need to manually assign the "Organization Administrator" to the user. In programmatically to check weather user has roles or not here is the code. ThemeDisplay  themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY); try {         Role role = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),RoleConstants.ORGANIZATION_ADMINISTRATOR);  //Get the Role List<UserGroupRole> userGroupList = UserGroupRoleLocalServiceUtil.getUserGroupRoles(themeDisplay.getUserId()); //Getting the Roles of the User for(UserGroupRole userGroupRole :userGroupList) { //Iterating the loop      if...

Checking the Weather user has userdelete Permission or not.

First of all we need the permission checker we can get it from the themedisplay . PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();  boolean deleteStatus  = false; try { Getting the all the Role of the User List<Role> roleList = RoleLocalServiceUtil.getUserRoles(themeDisplay.getUserId());     for(Role role : roleList) { Iterating the all the roles of the user           if(permissionChecker.hasPermission(themeDisplay.getScopeGroupId(), User.class.getName(),                          role.getRoleId(), ActionKeys.DELETE)) {            deleteStatus = true;         System.out.println("roleId"+role.getName());          }     } } catch (SystemException e) {           e.printStackTrace(); }

Ajax Implementation in the Liferay

Creating the Resource URL Liferay's default uses the resource url for ajax requests          <portlet:resourceURL id="addResource" var="addResourceURL">         </portlet:resourceURL> Creating the Ajax function creating the Jquery  ajax function function <portlet:namespace/>getEntries(){                 var url = "${addResourceURL}";                         $.ajax({                                 type : "POST",                                 url : url,                                 dataType : "JSON",                 ...