Posts

Liferay code to check is User login.

There several way to check user isLogin in liferay. 1. In Java code: From ThemeDisplay object ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); boolean signedIn = themeDisplay.isSignedIn(); 2. In Jsp file: <%@ taglib uri = "http://liferay.com/tld/theme" prefix = "liferay-theme" %> <liferay-theme:defineObjects />  < c:choose >   < c:when test = " <%= themeDisplay . isSignedIn() % > " >   <c:when >  < c:otherwise >  <c:otherwise > </ c:choose > 3. In vm file : if ($is_signed_in)  4. In Web content template: #set ($isSignedIn = $request.get("remote-user")) #if ($isSignedIn!='') #end   5. In javascript file:  <script >   $(document).ready(function(){          if((Liferay.ThemeDisplay.isSignedIn())){               ...

Sample code for geting different url in liferay.

Liferay developers often need to find different from render/servlet request. Here below i share some code to get different url in liferay Sample code:         HttpServletRequest servletRequest = PortalUtil.getHttpServletRequest(request);         String currentCompleteUrl = PortalUtil.getCurrentCompleteURL(servletRequest);         try {                         String renderCurrentURL =    PortalUtil.getCurrentURL(request);             String servletRequestCurrentURL = PortalUtil.getCurrentURL(servletRequest);             String canonicalURL    = PortalUtil.getCanonicalURL(currentCompleteUrl, themeDisplay, themeDisplay.getLayout());          ...

How to install sonar runner in unbuntu.

Create database and user: CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 'sonar' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar'; FLUSH PRIVILEGES;   Download and unzip Sonar distribution: wget http://dist.sonar.codehaus.org/sonarqube- 5.1 .zip unzip sonarqube- 5.1 .zip mv sonarqube- 5.1 /opt/sonar   Edit sonar.properties: Open /opt/sonar/conf/sonar.properties with your favourite text editor, and modify it. MySQL settings: sonar.jdbc.username=sonar sonar.jdbc.password=sonar sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance Web Server settings: sonar.web.host= 127.0.0.1 sonar.web.port=9000   Implement Sonar server as a service: sudo cp bin/linux-x86- 64 /sonar.sh /...

Create waraper to process ofbiz soap service response

How to call soap service is describe in my previous post. http://tariqliferay.blogspot.com/2015/09/how-to-create-soap-client-for-ofbiz.html Here you get response as OMElement. Then you need to process this. Now i show how can you make pojo/dto class from response for further need. Think you get campaign list in response as key="campaignList" and  value list a list of campaign. First create dto/pojo class as your requirement. Here below a sample dto: import java.io.Serializable; /**  * @author tariq  *  */ public class Campaign implements Serializable{     public String campaignName = null;     public String campaignType = null;     public String contentId = null;     public String createdStamp = null;     public String createdTxStamp = null;     public String emailSubscription = null;     public String lastUpdatedStamp = null;  ...

How to configure/integrate ldap with liferay.

Image
Its very easy to integrate/configure ldap with liferay. To do this you need below: 1. LDAP server(to manage user, groups and authentication) Follow below link to install Ubuntu in linux .. http://www.unixmen.com/install-and-configure-openldap-in-ubuntu-15-04-and-debian-8/   2. Login liferay as admin and go to control panel> got portal settings > authintication and then configure as below: Export Mapping: Users DN = dc=example,dc=com User Default Object Classes = top,person,inetOrgPerson,organizationalPerson User Mapping: Screen Name =cn Email Address =mail Password =userPassword First Name =givenName Last Name =sn Connection: Base Provider URL=ldap://localhost:389 Base DN=dc=example,dc=com Principal =cn=admin,dc=example,dc=com Credentials = ldap admin pass Users: Authentication Search Filter=(mail=@email_address@) Import Search Filter=(objectClass=person) Finally change the below properties: ldap.auth.password.encrypt...

How to create soap client for ofbiz service or ofbiz service invocation from another application.

Sometimes ofbiz developer need to integrate ofbiz with 3rd party or another web application. This is very simple to create soap service in ofbiz.In ofbiz here soap engine to mail soap service. To create soap service or make service exportable follow the bellow steps: 1. Set export="true" in service definition for example   <service name="createColleague" engine="java" auth="true"         location="org.ofbiz.crm.colleague.ColleagueService" invoke="createColleague" export="true" > </service> You find all exportable service or soap service wsdl under webtools component. Open a your browser new tab and below url, http://localhost:8080/webtools/control/SOAPService?wsdl  Here you find all soap or exportable service. 2. Create java client to all this as below, /**  *  */ import java.util.Map; import java.util.logging.Logger; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axio...

How to change Portrait/Profile photo in liferay programitically.

Sometime liferay developer need to change profile/portrait photo programmatically . Here i want to share my experience. Create portlet action url and method as below: In jsp file create action url: <script type="text/javascript" src="<%= request.getContextPath()%>/js/jasny-bootstrap.min.js"></script> <link rel="stylesheet" href="<%= request.getContextPath()%>/css/jasny-bootstrap.min.css"> <portlet:actionURL name="updateProfile" var="updateProfileURL" windowState="normal"/> <form action="<%=updateProfileURL %>" method="post" enctype="multipart/form-data" id='<portlet:namespace/>updateProfile'>                 <input name="<portlet:namespace/>userEmail" id='<portlet:namespace/>userEmail' type="hidden" value="" />                 <div class="col-xs-12 col...