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


Java UserLocalServiceUtil.getUserById方法代码示例

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


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

示例1: getUsersByLearningActivity

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<User> getUsersByLearningActivity(long actId) throws SystemException, PortalException
{ 			
	List<User> users = new ArrayList<User>();
	
	ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil.locate(ClpSerializer.getServletContextName(), "portletClassLoader");
	DynamicQuery consulta = DynamicQueryFactoryUtil.forClass(LearningActivityTry.class, classLoader)
				.add(PropertyFactoryUtil.forName("actId").eq(new Long(actId)));
				
	List<LearningActivityTry> activities = (List<LearningActivityTry>)learningActivityTryPersistence.findWithDynamicQuery(consulta);

	for(LearningActivityTry activity:activities){
		Long uId = activity.getUserId();
		User u = UserLocalServiceUtil.getUserById(uId.longValue());
		if(u!=null && !users.contains(u))
			users.add(u);
	}
	return users;		
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:20,代码来源:LearningActivityTryLocalServiceImpl.java

示例2: getRoom

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
public final ChatRoom getRoom(long roomId) throws PortalException, SystemException {
	ChatRoom result = getChatRoomLocalService().getChatRoom(roomId);
	if (result.getGuestId() != 0 && (result.getGuestName() == null || result.getGuestName().length() == 0)) {

		User u = UserLocalServiceUtil.getUserById(result.getGuestId());
		result.setGuestName(u.getFullName());

	}
	return result;
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:11,代码来源:ChatRoomServiceImpl.java

示例3: checkIfUserIsSurveyManager

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
public static boolean checkIfUserIsSurveyManager(String remoteUserId) {
	try {
		User user = UserLocalServiceUtil.getUserById(Long
				.parseLong(remoteUserId));
		List<Role> roles = user.getRoles();

		for (int i = 0; i < roles.size(); i++) {
			if (roles.get(i).getName().indexOf("Survey") >= 0) {
				return true;
			}
		}
	} catch (Exception err) {
	}
	return false;
}
 
开发者ID:SmartInfrastructures,项目名称:xipi,代码行数:16,代码来源:Util.java

示例4: login

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
@Override
public String[] login(HttpServletRequest request, HttpServletResponse response) throws AutoLoginException {
    String[] credentials = null;

    try {
        long companyId = PortalUtil.getCompanyId(request);

        if (!STORKUtil.isEnabled(companyId)) {
            return credentials;
        }

        HttpSession session = request.getSession();

        Long userId = (Long) session.getAttribute(FedWebKeys.STORK_ID_LOGIN);

        if (userId == null) {
            return credentials;
        }

        session.removeAttribute(FedWebKeys.STORK_ID_LOGIN);

        User user = UserLocalServiceUtil.getUserById(userId);

        credentials = new String[3];

        credentials[0] = String.valueOf(user.getUserId());
        credentials[1] = user.getPassword();
        credentials[2] = Boolean.TRUE.toString();
    } catch (Exception e) {
        _log.error(e, e);
    }

    return credentials;

}
 
开发者ID:csgf,项目名称:federated-login-ext,代码行数:36,代码来源:STORKAutoLogin.java

示例5: getStatusByUserUuid

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
@Override
public String getStatusByUserUuid() {
	try {
		User user = UserLocalServiceUtil.getUserById(getStatusByUserId());

		return user.getUuid();
	}
	catch (PortalException pe) {
		return StringPool.BLANK;
	}
}
 
开发者ID:juliocamarero,项目名称:jukebox-portlet,代码行数:12,代码来源:ArtistClp.java

示例6: getUserUuid

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
@Override
public String getUserUuid() {
	try {
		User user = UserLocalServiceUtil.getUserById(getUserId());

		return user.getUuid();
	}
	catch (PortalException pe) {
		return StringPool.BLANK;
	}
}
 
开发者ID:juliocamarero,项目名称:jukebox-portlet,代码行数:12,代码来源:AlbumClp.java

示例7: checkIfUserIsAdmin

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
public static boolean checkIfUserIsAdmin(String remoteUserId) {
	try {
		User user = UserLocalServiceUtil.getUserById(Long
				.parseLong(remoteUserId));
		List<Role> roles = user.getRoles();

		for (int i = 0; i < roles.size(); i++) {
			if (roles.get(i).getName().indexOf("Administrator") >= 0) {
				return true;
			}
		}
	} catch (Exception err) {
	}
	return false;
}
 
开发者ID:SmartInfrastructures,项目名称:xipi,代码行数:16,代码来源:Util.java

示例8: checkIfUserIsAdmin

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
private static boolean checkIfUserIsAdmin(String remoteUserId) {
	try {
		User user = UserLocalServiceUtil.getUserById(Long
				.parseLong(remoteUserId));
		List<Role> roles = user.getRoles();

		for (int i = 0; i < roles.size(); i++) {
			if (roles.get(i).getName().indexOf("Administrator") >= 0) {
				return true;
			}
		}
	} catch (Exception err) {
	}
	return false;
}
 
开发者ID:SmartInfrastructures,项目名称:xipi,代码行数:16,代码来源:ViewAction.java

示例9: checkIfUserIsSurvey

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
public static boolean checkIfUserIsSurvey(String remoteUserId) {
	try {
		User user = UserLocalServiceUtil.getUserById(Long
				.parseLong(remoteUserId));
		List<Role> roles = user.getRoles();

		for (int i = 0; i < roles.size(); i++) {
			if (roles.get(i).getName().indexOf("Survey") >= 0) {
				return true;
			}
		}
	} catch (Exception err) {
	}
	return false;
}
 
开发者ID:SmartInfrastructures,项目名称:xipi,代码行数:16,代码来源:Util.java

示例10: login

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
public String[] login(HttpServletRequest req, HttpServletResponse res)
	throws AutoLoginException {
	try {
		String[] credentials = null;
		long companyId = PortalUtil.getCompanyId(req);
		if (!PrefsPropsUtil.getBoolean(companyId,PropsUtil.CAS_AUTH_ENABLED)) {
			return credentials;
		}
		WebSSOUser webssoUser = (WebSSOUser) SecurityContextHolder
				.getContext().getAuthentication().getPrincipal();
		User user = null;
		try {
			_log.debug("Users Company Id "+companyId+"  GridId "+webssoUser.getGridId());
			UserIdMapper userIdMapper = UserIdMapperLocalServiceUtil
					.getUserIdMapperByExternalUserId("", webssoUser.getGridId());				
			user = UserLocalServiceUtil.getUserById(userIdMapper.getUserId());
		} catch (NoSuchUserIdMapperException nusime) {
			_log.debug(nusime.getMessage());
			user = addUser(companyId, webssoUser);
			UserIdMapperLocalServiceUtil.updateUserIdMapper(user
					.getUserId(), null, null, webssoUser.getGridId());
		}
		credentials = new String[3];
		credentials[0] = String.valueOf(user.getUserId());
		credentials[1] = user.getPassword();
		credentials[2] = Boolean.TRUE.toString();
		return credentials;
	} catch (Exception e) {
		throw new AutoLoginException(e);
	}
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:32,代码来源:CaGridLiferayCASAutoLoginHook.java

示例11: getUsersToCorrectP2P

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<User> getUsersToCorrectP2P(long actId, long userId, int numUsers, Calendar calendar) throws SystemException, PortalException{
	List<User> users = new ArrayList<User>();
	
	Calendar calendarStar = Calendar.getInstance();
	calendarStar.setTime(calendar.getTime());
	Calendar calendarEnd = Calendar.getInstance();
	calendarEnd.setTime(calendar.getTime());

	calendarStar.set(Calendar.HOUR_OF_DAY, 0);
	calendarStar.set(Calendar.MINUTE, 0);
	calendarStar.set(Calendar.SECOND, 0);
	
	calendarEnd.set(Calendar.HOUR_OF_DAY, 23);
	calendarEnd.set(Calendar.MINUTE, 59);
	calendarEnd.set(Calendar.SECOND, 59);
	
	int selected = 0;

	//Seleccionamos las actividades p2p entre ayer y antes de ayer.
	ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil.locate(ClpSerializer.getServletContextName(), "portletClassLoader");
	DynamicQuery consulta = DynamicQueryFactoryUtil.forClass(P2pActivity.class, classLoader)
			.add(PropertyFactoryUtil.forName("actId").eq(actId))
			.add(PropertyFactoryUtil.forName("userId").ne(userId))
			.add(PropertyFactoryUtil.forName("date").between(calendarStar.getTime(), calendarEnd.getTime()))
			.addOrder(OrderFactoryUtil.getOrderFactory().asc("countCorrections"));

	List<P2pActivity> activities = (List<P2pActivity>)p2pActivityPersistence.findWithDynamicQuery(consulta);

	for(P2pActivity activity:activities){

		Long uId = activity.getUserId();
		User u = UserLocalServiceUtil.getUserById(uId.longValue());
		int correctionsAsigned = P2pActivityCorrectionsLocalServiceUtil.getNumCorrectionsAsignToP2P(activity.getP2pActivityId());

		if(u!=null && !users.contains(u) ){
			users.add(u);
			selected++;
		}
		if(selected >= numUsers){
			return users;
		}
	}
	
	//Si no tenemos suficientes usuarios, buscamos otras 24 horas atras. Llamada recursiva con un dia menos.
	LearningActivity l = LearningActivityLocalServiceUtil.getLearningActivity(actId);

	Calendar calendarAct = Calendar.getInstance();
	calendarAct.setTime(calendar.getTime());

	calendarAct.set(Calendar.HOUR_OF_DAY,23);
	calendarAct.set(Calendar.MINUTE, 59);
	calendarAct.set(Calendar.SECOND, 59);
	
	Calendar dayBefore = Calendar.getInstance();
	dayBefore.setTime(calendarAct.getTime());
	dayBefore.set(Calendar.DAY_OF_YEAR, dayBefore.get(Calendar.DAY_OF_YEAR)-1);
	
	Calendar endDay =  Calendar.getInstance();
	endDay.setTime(l.getStartdate());
	
	//Paramos la recursividad cuando no tengamos mas dias en los que buscar.
	if(l.getStartdate().compareTo(dayBefore.getTime())<=0){
		
		List<User> usersBefore = getUsersToCorrectP2P(actId, userId, numUsers, dayBefore);
		
		for(User usu:usersBefore){
			if(usu!=null && !users.contains(usu))
				users.add(usu);
			
			selected++;
			if(selected >= numUsers){
				return users;
			}
		}
	}
	
	return users;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:80,代码来源:P2pActivityLocalServiceImpl.java

示例12: fromBuddyDetails

import com.liferay.portal.service.UserLocalServiceUtil; //导入方法依赖的package包/类
/**
 * Factory method which creates new Buddy object from BuddyDetails
 *
 * @param buddyDetails BuddyDetails
 * @return User
 */
public static Buddy fromBuddyDetails(BuddyDetails buddyDetails) {
    // Create new buddy
    Buddy buddy = new Buddy();
    // Map data to user details
    buddy.buddyId = buddyDetails.getBuddyId();
    buddy.companyId = buddyDetails.getCompanyId();
    buddy.fullName = buddyDetails.getFullName();
    buddy.screenName = buddyDetails.getScreenName();
    buddy.password = buddyDetails.getPassword();

    // Add additional info from local service util if it's not set in buddy details
    if (buddyDetails.getBuddyId() != null) {
        try {
            User user = UserLocalServiceUtil.getUserById(buddyDetails.getBuddyId());
            if (buddy.screenName == null) {
                buddy.screenName = user.getScreenName();
            }

            if (buddy.companyId == null) {
                buddy.companyId = user.getCompanyId();
            }

            if (buddy.fullName == null) {
                buddy.fullName = user.getFullName();
            }

            buddy.male = user.getMale();
            buddy.portraitId = user.getPortraitId();
            buddy.portraitImageToken = HttpUtil.encodeURL(DigesterUtil.digest(user.getUserUuid()));
            buddy.portraitToken = WebServerServletTokenUtil.getToken(user.getPortraitId());
            buddy.fullName = user.getFullName();

        } catch (Exception e) {
            // Just log
            if (log.isDebugEnabled()) {
                log.debug(e);
            }
        }
    }

    // Relations
    if (buddyDetails.getPresenceDetails() != null) {
        buddy.presence = Presence.fromPresenceDetails(buddyDetails.getPresenceDetails());
    }

    if (buddyDetails.getSettingsDetails() != null) {
        buddy.settings = Settings.fromSettingsDetails(buddyDetails.getSettingsDetails());
    }

    return buddy;
}
 
开发者ID:marcelmika,项目名称:lims,代码行数:58,代码来源:Buddy.java


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