Skip to content

Instantly share code, notes, and snippets.

@bmvakili
Created October 17, 2012 04:36
Show Gist options
  • Save bmvakili/3903719 to your computer and use it in GitHub Desktop.
Save bmvakili/3903719 to your computer and use it in GitHub Desktop.
Liferay scripts
// ### Javascript Sample ###
folder = Packages.com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil.fetchDLFolder(14083);
resource = Packages.com.liferay.portal.service.ResourceLocalServiceUtil.getResource(folder.getCompanyId(), "com.liferay.portlet.documentlibrary.model.DLFolder", Packages.com.liferay.portal.model.ResourceConstants.SCOPE_INDIVIDUAL, folder.getPrimaryKey());
folderExpandoBridge = folder.getExpandoBridge().hasAttribute("hiddenFolderProperties");
resourceActions = Packages.com.liferay.portal.security.permission.ResourceActionsUtil.getResourceActions("20", "com.liferay.portlet.documentlibrary.model.DLFolder");
administrator = Packages.com.liferay.portal.service.RoleLocalServiceUtil.getRole(folder.getCompanyId(), Packages.com.liferay.portal.model.RoleConstants.ADMINISTRATOR);
roleTypes = []
group = Packages.com.liferay.portal.service.GroupLocalServiceUtil.getGroup(folder.getGroupId());
roles = Packages.com.liferay.portal.security.permission.ResourceActionsUtil.getRoles(folder.getCompanyId(), group, "com.liferay.portlet.documentlibrary.model.DLFolder");
roles.remove(administrator);
itr = roles.iterator();
permissionChecker = Packages.com.liferay.portal.security.permission.PermissionThreadLocal.getPermissionChecker();
guestUnsupportedActions = Packages.com.liferay.portal.security.permission.ResourceActionsUtil.getResourceGuestUnsupportedActions("20", "com.liferay.portlet.documentlibrary.model.DLFolder");
out.println("Guest");
out.println("Unsupported Actions : " + guestUnsupportedActions);
while(itr.hasNext()) {
role = itr.next();
name = role.getName();
currentIndividualActions = Packages.com.liferay.portal.service.ResourcePermissionLocalServiceUtil.getAvailableResourcePermissionActionIds(resource.getCompanyId(), resource.getName(), resource.getScope(), resource.getPrimKey(), role.getRoleId(), resourceActions);
currentGroupActions = Packages.com.liferay.portal.service.ResourcePermissionLocalServiceUtil.getAvailableResourcePermissionActionIds(resource.getCompanyId(), resource.getName(), Packages.com.liferay.portal.model.ResourceConstants.SCOPE_GROUP, folder.getGroupId(), role.getRoleId(), resourceActions);
currentGroupTemplateActions = Packages.com.liferay.portal.service.ResourcePermissionLocalServiceUtil.getAvailableResourcePermissionActionIds(resource.getCompanyId(), resource.getName(), Packages.com.liferay.portal.model.ResourceConstants.SCOPE_GROUP_TEMPLATE, "0", role.getRoleId(), resourceActions);
currentCompanyActions = Packages.com.liferay.portal.service.ResourcePermissionLocalServiceUtil.getAvailableResourcePermissionActionIds(resource.getCompanyId(), resource.getName(), Packages.com.liferay.portal.model.ResourceConstants.SCOPE_COMPANY, ""+resource.getCompanyId(), role.getRoleId(), resourceActions);
var resourceActionOne = resourceActions[0];
out.println("R1" + resourceActionOne);
for ( ind = 0; ind < resourceActions.length; ind++) {
resourceAction = resourceActions[ind];
out.println(resourceAction);
if (currentIndividualActions.contains(resourceAction)) {
out.println("Individual Actions : "+ resourceAction);
}
}
out.println(role.getName() + " : ");
/**
out.println("Individual Actions : "+ currentIndividualActions);
out.println("Group Actions : "+ currentGroupActions);
out.println("Group Template Actions: " + currentGroupTemplateActions);
out.println("Company Actions : " + currentCompanyActions);
**/
}
out.println(roles);
out.println(resourceActions);
out.println(folder.getFolderId())
out.println(folder);
out.println(folderExpandoBridge);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment