Message Boards

Liferay 6.2 autentification-hook migration to Lr7

majdi Achouri, modified 4 Years ago.

Liferay 6.2 autentification-hook migration to Lr7

Junior Member Posts: 38 Join Date: 11/21/19 Recent Posts
Liferay 6.2 autentification-hook migration to Lr7
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Liferay 6.2 autentification-hook migration to Lr7

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
majdi Achouri:

Hello CommunityI have to migrate my  6.2 authentification-hook to Lr7 hook. By searching in the net and the liferay docs I was not able to find a concrete/ targeted way to migrate my 6.2 hook an Lr7 hook.
My hook is responsible for the login process with /custom_jsps folder to be able to customize the login jsp page ,and when Invoking the '/login/login' [== <struts-action-path>  ] the Struts LoginAction extends BaseStrutsPortletAction get called and do the work for the Login by executing the public void processAction and  the public String render methods.
what I found in the Lr documentation is that we have to create " liferay fragment &#034; to customize our the login.jsp for example  by specifying  Bundle-Version: 1.0.0
Fragment-Host: com.liferay.login.web;bundle-version=&#034;4.0.8&#034;    in the bnd.bnd file

The problem is that the liferay6.2-hook and the lr fragment project structure are not the same, ( see attached images please)
for example In the 6.2 version we can link our struts-action-path with the struts-action-path in the liferay-hook.xml, but this config is not available in the fragment, how to fix such config in fragment ? I'm blocking in this,
Also by following the Upgrade hook tutorial(https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/converting-strutsactionwrappers-to-mvccommands) I saw that there is an upgrade of the StrutsActions -->to  MVCCommands and adding this jsp sample to run the action method: <portlet:actionURL name="/blogs/edit_entry" var="editEntryURL" />, 
where Should I write such code( in the customized login.jsp page ?) 
Can anyone tell me how to link between MVCCommands with <portlet:actionURL > ?
(Thanks for helping)
                        

This has been unanswered for a while, which is typically a sign for missing information, or the answer being quite complex. Let's start with the basics:
Migration of a 6.2 hook to 7.2 typically involves inspection of what problem it solves, rather than what code it contains:
Fragments bundles are purely used for JSP overrides, and you'll need to implement additional bundle(s) for any active code: Fragment bundles never reach the state ACTIVE, thus they can't carry any code other than JSPs (well, there's other stuff they can contain - just not your typical code)
So, steps would be: Collect the underlying problem that your hook solved. See if this is still a problem that needs to be customized after skipping 2 versions (7.0 and 7.1). There also might be new extension points, introduced to help solving exactly your problem.
We can help you, if you mention what you've implemented in your 6.2 hook in the first place, e.g. if you explain the underlying problem here.
So: Instead of blindly migrating struts-actions to MVCCommands, you might have the chance to significantly simplify your modifications, or even discover that it's superfluous by now.
Depending on the nature of the problem solved, you might not even need a JSP Fragment (which is typically a heavy weapon, introducing hard-to-maintain code). AFAIK the login jsp(s) already contain extension points called Dynamic Includes: If your problem can be solved this way, upgrades to later versions will be a lot simpler. Another reason to write up your underlying problem.
majdi Achouri, modified 3 Years ago.

RE: Liferay 6.2 autentification-hook migration to Lr7

Junior Member Posts: 38 Join Date: 11/21/19 Recent Posts
Hi Olaf
thanks for your explanation and advices, By the way after some research in the net regarding my topic I saw that I need migrate my hook 6.2 based on Struts techno to an MVCCommand and by Extending an MVCPortlet to do the work inside
as the tuto explain https://help.liferay.com/hc/en-us/articles/360017878352-Converting-StrutsActionWrappers-to-MVCCommands.

the hook looks like : 

1.liferay-hook.xml: 
<struts-action>
        <struts-action-path>/login/login</struts-action-path>
        <struts-action-impl>com.portail.authentification.LoginAction</struts-action-impl>
 </struts-action>

So when triggering the login btn the /login/login gets called and the processAction() method first and then the render() methods gets called  those are two methods from the LoginAction Class gets called and do work for the login operation and the autentification

2. the class LoginAction.java looks like : 
public class LoginAction extends BaseStrutsPortletAction implements Serializable {
  @Override
  public void processAction(StrutsPortletAction originalStrutsPortletAction,
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {}  @Override
  public String render(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
      RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {}}


the problem I was not able to start migrating the struts hook Because the principe of MVCActionCommand is not enough clear comparing with the Struts techno for me ( and this is critical task for us)  thank you fro the support
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Liferay 6.2 autentification-hook migration to Lr7

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
majdi Achouri:

Hi Olaf
thanks for your explanation and advices, By the way after some research in the net regarding my topic I saw that I need migrate my hook 6.2 based on Struts techno to an MVCCommand and by Extending an MVCPortlet to do the work inside
as the tuto explain https://help.liferay.com/hc/en-us/articles/360017878352-Converting-StrutsActionWrappers-to-MVCCommands.
...
the problem I was not able to start migrating the struts hook Because the principe of MVCActionCommand is not enough clear comparing with the Struts techno for me ( and this is critical task for us)  thank you fro the support
I'm still strongly on the side of discouraging the question "how do I migrate a Struts action hook to a Liferay 7.x hook.
I'd rather see you describe what your custom requirements for logging in are. Then it's possible to point to a good way to implement it - and if you're lucky, it just needs some configuration.

By the way, I hope that your "Liferay 7" mention is not 7.0, but a current version (7.3 CE or 7.2 DXP)