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


Java PrincipalThreadLocal类代码示例

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


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

示例1: getURLView

import com.liferay.portal.security.auth.PrincipalThreadLocal; //导入依赖的package包/类
@Override
public final PortletURL getURLView(LiferayPortletResponse liferayPortletResponse,
		WindowState windowState) throws Exception {
	
	String portletId;
	
	if(_isRuntimePortlet){
		portletId = ACTIVITY_VIEWER_PORTLET_ID;
	}else{
		portletId = _portletId;
	}
	
	PortletURL portletURL = liferayPortletResponse.createLiferayPortletURL(_layout.getPlid(),portletId, PortletRequest.RENDER_PHASE);
	portletURL.setWindowState(windowState);
	portletURL.setParameter("actId",Long.toString( _learningactivity.getActId()));
	portletURL.setParameter("moduleId",Long.toString( _learningactivity.getModuleId()));
	portletURL.setParameter("actionEditingActivity", StringPool.FALSE);
	portletURL.setParameter("actionEditingDetails", StringPool.FALSE);
	portletURL.setParameter("actionEditingModule", StringPool.FALSE);
	portletURL.setParameter("actionCalifications", StringPool.FALSE);
	portletURL.setParameter("activityStarted", StringPool.TRUE);
	
	long userId = PrincipalThreadLocal.getUserId();
	
	if(Validator.isNotNull(userId)) {
		String mvcPath = getMvcPathView(userId,liferayPortletResponse,windowState);
		if(Validator.isNotNull(mvcPath)){
			portletURL.setParameter("mvcPath",mvcPath);
		}
	}
	
	prepareRuntimePortlet(portletURL);
	
	log.debug("portletURL::"+portletURL.toString());
	
	return portletURL;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:38,代码来源:LearningActivityBaseAssetRenderer.java

示例2: receive

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

示例3: receive

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

示例4: getURLCalifications

import com.liferay.portal.security.auth.PrincipalThreadLocal; //导入依赖的package包/类
public static final PortletURL getURLCalifications(LiferayPortletRequest liferayPortletRequest,
		LiferayPortletResponse liferayPortletResponse, LearningActivity activity) throws Exception {
	
	long plid = PortalUtil.getPlidFromPortletId(activity.getGroupId(), ACTIVITY_VIEWER_PORTLET_ID);
     
	log.debug("PLID: "+plid);
	
	if (plid == LayoutConstants.DEFAULT_PLID) {
		throw new NoSuchLayoutException();
	}		

	PortletURL portletURL = liferayPortletResponse.createLiferayPortletURL(plid, LMS_EDITACTIVITY_PORTLET_ID, PortletRequest.RENDER_PHASE);
	portletURL.setWindowState(WindowState.NORMAL);
	
	portletURL.setParameter("actionEditingDetails", StringPool.FALSE);
	portletURL.setParameter("actionEditingActivity", StringPool.FALSE);
	portletURL.setParameter("actionEditingModule", StringPool.FALSE);
	portletURL.setParameter("actionCalifications", StringPool.TRUE);
	portletURL.setParameter("actId",Long.toString( activity.getActId()));
	
	long userId = PrincipalThreadLocal.getUserId();
	
	if(Validator.isNotNull(userId)) {			
		//portletURL.setParameter("mvcPath", "/html/editactivity/editactivity.jsp");
		portletURL.setParameter("califications", StringPool.TRUE);
		portletURL.setParameter("editing", StringPool.FALSE);
		portletURL.setParameter("resId",Long.toString( activity.getActId()));
		portletURL.setParameter("resModuleId",Long.toString( activity.getModuleId())); 
	}
	
	portletURL.setParameter("p_o_p_id",ACTIVITY_VIEWER_PORTLET_ID);
	
	//log.debug(" getURLCalifications: "+portletURL);
	
	return portletURL;		
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:37,代码来源:LmsActivitiesList.java

示例5: getURLEditActivity

import com.liferay.portal.security.auth.PrincipalThreadLocal; //导入依赖的package包/类
public static final PortletURL getURLEditActivity(LiferayPortletRequest liferayPortletRequest,
		LiferayPortletResponse liferayPortletResponse, LearningActivity activity) throws Exception {
	PortletURL portletURL = null;
	if(activity!=null){
		long plid = PortalUtil.getPlidFromPortletId(activity.getGroupId(), ACTIVITY_VIEWER_PORTLET_ID);
	     
		
		log.debug("PLID: "+plid);
		
		if (plid == LayoutConstants.DEFAULT_PLID) {
			throw new NoSuchLayoutException();
		}		

		portletURL = liferayPortletResponse.createLiferayPortletURL(plid, LMS_EDITACTIVITY_PORTLET_ID, PortletRequest.RENDER_PHASE);
		portletURL.setWindowState(WindowState.NORMAL);
		portletURL.setParameter("actId",Long.toString( activity.getActId()));
		portletURL.setParameter("moduleId",Long.toString( activity.getModuleId()));
		portletURL.setParameter("actionEditingActivity", StringPool.TRUE);
		portletURL.setParameter("actionCalifications", StringPool.FALSE);
		portletURL.setParameter("actionEditingModule", StringPool.FALSE);
		portletURL.setParameter("actionEditingDetails", StringPool.FALSE);
		
		
		long userId = PrincipalThreadLocal.getUserId();
		
		if(Validator.isNotNull(userId)) {			
			portletURL.setParameter("mvcPath", "/html/editactivity/editactivity.jsp");
			portletURL.setParameter("editing", StringPool.TRUE);
			portletURL.setParameter("resId",Long.toString( activity.getActId()));
			portletURL.setParameter("resModuleId",Long.toString( activity.getModuleId())); 
		}
		
		portletURL.setParameter("p_o_p_id",ACTIVITY_VIEWER_PORTLET_ID);
		
		//log.debug(" getURLEditActivity: "+portletURL);
				
	}
	return portletURL;
	
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:41,代码来源:LmsActivitiesList.java

示例6: closeCourse

import com.liferay.portal.security.auth.PrincipalThreadLocal; //导入依赖的package包/类
@Indexable(type=IndexableType.REINDEX)
public Course closeCourse(long courseId) throws SystemException,
PortalException {

	Course course=CourseLocalServiceUtil.getCourse(courseId);
	if(!course.getClosed()){
		course.setClosed(true);
		course.setModifiedDate(new Date());
		Group courseGroup=GroupLocalServiceUtil.getGroup(course.getGroupCreatedId());
		courseGroup.setActive(false);
		GroupLocalServiceUtil.updateGroup(courseGroup);
		coursePersistence.update(course, true);		
		AssetEntry courseAsset=AssetEntryLocalServiceUtil.getEntry(Course.class.getName(), course.getCourseId());
		courseAsset.setVisible(false);
		AssetEntryLocalServiceUtil.updateAssetEntry(courseAsset);

		CourseEval courseEval=new CourseEvalRegistry().getCourseEval(course.getCourseEvalId());
		if(Validator.isNotNull(courseEval)) {
			courseEval.onCloseCourse(course);
		}
		
		//auditing
		AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), 
								courseId, PrincipalThreadLocal.getUserId(), AuditConstants.CLOSE, null);

	}

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

示例7: openCourse

import com.liferay.portal.security.auth.PrincipalThreadLocal; //导入依赖的package包/类
@Indexable(type=IndexableType.REINDEX)
public Course openCourse(long courseId) throws SystemException,
PortalException {

	Course course=CourseLocalServiceUtil.getCourse(courseId);
	if(course.getClosed()){
		course.setClosed(false);
		course.setModifiedDate(new Date());
		Group courseGroup=GroupLocalServiceUtil.getGroup(course.getGroupCreatedId());
		courseGroup.setActive(true);
		GroupLocalServiceUtil.updateGroup(courseGroup);
		coursePersistence.update(course, true);	
		AssetEntry courseAsset=AssetEntryLocalServiceUtil.getEntry(Course.class.getName(), course.getCourseId());
		courseAsset.setVisible(true);
		AssetEntryLocalServiceUtil.updateAssetEntry(courseAsset);

		CourseEval courseEval=new CourseEvalRegistry().getCourseEval(course.getCourseEvalId());
		if(Validator.isNotNull(courseEval)) {
			courseEval.onOpenCourse(course);
		}

		//auditing
		AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), 
				course.getCourseId(), PrincipalThreadLocal.getUserId(), AuditConstants.OPEN, null);
	}

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

示例8: receive

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