Foros de discusión

Liferay 7 Suggestion Required

Thirumal Reddy, modificado hace 7 años.

Liferay 7 Suggestion Required

Regular Member Mensajes: 216 Fecha de incorporación: 3/12/15 Mensajes recientes
Hi All,

now we working on migrating 6.2 plugins into 7.
in this process we need to migrate one Ext.
the Ext contains a class that extends EditRoleAction class.
in that class we are overriding two methods (updateRole and deleteRole).
what it does means when site admin creates new role from control panel the
roleId and organizationId are storing in one custom table. (we are passing organizationId through hidden field from edit_role.jsp(hook) )
But in Liferay 7 i know how to override MVCXXXCommand classes but only for Roles module all the requests are implemented in RolesAdminPortlet.java class
but i am unable to override this class.
i tried with ServiceWrapper and Model Listners but here i am unable to acheive my requirement.

please give me some suggestions to acheive my requirement.

Thanks and Regards,
Thirumal.
thumbnail
Milen Dyankov, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Expert Mensajes: 310 Fecha de incorporación: 30/10/12 Mensajes recientes
For the type of thing you describe, you should actually use model listeners or service wrappers.
What is the issue with using one of those?
Thirumal Reddy, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Regular Member Mensajes: 216 Fecha de incorporación: 3/12/15 Mensajes recientes
Hi Milen,
i am unable to get current organization Id in SW/ML because request object is not availble.

Thanks,
Thirumal.
thumbnail
David H Nebinger, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
1. JSP fragment bundle to add org dropdown.
2. Custom bundle to override MVCXXXCommand to add org id into the ServiceContext instance passed to most service apis.
3. Service wrapper on service to invoke the wrapped class for the save, then invokes your service w/ the org.
Thirumal Reddy, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Regular Member Mensajes: 216 Fecha de incorporación: 3/12/15 Mensajes recientes
Hi David,
I didn't understand clearly what do you mean,

what i understand is,

1. JSP fragment bundle to add org dropdown.

i can do it by JSP Fragment module by overriding edit_role.jsp and i'll pass organizationId as hidden field in the form

2.Custom bundle to override MVCXXXCommand to add org id into the ServiceContext instance passed to most service apis.

There are no MVCXXXCommand classes for roles module so how can i create my custom bundle

could you please elaborate..

Thanks,
Thirumal.
thumbnail
Milen Dyankov, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Expert Mensajes: 310 Fecha de incorporación: 30/10/12 Mensajes recientes
To be honest with you I don't understand your usecase. When a role is created it can be set as "organization" role but that's basically a role type. Meaning in different organizations it may have different set of users assigned to them. At creation time though, it is not related to any particular organization (or to every organization if you prefer)! What organizationID you pass?
Thirumal Reddy, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Regular Member Mensajes: 216 Fecha de incorporación: 3/12/15 Mensajes recientes
Hi Milen,
ok let me explain clearly..
let suppose we have one Organization(Org1) and we have one Users(User1)
User1 is SiteAdmin of Org1
If User1 logins into Org1 and creates a new role at the time of creating role we are passing Org1 Id through the form and we are getting it in
updateRole()
and after creating new role we are getting newly created roleId.
now we are storing roleId and organizationId in our Custom table.

If you still doesn't understand let me know i'll paste the code.

Thanks,
Thirumal.
thumbnail
Milen Dyankov, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Expert Mensajes: 310 Fecha de incorporación: 30/10/12 Mensajes recientes
what if the user belongs to more than one organization?
Thirumal Reddy, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Regular Member Mensajes: 216 Fecha de incorporación: 3/12/15 Mensajes recientes
It's not a problem
we are passing currently logined organization organizationId

if (themeDisplay.getRefererPlid() > 0) {
Layout refererLayout = LayoutLocalServiceUtil.fetchLayout(themeDisplay.getRefererPlid());
if (refererLayout != null) {
Group refererGroup = refererLayout.getGroup();
currentGroupIdInControlPanel = refererGroup.getGroupId();
long orgId = GroupLocalServiceUtil.getGroup(currentGroupIdInControlPanel).getOrganizationId();
}
}


got it.? or do you need any extra info

Thanks..
Thirumal.
thumbnail
Milen Dyankov, modificado hace 7 años.

RE: Liferay 7 Suggestion Required

Expert Mensajes: 310 Fecha de incorporación: 30/10/12 Mensajes recientes
That seems weird and error prone. Basically you'll get different ID depending on which organization was lastly used by the user. I understand this somehow works for you right now but it's a time bomb set to explode somewhere in the future.

That said, if you absolutely must do what you do, your best bet is to create a 'PortletFilter' to 'RolesAdminPortlet'. In 7 you can add filter to any portlet (see this sample). So you can get what you need form the JSP and perform whatever action you want in the filter (before or after calling the portlet). Using 'ModelListener' in your case makes no sense because you will never be able to pass that additional information that far (there is no ServiceContext there AFAIK).

Then again, if I were you, I would reconsider the design. I don't know all the details obviously but again this approach seems wrong from data consistence perspective.