Last active
February 22, 2016 16:22
-
-
Save topolik/db15fdf0a09254d5312d to your computer and use it in GitHub Desktop.
This script grants all available permissions to Batman role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.liferay.portal.kernel.model.*; | |
import com.liferay.portal.kernel.service.*; | |
import com.liferay.portal.kernel.security.permission.*; | |
import com.liferay.portal.kernel.util.*; | |
long companyId = PortalUtil.getDefaultCompanyId(); | |
Role batman = RoleLocalServiceUtil.getRole(companyId, "Batman"); | |
List<String> models = ResourceActionsUtil.getModelNames(); | |
for(Portlet portlet : PortletLocalServiceUtil.getPortlets()) { | |
models.add(portlet.getPortletId()); | |
} | |
models = new ArrayList(new TreeSet(models)); | |
for(String model : models) { | |
List<String> actions = ResourceActionsUtil.getModelResourceActions(model); | |
if (actions.size() == 0) { | |
actions = ResourceActionsUtil.getPortletResourceActions(model); | |
} | |
ResourcePermissionLocalServiceUtil.setResourcePermissions( | |
companyId, model, ResourceConstants.SCOPE_COMPANY, | |
String.valueOf(companyId), batman.getRoleId(), | |
actions.toArray(new String[0])); | |
out.println(model + ": " + new ArrayList(actions)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment