Monday 17 December 2018

Sonar Integration with MAVEN


1) Download the apache-maven-3.3.9 software
2) Download the sonarqube-7.4 software
3) Extract the above two softwares into a one folder
4) Set up a maven path in Environment system variable
        C:\Softwaes\apache-maven-3.2.1\bin
5)  Check the maven path setup or not
       Goto Command Prompt -> mvn -version
6)  Add the below properties in setting.xml file
        Goto   C:\Softwaes\apache-maven-3.2.1\conf\
       1)   Open setting.xml file uncomment the below property under "<pluginGroups>" tag
                         <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
      2) Add the below property under  "<profiles>" tag
             <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- Optional URL to server. Default value is http://localhost:9000 -->
                <sonar.host.url>
                  http://localhost:9000
                </sonar.host.url>
            </properties>
        </profile>
7) Run the sonarqube server
8) Create maven application or go to existing application
1) build the maven application
mvn clean install
2) mvn sonar:sonar
9) Access Sonar url "localhost:9000"
10) Get the report of project status under PROJECTS

        

Wednesday 5 December 2018


How to Inject OSGi custom services in Custom Portlets in Liferay 7



1) Create a service builder portlet by using servicebuilder plugin.
2) Generate the OSGI service.
3) Goto xxx-service portlet under build.gradle file 
The below dependencies are generated.
dependencies {
        compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
compileOnly group: "com.liferay", name: "com.liferay.osgi.util", version: "3.0.0"
compileOnly group: "com.liferay", name: "com.liferay.portal.spring.extender", version: "2.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
compileOnly project(":modules:EmployeeApp:EmployeeApp-api")
}
4)  Create a sample Portlet
5) Use the custom services in sample portlet
         Add the below dependencie in sample portlet build.gradle file
        compileOnly project(":modules:EmployeeApp:EmployeeApp-api")
6) Refresh the gradle project

Tuesday 6 February 2018

User Landing page validation based on roles
================================

Portal.properties
==================
login.events.post=com.agco.dealer.hook.events.controller.CustomLoginPostAction

liferay-hooks.xml
=================
<hook>
<portal-properties>portal.properties</portal-properties>
</hook>


package com.agco.dealer.hook.events.controller;

public class CustomLoginPostAction extends Action {


public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

long companyId = themeDisplay.getCompanyId();
        User user = themeDisplay.getUser();
        long userId = user.getUserId();

List<Role> userRoles = RoleLocalServiceUtil.getUserRoles(user.getUserId());
for(Role role : userRoles) {


  if(role.getName().equalsIgnoreCase("X")){
  response.sendRedirect("/web/test");

}
if(role.getName().equalsIgnoreCase("Y")){
  response.sendRedirect("/web/sample");

}
}



}
}

  Inter Portlet Communication (IPC) in Liferay 7.4 Public Render Parameter IPC: 1) Create a new module project -> SenderPortlet 2) In  Se...