Monday, 15 January 2018

Lets under stand what are changes with Liferay 7/DXP version

Latest and stable Liferay version :

  • Liferay Community Edition = Liferay 7.1
  • Liferay Enterprise Edition = Liferay DXP

Technological update required:


  • Tomcat 8
  • JDK 8
  • Mysql 5.7
  • Eclipse Update / Liferay IDE 3

 Look and Feel :


  • Lexicon Design Language
    • set of patterns (visual and interaction)
    • designed to be fluid and extensible
  • Optimized product navigation
  • New Forms user experience
  • Geolocate any content
  • New image, file and media selector
  • Fast response - avoiding full page refreshes
  • Single Page Applications – senna.js
  • Very Good News - IE support 10,11/Edge

Modularity - OSGI


  • Monolithic to Microservices
  • Now 500+ new modules (bundles in the osgi world),
  • We can change any way we like, simply by overriding them with our own modules.
  • No ext plugins any more.

OSGI:


  • Liferay Module Framework
    • Apache Felix
    • Declarative Services (replaces .xml configurations)
    • Bndtools
    • Gogo Shell for manipulating the module lifecycle and many other things
  • Semantic Versioning
  • Blade Tool/Blade CLI

Others :


  • Lucene Gone, Elastic Search(Separate Server)
    • Optionally Solr, support only in EE
  • Goodbye Ant, Hello Gradle (maven is still there)
  • Build tool based on Node.js for Theme development
  • New mobile SDK with Liferay screens 2
  • Clustering not supported in CE

Wednesday, 3 January 2018

Liferay Interview Questions

Liferay is one of the most popular JSR compliant open source portal. This can be used to drive multiple websites with the variety of features and look and feel. Liferay is developed in Java and the major portlet development on it is also supported by Java and few other languages.

I have worked on Liferay for more than 3 years and found that following interview questions are must know before getting a decent Liferay developer job.

1) What are the various ways in which you can customize the default behavior of Liferay that ships to you?
2) What is the difference between a Liferay Hook and Liferay EXT?
3) Suppose I want to customize the behavior of Calendar portal that comes out of the box with Liferay, how can I do that?
4) How will you configure Liferay to authenticate users from LDAP?
5) What is inter-portlet communication and how can that be achieved?
6) What is the difference between view and edit modes of a portlet?
7) What is service.xml and how will you use Liferay service builder?
8 ) Suppose I have a portlet written for Liferay 6.1 and I want to run it on Liferay 6.2, how can I do that? What if I get some spring and hibernate related exceptions with Liferay 6?
9) There is a requirement from the client that out of 4 portlets that you have written only 2 should be visible to a particular category of users. How will you achieve that? What if some fields in the remaining 2 portlets have also to be controlled based on user role?
10) What is the purpose of portal-ext.properties?
11) What steps will you follow to change the layout and theme of the portal pages?
12) Suppose I want to change the background color of the footer in Liferay, what steps should I follow?
13) Which JSR is being implemented by Liferay?
14) What improvements would you like to see in Liferay 6 portal?
15) There are 1000 users using the portlet developed by you, how will you take care of transaction management.
16) A client has two different portal applications for Sales and HR department. The client wants to run these portal applications on the same server but with separate URLs like http://:/sales and http://:/hr. How will you achieve that?
17) What are the minimum Java methods one needs to override in order to write a portlet?
18) How will you make the user go from one JSP to another JSP page in a portlet?
19) While building a service using service builder, what is the purpose of specifying remoteservice=true in service.xml?
20) How to control the category in which the Liferay portlet created by me will be displayed?
21) What is hot deployment feature of Liferay? Where will you place your portlets for them to be deployed without server restart?
22) Does Liferay support email notifications out of the box for portlets involving workflow?
23) What is the purpose of mode and persistence packages which are created by the Liferay service builder?
24) If there are 3 portlets and all of them need to talk to different database systems (say MySQL, Oracle and SQL Server) because of some legacy application requirements. How will you make them connect to different databases?
25) Can you configure the database connection pool created by Liferay?
26) Can you list down various tools and frameworks used by Liferay? e.g. It uses Lucene for search
27) Suppose a client is pursuing a Liferay based solution to their requirements, what non-functional clarifications will you ask the customer?
28) Is there a build number associated with a portlet assigned by the service builder? Where can we find the current build number?
29) Have you tried the Liferay 6 Eclipse plugin? What all limitations have you found?
30) How do you log events in a portlet? Do I need to configure Log4J for every portlet or is there a common place where one can configure Log4J so that all Liferay portlets can use logging API?
31) Do you know how to update your setup of Liferay 6.1 to Liferay 6.2?
32) Can I run my Struts 1.3 based legacy application as a portlet application? How?
33) Is it a good design to meet the customer requirements by creating a single portlet or splitting them into multiple portlets? What criteria will you use to split the functionality into multiple portlets?
34) What advantages do you see in running the Liferay portal application on an application server like JBoss than running it on a web server like Tomcat?
35) What all other portals have you heard of? How do you compare them to Liferay?
36) How will you implement i18 in a portal application? What if you want the user to choose his language preference?
37) There is a portlet application for managing images similar to Flickr. The user wants to see the images on the full screen. Will Liferay allow you to do that?
38) I have a war file of the portlet which is created using service builder, what is the difference between pasting this war file in the deploy folder of Liferay and application folder of the server (like web apps in case of Tomcat)?
39) How will you set-up a clustered Liferay portal on 5 servers available to you?
40) How much user base can Liferay support without affecting performance?
41) There is a JRE shipped with Liferay package, do we not need a JDK and what is the purpose of bundled JRE?
42) Suppose there is a requirement from client to implement search functionality in Liferay portlet, does Liferay provides any API out of the box to support search?
43) What are the various ways in which one can override the default behaviour of Liferay?
44) The service builder can also build WSDL for you. What is the benefit of this feature provided by Liferay?
45) How will you build a portlet that can be added only single or multiple times in to the portal application?
46) Is it possible to set a session time out for a portlet which is different from other portlets and the Liferay portal?
47) What is the flow of HTTP request in Liferay?
48) The JSPPortlet.java extends  the MVCPortlet.java class. What purpose does MVCPortlet.java fulfill?
49) How do you perform Junit tests on your portlet? How do tackle the dependency on the MVCPortlet.java?
50) Is it mandatory to have the view logic in view.jsp? Can one configure some other JSP (say MyJSP.jsp) to be default view page than view.jsp?

Wednesday, 15 November 2017

Implicit Objects From Liferay JSP

We Can access Various Information related to the user, portlet, layout, theme, etc in the JSP files Using Liferay JSP Implicit Objects. Let's see what are all Complete List of Liferay Implicit Objects available in Liferay 7.

In Liferay have two tag libraries which grant access to Liferay JSP Implicit Objects.

Implicit Objects From Portlet:defineObjects Taglib.

To Get all these implicit objects, <portlet:defineObjects /> must be added In the JSP, these objects hold the information about the portlet parameters and related data.

actionRequest
actionResponse
eventRequest
eventResponse
liferayPortletRequest
liferayPortletResponse
portletConfig
portletName
portletPreferences
portletPreferencesValues
portletSession
portletSessionScope
renderRequest
renderResponse
resourceRequest
resourceResponse
searchContainerReference

Implicit Objects From Liferay-Theme:defineObjects Taglib

To Get all these implicit objects, <liferay-theme:defineObjects /> must be added In the JSP, these objects hold various information related user, portlet, layout, theme, portal, permissions etc.

account
colorScheme
company
contact
layout
layouts
layoutTypePortlet
locale
permissionChecker
plid
portletDisplay
portletGroupId
realUser
scopeGroupId
theme
themeDisplay
timeZone
user

Implicit Objects From JSP

These are the default implicit objects available from the JSP, you don't have to include any Taglib for them.

application
config
out
page
pageContext
request
response
session

Thursday, 14 September 2017

Liferay Default Theme Velocity Variables

List of velocity variables in theme template


Liferay Default Theme Velocity Variables tutorial will show light on the available velocity variables in Liferay theme. As you already know, Liferay already set parent variables in init.VM (/Liferay-home/tomcat/web apps/ROOT/HTML/themes/unstyled-theme/templates/init.vm).

Variables:

  • $theme_display
  • $portlet_display
  • $request
  • $css_folder       — -$theme_display.getPathThemeCss()
  • $images_folder —  $theme_display.getPathThemeImages()
  • $javascript_folder –$theme_display.getPathThemeJavaScript()
  • $templates_folder — $theme_display.getPathThemeTemplates()
  • $full_css_path
  • $company
  • $layout  –  Current layout
  • $user
  • $full_templates_path
  • $is_signed_in  — $theme_display.isSignedIn()
  • $current_time
  • $the_year
  • $permissionChecker.isOmniadmin() –> to check Super Admin
  • $dateUtil
  • $escapeTool
  • $propsUtil  -> To get Portal Ext Properties ($propsUtil.get(“propertye-key”))
  • $paramUtil
  • $getterUtil
  • $htmlUtil
  • $portalUtil
  • $portal
  • $prefsPropsUtil
  • $propsUtil
  • $portletURLFactory   ->    Here is sample code to create Portlet URL’s in Velocity templates.                     #set($test_plid = $portalUtil.getPlidFromPortletId($theme_display.getScopeGroupId(), false,                      “test_WAR_testportlet”))                                                                                                                   #set ($test_url = $portletURLFactory.create($request, “test_WAR_testportlet”,                                              $test_plid, “RENDER_PHASE”))                                                                                                                      $test_url.setWindowState(“normal”)                                                                                                        $test_url.setPortletMode(“view”)                                                                                                              $test_url.setParameter(“privateLayout”, “false”)                                                                                      $test_url.setParameter(“cmd”, “basicView”)
  • $stringUtil
  • $unicodeFormatter
  • $validator
  • $arrayUtil
  • $browserSniffer
  • $dateFormats
  • $dateTool
  • $dateUtil
  • $escapeTool
  • $expandoColumnLocalService
  • $expandoRowLocalService
  • $expandoTableLocalService
  • $expandoValueLocalService
  • $httpUtil
  • $imageToken
  • $iteratorTool
  • $languageUtil
  • $unicodeLanguageUtil
  • $localeUtil
  • $randomizer
  • $serviceLocator
  • $sessionClicks
  • $staticFieldGetter
  • $listTool
  • $mathTool
  • $sortTool
  • $numberTool                                                                                                                                                                                                                                                                                                                  Useful code snippets in Liferay theme Velocity templates:
  • Theme. Runtime is used to insert portlet at theme level
    • $theme.runtime(“emailnotification_WAR_kpiemailnotificationportlet_INSTANCE_adfckdkkek”)
  • to check Omni admin
    • #if ($is_signed_in && $permissionChecker.isOmniadmin())
      #dockbar()
      #end
  • To get the cotent based on locale:
    • $languageUtil.get($locale, $the_title, $page.getName($locale))

  • Wednesday, 13 September 2017

    Liferay - Build number deployment error

    Many times while deploying portlet you people might have seen following error.


    Build namespace ABC has build number X which is newer than Y.

    Lets first understand why this error is coming . Whenever we build services for our portlets buidl number inside service.properties is getting incremented. And when you deploy portlet Liferay will compare build number available inside service.properties against the build number available inside servicecomponent table. If the build number inside service.properties is less then the one inside servicecomponent table it means you are downgrading your build and your DB changes wont be affected . At that time portal will throw this exception saying

     "Build namespace ABC has build number 3 which is newer than 1". 

    To resolve this problem we need to increase the build number inside service.properties file . For above scenario we need to changes build number to either 3 or greater then 3.

    build.number=4 

    Another solution (not recommended) is you can delete entries for your portlet from servicecomponent table. For more information check this thread on Liferay Forum.

    Popup in Liferay Using Alloy-ui

    Here is the sample example to display pop up in liferay using Alloy -ui

    In pop up body you can display any thing you want

    here in our example we will display simple greeting message in pop up window

    These are Imports:

    <%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
    <%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
    <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
    <%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
    <%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
    <%@page import="com.liferay.portal.kernel.language.LanguageUtil"%>
    <%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
    <liferay-theme:defineObjects/>
    <portlet:defineObjects/>

    Render URL

    <portlet:renderURL var="simpleDialogIframe"
     windowState="<%=LiferayWindowState.POP_UP.toString()%>">
     <portlet:param name="render" value="showPopUp"/>
     </portlet:renderURL>

    In Controller Render()

    @RenderMapping(params = "render=showPopUp")
    public String showPopup(RenderRequest request, RenderResponse response){
    System.out.println("Under Render");
    return showPopUp;
    }

    Button On Click Opening PopUp

     <aui:button name="f1" value="Click" onClick="popUpModel()"/>

    PopUp Script

     <aui:script>
     function popUpModel(){
     var url = "<%=simpleDialogIframe.toString()%>";
       AUI().use('aui-base', 'liferay-util-window', 'aui-io-plugin-deprecated', function(A){
           var popupWidth = 300;
           var customPopUp = Liferay.Util.Window.getWindow({
               dialog:{
                   centered: true,
                   constrain2view: true,
                   modal: true,
                   resizable: false,
                   destroyOnClose: true,
                   destroyOnHide: true,
                   width: popupWidth,
                   height:250,
                   after:{
                       destroy: function(event){
                       }
                   }
               },
               id: "<portlet:namespace/>dialogId"
           }).plug(A.Plugin.DialogIframe,{
               autoLoad: true,
               iframeCssClass: 'dialog-iframe',
               uri: url
           }).render();

           customPopUp.show();
           customPopUp.titleNode.html('<h1>RITHWIK</h1>');

       });
    }

    </aui:script>

    in our example we have created one spring portlet in that i am opening a PopUp in PopUp I am rendering jsp 

    Friday, 19 May 2017

    Bootstrap Datepicker Change Language Dynamically

    I am now wanting to dynamically change the language of the date picker when the user changes a language of PORTAL.

    I'm trying to localize the bootstrap-datetimepicker which has a folder 'locales' that contains the different languages.

    The plugin supports i18n for the month and weekday names and the weekStart option. The default is English ('en'); other available translations are avilable in the js/locales/ directory, simply include your desired locale after the plugin. To add more languages, simply add a key to $.fn.datetimepicker.dates, before calling .datetimepicker().  

    To your View page and design your page likes this:

        <div class="span12">
              
                <span class="span5">
                    <aui:input  name="fromdate" id="from-date-input" value='${fromdateValue}'
                           inlineField="true" readonly='true' data-date-autoclose='true'>                  
                    </aui:input>
                </span>
              
                <span class="span5">
                    <aui:input  name="todate" id="to-date-input" value='${todateValue}'
                             inlineField="true" readonly='true' data-date-autoclose='true'>
                    </aui:input>
                </span>
              
                <span class="span2">
                    <input type="submit" value="Go" name="Go" onclick="<portlet:namespace/>dateValidate();" >
                </span>
              
            </div>


    Now We have to download bootstrap-datetimepicker.de.js from bootstrap site.

    NOTE:The default is English (“en”); Am using GERMAN(de) for demonstration, other available translations are available in the js/locales/ directory, simply include your desired locale after the plugin.

    Then we have JS folder in our Portlet. There we have put the file bootstrap-datetimepicker-de.js with the following content.


     datetimepicker-de.js code like that:

    /**
     * German translation for bootstrap-datepicker
     * Sam Zurcher <sam@orelias.ch>
     */
    ;(function($){
        $.fn.datepicker.dates['de'] = {
            days: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"],
            daysShort: ["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam"],
            daysMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
            months: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
            monthsShort: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
            today: "Heute",
            monthsTitle: "Monate",
            clear: "Löschen",
            weekStart: 1,
            format: "dd.mm.yyyy"
        };
    }(jQuery));


    Next we can add this bootstrap to our liferay-portlet.xml file.  like

    <footer-portlet-javascript>/js/bootstrap-datepicker.de.js</footer-portlet-javascript>

    Next we can add the script to our view page JSP, If locale change Date-picker should be change en to de:

    <script>
           $(document).ready(function(){
                 var locale = "<%=themeDisplay.getLocale().toString()%>";
                 console.log("Locale Value is......."+locale);
                 var jslocale = 'en';
                 if(locale=="de_DE"){
                     jslocale='de';
                 }
                 $("#<portlet:namespace/>to-date-input , #<portlet:namespace/>from-date-input").datepicker({
                   autoclose:true,
                   format: "dd/mm/yyyy",
                   endDate: '+0d',
                   language: jslocale
                  });
                }); 

    </script> 

    To restrict the date picker from taking future date:
    I have added a Bootstrap property in above script-

     endDate: '+0d'

     Now its time for validation on datepicker:
    For my case i added these 3 validation- 
    1.From and To dates are required.
    2.From date cannot be greater than the To date.
    3.Date range must be within 1 month.

        function <portlet:namespace/>dateValidate(){
            var fromdate="";
            var todate ="";
            var startDate = "";
            var endDate = "";
            var months = 0;
            var daysDiff = 0;
            var timeDiff = 0;
            var selFromDate = $("#<portlet:namespace/>from-date-input").val();
            var selToDate = $("#<portlet:namespace/>to-date-input").val();
          
            if(selFromDate!=null && selFromDate!='' && selToDate!=null && selToDate!=''){
                  var fdate = selFromDate.split("/")
                  var tdate = selToDate.split("/")
                  var fromNewDat = new Date(fdate[2], fdate[1] - 1, fdate[0]);
                  var toNewDat = new Date(tdate[2], tdate[1] - 1, tdate[0]);
                  startDate = new Date(fromNewDat);
                  endDate = new Date(toNewDat);
                  timeDiff = endDate - startDate;
                  daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
                 }
            if (selFromDate == "" || selToDate == ""){
                $('#<portlet:namespace/>errorMessage').html('From and To dates are required');
            }else if (startDate > endDate){
                $('#<portlet:namespace/>errorMessage').html('From date cannot be greater than the To date');
            }else if(daysDiff > 30){
                $('#<portlet:namespace/>errorMessage').html('Date range must be within 1 month');
            }else {
                $('#<portlet:namespace/>errorMessage').html('');
            }  
        }

    Tuesday, 9 May 2017

    Liferay Maven Introduction & Install Maven

    Q-what is maven?
    ans-"maven is a software management and comprehension tool based on the concept of project object model.

    Maven do many things for us like resolving dependencies, create project structure, build  a project, creating war/jar etc. By using Maven you can also create portlet, theme, services without any need of SDK.

    (POM) which can manage project build , reporting and  documentation from center piece of information."


    All build system are essentials the same
    There are some step for build project
    1-compile source code.
    2-copy resource
    3-compile and run test.
    4-packge project.
    5-deploy project
    6-clean up the code.


    Development of maven wanted:-
    Advantages of maven: - Maven wanted a standard way to build the project they wanted clear definition what the project consist of an easy way to publish project information and way to share jar across several the project.
    they wanted an easy way to build the project and share your project with the colleagues or with the client
    so they come up with the tool which is called maven.. which is for building and managing  any java project
    maven is intended to make day to day java developer work easier


    POM(project object model)
    Maven uses the concept of POM.

    Q-What is pom?
    ans- POM is fundamental unit of work in maven you can say.
    "pom is XML file that contain information about the project and configuration details used by maven
    to build the project "


     Note-XML file contains some information
    1-  Describe a project
    2- This information contain name, version and artifact, source code location, Dependences of project
    3- It also retail the plugin information and profile.
    4- It uses XML by default
    5- But not the way ant uses XML.


    MAVEN Advantag and objective:- 
    1: - Making the build process easy.
    2: - Provide the uniform an information
    3: - Provide quality project information
    4: - Provide guildlines for best practice Development
    5: - Allowing transprant migration for a new feature.


    Create first maven project simple

    step1- First set class path  with maven
    step2- Copy that maven project path and pased on command line.
    step3- mvn archetype: generate  (this command is used for generate  project from existeing template ) maven project( this command will  help you to create a perfect diretory structure for you)
    ( when you entre for this command we need internate for download plugin)

    note :- Generally what happend is  if yu are not using maven than you need to make project structural  by your self.

    How to create maven project with eclipse:-
    ans:-
    step:- Goto file-new- choose project-search maven-select maven project-next-next-we need to give group id, artifact id,version,package  and leave everything is default
    and finish

    after  eclipse it will create maven project for us.
     
    How maven work internally? 

    Suppose you need any dependencies jar file maven it provide automatically download required  dependencies for that we need to dependency on jar.

    Jquery Validation for radio button

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
    <script type="text/javascript" src="jquery/jquery.validate.js"></script>


    <script type="text/javascript">
        $(document).ready(function() {


            <!--simple validation for  radio button ------->

          
            $("#SaveConfirm").click(function(){
                var test=0;
                console.log("here>>>>>>>>>>>");
                if(!($("#r1").is(':checked') || $("#r2").is(':checked')){
                    console.log("hide");
                    $("#error1").html("Enter select First radio buttion");
                    test=1;
                    }
                else{
                console.log("show");
                $("#error1").html("");
                console.log("show2s");
                }
              
                if(!($("#r3").is(':checked') || $("#r4").is(':checked'))){
                console.log("hide");
                $("#error2").html("Enter select second radio buttion");
                test=1;
                }
            else{
            console.log("show");
            $("#error2").html("");
            console.log("show2s");
            }
         
                if(test==1)
                    return;
              
            });
        });
    </script>


    <script type="text/javascript">
    $(document).ready(function(){


    <!--validation for if radio button is checked with JQuery?------->

      
    $('.fistRed').change(function(){
          
            if($(this).is(':checked'))
                $('#error1').html('');
        });
          
    $('.secdRed').change(function(){
      
        if($(this).is(':checked'))
            $('#error2').html('');
    })     
    });
    </script>

     

     <!--Input Fields---->


    <div colspan="2" align="center">
    <tr>
          <td><p>
            <label>
              <input type="radio" id="r1" name="radio1"  class="form-input fistRed" />
              yes</label>
            <label>
              <input type="radio" id="r2" name="radio1"  class="form-input fistRed" />
              no</label>
            <br />
          </p></td>
        </tr>
        <label class="form-label" style="color:red;" id="error1"></label><br>
        <tr>
          <td><p>
            <label>
              <input type="radio" id="r3" name="radio2"  class="form-input secdRed" />
              yes</label>
            <label>
              <input type="radio" id="r4" name="radio2"  class="form-input secdRed"/>
              no</label>
            <br />
          </p></td>
        </tr>
        <label class="form-label" style="color:red;" id="error2"></label>
            
    <div colspan="2" align="center">
    <input type="submit" value="Rigister" id="SaveConfirm">
    </div>
    </div>

    Friday, 31 March 2017

    Select folder from document library in custom portlet

     To get specific folder folderId from Document media folders hierarchy.

     Need to do, like that other than using loops.

    Step-1  Make your folders hierarchy.

    public static final String  Base_Folder= "Documents/ABC/XYZ";

    In this Base_Folder Variable we need to get FolderId to XYZ folder

        public static long getBaseLiferayFolderId(long groupId) throws PortalException,
         SystemException {
            //here we are geting parentFolderId
          String liferayBasePath = Base_Folder;
          long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
          List<String> folderNames = Arrays.asList(liferayBasePath.split(StringPool.SLASH));
          for (String folderName : folderNames) {
           if (!StringPool.BLANK.equalsIgnoreCase(folderName)) {
            parentFolderId = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, folderName).getFolderId();
           }
          }
          return parentFolderId;
         }

    Thursday, 30 March 2017

    Run liferay on other then default root context

    Simple 5 steps to change the context

     

    Step1: Rename the folder ROOT dir to yours own context name(Example: liferay)

    Step2: Rename file ROOT.xml to liferay.xml in %LIFERAY-HOME%\conf\Catalina\localhost

    Step3: Create empty Directory/Folder ROOT in %LIFERAY-HOME%\webapps\

    Step4:

    Original Code

    <Context path="" crossContext="true">
        ......
            ....................
    </Context>
     

    Modified Code

     
    <Context path="/liferay" crossContext="true">
        ......
            ....................
    </Context>
     
    Step5: Create file portal-ext.properties in %LIFERAY-HOME%\webapps\liferay\WEB_INF\classes\

    copy paste the below code

    portal.ctx=/liferay
     

     

    Wednesday, 29 March 2017

    Different ways of getting a Journal Article Content in LIFERAY

    This blog helps you to fetch the “Journal Article Content “or “web content “in different ways based upon our requirement.

    (i) Getting the Journal Article of Particular Name :-

    String articleName =  “sourabh”;// I need the sourabh web content details

    String content = StringPool.BLANK;

    JournalArticlejournalArticle = JournalArticleLocalServiceUtil.getArticleByUrlTitle (themeDisplay.getScopeGroupId(), articleName);// getting the journalArticle Object based on name

    String articleId = journalArticle.getArticleId();

    JournalArticleDisplayarticleDisplay =  JournalContentUtil.getDisplay (themeDisplay.getScopeGroupId(), articleId,””,themeDisplay.getLanguageId(),themeDisplay);

    content = articleDisplay.getContent();// by using display content object I am fetching the data of my sourabh Web content.

     

    (ii) Getting the Journal Article based on Tag Name :-

     

    If we want to fetch the specific tag based web content details then the following code will be useful.

     

    String content = StringPool.BLANK;

    AssetTagassetTag = AssetTagLocalServiceUtil.getTag(themeDisplay.getScopeGroupId(), “mytagname”);
    long assetTagId = assetTag.getTagId();
    List assetEntrylist = AssetEntryLocalServiceUtil.getAssetTagAssetEntries(assetTagId);

    for(AssetEntryassetEntry : assetEntrylist) {
    JournalArticleResourcejournalArticleResourceObj = JournalArticleResourceLocalServiceUtil.getJournalArticleResource(assetEntry.getClassPK());
    JournalArticlejournalArticleObj = JournalArticleLocalServiceUtil.getArticle(themeDisplay.getScopeGroupId(),journalArticleResourceObj.getArticleId());
    String articleId = journalArticleObj.getArticleId();
    JournalArticleDisplayarticleDisplay =  JournalContentUtil.getDisplay (themeDisplay.getScopeGroupId(), articleId,””,themeDisplay.getLanguageId(),themeDisplay);
    content = articleDisplay.getContent();

    }

     

    (iii) Getting the Journal Article based on Structure Id or Template Id:-

     

    If we want to fetch the specific Structure of template based web content details then the following code will be useful.


    String content = StringPool.BLANK;
    List articleList = JournalArticleLocalServiceUtil.getStructureArticles(themeDisplay.getScopeGroupId(), “tagId”);
    // for template use API  getTemplateArticles
    for(JournalArticlejournalArticle : articleList) {

    String articleId = journalArticle.getArticleId();

    JournalArticleDisplayarticleDisplay =  JournalContentUtil.getDisplay (themeDisplay.getScopeGroupId(), articleId,””,themeDisplay.getLanguageId(),themeDisplay);

    content = articleDisplay.getContent();
    }

     

    (iv) Fetching the Journal Article content in template file in Liferay

     

    If we want to fetch the journal article of web content details in template file then the following code will be useful. 

    The following code will shows the tag based journal Article content in template.

     

    #set($assetTag =$serviceLocator.findService(‘com.liferay.portlet.asset.service.AssetTagLocalService’))
    #set($assetEntryService =$serviceLocator.findService(‘com.liferay.portlet.asset.service.AssetEntryLocalService’))
    #set($journalArticleResourceLocal=$serviceLocator.findService(‘com.liferay.portlet.journal.service.JournalArticleResourceLocalService’))
    #set($journalArticleLocal=$serviceLocator.findService(‘com.liferay.portlet.journal.service.JournalArticleLocalService’))
    #set($journalContentUtil =$utilLocator.findUtil(‘com.liferay.portlet.journalcontent.util.JournalContent’))
    #set($groupId = $getterUtil.getLong($groupId))
    #set($languageId = $request.theme-display.language-id)

    #set($assetTagObj=$assetTag.getTag($groupId,”myTag”))
    #set($assetId = $assetTagObj.getTagId())
    #set($assestList= $assetEntryService.getAssetTagAssetEntries($assetId))
    #set($assetEntry = “”)
    #foreach($assetEntry in $assestList)
    #set($journalArticleResource =$journalArticleResourceLocal.getJournalArticleResource($assetEntry.getClassPK()))
    #set($journalArticle = $journalArticleLocal.getArticle($groupId,$journalArticleResource.getArticleId()))
    #set($latestArticle= $journalArticleLocal.getLatestArticle($groupId,$journalArticle.getArticleId()))
    #set( $journalArticleDisplay= $journalContentUtil.getDisplay($groupId,$latestArticle.getArticleId(), null,null,$languageId,null, 1, $xmlRequest))
    $journalArticleDisplay.getContent()
    #end

     

    Thursday, 5 January 2017

    Overriding classes and properties using OSGi - DXP...

    Here i have published all possible ways to override Liferay classes and properties for which we were using hook in older Liferay version.


    1) Create Custom portlet data handler

     @Component(
            property = {
                "javax.portlet.name=com.sample.portlet"
            },
            service = PortletDataHandler.class
        )
    public class SamplePortletDataHandler extends BasePortletDataHandler
    {
    // Override methods which you required to override
    } 

    2) Create Custom Model Listener

     @Component(
            immediate = true,
            service = ModelListener.class
        )
    public class LayoutModelListener extends BaseModelListener<Layout>
    {
     // Override methods which you required
    }

    4) Custom Action

    @Component(
            property = {
                "javax.portlet.name=" + PollsPortletKeys.POLLS,
                "javax.portlet.name=" + PollsPortletKeys.POLLS_DISPLAY,
                "mvc.command.name=/polls/edit_question"
            },
            service = MVCActionCommand.class
        )
    public class CustomMVCActionCommand  extends BaseMVCActionCommand
    {
     // Override methods which you required
    }

    5) Custom Render

    @Component(
            property = {
                "javax.portlet.name=" + PollsPortletKeys.POLLS_DISPLAY,
                "mvc.command.name=/polls_display/view"
            },
            service = MVCRenderCommand.class
    )
    public class CustomActionMVCRenderCommand implements MVCRenderCommand
    {
     // Override methods which you required
    }

    6) Override Liferay Language Properties

    @Component(
            property = { "language.id=en_US" },
            service = ResourceBundle.class
        )
    public class ENResourceBundleComponent  extends ResourceBundle {

        @Override
        protected Object handleGetObject(String key) {
            return _resourceBundle.getObject(key);
        }

        @Override
        public Enumeration<String> getKeys() {
            return _resourceBundle.getKeys();
        }

        private final ResourceBundle _resourceBundle = ResourceBundle.getBundle(
            "content.Language", UTF8Control.INSTANCE);
    }

    7) Override Liferay Module Language Properties

    @Component(
        immediate = true,
        property = {
            "bundle.symbolic.name=com.liferay.polls.web",
            "resource.bundle.base.name=content.Language",
            "servlet.context.name=polls-web"
        }
    )
    public class ResourceBundleLoaderComponent  implements ResourceBundleLoader {

        @Override
        public ResourceBundle loadResourceBundle(String languageId) {
            return _resourceBundleLoader.loadResourceBundle(languageId);
        }

        @Reference(target = "(bundle.symbolic.name=com.liferay.polls.web)")
        public void setResourceBundleLoader(
            ResourceBundleLoader resourceBundleLoader) {

            _resourceBundleLoader = new AggregateResourceBundleLoader(
                new CacheResourceBundleLoader(
                    new ClassResourceBundleLoader(
                        "content.Language",
                        ResourceBundleLoaderComponent.class.getClassLoader())),
                resourceBundleLoader);
        }

        private AggregateResourceBundleLoader _resourceBundleLoader;

    }


    8) Override Liferay services

    @Component(service = ServiceWrapper.class)
    public class CustomUserLocalService extends UserLocalServiceWrapper {
    // Override methods which you require   
    }

     Note:

    Portal-ext.prioperties cannot be override through OSGi and you will have to manually update portal-ext.properties which we are keeping inside WEB-INF/classes

     

    Friday, 9 December 2016

    Liferay DXP: Technical Specifications

     Deployment Compatibility

     
    Operating Systems
    •     Linux (CentOS, RHEL, SUSE, Ubuntu, and others)
    •     Unix (AIX, HP-UX, Solaris, and others)
    •     Windows Server
    •     Mac OS X

    Public & Private Clouds
    •     Liferay DXP is deployable to the cloud and virtualized environments.

    Application Servers
    •     JBoss EAP
    •     Resin
    •     tcServer
    •     Tomcat
    •     WebLogic
    •     WebSphere
    •     Wildfly
    Databases
    •     DB2
    •     MariaDB
    •     MySQL
    •     Oracle
    •     PostgreSQL
    •     SQL Server
    •     Sybase

    Platfrom Details 

    Performance Scalablity

    • Clustering at any combination of tiers (presentation, service, business logic, and database)
    • Advanced caching (i.e., Ehcache)
    • Elasticsearch platform support
    • Performance monitoring support (JMX, Java profiling, etc.)
    Security
    •    Government-grade encryption such as: DES, MD5, SHA and RSA.
    •    Pluggable authentication
    •    Email verification
    •    Granular permissioning
    •    LDAP authentication
    •    Session management
    Developer Languages
    •      Java
    •     Groovy
    •     Ruby
    •     Python
    •     Scala
     Web Services
    •     SOAP
    •     JSON
    •     RMI
    •     Spring Remoting
    •     WebDAV
    Identity Management Support
    •     LDAP authentication
    •     SAML producer / consumer OAuth
    •     Oracle Access Manager
    •     Novell Identity Manager
    •     Sun Identity Manager
    •     OpenSSO / OpenAM
    •     SiteMinder
    •     Tivoli Access Manager
    •     Facebook standards
    JavaScript Frameworks
    •     AlloyUI
    •     GWT
    •     JQuery
    •     JSF
    •     Metal.js
    •     Vaadin
                  ...and others
    Frontend Frameworks
    •     AlloyUI
    •     Application Display Templates
    •     Device detection
    •     TagLibs
    •     Twitter Bootstrap
    Backend Frameworks
    •     Asset
    •     Cache
    •     Comments
    •     Data handlers
    •     File storage
    •     Membership policies
    •     Message bus
    •     Permissions
    •     Ratings
    •     Recycle bin
    •     Scheduler
    •     Scripting
    •     ServiceContext
    •     Upgrade
    •     Workflow
    Theme Developer Languages
    •     Freemarker
    •     Velocity
    Other Standards/Technologies
    •     AJAX
    •     iCalendar & Microformat
    •     JSR-168 (Portlet)
    •     JSR-286 (Portlet 2.0)
    •     WSRP 1 & 2
    •     JSR-127 (JSF)
    •     JSR-314 (JSF 2.0,2.1), JSR-344 (JSF 2.2)
    •     JSR-170 (Content Repository)
    •     Spring 3.0 & AOP
    •     CMIS 1.0/2.0
    •     OpenSearch 1.1
    •     OpenSocial 2.5
    •     Hibernate collection of projects
    •     OSGi Core 6.0
    •     SAML 2.0
    •     OAuth 1.1

    Content Management Features

    Content Repository

    • Multi-repository support
    • Customizable document types
    • Metadata per document type
    • Microsoft Office© integration
    • CMIS support
    • Check in/check out
    • Content previews
    • Content versioning
    • Define workflows per document type
    • Mobile/desktop file synchronization using Liferay Sync

    Sites Publishing

    • Dynamic and static site templates
    • Drag and drop site maps
    • Sitemap protocol support
    • Friendly page URLs
    • Remote server staging and scheduling
    • Multiple site variations/versions
    • Faceted search
    • Recycle bin
    • User customizable pages

    Content Creation

    • AlloyEditor
    • Templating: FreeMarker or Velocity
    • Global content sharing between sites
    • Content sharing in site hierarchy

    Themes & Layout

    • JavaScript framework: AlloyUI 3.0
    • CSS framework: Twitter Bootstrap
    • HTML 5.0 compliant
    • Responsive mobile theme
    • Multiple page layout templates

    Mobile

    • Mobile previews within browser
    • Mobile responsive theme
    • Mobile device recognition
    • Eclipse-based Mobile SDK

    Colaboration & Social Features

    Wikis, Blogs & Message Board Blogs

    • AlloyEditor
    • Ratings / Comments
    • RSS feeds
    • Categories / Tags
    • Related assets
    • Reader subscriptions
    • Recent blogs lists
    • Badge icon for social activity
    • Social bookmarks
    • Inappropriate content flagging

    Wikis

    • AlloyEditor
    • Versioning & reversion
    • Creole, HTML or MediaWiki syntax
    • Attach files
    • Threaded comments

    Message Board

    • Recent Posts List, My Posts List
    • Reader Subscriptions
    • Anonymous Posting
    • Attach Files
    • Support for Categories & Threads Reorganization
    • Inappropriate Content Flagging

    Calendar

    • AJAX-based interface
    • iCal and microformats support
    • Personal and group
    • Task lists
    • Resource scheduling
    • Email, IM, or SMS event reminders

     Alerts/Annoucements

    • Broadcast news or status
    • Scheduled start/stop
    • Site or role based targeting