当前位置: 首页>>代码示例>>Java>>正文


Java Role.getType方法代码示例

本文整理汇总了Java中com.liferay.portal.kernel.model.Role.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Role.getType方法的具体用法?Java Role.getType怎么用?Java Role.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.liferay.portal.kernel.model.Role的用法示例。


在下文中一共展示了Role.getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: getRoleLists

import com.liferay.portal.kernel.model.Role; //导入方法依赖的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

示例3: addRolesFieldsToData

import com.liferay.portal.kernel.model.Role; //导入方法依赖的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.Role.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。