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


Java Role类代码示例

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


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

示例1: findRoleByJobPosId

import com.liferay.portal.model.Role; //导入依赖的package包/类
public List<Role> findRoleByJobPosId(long jobPosId) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(FIND_BY_JOBPOSID);
	params.add(jobPosId);		
	System.out.println(sql);
	System.out.println(FIND_BY_JOBPOSID);
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("Role_", Role.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	if (query.list() != null){
		return (List<Role>) query.list();
	}
	return new ArrayList<Role>();
	//return (List<WorkingUnit>) query.list();
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:21,代码来源:JobPos2RoleFinderImpl.java

示例2: findRoleNotInJobPosId

import com.liferay.portal.model.Role; //导入依赖的package包/类
public List<Role> findRoleNotInJobPosId(long jobPosId) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(FIND_BY_NOTINJOBPOSID);
	params.add(jobPosId);		
	
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("Role_", Role.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	if (query.list() != null){
		return (List<Role>) query.list();
	}
	return new ArrayList<Role>();
	//return (List<WorkingUnit>) query.list();
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:20,代码来源:JobPos2RoleFinderImpl.java

示例3: getRoleIdByJobPosId

import com.liferay.portal.model.Role; //导入依赖的package包/类
public ArrayList<Role> getRoleIdByJobPosId(ArrayList<Role> listRole, long jobPosId) throws PortalException, SystemException {
	List<JobPos2Role> listJobPos2Role =  jobPos2RolePersistence.findByJP(jobPosId);
	ArrayList<Role> roles = new ArrayList<Role>();
	for (int i = 0; i < listJobPos2Role.size();i++){
		//roleIds[i] = listJobPos2Role.get(i).getRoleId();
		int index = -1;
		for (int k = 0; k < listRole.size();k++){
			if (listRole.get(k).getRoleId() == listJobPos2Role.get(i).getRoleId()){
				index = k;
				break;
			}
		}
		if (index >= 0){
			roles.add(listRole.get(index));
			listRole.remove(index);
		}
	}
	return roles;
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:20,代码来源:Jobpos2RoleLocalServiceImpl.java

示例4: prepareRuntimePortlet

import com.liferay.portal.model.Role; //导入依赖的package包/类
private void prepareRuntimePortlet(PortletURL portletURL)
		throws SystemException, PortalException {
	if(_isRuntimePortlet){

		portletURL.setParameter("p_o_p_id",ACTIVITY_VIEWER_PORTLET_ID);

		PortletPreferencesFactoryUtil.getLayoutPortletSetup(_layout, _portletId);
		String resourcePrimKey = PortletPermissionUtil.getPrimaryKey(_layout.getPlid(), _portletId);
		String portletName = _portletId;

		int warSeparatorIndex = portletName.indexOf(PortletConstants.WAR_SEPARATOR);
		if (warSeparatorIndex != -1) {
			portletName = portletName.substring(0, warSeparatorIndex);
		}

		if ((ResourcePermissionLocalServiceUtil.getResourcePermissionsCount(
				_learningactivity.getCompanyId(), portletName,
				ResourceConstants.SCOPE_INDIVIDUAL, resourcePrimKey) == 0)&&
			(ResourceActionLocalServiceUtil.fetchResourceAction(portletName, ACTION_VIEW)!=null)) {
        	Role siteMember = RoleLocalServiceUtil.getRole(_learningactivity.getCompanyId(),RoleConstants.SITE_MEMBER);
        	ResourcePermissionLocalServiceUtil.setResourcePermissions(_learningactivity.getCompanyId(), portletName, ResourceConstants.SCOPE_INDIVIDUAL, 
       				resourcePrimKey,siteMember.getRoleId(), new String[]{ACTION_VIEW});
		}

	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:27,代码来源:LearningActivityBaseAssetRenderer.java

示例5: getVisibleActivities

import com.liferay.portal.model.Role; //导入依赖的package包/类
public static List<LearningActivity> getVisibleActivities(ThemeDisplay themeDisplay,
		List<LearningActivity> res, PermissionChecker permissionChecker)
		throws PortalException, SystemException {
	List<LearningActivity> res2 = null;
	if(res != null && res.size()>0){
		res2 = new ArrayList<LearningActivity>();
		res2.addAll(res);
		Role siteMemberRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), RoleConstants.SITE_MEMBER);
		for(java.util.ListIterator<LearningActivity> itr = res2.listIterator(); itr.hasNext();){
			LearningActivity activity = itr.next();
			try {
				if(!ResourcePermissionLocalServiceUtil.hasResourcePermission(activity.getCompanyId(), LearningActivity.class.getName(), 
						ResourceConstants.SCOPE_INDIVIDUAL,	Long.toString(activity.getActId()),siteMemberRole.getRoleId(), ActionKeys.VIEW)
						&& !permissionChecker.hasPermission(activity.getGroupId(), LearningActivity.class.getName(), activity.getActId() , "CORRECT"))
					itr.remove();
			} catch (SystemException e) {
				e.printStackTrace();
			}
		}
	}
	return res2;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:23,代码来源:LiferaylmsUtil.java

示例6: matchesRole

import com.liferay.portal.model.Role; //导入依赖的package包/类
/**
 * Check whether a Liferay-Role matches any role defined by this enum
 *
 * @param cmpRole the Liferay role
 * @return the supported enum or null, if not supported
 */
public static E_Role matchesRole(final Role cmpRole) {
	E_Role result = null;

	if (cmpRole != null) {
		for (final E_Role role : E_Role.values()) {
			if (getRoleName(role).equals(cmpRole.getName())
			        && role.getType() == cmpRole.getType()) {
				result = role;
				// System.out.println(role.getName()+" ("+role.getType()+") == "+cmpRole.getName()+" ("+cmpRole.getType()+")");
				break;
			} else {
				// System.out.println(role.getName()+" ("+role.getType()+") != "+cmpRole.getName()+" ("+cmpRole.getType()+")");
			}
		}
	}

	return result;
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:25,代码来源:CustomPortalServiceHandler.java

示例7: getRole

import com.liferay.portal.model.Role; //导入依赖的package包/类
/**
 * Gets the role.
 *
 * @param display the display
 * @return the role
 */
protected E_Role getRole(final ThemeDisplay display) {
	E_Role result = null;

	final User user = display.getUser();
	if (user != null && user.getEmailAddress() != null) {
		List<Role> roles = null;
		try {
			roles = user.getRoles();
		} catch (final SystemException e) {
		}
		if (roles != null) {
			for (final Role role : roles) {
				result = CustomPortalServiceHandler.matchesRole(role);
				if (result != null) {
					break;
				}
			}
		}
	}

	return result;

}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:30,代码来源:BaseController.java

示例8: isLoggedInMgmt

import com.liferay.portal.model.Role; //导入依赖的package包/类
/**
 * Checks if is logged in mgmt.
 *
 * @param request the request
 * @return true, if is logged in mgmt
 */
protected boolean isLoggedInMgmt(final PortletRequest request) {
	boolean result = false;
	final ThemeDisplay themeDisplay = (ThemeDisplay) request
	        .getAttribute(WebKeys.THEME_DISPLAY);
	if (themeDisplay.isSignedIn()) {
		final User user = themeDisplay.getUser();
		if (user != null) {
			try {
				final List<Role> roles = user.getRoles();
				String mgmtRoleName = CustomPortalServiceHandler.getConfigValue(E_ConfigKey.ROLE_NAME_MGMT);
				for (final Role role : roles) {
					if (role.getName().equals(mgmtRoleName)) {
						result = true;
						break;
					}
				}
			} catch (final Throwable t) {
			}
		}
	}
	return result;
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:29,代码来源:BaseController.java

示例9: isLoggedInOrg

import com.liferay.portal.model.Role; //导入依赖的package包/类
/**
 * Checks if is logged in org.
 *
 * @param request the request
 * @return true, if is logged in org
 */
protected boolean isLoggedInOrg(final PortletRequest request) {
	boolean result = false;
	final ThemeDisplay themeDisplay = (ThemeDisplay) request
	        .getAttribute(WebKeys.THEME_DISPLAY);
	if (themeDisplay.isSignedIn()) {
		final User user = themeDisplay.getUser();
		if (user != null) {
			try {
				final List<Role> roles = user.getRoles();
				final String orgRoleName = CustomPortalServiceHandler.getConfigValue(E_ConfigKey.ROLE_NAME_ORG);
				for (final Role role : roles) {
					if (role.getName().equals(orgRoleName)) {
						result = true;
						break;
					}
				}
			} catch (final Throwable t) {
			}
		}
	}
	return result;
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:29,代码来源:BaseController.java

示例10: getAvailableRoles

import com.liferay.portal.model.Role; //导入依赖的package包/类
public List<Role> getAvailableRoles(long companyId) throws SystemException, PortalException {
	List<Role> results = new ArrayList<Role>();
	
	for (AdminIPValidationData data : adminIPValidationDataPersistence.findByCompany(companyId)) {
		Long[] roleIds = data.getRolesAsArray();
		for (Long roleId : roleIds) {
			if (roleId != null) {
				Role role = RoleLocalServiceUtil.getRole(roleId);
				if (!results.contains(role)) {
					results.add(role);
				}
			}
		}
	}
	
	return results;
}
 
开发者ID:technopolis,项目名称:role-access-lists,代码行数:18,代码来源:AdminIPValidationDataLocalServiceImpl.java

示例11: receive

import com.liferay.portal.model.Role; //导入依赖的package包/类
@Override
public void receive(Message message) throws MessageListenerException {
	
	try {
		this.groupId	= message.getLong("groupId");
		this.fileName = message.getString("fileName");
		this.key = message.getString(key);
		this.serviceContext = (ServiceContext)message.get("serviceContext");
		this.themeDisplay = (ThemeDisplay)message.get("themeDisplay");
	
		Role adminRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),"Administrator");
		List<User> adminUsers = UserLocalServiceUtil.getRoleUsers(adminRole.getRoleId());
		 
		PrincipalThreadLocal.setName(adminUsers.get(0).getUserId());
		PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(adminUsers.get(0));
		PermissionThreadLocal.setPermissionChecker(permissionChecker);
	
		MultiVMPoolUtil.put("exportCourseCache", key, true);
		try {
			doExportCourse();
		} finally {
			MultiVMPoolUtil.remove("exportCourseCache", key);
		}
		
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:30,代码来源:ExportCourse.java

示例12: receive

import com.liferay.portal.model.Role; //导入依赖的package包/类
@Override
public void receive(Message message) throws MessageListenerException {
	
	try {
		
		this.groupId	= message.getLong("groupId");
		this.newCourseName = message.getString("newCourseName");
		this.startDate 	= (Date)message.get("startDate");
		this.endDate 	= (Date)message.get("endDate");
		this.serviceContext = (ServiceContext)message.get("serviceContext");
		this.themeDisplay = (ThemeDisplay)message.get("themeDisplay");
		this.childCourse =(Boolean)message.get("childCourse");
		this.visible = message.getBoolean("visible");
		this.includeTeacher = message.getBoolean("includeTeacher");
		this.cloneForum = message.getBoolean("cloneForum");
		Role adminRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),"Administrator");
		List<User> adminUsers = UserLocalServiceUtil.getRoleUsers(adminRole.getRoleId());
		 
		PrincipalThreadLocal.setName(adminUsers.get(0).getUserId());
		PermissionChecker permissionChecker =PermissionCheckerFactoryUtil.create(adminUsers.get(0), true);
		PermissionThreadLocal.setPermissionChecker(permissionChecker);
	
		doCloneCourse();
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:29,代码来源:CloneCourse.java

示例13: setRolePermissions

import com.liferay.portal.model.Role; //导入依赖的package包/类
private static void setRolePermissions(Role role, String name, java.util.List<ResourceAction>actions) throws PortalException, SystemException {
	String[] actionIds=new String[actions.size()];
	int counter=0;
	
	for(ResourceAction raction:actions){
		actionIds[counter]=raction.getActionId();
		counter++;
	}
	
	if (ResourceBlockLocalServiceUtil.isSupported(name)) 
		ResourceBlockLocalServiceUtil.setCompanyScopePermissions(role.getCompanyId(), name, role.getRoleId(),Arrays.asList(actionIds));
	else 
		ResourcePermissionLocalServiceUtil.setResourcePermissions(role.getCompanyId(), name, ResourceConstants.SCOPE_COMPANY, String.valueOf(role.getCompanyId()), role.getRoleId(), actionIds);
	
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:16,代码来源:StartupAction.java

示例14: getCourseStudents

import com.liferay.portal.model.Role; //导入依赖的package包/类
@JSONWebService
public java.util.List<String> getCourseStudents(long courseId) throws PortalException, SystemException
{
	User user=getUser();
	
	ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
	Course course=courseLocalService.getCourse(courseId);
	if(course.getCompanyId()==user.getCompanyId())
	{
		LmsPrefs prefs=LmsPrefsLocalServiceUtil.getLmsPrefs(course.getCompanyId());
	
	Role commmanager=RoleLocalServiceUtil.getRole(course.getCompanyId(), RoleConstants.SITE_MEMBER) ;
	java.util.List<String> users=new java.util.ArrayList<String>();
	long createdGroupId=course.getGroupCreatedId();
	java.util.List<User> userst=UserLocalServiceUtil.getGroupUsers(createdGroupId);
	
	for(User usert:userst)
	{
		List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRoles(usert.getUserId(),createdGroupId);
		boolean remove =false;
		for(UserGroupRole ugr:userGroupRoles){
			if(ugr.getRoleId()==prefs.getEditorRole()||ugr.getRoleId()==prefs.getTeacherRole()){
				remove = true;
				break;
			}
		}
		if(!remove){
			users.add(usert.getScreenName());
		}
	}
	return users;
	}
	return null;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:35,代码来源:CourseServiceImpl.java

示例15: receive

import com.liferay.portal.model.Role; //导入依赖的package包/类
@Override
public void receive(Message message) throws MessageListenerException {
	
	try {
		
		this.newEditionName = message.getString("newEditionName");
		this.startDate 	= (Date)message.get("startDate");
		this.endDate 	= (Date)message.get("endDate");
		this.serviceContext = (ServiceContext)message.get("serviceContext");
		this.themeDisplay = (ThemeDisplay)message.get("themeDisplay");
		this.parentCourseId = (Long)message.get("parentCourseId");
		this.isLinked = (Boolean)message.get("isLinked");
		this.startExecutionDate = (Date) message.get("startExecutionDate");
		this.endExecutionDate = (Date) message.get("endExecutionDate");
		this.editionFriendlyURL = (String)message.get("editionFriendlyURL");
		this.editionLayoutId = (Long)message.get("editionLayoutId");
		log.debug("Parent Course Id: "+parentCourseId);
		Role adminRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(),"Administrator");
		List<User> adminUsers = UserLocalServiceUtil.getRoleUsers(adminRole.getRoleId());
		 
		PrincipalThreadLocal.setName(adminUsers.get(0).getUserId());
		PermissionChecker permissionChecker =PermissionCheckerFactoryUtil.create(adminUsers.get(0));
		PermissionThreadLocal.setPermissionChecker(permissionChecker);
	
		doCreateEdition();
		
		
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:33,代码来源:CreateEdition.java


注:本文中的com.liferay.portal.model.Role类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。