Liferay.com

Friday, September 18, 2015

Tomcat windows click on startup.bat disappering

Start tomcat with catalina.bat run option

C:\lr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\bin>catalina.bat run
Using CATALINA_BASE:   "C:\lr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27"
Using CATALINA_HOME:   "C:\lr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27"
Using CATALINA_TMPDIR: "C:\lr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\
Using JRE_HOME:        "C:\lr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27/
Using CLASSPATH:       "C:\lr\liferay-portal-6.1.20-ee-ga2\tomcat-7.0.27\
Error occurred during initialization of VM
Could not reserve enough space for object heap

You will know the issue why it was disappearing. Fix it based on error accordingly. In this particular case I reduce -XX:MaxPermSize value from 512m to 256m


Tuesday, March 3, 2015

Configure Test Mail Server Tool

Steps 2 configure Test Mail Server Tool
1) download & install Test Mail Server Tool from below link - once installed changed the port to 2525

 http://www.toolheap.com/test-mail-server-tool/

2) configure liferay mail settings accordingly (Server Administration > Mail )



no user details given while configuring mail settings in Liferay

3) open eml file viewer installed from below link, browse to mail path to store received email (C:\Users\Nagendra Busam\Desktop\Mail Sent to Local Server) . As I have testing this on Windows 7, it is doesn't have eml viewer by default installed this.
http://www.freeviewer.org/eml/

4) created user to check whether default MESSAGE if not configured mail server shows up (as below)

][MailEngine:592] Failed to connect to a valid mail server. Please make sure one is properly configured. Could not connect to SMTP host: localhost, port: 25

If not showing up you have configured your mail server properly

Thursday, February 26, 2015

Change Liferay site name to different name


1) Go to the place show in control panel, do the change to Name field


2) through portal properties

I think you need to change company.default.name property value to whatever you want to

Thanks.

Wednesday, September 24, 2014

Quick checking of API methods - Groovy Script (at Control Panel > Server Administration > Script)

Here are some snippets,

======================================================
Case 1 : here I am checking whether a particular User Group & Role exists
======================================================

import com.liferay.portal.service.UserGroupLocalServiceUtil
import com.liferay.portal.service.*
import com.liferay.portal.util.*
import com.liferay.portal.kernel.util.PropsUtil
import com.liferay.portal.kernel.util.PropsKeys

companyId = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID)).getCompanyId()
out.println(companyId );

try{
// Get User Group(s)
def customGroup = UserGroupLocalServiceUtil.getUserGroup(companyId , "My Org Admin")
out.println("User Group exists : Agency Admin :"+customGroup)

// Get role(s)
def customRole = RoleLocalServiceUtil.getRole(companyId, "My Org Admin")
out.println("Role exists : Agency Admin :"+customRole)

def groupIds = [customGroup.getGroupId()] as long[]
GroupLocalServiceUtil.addRoleGroups(customRole.getRoleId(), groupIds)
}catch(Exception){
out.println("My Org Admin -- UG not exists")
}

======================================================
Case 2 : updating one of my custom field
======================================================

import com.liferay.portal.service.*
import com.liferay.portal.util.*
import com.liferay.portal.kernel.json.*
import com.liferay.portal.kernel.util.PropsUtil
import com.liferay.portal.kernel.util.PropsKeys
import com.liferay.portal.model.RoleConstants

companyId = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID)).getCompanyId()
out.println(companyId );

try{
role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR)
users = UserLocalServiceUtil.getRoleUsers(role.getRoleId())
out.println(users)
out.println(JSONFactoryUtil.looseSerialize(users))
out.println(">>>>>>>>>>>>>>>>>>>>>. groovy iterate")
users.each() { it ->
println it
field = it.getExpandoBridge().getAttribute("sbm-user-id", false)
out.println("initial value :"+field)

if(!field){
it.getExpandoBridge().setAttribute("sbm-user-id", it.getEmailAddress())
}

out.println("end value :"+it.getExpandoBridge().getAttribute("sbm-user-id", false))
}


}catch(Exception){
out.println("Administrator role not exists")
}

Hope it helps some body :)

Thanks.


Tuesday, September 23, 2014

Grabbing permission keys of a custom role from control panel

We ran into a use case where we need to automate creation of custom roles having several hundreds of permission keys.

It's kind of tire some to grab each & every one either by looking into source code or grabbing using some browser tools.

I wrote a simple java script to grab keys for each portlet. We need to go to each portlet level to grab exact keys.

It will print in console relevant permissions for that particular portlet. I am using 6.2 for you reference

HOW TO TEST

>> After you navigation to your custom role, particular portlet - CTRL+SHIFT+J (in chrome)
>> paste below code & hit enter - it will spill relevant keys on console.

/*
Start
*/

var topPortletTxt = AUI().one('#_128_permissionContentContainer').one('h3').text();
var topGeneralNode = AUI().one('#_128_permissionContentContainer').one('h4');
var topGeneralTxt;
if(topGeneralNode != null){
topGeneralTxt = topGeneralNode.get('firstChild').get('textContent');
}

console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' + topGeneralTxt + ' > ' + topPortletTxt + '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<');

var resourcePermissionsFull = "";

var resourcePermissionStartOpen = '';

var resourcePermissionEnd = "
";
var resourcePermissionActionStart = "";
var resourcePermissionActionClose = "
";
var topLevelResourceId = AUI().one('#_128_portletResource').val();

var commentStart = '';
resourcePermissionsFull = resourcePermissionsFull + commentStart + topGeneralTxt + ' > ' + topPortletTxt + commentEnd + '\n';
resourcePermissionsFull = resourcePermissionsFull + resourcePermissionStartOpen + topLevelResourceId + resourcePermissionStartClose;

var generalResourcePermissionsAll = "";
topGeneralNode.get('nextElementSibling').all(':checked').each(function(node1) {
        console.log(node1.val());
        if (node1.val().indexOf(topLevelResourceId) != -1) {
            generalResourcePermissionsAll = generalResourcePermissionsAll + resourcePermissionActionStart + node1.val().replace(topLevelResourceId, '') + resourcePermissionActionClose;
        }
    }

);

resourcePermissionsFull = resourcePermissionsFull + generalResourcePermissionsAll + resourcePermissionEnd;

console.log("resourcePermissionsFull : Top > \n\n" + resourcePermissionsFull);

// Related portlet permissions
/*
var relatedPortletsTxt = AUI().one('#_128_relatedPortletResources').ancestor().get('previousElementSibling').get('textContent');

var resourcePermissionsFull = resourcePermissionsFull + commentStart + topPortletTxt + ' > ' + relatedPortletsTxt + commentEnd + '\n';

var resourcePermissionsAll2 = "";
AUI().one('#_128_relatedPortletResources').get('nextElementSibling').all(':checked').each(function(node2) {
            console.log(">>" + node2.val());
var resourceId = parseInt(node2.val(), 10);
var resourcePermissionStartTemp = resourcePermissionStartOpen + resourceId + resourcePermissionStartClose;

resourcePermissionsAll2 = resourcePermissionsAll2 + resourcePermissionStartTemp;
resourcePermissionsAll2 = resourcePermissionsAll2 + resourcePermissionActionStart + node2.val().replace(resourceId, '') + resourcePermissionActionClose;
resourcePermissionsAll2 = resourcePermissionsAll2 + resourcePermissionEnd;

}
);
console.log("resourcePermissionsAll2" + resourcePermissionsAll2)

resourcePermissionsFull = resourcePermissionsFull + resourcePermissionsAll2;

console.log("resourcePermissionsFull : After Related portlet permissions > \n\n" + resourcePermissionsFull);
*/

// Resource permissions

var topResourceTxt = AUI().all('.permission-group').get('previousElementSibling').get('firstChild').get('textContent');

AUI().all('.permission-group h5').each(
    function(node) {
        console.log(topResourceTxt + ' > ' + node.html());
        resourcePermissionsFull = resourcePermissionsFull + commentStart + topResourceTxt + ' > ' + node.html() + commentEnd + '\n';

        var nodeIdPackageConv = node.get('id').replace('resource_', '').replace(/_/g, ".");
        console.log(nodeIdPackageConv);
        var resourcePermissionStartTemp = resourcePermissionStartOpen + nodeIdPackageConv + resourcePermissionStartClose;
        var resourcePermissionsAll = "";
        node.get('nextElementSibling').all(':checked').each(function(node2) {

            console.log(">>" + node2.val().replace(nodeIdPackageConv, ''));
            resourcePermissionsAll = resourcePermissionsAll + resourcePermissionActionStart + node2.val().replace(nodeIdPackageConv, '') + resourcePermissionActionClose;
        })
        resourcePermissionsFull = resourcePermissionsFull + resourcePermissionStartTemp + resourcePermissionsAll + resourcePermissionEnd;
    }
);

console.log("resourcePermissionsFull : Final > \n\n" + resourcePermissionsFull);

/*
End
*/

Hope it helps some body :)

Thanks.

Friday, July 18, 2014

Useful portal properties

########### you can hide Openid, Create Account,Forgot Password links by setting below properties in portal-ext.propeties. ###########
##
## Company
##
company.security.send.password=false

company.security.login.form.autocomplete=false

company.security.send.password.reset.link=false

company.security.strangers=false

company.security.strangers.verify=false

##
## OpenID
##

open.id.auth.enabled=false


Set below property to false in portal-ext.properties file if your liferay application server has concurrency issues with deploying large WARs.
auto.deploy.unpack.war=false


########### You can hide Liferay Version by adding below property in portal-ext.properties file ###########
# to hide Liferay Version
http.header.version.verbosity=partial


##  Steps to Change Liferay Context path:
##  Step 1: go to {liferay.home}\conf\Catalina\localhost\ROOT.xml
##  Rename ROOT.xml to required name. Eg. if you want context as portal then you have to rename ROOT.xml as portal.xml
##  Step 2: open portal.xml edit as below.
##   
##  Step 3: Add following property in portal-ext.properties
##  portal.ctx=/portal 

##  Done, restart your server. then access your server using : localhost:8080/portal

P.S. some properties are compiled by gather from online resources

Saturday, July 12, 2014

How to change maximize & minize icon in 6.2

There was a peculiar use case I ran into when i am working on a project.

Portlet icons needs to be changed in following scenarios
1) default maximize icon
2) icon we have with portlet once maximized
3) icon we have with portlet once minimized

Here is the CSS code snippet for the same.
/*to change icono f maximize to icon-resize-full*/
.aui .icon-plus:before {
    content: "\f065";
}
/* to change icon next to Restore when portlet minimized to icon-plus*/
.aui .icon-resize-vertical:before{
 content: "\f067";
}

Hope it helps somebody - Cheers :)