本文整理汇总了Java中com.liferay.portal.kernel.model.RoleConstants类的典型用法代码示例。如果您正苦于以下问题:Java RoleConstants类的具体用法?Java RoleConstants怎么用?Java RoleConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoleConstants类属于com.liferay.portal.kernel.model包,在下文中一共展示了RoleConstants类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setFolderPermissions
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的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.RoleConstants; //导入依赖的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.RoleConstants; //导入依赖的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: addRole
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的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
示例5: setFilePermissions
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的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
示例6: setOrgRoles
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的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
示例7: setSiteRoles
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的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
示例8: setFilePermissions
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的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
示例9: setFolderPermissions
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的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
示例10: getRoleLists
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的package包/类
/**
* Get Role lists
*
* This method filter roles
*
* @param resourceRequest
* @param resourceResponse
* @return filtered role list json strings
*/
protected String getRoleLists(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {
ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
boolean isOrganizationsSelected = ParamUtil.getBoolean(resourceRequest, "isOrganizationSelected", false);
boolean isSitesSelected = ParamUtil.getBoolean(resourceRequest, "isSitesSelected", false);
List<Role> roles = _roleLocalService.getRoles(themeDisplay.getCompanyId());
if (_log.isDebugEnabled()) {
String roleids = roles.stream()
.map(r -> RoleConstants.getTypeLabel(r.getType()))
.collect(Collectors.joining(","));
_log.debug("All role ids : " + roleids);
}
for ( Role role : roles) {
JSONObject curUserJSONObject = JSONFactoryUtil.createJSONObject();
if (role.getType() == RoleConstants.TYPE_SITE && false == isSitesSelected) {
continue;
}
if(role.getType() == RoleConstants.TYPE_ORGANIZATION && false == isOrganizationsSelected) {
continue;
}
if (_log.isDebugEnabled()) {
_log.debug("selected role <" + role.getTitle(themeDisplay.getLocale()) + ">");
_log.debug(role.toString());
}
curUserJSONObject.put("name", role.getTitle(themeDisplay.getLocale()));
curUserJSONObject.put("roleId", role.getRoleId());
curUserJSONObject.put("type", role.getType());
jsonArray.put(curUserJSONObject);
}
return jsonArray.toJSONString();
}
开发者ID:yasuflatland-lf,项目名称:liferay-dummy-factory,代码行数:51,代码来源:RoleMVCResourceCommand.java
示例11: addRolesFieldsToData
import com.liferay.portal.kernel.model.RoleConstants; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void addRolesFieldsToData(
String className, Data data, String permissionsClassName)
throws PortalException, SystemException {
String actionId = getPermissionsActionId(data);
Object aux = data.get(permissionsClassName);
Set<List<Object>> resourcePermissions = null;
if (aux instanceof List) {
resourcePermissions = new HashSet<List<Object>>();
resourcePermissions.add((List<Object>)aux);
}
else if (aux instanceof Set) {
resourcePermissions = (Set<List<Object>>)aux;
}
if (resourcePermissions == null) {
return;
}
Set<String> roleIds = new HashSet<String>();
Set<String> groupRoleIds = new HashSet<String>();
for (List<Object> resourcePermission : resourcePermissions) {
long roleId = (Long)resourcePermission.get(0);
long actionIds = (Long)resourcePermission.get(1);
if (resourcePermission.size() > 2) {
int scope = (Integer)resourcePermission.get(2);
if (scope != ResourceConstants.SCOPE_INDIVIDUAL) {
continue;
}
}
if (hasActionId(actionIds, className, actionId)) {
Role role = RoleLocalServiceUtil.fetchRole(roleId);
if (role == null) {
continue;
}
long groupId = data.get("permissionsGroupId", 0L);
int type = role.getType();
if ((type == RoleConstants.TYPE_ORGANIZATION) ||
(type == RoleConstants.TYPE_SITE)) {
groupRoleIds.add(groupId + StringPool.DASH + roleId);
}
else {
roleIds.add(String.valueOf(roleId));
}
}
}
ModelFactory modelFactory = data.getModel().getModelFactory();
Model permissionsModel = modelFactory.getModelObject(
permissionsClassName);
data.addModelTableInfo(permissionsModel);
data.set("permissionsRoleId", roleIds);
data.set("permissionsGroupRoleId", groupRoleIds);
}
开发者ID:jorgediaz-lr,项目名称:index-checker,代码行数:71,代码来源:IndexCheckerPermissionsHelper.java
注:本文中的com.liferay.portal.kernel.model.RoleConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论