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


Java ServiceContext类代码示例

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


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

示例1: editUserInscriptionDates

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public void editUserInscriptionDates(long courseId,long userId,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.getUser(userId);
		if (!GroupLocalServiceUtil.hasUserGroup(user.getUserId(), course.getGroupCreatedId())) {
			return;
		}		
		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.UPDATE, null);		 
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:26,代码来源:CourseServiceImpl.java

示例2: updateUser

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
@JSONWebService
public void updateUser(String login, String firstName,String lastName,String email) throws PortalException, SystemException
{
	ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
	
		User user = UserLocalServiceUtil.getUserByScreenName(
				serviceContext.getCompanyId(), login);
		user.setFirstName(firstName);
		user.setLastName(lastName);
		user.setEmailAddress(email);
		List<UserGroup> userGroups = user.getUserGroups();
		long[] userArray = new long[] { user.getUserId() };
		if(PortalPermissionUtil.contains(
				getPermissionChecker(), ActionKeys.ADD_USER))
		{
			UserLocalServiceUtil.updateUser(user);
		}

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

示例3: updateDictMetaData

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public DictMetaData updateDictMetaData(long id, long dictDataId, String attributeName, String attributeValue, ServiceContext serviceContext)
	throws PortalException, SystemException {

	//validate(collectionName, dataCode, title, status);

	DictMetaData dictMetaData = dictMetaDataPersistence.findByPrimaryKey(id);

	dictMetaData.setModifiedDate(serviceContext.getModifiedDate(null));
	dictMetaData.setDictDataId(dictDataId);
	dictMetaData.setAttributeName(attributeName);
	dictMetaData.setAttributeValue(attributeValue);
	
	dictMetaDataPersistence.update(dictMetaData);

	if ((serviceContext.getGroupPermissions() != null) ||
		(serviceContext.getGuestPermissions() != null)) {

		updateDictMetaDataResources(
			dictMetaData, serviceContext.getGroupPermissions(),
			serviceContext.getGuestPermissions(), serviceContext);
	}

	return getDictMetaData(dictMetaData.getDictMetaDataId());
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:25,代码来源:DictMetaDataLocalServiceImpl.java

示例4: addDossierDoc2Template

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
/** 
 * Thêm quan hệ giữa thành phần hồ sơ với biểu mẫu
 * 
 * Version: OEP 2.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  21-September-2015  trungdk    Tạo mới
 * @param dossierDocId thành phần hồ sơ
 * @param docTemplateId mẫu thành phần hồ sơ mặc định
 * @return: quan hệ thành phần hồ sơ với biểu mẫu vừa được tạo
 */
@Indexable(type = IndexableType.REINDEX)	
public DossierDoc2Template addDossierDoc2Template(
		long dossierDocId,
		long docTemplateId,
		ServiceContext serviceContext) throws SystemException, PortalException {
	validate();
	DossierDoc2Template dossierDoc2Template = dossierDoc2TemplatePersistence.create(new DossierDoc2TemplatePK(dossierDocId, docTemplateId));
			
	
	dossierDoc2TemplatePersistence.update(dossierDoc2Template);

	if (_log.isInfoEnabled()) {
		_log.info("Create new dossierdoc2template");
	}
	
	return getDossierDoc2Template(dossierDocId, docTemplateId);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:31,代码来源:DossierDoc2TemplateLocalServiceImpl.java

示例5: findByLikeName

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public List<DossierProc> findByLikeName(String name, int startIndex, int endIndex, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(DossierProcFinder.class.getName(), FIND_BY_LIKE_NAME);
	sql = sql.replace("[$COMPANY_FILTER$]", " AND COMPANYID = ?");
	params.add(serviceContext.getCompanyId());
	if (!StringUtil.isNullOrEmpty(name)) {
		sql = sql.replace("[$NAME_FILTER$]", " AND LOWER(NAME) LIKE ?");
		params.add("%" + name.toLowerCase() + "%");			
	}
	else {
		sql = sql.replace("[$NAME_FILTER$]", "");
	}
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("DossierProc", DossierProcImpl.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	return (List<DossierProc>) QueryUtil.list(query, getDialect(), startIndex, endIndex);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:24,代码来源:DossierProcFinderImpl.java

示例6: findByLikeName

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public List<EbPartnerShip> findByLikeName(String name, int startIndex, int endIndex, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(EbPartnerShipFinder.class.getName(), FIND_BY_LIKE_NAME);
	sql = sql.replace("[$COMPANY_FILTER$]", " AND COMPANYID = ?");
	params.add(serviceContext.getCompanyId());
	if (!StringUtil.isNullOrEmpty(name)) {
		sql = sql.replace("[$NAME_FILTER$]", " AND LOWER(NAME) LIKE ?");
		params.add("%" + name.toLowerCase() + "%");			
	}
	else {
		sql = sql.replace("[$NAME_FILTER$]", "");
	}
	SQLQuery query = session.createSQLQuery(sql);
	query.addEntity("EbPartnerShip", EbPartnerShipImpl.class);
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	return (List<EbPartnerShip>) QueryUtil.list(query, getDialect(), startIndex, endIndex);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:24,代码来源:EbPartnerShipFinderImpl.java

示例7: updateDictCollectionResources

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public void updateDictCollectionResources(
		DictCollection dictCollection, String[] groupPermissions,
		String[] guestPermissions, ServiceContext serviceContext)
	throws PortalException, SystemException {

	resourceLocalService.updateResources(
		dictCollection.getCompanyId(), serviceContext.getScopeGroupId(),
		DictCollection.class.getName(), dictCollection.getDictCollectionId(), groupPermissions,
		guestPermissions);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:11,代码来源:DictCollectionLocalServiceImpl.java

示例8: findByActIdAndUserId

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public P2pActivity findByActIdAndUserId(long actId, long userId)
		throws SystemException {
	try{
		List<P2pActivity> myp2ps = p2pActivityPersistence.findByActIdAndUserId(actId, userId);

		
		
		if(!myp2ps.isEmpty()){
			for(P2pActivity myActivity : myp2ps){
				//auditing
				ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
				if(serviceContext!=null){
					AuditingLogFactory.audit(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), P2pActivity.class.getName(), 
							myActivity.getActId(), serviceContext.getUserId(), AuditConstants.GET, null);
				}else{
					LearningActivity la = learningActivityPersistence.fetchByPrimaryKey(actId);
					if(la!=null){
						AuditingLogFactory.audit(la.getCompanyId(), la.getGroupId(), P2pActivity.class.getName(), 
								myActivity.getActId(), la.getUserId(), AuditConstants.GET, null);
					}
				}
				
				return myActivity;
			}
		}
		return null;
	}
	catch(Exception e){
		if (_log.isErrorEnabled()) { 
			_log.error("Error getting P2pActivityLocalService.findByActIdAndUserId");
			_log.error(e.getMessage());
		}
		return null;
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:36,代码来源:P2pActivityLocalServiceImpl.java

示例9: updateCreateFile

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
/** 
 * Cập nhật thông tin vết hồ sơ được tạo ra tại các bước trong quy trình xử lý
 * 
 * Version: OEP 2.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  21-September-2015  trungdk    Tạo mới
 * @param id mã vết hồ sơ tại các bước trong quy trình
 * @param dossierProcessId nằm trong quy trình nào
 * @param dossierStepId nằm tại bước xử lý nào
 * @param stepDate thời gian bắt đầu của bước
 * @param docFileId file hồ sơ được tạo ra bởi form xử lý
 * @return: vết hồ sơ của quy trình mới được cập nhật
 */
@Indexable(type = IndexableType.REINDEX)
public CreateFile updateCreateFile(
		long id, 
		long processOrderId,
		long dossierStepId,
		Date stepDate,
		long docFileId,
		ServiceContext serviceContext)
	throws PortalException, SystemException {

	validate();

	CreateFile createFile = createFilePersistence.findByPrimaryKey(id);
	createFile.setProcessOrderId(processOrderId);
	createFile.setDossierStepId(dossierStepId);
	createFile.setCreateDate(stepDate);
	createFile.setDocFileId(docFileId);
	
	createFilePersistence.update(createFile);

	if ((serviceContext.getGroupPermissions() != null) ||
		(serviceContext.getGuestPermissions() != null)) {

		updateCreateFileResources(
			createFile, serviceContext.getGroupPermissions(),
			serviceContext.getGuestPermissions(), serviceContext);
	}

	return getCreateFile(createFile.getCreateFileId());
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:47,代码来源:CreateFileLocalServiceImpl.java

示例10: updateDossierProcessResources

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public void updateDossierProcessResources(
		DossierProcess dossierProcess, String[] groupPermissions,
		String[] guestPermissions, ServiceContext serviceContext)
	throws PortalException, SystemException {

	resourceLocalService.updateResources(
		dossierProcess.getCompanyId(), serviceContext.getScopeGroupId(),
		DossierProcess.class.getName(), dossierProcess.getDossierProcessId(), groupPermissions,
		guestPermissions);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:11,代码来源:DossierProcessLocalServiceImpl.java

示例11: modLearningActivity

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public LearningActivity modLearningActivity (LearningActivity larn, 
		ServiceContext serviceContext)
				throws SystemException, PortalException {

	larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "title");
	larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "description");
	learningActivityPersistence.update(larn, false);
	long userId=serviceContext.getUserId();

	assetEntryLocalService.updateEntry(
			userId, larn.getGroupId(), LearningActivity.class.getName(),
			larn.getActId(), larn.getUuid(),larn.getTypeId(), serviceContext.getAssetCategoryIds(),
			serviceContext.getAssetTagNames(), true, null, null, 
			new java.util.Date(System.currentTimeMillis()), null,
			ContentTypes.TEXT_HTML, larn.getTitle(), null, larn.getDescription(),null, null, 0, 0,
			null, false);
	SocialActivityLocalServiceUtil.addActivity(
			larn.getUserId(), larn.getGroupId(),
			LearningActivity.class.getName(), larn.getActId(),
			1, StringPool.BLANK, 0);

	//auditing
	AuditingLogFactory.audit(larn.getCompanyId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getPrimaryKey(), serviceContext.getUserId(), AuditConstants.UPDATE, null);

	return larn;

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

示例12: countByWorkingUnit

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
public int countByWorkingUnit(long workingUnitId, ServiceContext serviceContext) {
	List<Object> params = new ArrayList<Object>();
	Session session = openSession();
	String sql = CustomSQLUtil.get(AppRole2EmployeeFinder.class.getName(), COUNT_BY_WORKING_UNIT);		
	sql = sql.replace("[$COMPANY_FILTER$]", " AND companyId = ?");
	params.add(serviceContext.getCompanyId());
	
	sql = sql.replace("[$GROUP_FILTER$]", "");
	if (workingUnitId != 0) {
		sql = sql.replace("[$WORKINGUNIT_FILTER$]", " AND employeeId IN (SELECT oep_usermgt_employee.employeeId FROM oep_usermgt_employee INNER JOIN oep_usermgt_workingunit ON oep_usermgt_employee.workingUnitId = oep_usermgt_workingunit.workingUnitId WHERE oep_usermgt_workingunit.workingUnitId = ?)");
		params.add(workingUnitId);			
	}
	else {
		sql = sql.replace("[$WORKINGUNIT_FILTER$]", "");
	}
	_log.info("SQL:" + sql);
	
	SQLQuery query = session.createSQLQuery(sql);
	query.addScalar("total", Type.LONG);
	
	if (params != null && params.size() > 0) {
		for (int index = 0; index < params.size(); index++) {
			query.setString(index, String.valueOf(params.get(index)));
		}
	}
	
	List temps = query.list();
	if (temps != null && temps.size() > 0) {
		Long total = (Long) temps.get(0);
		return total.intValue();
	}
	return 0;
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:34,代码来源:AppRole2EmployeeFinderImpl.java

示例13: updateApplication

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
/** 
 * Cập nhật thông tin một ứng dụng tích hợp vào cổng
 * 
 * Version: OEP 2.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  21-September-2015  trungdk    Tạo mới
 * @param id mã phân biệt của ứng dụng trong cổng
 * @param appCode mã duy nhất của ứng dụng
 * @param appName tên ứng dụng
 * @param appPin mã pin bảo mật ứng dụng
 * @param appUrl địa chỉ url gốc để truy xuất vào ứng dụng
 * @param appBigIcon lưu ảnh icon ứng dụng
 * @param appSmallIcon lưu ảnh icon ứng dụng
 * @param pingTime thời điểm ping cuối cùng của ứng dụng với hệ thống
 * @param sequenceNo thứ tự quan trọng của ứng dụng trong hệ thống
 * @param serviceContext ngữ cảnh dịch vụ
 * @return: đối tượng thủ tục hành chính mới được cập nhật
 */
public Application updateApplication(
		long id, 
		String appCode,
		String appName,
		String appPin,
		String appUrl,
		Blob appBigIcon,
		Blob appSmallIcon,
		Date pingTime,
		int sequenceNo,
		ServiceContext serviceContext)
	throws PortalException, SystemException {

	Application application = applicationPersistence.findByPrimaryKey(id);

	application.setModifiedDate(serviceContext.getModifiedDate(null));
	application.setAppCode(appCode);
	application.setAppName(appName);
	application.setAppPin(appPin);
	application.setAppUrl(appUrl);
	application.setAppBigIcon(appBigIcon);
	application.setAppSmallIcon(appSmallIcon);
	application.setPingTime(pingTime);
	application.setSequenceNo(sequenceNo);

	applicationPersistence.update(application);

	if ((serviceContext.getGroupPermissions() != null) ||
		(serviceContext.getGuestPermissions() != null)) {

		updateApplicationResources(
			application, serviceContext.getGroupPermissions(),
			serviceContext.getGuestPermissions(), serviceContext);
	}

	return getApplication(application.getApplicationId());
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:59,代码来源:ApplicationLocalServiceImpl.java

示例14: addDocTemplate

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
/** 
 * Thêm một biểu mẫu tài liệu
 * 
 * Version: OEP 2.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  21-September-2015  trungdk    Tạo mới
 * @param templateNo mã biểu mẫu
 * @param title Tiêu đề biểu mẫu
 * @param enTitle Tiêu đề Tiếng Anh của biểu mẫu
 * @param fileEntryId Mã tài liệu mẫu bằng module quản lý phương tiện
 * @return: biểu mẫu tài liệu mới tạo
 */
@Indexable(type = IndexableType.REINDEX)	
public DocTemplate addDocTemplate(
		String templateNo, 
		String title,
		String enTitle,
		long fileEntryId,
		ServiceContext serviceContext) throws SystemException, PortalException {
	validate(templateNo);
	long id = counterLocalService.increment();
	DocTemplate docTemplate = docTemplatePersistence.create(id);
	Date now = new Date();
	
	docTemplate.setCompanyId(serviceContext.getCompanyId());
	docTemplate.setGroupId(serviceContext.getScopeGroupId());
	docTemplate.setUserId(serviceContext.getUserId());
	docTemplate.setCreateDate(serviceContext.getCreateDate(now));
	docTemplate.setTemplateNo(templateNo);
	docTemplate.setTitle(title);
	docTemplate.setEnTitle(enTitle);
	docTemplate.setFileEntryId(fileEntryId);
	
	docTemplatePersistence.update(docTemplate);

	if (_log.isInfoEnabled()) {
		_log.info("Tạo mới biểu mẫu với mã " + id);
	}
	
	if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {
		addDocTemplateResources(docTemplate, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions(), serviceContext);
	}
	else {
		addDocTemplateResources(docTemplate, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions(), serviceContext);
	}
	return getDocTemplate(id);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:51,代码来源:DocTemplateLocalServiceImpl.java

示例15: addAppRole

import com.liferay.portal.service.ServiceContext; //导入依赖的package包/类
/** 
 * Thêm mới một quyền truy cập ứng dụng
 * 
 * Version: OEP 2.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  21-September-2015  trungdk    Tạo mới
 * @param applicationId mã ứng dụng
 * @param roleCode mã quyền truy cập ứng dụng
 * @param roleName tên quyền truy cập
 * @param serviceContext ngữ cảnh dịch vụ
 * @return: đối tượng quyền truy cập ứng dụng mới được thêm vào
 */
@Indexable(type = IndexableType.REINDEX)	
public AppRole addAppRole(
		long applicationId,
		String roleCode,
		String roleName,
		ServiceContext serviceContext) throws SystemException, PortalException {
	long id = counterLocalService.increment();
	AppRole appRole = appRolePersistence.create(id);
	Date now = new Date();
					
	appRole.setCompanyId(serviceContext.getCompanyId());
	appRole.setGroupId(serviceContext.getScopeGroupId());
	appRole.setUserId(serviceContext.getUserId());
	appRole.setCreateDate(serviceContext.getCreateDate(now));
	
	appRole.setApplicationId(applicationId);
	appRole.setRoleCode(roleCode);
	appRole.setRoleName(roleName);
	
	appRolePersistence.update(appRole);

	if (_log.isInfoEnabled()) {
		_log.info("Create new app role " + id);
	}
	
	if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {
		addAppRoleResources(appRole, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions(), serviceContext);
	}
	else {
		addAppRoleResources(appRole, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions(), serviceContext);
	}
	return getAppRole(id);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:49,代码来源:AppRoleLocalServiceImpl.java


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