本文整理汇总了Java中com.liferay.portal.kernel.model.Role类的典型用法代码示例。如果您正苦于以下问题:Java Role类的具体用法?Java Role怎么用?Java Role使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Role类属于com.liferay.portal.kernel.model包,在下文中一共展示了Role类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setFolderPermissions
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
public static void setFolderPermissions(Folder folder) throws Exception{
ResourcePermission resourcePermission = null;
final Role guestMemberRole = RoleLocalServiceUtil.getRole(folder.getCompanyId(), RoleConstants.GUEST);
final Role siteMemberRole = RoleLocalServiceUtil.getRole(folder.getCompanyId(), RoleConstants.SITE_MEMBER);
ResourceAction resourceAction = ResourceActionLocalServiceUtil.getResourceAction(DLFolder.class.getName(), ActionKeys.VIEW);
String[] actionIdsGuest = new String[] { ActionKeys.VIEW, ActionKeys.ACCESS };
String[] actionIds = new String[] { ActionKeys.VIEW, ActionKeys.ACCESS, ActionKeys.SUBSCRIBE, ActionKeys.ADD_DOCUMENT, ActionKeys.UPDATE, ActionKeys.ADD_SHORTCUT, ActionKeys.ADD_SUBFOLDER, ActionKeys.PERMISSIONS, ActionKeys.DELETE };
try{
ResourcePermissionLocalServiceUtil.setResourcePermissions(folder.getCompanyId(),
DLFolder.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(folder.getPrimaryKey()), guestMemberRole.getRoleId(), actionIdsGuest);
ResourcePermissionLocalServiceUtil.setResourcePermissions(folder.getCompanyId(),
DLFolder.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(folder.getPrimaryKey()), siteMemberRole.getRoleId(), actionIds);
} catch (NoSuchResourcePermissionException e){
resourcePermission = ResourcePermissionLocalServiceUtil
.createResourcePermission(CounterLocalServiceUtil.increment());
resourcePermission.setCompanyId(folder.getCompanyId());
resourcePermission.setName(DLFolder.class.getName());
resourcePermission.setScope(ResourceConstants.SCOPE_INDIVIDUAL);
resourcePermission.setPrimKey(String.valueOf(folder.getPrimaryKey()));
resourcePermission.setRoleId(guestMemberRole.getRoleId());
resourcePermission.setActionIds(resourceAction.getBitwiseValue());// (ActionKeys.VIEW);
ResourcePermissionLocalServiceUtil.addResourcePermission(resourcePermission);
}
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:27,代码来源:DocumentUtils.java
示例2: getRegularRoleIds
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
/**
* Fetch regular roles
*
* @param roleIds
* @return
* @throws PortalException
*/
public long[] getRegularRoleIds(long[] roleIds) throws PortalException {
Map<Integer, List<Role>> roles = _commonUtil.filterRoles(roleIds);
List<Role> regularRoles = roles.get(RoleConstants.TYPE_REGULAR);
if (Validator.isNull(regularRoles) || regularRoles.size() == 0) {
return null;
}
if (_log.isDebugEnabled()) {
String regularids = regularRoles.stream().map(r -> String.valueOf(r.getRoleId()))
.collect(Collectors.joining(","));
_log.debug("Regular ids : " + regularids);
}
return regularRoles.stream().mapToLong(Role::getRoleId).toArray();
}
开发者ID:yasuflatland-lf,项目名称:liferay-dummy-factory,代码行数:24,代码来源:UserDataService.java
示例3: addRoleMultiSelect
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
public void addRoleMultiSelect(String name) throws SystemException {
List<Role> roles = RoleLocalServiceUtil.getRoles(
QueryUtil.ALL_POS, QueryUtil.ALL_POS);
List<KeyValuePair> values = new ArrayList<KeyValuePair>(roles.size());
for (Role role : roles) {
if (role.getType() == RoleConstants.TYPE_REGULAR) {
long roleId = role.getRoleId();
String roleName = role.getName();
if (Validator.isNull(roleId) || Validator.isNull(roleName)) {
continue;
}
values.add(new KeyValuePair(roleName, String.valueOf(roleId)));
}
}
addMultiSelectList(name, values);
}
开发者ID:sorin-pop,项目名称:data-manipulator,代码行数:22,代码来源:DisplayFields.java
示例4: getAdminUser
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
/**
* Returns Liferay user, that has Administrator role assigned.
*
* @param companyId company ID
* @return Liferay {@link com.mimacom.liferay.portal.setup.domain.User}
* instance, if no user is found, returns null
* @throws Exception if cannot obtain permission checker
*/
private static User getAdminUser(final long companyId) throws Exception {
try {
Role adminRole = RoleLocalServiceUtil.getRole(companyId, ADMIN_ROLE_NAME);
List<User> adminUsers = UserLocalServiceUtil.getRoleUsers(adminRole.getRoleId());
if (adminUsers == null || adminUsers.isEmpty()) {
return null;
}
return adminUsers.get(0);
} catch (PortalException | SystemException e) {
throw new Exception("Cannot obtain Liferay role for role name: " + ADMIN_ROLE_NAME, e);
}
}
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:24,代码来源:LiferaySetup.java
示例5: addRole
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
private static void addRole(final com.mimacom.liferay.portal.setup.domain.Role role) {
Map<Locale, String> localeTitleMap = new HashMap<>();
localeTitleMap.put(Locale.ENGLISH, role.getName());
try {
int roleType = RoleConstants.TYPE_REGULAR;
if (role.getType() != null) {
if (role.getType().equals("site")) {
roleType = RoleConstants.TYPE_SITE;
} else if (role.getType().equals("organization")) {
roleType = RoleConstants.TYPE_ORGANIZATION;
}
}
long defaultUserId = UserLocalServiceUtil.getDefaultUserId(COMPANY_ID);
RoleLocalServiceUtil.addRole(defaultUserId, null, 0, role.getName(), localeTitleMap,
null, roleType, null, null);
LOG.info("Setup: Role " + role.getName() + " does not exist, adding...");
} catch (PortalException | SystemException e) {
LOG.error("error while adding up roles", e);
}
}
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:27,代码来源:SetupRoles.java
示例6: _getRoleName
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
private static String _getRoleName(long roleId) {
String roleName = StringPool.BLANK;
try {
Role role = RoleLocalServiceUtil.getRole(roleId);
roleName = role.getName();
} catch (Exception e) {
}
return roleName;
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:11,代码来源:ServiceProcessUtils.java
示例7: getRoleApplicant
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
public static Role getRoleApplicant(long companyId, String roleName) {
Role roleDefault = null;
try {
roleDefault = RoleLocalServiceUtil.getRole(companyId, ServiceProps.APPLICANT_ROLE_NAME);
} catch (Exception e) {
roleDefault = RoleLocalServiceUtil.createRole(CounterLocalServiceUtil.increment(Role.class.getName()));
roleDefault.setName(ServiceProps.APPLICANT_ROLE_NAME);
}
return roleDefault;
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:15,代码来源:UserMgtUtils.java
示例8: doGetDocument
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
@Override
protected Document doGetDocument(ResourceRole resourceRole) throws Exception {
Document document = getBaseModelDocument(CLASS_NAME, resourceRole);
document.addKeywordSortable(Field.COMPANY_ID, String.valueOf(resourceRole.getCompanyId()));
document.addDateSortable(Field.MODIFIED_DATE, resourceRole.getModifiedDate());
document.addKeywordSortable(Field.USER_ID, String.valueOf(resourceRole.getUserId()));
document.addKeywordSortable(Field.USER_NAME, String.valueOf(resourceRole.getUserName()));
document.addNumberSortable(ResourceRoleTerm.GROUP_ID, resourceRole.getGroupId());
document.addNumberSortable(ResourceRoleTerm.RESOURCEROLE_ID, resourceRole.getResourceRoleId());
document.addTextSortable(ResourceRoleTerm.CLASS_NAME, resourceRole.getClassName());
document.addTextSortable(ResourceRoleTerm.CLASS_PK, resourceRole.getClassPK());
document.addNumberSortable(ResourceRoleTerm.ROLE_ID, resourceRole.getRoleId());
document.addTextSortable("selected", Boolean.TRUE.toString());
Role role = RoleLocalServiceUtil.fetchRole(resourceRole.getRoleId());
String roleName = StringPool.BLANK;
if (Validator.isNotNull(role)) {
roleName = role.getName();
}
document.addTextSortable(ResourceRoleTerm.ROLE_NAME, roleName);
return document;
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:31,代码来源:ResourceRoleIndexer.java
示例9: setFilePermissions
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
public static void setFilePermissions(FileEntry fileEntry) throws Exception{
ResourcePermission resourcePermission = null;
final Role guestMemberRole = RoleLocalServiceUtil.getRole(fileEntry.getCompanyId(), RoleConstants.GUEST);
ResourceAction resourceAction = ResourceActionLocalServiceUtil.getResourceAction(DLFileEntry.class.getName(), ActionKeys.VIEW);
String[] actionIdsGuest = new String[] { ActionKeys.VIEW, ActionKeys.ACCESS };
try{
resourcePermission = ResourcePermissionLocalServiceUtil.getResourcePermission(fileEntry.getCompanyId(),
DLFileEntry.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(fileEntry
.getPrimaryKey()), guestMemberRole.getRoleId());
ResourcePermissionLocalServiceUtil.setResourcePermissions(fileEntry.getCompanyId(),
DLFileEntry.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(fileEntry.getPrimaryKey()), guestMemberRole.getRoleId(), actionIdsGuest);
// if (Validator.isNotNull(resourcePermission)){
// resourcePermission.setActionIds(resourceAction.getBitwiseValue());
// ResourcePermissionLocalServiceUtil.updateResourcePermission(resourcePermission);
// }
} catch (NoSuchResourcePermissionException e){
resourcePermission = ResourcePermissionLocalServiceUtil
.createResourcePermission(CounterLocalServiceUtil.increment());
resourcePermission.setCompanyId(fileEntry.getCompanyId());
resourcePermission.setName(DLFileEntry.class.getName());
resourcePermission.setScope(ResourceConstants.SCOPE_INDIVIDUAL);
resourcePermission.setPrimKey(String.valueOf(fileEntry.getPrimaryKey()));
resourcePermission.setRoleId(guestMemberRole.getRoleId());
resourcePermission.setActionIds(resourceAction.getBitwiseValue());// (ActionKeys.VIEW);
ResourcePermissionLocalServiceUtil.addResourcePermission(resourcePermission);
}
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:31,代码来源:DocumentUtils.java
示例10: hasResource
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
@Override
public boolean hasResource(ServiceContext context, String name, String actionId) {
boolean hasPermission = false;
List<Role> roles = RoleLocalServiceUtil.getUserRoles(context.getUserId());
try {
for (Role role : roles) {
if (role.getName().equals("Administrator")) {
hasPermission = true;
break;
}
hasPermission = ResourcePermissionLocalServiceUtil.hasResourcePermission(context.getCompanyId(), name,
ResourceConstants.SCOPE_INDIVIDUAL, Long.toString(role.getRoleId()), role.getRoleId(),
actionId);
if (hasPermission) {
break;
}
}
} catch (Exception e) {
_log.error(e);
}
return hasPermission;
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:33,代码来源:BackendAuthImpl.java
示例11: userHasResource
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
@Override
public boolean userHasResource(
ServiceContext context, String name, String actionId) {
boolean hasPermission = false;
List<Role> roles =
RoleLocalServiceUtil.getUserRoles(context.getUserId());
try {
for (Role role : roles) {
hasPermission =
ResourcePermissionLocalServiceUtil.hasResourcePermission(
context.getCompanyId(), name,
ResourceConstants.SCOPE_INDIVIDUAL,
Long.toString(role.getRoleId()), role.getRoleId(),
actionId);
if (hasPermission) {
break;
}
}
}
catch (Exception e) {
_log.error(e);
}
return hasPermission;
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:32,代码来源:BackendAuthImpl.java
示例12: setOrgRoles
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
/**
* Set org roles
*
* Filtering only organization roles out from role ids and asign
* organization roles to a user.
*
* @param userId
* @param organizationIds
* @param roleIds
* @throws PortalException
*/
public void setOrgRoles(long userId, long[] organizationIds, long[] roleIds) throws PortalException {
Map<Integer, List<Role>> roles = _commonUtil.filterRoles(roleIds);
List<Role> orgRoles = roles.get(RoleConstants.TYPE_ORGANIZATION);
if (Validator.isNull(orgRoles) || orgRoles.size() == 0) {
return;
}
long[] orgIds = orgRoles.stream().mapToLong(Role::getRoleId).toArray();
if (_log.isDebugEnabled()) {
String orgids = orgRoles.stream().map(o -> String.valueOf(o.getPrimaryKey()))
.collect(Collectors.joining(","));
_log.debug("Organization ids : " + orgids);
}
if (0 == orgIds.length) {
_log.debug("Organization didn't exist in the ids. exit");
return;
}
List<Organization> orgs = _organizationLocalService.getOrganizations(organizationIds);
long[] orgGroupdIds = orgs.stream().mapToLong(Organization::getGroupId).toArray();
for (long orgGroupdId : orgGroupdIds) {
_userGroupRoleLocalService.addUserGroupRoles(userId, orgGroupdId, orgIds);
}
}
开发者ID:yasuflatland-lf,项目名称:liferay-dummy-factory,代码行数:41,代码来源:UserDataService.java
示例13: setSiteRoles
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
/**
* Set site roles
*
* Filtering only site roles out from role ids and asign site roles to a
* user.
*
* @param userId
* @param groupIds
* @param roleIds
* @throws PortalException
*/
public void setSiteRoles(long userId, long[] groupIds, long[] roleIds) throws PortalException {
Map<Integer, List<Role>> roles = _commonUtil.filterRoles(roleIds);
List<Role> siteRoles = roles.get(RoleConstants.TYPE_SITE);
if (Validator.isNull(siteRoles) || siteRoles.size() == 0) {
return;
}
long[] siteIds = siteRoles.stream().mapToLong(Role::getRoleId).toArray();
if (_log.isDebugEnabled()) {
String siteids = siteRoles.stream().map(s -> String.valueOf(s.getRoleId()))
.collect(Collectors.joining(","));
_log.debug("Site ids : " + siteids);
}
if (0 == siteIds.length) {
_log.debug("Site roles didn't exist in the ids. exit");
return;
}
for (long groupId : groupIds) {
_userGroupRoleLocalService.addUserGroupRoles(userId, groupId, siteIds);
}
}
开发者ID:yasuflatland-lf,项目名称:liferay-dummy-factory,代码行数:38,代码来源:UserDataService.java
示例14: deleteObjects
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
private static void deleteObjects(final List<ObjectsToBeDeleted> objectsToBeDeleted) {
for (ObjectsToBeDeleted otbd : objectsToBeDeleted) {
if (otbd.getRoles() != null) {
List<com.mimacom.liferay.portal.setup.domain.Role> roles = otbd.getRoles()
.getRole();
SetupRoles.deleteRoles(roles, otbd.getDeleteMethod());
}
if (otbd.getUsers() != null) {
List<com.mimacom.liferay.portal.setup.domain.User> users = otbd.getUsers()
.getUser();
SetupUsers.deleteUsers(users, otbd.getDeleteMethod());
}
if (otbd.getOrganizations() != null) {
List<Organization> organizations = otbd
.getOrganizations().getOrganization();
SetupOrganizations.deleteOrganization(organizations, otbd.getDeleteMethod());
}
if (otbd.getCustomFields() != null) {
List<CustomFields.Field> customFields = otbd.getCustomFields().getField();
SetupCustomFields.deleteCustomFields(customFields, otbd.getDeleteMethod());
}
}
}
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:29,代码来源:LiferaySetup.java
示例15: convertRoleListToHashMap
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
private static Map<String, com.mimacom.liferay.portal.setup.domain.Role> convertRoleListToHashMap(
final List<com.mimacom.liferay.portal.setup.domain.Role> objects) {
HashMap<String, com.mimacom.liferay.portal.setup.domain.Role> map = new HashMap<>();
for (com.mimacom.liferay.portal.setup.domain.Role role : objects) {
map.put(role.getName(), role);
}
return map;
}
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:10,代码来源:SetupRoles.java
示例16: addRolesToUser
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
private static void addRolesToUser(final com.mimacom.liferay.portal.setup.domain.User setupUser,
final User liferayUser) {
try {
for (com.mimacom.liferay.portal.setup.domain.Role userRole : setupUser.getRole()) {
Role role = RoleLocalServiceUtil.getRole(COMPANY_ID, userRole.getName());
long[] roleIds = {role.getRoleId()};
String roleType = userRole.getType();
switch (roleType) {
case "portal":
RoleLocalServiceUtil.addUserRoles(liferayUser.getUserId(), roleIds);
LOG.info("Adding regular role " + userRole.getName() + " to user "
+ liferayUser.getEmailAddress());
break;
case "site":
case "organization":
Group group = GroupLocalServiceUtil.getGroup(COMPANY_ID, userRole.getSite());
UserGroupRoleLocalServiceUtil.addUserGroupRoles(liferayUser.getUserId(),
group.getGroupId(), roleIds);
LOG.info("Adding " + roleType + " role " + userRole.getName() + " to user "
+ liferayUser.getEmailAddress());
break;
default:
LOG.error("unknown role type " + roleType);
break;
}
}
} catch (PortalException | SystemException e) {
LOG.error("Error in adding roles to user " + setupUser.getEmailAddress(), e);
}
}
开发者ID:mimacom,项目名称:liferay-db-setup-core,代码行数:36,代码来源:SetupUsers.java
示例17: setFilePermissions
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
public static void setFilePermissions(FileEntry fileEntry)
throws Exception {
ResourcePermission resourcePermission = null;
final Role guestMemberRole = RoleLocalServiceUtil.getRole(
fileEntry.getCompanyId(), RoleConstants.GUEST);
ResourceAction resourceAction =
ResourceActionLocalServiceUtil.getResourceAction(
DLFileEntry.class.getName(), ActionKeys.VIEW);
String[] actionIdsGuest = new String[] {
ActionKeys.VIEW, ActionKeys.ACCESS
};
try {
resourcePermission =
ResourcePermissionLocalServiceUtil.getResourcePermission(
fileEntry.getCompanyId(), DLFileEntry.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(fileEntry.getPrimaryKey()),
guestMemberRole.getRoleId());
ResourcePermissionLocalServiceUtil.setResourcePermissions(
fileEntry.getCompanyId(), DLFileEntry.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(fileEntry.getPrimaryKey()),
guestMemberRole.getRoleId(), actionIdsGuest);
// if (Validator.isNotNull(resourcePermission)){
// resourcePermission.setActionIds(resourceAction.getBitwiseValue());
// ResourcePermissionLocalServiceUtil.updateResourcePermission(resourcePermission);
// }
}
catch (NoSuchResourcePermissionException e) {
resourcePermission =
ResourcePermissionLocalServiceUtil.createResourcePermission(
CounterLocalServiceUtil.increment());
resourcePermission.setCompanyId(fileEntry.getCompanyId());
resourcePermission.setName(DLFileEntry.class.getName());
resourcePermission.setScope(ResourceConstants.SCOPE_INDIVIDUAL);
resourcePermission.setPrimKey(
String.valueOf(fileEntry.getPrimaryKey()));
resourcePermission.setRoleId(guestMemberRole.getRoleId());
resourcePermission.setActionIds(resourceAction.getBitwiseValue());// (ActionKeys.VIEW);
ResourcePermissionLocalServiceUtil.addResourcePermission(
resourcePermission);
}
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:47,代码来源:DLFolderUtil.java
示例18: setFolderPermissions
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
public static void setFolderPermissions(Folder folder)
throws Exception {
ResourcePermission resourcePermission = null;
final Role guestMemberRole = RoleLocalServiceUtil.getRole(
folder.getCompanyId(), RoleConstants.GUEST);
final Role siteMemberRole = RoleLocalServiceUtil.getRole(
folder.getCompanyId(), RoleConstants.SITE_MEMBER);
ResourceAction resourceAction =
ResourceActionLocalServiceUtil.getResourceAction(
DLFolder.class.getName(), ActionKeys.VIEW);
String[] actionIdsGuest = new String[] {
ActionKeys.VIEW, ActionKeys.ACCESS
};
String[] actionIds = new String[] {
ActionKeys.VIEW, ActionKeys.ACCESS, ActionKeys.SUBSCRIBE,
ActionKeys.ADD_DOCUMENT, ActionKeys.UPDATE, ActionKeys.ADD_SHORTCUT,
ActionKeys.ADD_SUBFOLDER, ActionKeys.PERMISSIONS, ActionKeys.DELETE
};
try {
ResourcePermissionLocalServiceUtil.setResourcePermissions(
folder.getCompanyId(), DLFolder.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(folder.getPrimaryKey()),
guestMemberRole.getRoleId(), actionIdsGuest);
ResourcePermissionLocalServiceUtil.setResourcePermissions(
folder.getCompanyId(), DLFolder.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(folder.getPrimaryKey()),
siteMemberRole.getRoleId(), actionIds);
}
catch (NoSuchResourcePermissionException e) {
resourcePermission =
ResourcePermissionLocalServiceUtil.createResourcePermission(
CounterLocalServiceUtil.increment());
resourcePermission.setCompanyId(folder.getCompanyId());
resourcePermission.setName(DLFolder.class.getName());
resourcePermission.setScope(ResourceConstants.SCOPE_INDIVIDUAL);
resourcePermission.setPrimKey(
String.valueOf(folder.getPrimaryKey()));
resourcePermission.setRoleId(guestMemberRole.getRoleId());
resourcePermission.setActionIds(resourceAction.getBitwiseValue());// (ActionKeys.VIEW);
ResourcePermissionLocalServiceUtil.addResourcePermission(
resourcePermission);
}
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:47,代码来源:DLFolderUtil.java
示例19: mapperResourceRoleModel
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
public static ResourceRoleModel mapperResourceRoleModel(ResourceRole resourceRole) {
ResourceRoleModel ett = new ResourceRoleModel();
try {
ett.setRoleId(resourceRole.getRoleId());
Role role = RoleLocalServiceUtil.fetchRole(resourceRole.getRoleId());
ett.setRoleName(role.getName());
ett.setSelected(true);
} catch (Exception e) {
_log.error(e);
}
return ett;
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:21,代码来源:ResourceRoleUtils.java
示例20: assignPermission
import com.liferay.portal.kernel.model.Role; //导入依赖的package包/类
public void assignPermission(long jobPosId, String[] actionIds, ServiceContext serviceContext) {
JobPos jobPos = jobPosPersistence.fetchByPrimaryKey(jobPosId);
long roleId = jobPos.getMappingRoleId();
String modelName = UserMGTConstants.WORKINGUNIT_MGT_CENTER;
String[] listPermission = ActionKeys.LIST_PERMISSION;
try {
ResourcePermissionLocalServiceUtil.setResourcePermissions(jobPos.getCompanyId(), modelName,
ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(roleId), roleId, actionIds);
} catch (PortalException e) {
for (int i = 0; i < listPermission.length; i++) {
String actionId = listPermission[i];
ResourceAction resourceAction = ResourceActionLocalServiceUtil
.fetchResourceAction(UserMGTConstants.WORKINGUNIT_MGT_CENTER, actionId);
if (Validator.isNotNull(resourceAction)) {
resourceAction.setBitwiseValue((long) Math.pow(2, i));
ResourceActionLocalServiceUtil.updateResourceAction(resourceAction);
} else {
ResourceActionLocalServiceUtil.addResourceAction(Role.class.getName(), actionId, (long) Math.pow(2, i));
}
}
// for (String actionKey : actionIds) {
// try {
// if (!ResourcePermissionLocalServiceUtil.hasResourcePermission(jobPos.getCompanyId(), modelName,
// ResourceConstants.SCOPE_INDIVIDUAL, "" + roleId, roleId, actionKey)) {
// ResourcePermissionLocalServiceUtil.setResourcePermissions(jobPos.getCompanyId(), modelName,
// ResourceConstants.SCOPE_INDIVIDUAL, "" + roleId, roleId, actionIds);
// } else {
// System.out.println("Role(" + roleId + ") already have this permission(" + actionKey
// + ") for this model(" + modelName + ")");
// }
// } catch (PortalException ex) {
// ex.printStackTrace();
// }
// }
}
}
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:51,代码来源:JobPosLocalServiceImpl.java
注:本文中的com.liferay.portal.kernel.model.Role类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论