• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RoleLocalServiceUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: prepareRuntimePortlet

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的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


示例2: getVisibleActivities

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的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


示例3: addStudentToCourse

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
@JSONWebService
public void addStudentToCourse(long courseId,String login) throws PortalException, SystemException
{
	ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
	Course course=courseLocalService.fetchCourse(courseId);
	User user = userLocalService.fetchUserByScreenName(serviceContext.getCompanyId(), login);
	if(course!=null && user!=null){
		if(getPermissionChecker().hasPermission(course.getGroupId(),  Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
		{
			
			if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
				GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
				//sendEmail(user,course);
			}
			
			UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
					course.getGroupCreatedId(), RoleLocalServiceUtil.getRole(serviceContext.getCompanyId(), RoleConstants.SITE_MEMBER).getRoleId());

			//auditing
			AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);
			
		 
		}
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:26,代码来源:CourseServiceImpl.java


示例4: getTeachersFromCourse

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public List<User> getTeachersFromCourse(long courseId) {
	List<User> users = new ArrayList<User>();
	try{
		
		Course course = courseLocalService.fetchCourse(courseId);
					
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.getLmsPrefs(course.getCompanyId());
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		return getTeachersFromCourse(course, teacherRoleId);
	}catch(Exception e){
		e.printStackTrace();
	}
	
	return users;
	
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:17,代码来源:CourseLocalServiceImpl.java


示例5: getAvailableRoles

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的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


示例6: receive

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的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


示例7: receive

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的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


示例8: addUserRole

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public void addUserRole(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception{

		long courseId = ParamUtil.getLong(actionRequest, "courseId", 0);
		long roleId = ParamUtil.getLong(actionRequest, "roleId", 0);
//		long userId = ParamUtil.getLong(actionRequest, "userId", 0);
		// Multiusuario
		long[] to = ParamUtil.getLongValues(actionRequest, "to");
//		long[] userIds=new long[1];
//		userIds[0]=ParamUtil.getLong(actionRequest, "userId");
		Course course = CourseLocalServiceUtil.getCourse(courseId);
		
		LmsPrefs prefs=LmsPrefsLocalServiceUtil.getLmsPrefs(course.getCompanyId());
		Long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		Long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		for (long userId : to) {
			if (!GroupLocalServiceUtil.hasUserGroup(userId, course.getGroupCreatedId())) {
				GroupLocalServiceUtil.addUserGroups(userId,	new long[] { course.getGroupCreatedId() });
			//The application only send one mail at listener
			//User user = UserLocalServiceUtil.getUser(userId);
			//sendEmail(user, course);
			}
			UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { userId }, course.getGroupCreatedId(), roleId);
			
			if(roleId == teacherRoleId){
				AuditingLogFactory.audit(course.getCompanyId(), course.getGroupCreatedId(), Course.class.getName(), 
						course.getCourseId(),userId, AuditConstants.REGISTER, "COURSE_TUTOR_ADD");
			}
			if(roleId == editorRoleId){
				AuditingLogFactory.audit(course.getCompanyId(), course.getGroupCreatedId(), Course.class.getName(), 
						course.getCourseId(),userId, AuditConstants.REGISTER, "COURSE_EDITOR_ADD");
			}
		}	
		
		actionResponse.setRenderParameters(actionRequest.getParameterMap());
	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:37,代码来源:BaseCourseAdminPortlet.java


示例9: countStartedOnlyStudents

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public long countStartedOnlyStudents(long actId, long companyId, long courseGropupCreatedId, List<User> _students){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT * FROM lms_learningactivityresult r INNER JOIN users_groups ug ON r.userId = ug.userId AND ug.groupId ="+courseGropupCreatedId+
				" WHERE actId="+actId;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND r.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:38,代码来源:LearningActivityResultFinderImpl.java


示例10: countFinishedOnlyStudents

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public long countFinishedOnlyStudents(long actId, long companyId, long courseGropupCreatedId, List<User> _students){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_learningactivityresult r INNER JOIN users_groups ug ON r.userId = ug.userId AND ug.groupId ="+courseGropupCreatedId+
				" WHERE actId="+actId+" AND r.endDate IS NOT NULL ";
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND r.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:39,代码来源:LearningActivityResultFinderImpl.java


示例11: countStartedOnlyStudents

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public long countStartedOnlyStudents(long actId, long companyId, long courseGropupCreatedId, List<User> _students){
	Session session = null;
	;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_learningactivityresult r INNER JOIN users_groups ug ON r.userId = ug.userId AND ug.groupId ="+courseGropupCreatedId+
				" WHERE actId="+actId;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND r.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:39,代码来源:SurveyResultFinderImpl.java


示例12: countStudentsByQuestionIdAndAnswerId

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public long countStudentsByQuestionIdAndAnswerId(long questionId, long answerId, long companyId, long courseGropupCreatedId){ 
	Session session = null;
	;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_surveyresult r INNER JOIN users_groups ug ON r.userId = ug.userId AND ug.groupId ="+courseGropupCreatedId+
				" WHERE answerId="+answerId+" AND questionId="+questionId;
		
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:31,代码来源:SurveyResultFinderImpl.java


示例13: countStudentsByQuestionId

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public long countStudentsByQuestionId(long questionId, long companyId, long courseGropupCreatedId){ 
	Session session = null;
	;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_surveyresult r INNER JOIN users_groups ug ON r.userId = ug.userId AND ug.groupId ="+courseGropupCreatedId+
				" WHERE questionId="+questionId;
		
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:31,代码来源:SurveyResultFinderImpl.java


示例14: getCourseStudents

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的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: addStudentToCourseWithDates

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
@JSONWebService
public void addStudentToCourseWithDates(long courseId,String login,Date allowStartDate,Date allowFinishDate) throws PortalException, SystemException
{
	ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
	Course course=courseLocalService.getCourse(courseId);
	if(getPermissionChecker().hasPermission(course.getGroupId(),  Course.class.getName(),courseId,"ASSIGN_MEMBERS")&& ! course.isClosed())
	{
		User user = userLocalService.getUserByScreenName(serviceContext.getCompanyId(), login);
		if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
			GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
			//sendEmail(user,course);
		}
		
		UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
				course.getGroupCreatedId(), RoleLocalServiceUtil.getRole(serviceContext.getCompanyId(), RoleConstants.SITE_MEMBER).getRoleId());
		CourseResult courseResult=courseResultLocalService.getCourseResultByCourseAndUser(courseId, user.getUserId());
		if(courseResult==null)
		{
			courseResultLocalService.create(courseId, user.getUserId(), allowStartDate, allowFinishDate);
		}
		else
		{
			courseResult.setAllowStartDate(allowStartDate);
			courseResult.setAllowFinishDate(allowFinishDate);
			courseResultLocalService.updateCourseResult(courseResult);
		}
		//auditing
		AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), serviceContext.getUserId(), AuditConstants.REGISTER, null);		 
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:31,代码来源:CourseServiceImpl.java


示例16: getAdministratorUser

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
private static User getAdministratorUser(long companyId) throws PortalException, SystemException
{
	// El nombre del rol "Administrator" no puede cambiar a trav�s del UI, es un caso excepcional de s�lo lectura
	// Sin embargo pueden haber varios administradores (con el rol "Administrator"),
	// hacemos lo siguiente: devolvemos el que tenga userName "test" y as� tenderemos
	// a devolver siempre el mismo, si no hay un administrador "test" (pues puede cambiarse) devolvemos el primero.
	long adminRoleId = RoleLocalServiceUtil.getRole(companyId, "Administrator").getRoleId();
	List<User> adminList = UserLocalServiceUtil.getRoleUsers(adminRoleId);
	for(User user : adminList)
	{
		if (user.getScreenName().equals("test"))
			return user;
	}
	return adminList.get(0); // Devolvemos el primero.
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:16,代码来源:CourseLocalServiceImpl.java


示例17: addStudentToCourseWithDates

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public void addStudentToCourseWithDates(long courseId,long userId,Date allowStartDate,Date allowFinishDate) throws PortalException, SystemException
{
	Course course=courseLocalService.getCourse(courseId);
	;
		User user = userLocalService.fetchUser(userId);
		if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
			GroupLocalServiceUtil.addUserGroups(user.getUserId(), new long[] { course.getGroupCreatedId() });
			//sendEmail(user,course);
		}
		
		UserGroupRoleLocalServiceUtil.addUserGroupRoles(new long[] { user.getUserId() },
				course.getGroupCreatedId(), RoleLocalServiceUtil.getRole(user.getCompanyId(), RoleConstants.SITE_MEMBER).getRoleId());
		CourseResult courseResult=courseResultLocalService.getCourseResultByCourseAndUser(courseId, user.getUserId());
		if(courseResult==null)
		{
			courseResultLocalService.create(courseId, user.getUserId(), allowStartDate, allowFinishDate);
		}
		else
		{
			courseResult.setAllowStartDate(allowStartDate);
			courseResult.setAllowFinishDate(allowFinishDate);
			courseResultLocalService.updateCourseResult(courseResult);
		}
		//auditing
		AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), userId, AuditConstants.REGISTER, null);		 
	
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:28,代码来源:CourseLocalServiceImpl.java


示例18: receive

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的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


示例19: getDefaultAdmin

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
public static User getDefaultAdmin(long companyId) {
User result = null;
      Role role = null;
      try {
          role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
          List<User> admins = UserLocalServiceUtil.getRoleUsers(role.getRoleId());
          if (admins != null && admins.size() > 0)
          	result = admins.get(0);
      } catch (final Exception e) {
          m_objLog.error("Utils::getAdmin Exception", e);
      }
      return result;
  }
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:14,代码来源:ParticityInitializer.java


示例20: checkRole

import com.liferay.portal.service.RoleLocalServiceUtil; //导入依赖的package包/类
/**
 * Check for a specific role name and create a regular role if not existent
 *
 * @param companyId the company Id of the given role
 * @param roleName the role name
 * @return the role
 */
public static Role checkRole(final long userId, final long companyId, final String roleName, int roleType) {
	Role result = null;

	Role role = null;
	try {
		role = RoleLocalServiceUtil.fetchRole(companyId,
		        roleName);
		if (role != null && role.getType() == roleType)
			result = role;
	} catch (final SystemException e) {
	}
	if (role == null) {
		try {
			/*role = RoleLocalServiceUtil.createRole(CounterLocalServiceUtil
			        .increment(Role.class.getName()));
			role.setName(roleName);
			role.setCompanyId(companyId);
			role.setDescription(roleName);
			role.setTitle(roleName);
			role.setType(RoleConstants.TYPE_REGULAR);
			result = RoleLocalServiceUtil.updateRole(role);*/
			result = RoleLocalServiceUtil.addRole(userId, Role.class.getName(), CounterLocalServiceUtil
			        .increment(Role.class.getName()), roleName, null, null, roleType, null, null);
		} catch (final Throwable t) {
			m_objLog.error(t);
		}
	}

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StringTag类代码示例发布时间:2022-05-23
下一篇:
Java IRegistry类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap