
How to Rename a System Role
Table of Contents [-]
Here's how to do it, using example of renaming "Administrator" to "Site Wide Administrator"
In both ext-web\docroot\WEB-INF\liferay-portlet.xml and liferay-portlet-ext.xml, update the role-mapper:
<role-mapper> <role-name>administrator</role-name> <role-link>Site Wide Administrator</role-link> </role-mapper>
Update the SQL script:
update Role_ set name='Site Wide Administrator' where name='Administrator';
Modify portal-ejb\src\com\liferay\portal\util\RoleNames.java, then patch ext-ear\modules\portal-ejb.jar:
public static final String ADMINISTRATOR = "Site Wide Administrator";
Classes that reference this constant do not need to be updated, just recompiled. Search the portal-ejb\src & portal-web\docroot for references to RoleNames.ADMINISTRATOR.
Also, since this value is copied in com.liferay.portal.model.Role:
public static final String ADMINISTRATOR = RoleNames.ADMINISTRATOR;
...you need to also search for Role.ADMINISTRATOR in the source.
I copied the affected source files into my patch folder to be recompiled.
The reason is that the Java compiler copies the value of the String at compile time, not at runtime,
For example, in com.liferay.portal.model.Role:
public static final String ADMINISTRATOR = RoleNames.ADMINISTRATOR;
This line is compiled to
public static final String ADMINISTRATOR = "Site Wide Administrator";
Which is why all referencing objects need to be recompiled.
Deploy all the changes, then the renaming is done.