Sunday, 8 November 2020

Q:- Liferay Code migration process from 6.2 to 7.1/DXP

 Liferay Code migration process from 6.2 to 7.1/DXP

---------------------------------------------

Step1:-Remove unused objects

Sites

Remove unused sites and it’s content.

Instances

Remove instance which is no longer needed. Since they consume highest object in the hierarchy, removing it can optimize upgradation process.

Web Content

Liferay generates a new version whenever we are updating any web content. You can safely delete all older versions of web content.

Users

Remove all inactive users and it’s related data to optimize the process.

Layouts

Remove unnecessary layouts.


Step2:-After removing unused objects from your portal, make sure to test those in your older environment.

 In that case, you can more easily find out any issues, knowing that they’re not related to upgrade processes


Step3:-Liferay Database migration


Step4:-Code migration

Once your database will migrate to DXP you need to update your existing code to make it compatible with DXP. Liferay provides code upgrade tool for it.


You can follow LR’s documentation to upgrade your existing code to LR DXP


Step5:-Change in Deployment Process

As we know Liferay DXP adopted OSGi framework container which is based on modules based application.

Due to this reason deployment process in LR has been changed.



Step6:- Post-migration issues


Here I’ve added some of the common post migration issues which generally happen.


1:-You must first upgrade to Liferay Portal 7100

This exception will be thrown when you started LR 7.x with 6.x database.

To resolve this issue you need to re-run the database upgrade tool before starting LR DXP.


2:-PwdEncryptorException: invalid keyLength value

You will face this kind of exception when an incorrect password encryption algorithm.

To resolve this error you need to add below property in the portal.properties file.

passwords.encryption.algorithm.legacy=SHA.


STep7:-Search Engine

From Liferay DXP, they have integrated elasticsearch as an embedded search engine.

For production use, Liferay only supports Elasticsearch when it runs in a separate JVM


Q:- Liferay Database migration from 6.2 to 7.1/DXP

 Liferay Database migration from 6.2 to 7.1/DXP


Step1-Create a separate database for migration in MySQL

--------------------------------------------------------


Step2:-Take backup and restore

-----------------------------

Create a database dump from liferay 6.2 database and restore that dump into a new liferay 7.1/DXP of  database and then

To restore dump file into new DB(Liferay 7.1/DXP)


Step3:-Specify database connection properties

--------------------------------------------

Create a file ‘portal-setup-wizard.properties’ and specify the below DB connection properties within it:


jdbc.default.driverClassName=com.mysql.jdbc.Driver

jdbc.default.url=jdbc:mysql://localhost:3306/liferay_dxp_db

jdbc.default.username=root

jdbc.default.password=root


Note: DO NOT START Liferay DXP server at this point. Otherwise, you will get an error like java.lang.RuntimeException


Step4:-Copy data

-------------------

Copy document_library (You can find from [Liferay Home]/data/) folder from Liferay 6.2 to Liferay 7.1/DXP,

copy images folders into data folder also.

This data will be stored in the default store and you can also choose your location,

 it's up to your choice.


Step5:-Disable indexer and autoUpgrade:-

---------------------------------------

Now, we need to disable indexing since we are going to start the database upgrade process for our new environment.

Using this we can disable reindexing content and performance issues to be arised. For this, we have to follow below steps.


Need to create file in liferay 7.1/DXP :


"com.liferay.portal.search.configuration.IndexStatusManagerConfiguration.config" on this location [Liferay Home]/osgi/configs and add below content


indexReadOnly="true"

Then create another file in the same folder :


"com.liferay.portal.upgrade.internal.configuration.ReleaseManagerConfiguration.config" and add below content


autoUpgrade="false"



Step6:-Configure the upgrade tool

--------------------------------

Now, we need to configure below files before running the upgrade:

1.app-server.properties  -> tomcat server details

2.portal-upgrade-database.properties -> specify db details

3.portal-upgrade-ext.properties  -> specify old lifeary ext property details


Step7:-Verify buildNumber

---------------------------

We have to check a release buildNumber from DB before running the upgrade tool, it will be incremented after each deployment in Service Builder

which is used for generating internal database persistence code.


Using this query you can find current buildNumber:


Run upgrade tool using below command (Path [Liferay Home]/tools folder) :


For window


Double click on “db_upgrade.bat” file


Step8:-Enabling indexer

------------------------

Now, The last and most important step is remaining which can only be taken post-upgrade and to enable indexer. For this, you have to modify the file "com.liferay.portal.search.configuration.IndexStatusManagerConfiguration.config" in the folder [Liferay Home]/osgi/configs with the following content


indexReadOnly="false"


Q:-What is OSGI and OSGI Architecture ?

Q:-Problems With Non Modular Applications in liferay 7?

Ans:-Two major things

1:-Increases complexity

2:-maintenance becomes harder over time

Q:-What is OSGI and OSGI  Architecture ?

Ans:-OSGI stands for Open Services Gateway Initiative

OSGI is a  framework like we have spring framework  , we have hibernate framework , we have Struts framework

OSGI also one framework  here in liferay 7, so here we can use OSGI and we can build small modularity kind of application

Modularity is nothing but the small small piece of application that is called Modularity .OSGI allow you to divide your application into multiple module

in liferay 7 every things as a services compare to old version. liferay6.2 we have a concept called SDK(software development kits)

Where we can build portlet there , layout , hook and ext but liferay 7 we have concept called portlet, theme , layout but every thing as a services

OSGI can understand only services if you want exectute any program using OSGI architecture we have to define our services OSGI can understand only service.


OSGi is providing environment where all these bundles and components can communicate each other.

each component can independent. So when ever you want to call my service , we can access application that is work of OSGi architecture .

 

OSGI provides an architecture for developing and deploying modular applications.


Q:-Architecture Of OSGI:/How its work

Ans:-OSGi architecture divided into three layers.

1:-Module Layer:- 

module layer is concern with packaging and sharing the code

Module layer define osgi module concept called "Bundle" OSGI bundle is nothing but a JAR file.

bundle contains our class files and their related resources.


2:-Lifecycle layer:- 

-------------------

OSGI lifecycle layer define How bundle are dynamically installed and manage in the OSGI framework.

Life Cycle is responsible to manage lifecycle of bundles. OSGi bundle have several lifecycle stages install, start, update, stop and uninstall.

All these stages handles in this layer.


lifecycle is concern with providing execution time , model management and access to the underline OSGI framework.


3:-Service layer:- 

------------------

Service layer is concern with interaction and communication among module.

Services layer provide mechanism to share services between bundles. It will provide environment to register services and make available to other bundles.


Service Registry:- you are adding service in the service registry , what it will do it will register your service in the SGI and make available to other bundle

service register is interface it will handle the service.


Q:-liferay cycle of OSGI:- it manage by OSGI container.

start, stop, update, and uninstall bundles.


INSTALLED : The bundle has been successfully installed.

RESOLVED : All Java classes that the bundle needs are available. This state indicates that the bundle is either ready to be started or has stopped.

STARTING: The bundle is being started, the BundleActivator.start

ACTIVE : The bundle has been successfully activated and is running. Its Bundle Activator start method has been called and returned.

STOPPING : The bundle is being stopped. The BundleActivator.stop method has been called but the stop method has not yet returned.


Q:- What are the Benefits Of OSGi:-

Ans:-

using OSGI we can separate them as independent modules.

Easy maintenance

Each Module with its own clear responsibility

Restrict and Expose the visibility of classes properly



Q:-What Is OSGI Container?

OSGI Container manages the Lifecycle of  Components, Services and Bundle or Modules

Q:-We have deployed the service. How would we know whether the service is registered or not.?

ans:- For a quick check open the Gogo Shell.

We will find the bundle id of deployed bundle. The Active status of a bundle indicates that the bundle is active inside the container.

Finding Bundle ID

g! lb proliferay

START LEVEL 20

   ID|State      |Level|Name

  513|Active     |    1|com.proliferay.demo (1.0.0.201611210957)

  514|Active     |   10|com.proliferay.sample.osgi.service (1.0.0.201611210909)

g!


 Q1:-What is Portlet Name Space?

 Portlet Name Space will give unique name to the elements in the page and these elements are associated to respective portlet.

This will avoid name conflicts in the page.


We may use many portlets within one page and there may be chance to get name collision among elements in the page. 

portlet name space will avoid those name conflicts in the page.

 

Each portlet have its own portlet name space value so that we need to append these portlet name space value to each element in the portlet 

like HTML tag names or ids and we can use this for request parameters.

Q2:-How can i get Portlet Namespace Value?

 

We can use following two ways

 

Using <portlet:namespace/> Tag.:-We can use <portlet:namespace/> Tag so that we can append portlet name space value for element names,ids and request parameters.


Using renderResponse Object:- We can also use renderResponse object to get portet Name space value. renderResponse is liferay implicit object and  these Objects will be available in JSP page.

Example:-

<input type="text" name="<%=renderResponse.getNamespace()%>employeeName" id="<%=renderResponse.getNamespace()%>employeeName"/>



Q:-Follow below steps to complete CRUD operation for your custom entity.

ans:-1)Create service-builder module for your custom entity

a.Go to liferay workspace project → modules → new

b.Select other → Liferay → Liferay Module Project and Click on “Next”

c.Enter project name

d.Select “Project Template Name” as “service-builder” and Click on “Next”

e.Enter Package name and click on “Finish”. The necessary file structure for service-builder automatically get created as below


2) Add entity in xxx-service/service.xml like as below.

3) Build the service-builder module.


4) Create MVC Portlet

a.Go to liferay workspace project → modules → new

b.Select other → Liferay → Liferay Module Project and Click on “Next”

c.Enter project name

d.Select “Project Template Name” as “mvc-portlet” and Click on “Next”

e.Enter Package name and Click on “Finish”. The necessary file structure for mvc module will gets created as below.


5)In order to add dependency of student-api in mvc portlet, add below line in “build.gradle” of your mvc portlet.

in build.gradle

uild.gradle