Posts

Showing posts from January, 2020

Making authenticated requests to Liferay 7.2

Image
Making authenticated requests to Liferay 7.2 Overview This article will describe how to make authenticated requests in Liferay 7.2 with Basic Authentication. Configuration First of all, you need to enable "Auto Login Basic Authentication Header". Go to  Control Panel -> Configuration -> System Settings > API Authentication . Check the ' Enabled ' flag: Making the request Let's say, you have some restricted document in Documents and Media, with the URL: http://localhost:8080/documents/20123/35301/Liferay+DXP+7.2+Datasheet.pdf/4f069157-d409-577e-eda5-cf46b131b9cf You can't access this link being not logged in, because it does not have View permissions for Guest. So, you need to access this URL being logged in. For this you need to send HTTP Authorization header. Command with basic authorization: curl -H "Authorization: Basic [auth-string]" [url] , where  auth-string  is encoded email:password pair. To obtain

Liferay 7.2 - MVCActionCommand Override

Liferay 7.2 - MVCActionCommand Override Overview This article describes how override Liferay's OOTB action commands. Why do you need it? You may need it to inject custom functionality before or after original MVCActionCommand execution: read additional data from request, save it to database, etc. For developers familiar with Liferay 6.2 - this is a replacement for Struts Action hooks. Most of Struts Actions have been replaced with MVCCommands in the Liferay internal code - that's why extension point has been changed also. MVCActionCommand implementation 1. Find MVCActionCommand, which you need to customize. We'll customize user creation process. Thus, the target one will be:  com.liferay.users.admin.web.internal.portlet.action.EditUserMVCActionCommand 2.  Check  mvc.command.name  and  javax.portlet.name  properties. For our class they are: "javax.portlet.name=" + UsersAdminPortletKeys.MY_ORGANIZATIONS, "javax.portlet.name=" + User

Installing Blade CLI from Command Line

Installing Blade CLI from Command Line Download JPM Jar file Download biz.aQute.jpm.run.jar file using link: https://raw.githubusercontent.com/jpm4j/jpm4j.installers/master/dist/biz.aQute.jpm.run.jar Initialize JPM Run command: java -jar biz.aQute.jpm.run.jar init Install Blade Run command: jpm install -f https://releases.liferay.com/tools/blade-cli/latest/blade.jar to install blade. Update blade to make sure you have the latest version, sample:  blade update Current blade version 3.3.0.201811151753 Updating from: https://repository-cdn.liferay.com/nexus/content/repositories/liferay-public-releases/com/liferay/blade/com.liferay.blade.cli//3.8.0/com.liferay.blade.cli-3.8.0.jar Update completed successfully. Congratulations! Now you have Blade CLI installed. Sample command for mvc-portlet: blade create -t mvc-portlet -p com.demo.portlet -c DemoPortlet demo-portlet Enjoy 😏