Sunday 31 August 2014

Export Roles in Liferay 6.1

Many a times, it is required to have Import/Export functionality for Roles.
This functionality is already supported in Liferay 6.2 where we can do lar import/export for roles and organizations as well.

Below is the code snippet for Exporting Roles along with Permissions in the form of xml in Liferay 6.1.

Create a hook in liferay eg, RolesMgmt hook. Create a class called as ExportRolesAction which extends BaseStrutsPortletAction.

Refer below code for the same:




Now, you can override view.jsp from path - /portal-web/docroot/html/portlet/role_admin/view.jsp
and add code to display buttons for Import Roles and Export Roles on front end.

So in addition to the existing code of view.jsp, you can add below code snippet for the import/export:


You can also add code for validating the checkboxes like disabling the checkboxes of default role types. In the next post I shall be giving sample code for Roles Import.

Thanks for reading!
Happy Learning!

1 comment: