Thursday 23 July 2020

liferay headless delivery open APIs URL

localhost:8080/o/headless-delivery/v1.0/openapi.json

Liferay 7.x inclusion of CSS or JS files into the portlet or widget

Include the below entries under portlet component properties:

"com.liferay.portlet.header-portlet-javascript":"/js/main1.js"
"com.liferay.portlet.header-portlet-javascript":"/js/main2.js"

liferay 7.x questions and answers - for certification

1. When multiple implementations are available for osgi-api which are used to identify the particular implementation for that client?
Sol : Policies & filters

2. bnd tools generate _____ file by using build.gradle entries.
Sol : MANIFEST.MF

3. what is require-capability & provide capability?

4. provide-capability vs export in osgi?

5. why we are using blade CLI in liferay development?
Sol : Blade CLI provides module project templates are mvc-portlet, service, service-builder and so on.

portlet lifecycle phases

1. init phase
2. render phase
3. action phase
4. resource phase
5. event phase
6. destroy phase

Liferay theme creation basic commands/tools to setup or configuration


Install Node.js
1.    Find the node-[version]-[os] installer from node site.
2.    Run the installer for your operating system and follow the instructions.
3.    Open a Command Prompt/Terminal window.
4.    Run node -v in your command line to verify your installation once you have installed node.js and npm.
o    The node version should be 8.x.x
5.    Run npm -version to double-check the appropriate version is installed.
o    The npm version should be 6.x.x
You can also find the Node installers at https://nodejs.org.
Install Yeoman and Gulp Dependencies
1.    Open the command line.
2.    Type npm install -g yo gulp.
o    Note: Users on OSX or Linux will need administrative access to run this command. To do this, they may need to run sudo before the command.
3.    Press Enter.
This should have installed the Yeoman and gulp global dependencies. Now we can go ahead and install the Liferay Theme Generator. If you are running Windows, you should also install Windows Build Tools before Installing the Liferay Theme Generator. Let's do this next.

Install the Liferay Theme Generator
1.    Type npm install -g generator-liferay-theme in the Command Prompt/Terminal.
o    Note: Like before, Users on OSX or Linux may need to run sudo before the command.
2.    Press Enter.
3.    Type yo in the command line to see that the generator is installed.
4.    Press Enter.
5.    Type Y or N if an initial prompt asks to collect data.
6.    Press Enter.
7.    Choose Get me out of here!.
8.    Press Enter.

Liferay OSGi framework

1. OSGi Framework provides runtime environment (container) and development environment (annotations, dependency injection)
Note: @Reference works for concrete classes only. That means not work for interface and abstract classes (getting null as object value) 

2. Component lifecycle - active, activated and deactivated

3. Component registered in OSGi Container and service registered in Service registry

4. invoke method (getTime()) from gogo shell - "osgi.command.function=getTime", "osgi.command.scope=custom"

5. We can determine multiple implementations for single interface by using 1. ranking, 2. target

6. Export-Package & Import-Package vs Provide-Capability & Require-Capability

7. Bundle lifecycle - 1. Installed, 2. Resolved, 3. Active, 4.

8. Spring beans generated by liferay service builder by which annotation can use/reference it ?
sol : @ServiceReference annotation.
Explanation : AssignmentServiceImpl is not OSGi component class. Hence, need to use @servicereference.

9. MVC Commands take care of the portlet life-cycle and interaction b/w UI & Back-end.
     a. MVC Commands are wired to a certain portlet life-cycle (render, action & resource)
     b. They respond to certain 'mvc.command.name' defined in component properties.
     c. they register to a certain portlet with the 'javax.portlet.name' component property.

10. To make silence the generated API under any xxxxLocalServiceImpl classes, simply override that API by @override and define to throw UnsupportedOperationException

11. what is the bundle State when its working as expected after deployment of fragment module ?
Sol : Resolved

12. how many ways override JSPs and what are those ?
Sol : 2 ways and  a. override that JSP by creating fragment module. b. update that JSP by creating render filter and customize the JSP output.

13. What is LifecycleAction and why will use it?
Sol : LifecycleAction allows us to customize liferay's application by using events. Events are 1. application.startup.events, 2. prelogin.events, 3. postlogin.events and etc.,

14. what is  the use of servicewrapper?
Sol : By using Servicewrapper we can customize service methods either pre or post execution.

15. How we can override struts action?

Sol : Our custom component class should extends BaseStrutsAction and property is "path=/portal/logout"

Sample :
1. Step 1 :  @Component(
2.        immediate = true,
3.        property = {
4.            "path=/portal/logout"
5.        },
6.        service = StrutsAction.class)

1.Step 2 :        @Override
2.        public String execute(
3.            StrutsAction originalStrutsAction, HttpServletRequest request,
4.            HttpServletResponse response)
5.            throws Exception {
6.    
7.            System.out.println("Overriding the Portal Logout Action!");
8.    
9.            originalStrutsAction.execute(request, response);
10.   
11.           response.sendRedirect("https://university.liferay.com");
12.   
13.           return null;
14.       }

16. How to override MVCActionCommand?
Sol : Our custom component class should extends BaseMVCActionCommand, and property is property = {
"javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY,
"javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY_ADMIN,
"javax.portlet.name=" + DLPortletKeys.MEDIA_GALLERY_DISPLAY,
"mvc.command.name=/document_library/edit_folder",
"service.ranking:Integer=100"
}
17. Model entity listener ?
Sol : Events we are able to listen for when an action on a Model Entity is executed in the persistence layer. There are a few use cases for Model Listeners such as an Audit Listener, Cache Clearing Listener, and Validation Listener. The use case we are implementing is the fourth use case, the Entity Update Listener.

Snippet : @Component(immediate = true, service = ModelListener.class)
public class UserPostUpdateModelListener extends BaseModelListener<User> {
}

18. message bus listener ?