public static UserData convertLiferayUser(User user) throws SystemException { if (user == null) { return null; } UserData ud = new UserData(); ud.setEmail(user.getEmailAddress()); ud.setLogin(user.getScreenName()); ud.setFirstName(user.getFirstName()); ud.setLastName(user.getLastName()); ud.setJobTitle(user.getJobTitle()); ud.setCompanyId(user.getCompanyId()); ud.setLiferayUserId(user.getUserId()); for (Role role : user.getRoles()) { ud.addRoleName(role.getName(), role.getDescription()); } setGroupRoles(ud, user); return ud; }
@Override public <T> T get(String columnName, User user) { try { return get(columnName, user.getCompanyId(), user.getUserId()); } catch (Exception ex) { return null; } }
@Override public boolean isMember(Organization organization, User user) { try { return user.getOrganizations().contains(organization); } catch (Exception e) { String msg = String.format("Failed to lookup if user [%s] is member in organization [%s]", user.getScreenName(), organization.getName()); log(msg, e); throw new RuntimeException(msg, e); } }
private static void refreshUsers() throws SystemException { if (debug) { log("refreshing users"); } for (User user: UserLocalServiceUtil.getUsers(0, QueryUtil.ALL_POS)) { if (debug) { log("have user " + user.getScreenName() + ", " + user.getEmailAddress()); } cache.put(user.getScreenName(), new UserContainer(user)); emailCache.put(user.getEmailAddress(), new UserContainer(user)); } }
public static UserData convertLiferayUser(User user) throws SystemException { if (user == null) { return null; } UserDataBean ud = new UserDataBean(); ud.setEmail(user.getEmailAddress()); ud.setLogin(user.getScreenName()); ud.setFirstName(user.getFirstName()); ud.setLastName(user.getLastName()); ud.setJobTitle(user.getJobTitle()); ud.setCompanyId(user.getCompanyId()); for (Role role : user.getRoles()) { ud.addRole(role.getName()); } setGroupRoles(ud, user); Map<String, Serializable> customAttributes = user.getExpandoBridge().getAttributes(false); Map<String, Object> attributes = new HashMap<String, Object>(); for(Map.Entry<String, Serializable> entry: customAttributes.entrySet()) { String attributeKey = entry.getKey(); Serializable value = entry.getValue(); if(attributeKey.contains(APERTE_PREFIX_ATTRIBUTE)) attributes.put(attributeKey, value); } ud.setAttributes(attributes); return ud; }
String uid = user.getScreenName(); HttpSession session = request.getSession(false); userCredentials.cn = user.getFullName(); userCredentials.mail = user.getEmailAddress(); userCredentials.portalUserId = user.getUserId(); userCredentials.httpSessionId = session.getId(); logger.debug("user credentials created for user " + uid); // + "/" + password);
user.setCompanyId(companyId); user.setPassword(password1); user.setPasswordEncrypted(true); user.setPasswordReset(false); user.setPasswordModifiedDate(new Date()); user.setScreenName(ideaPersonVgrId); user.setGreeting(greeting); user.setEmailAddress(emailAddress); user.setFacebookId(facebookId); user.setOpenId(openId); user.setFirstName(firstName); user.setLastName(lastName); user.setJobTitle(jobTitle); user.setCreateDate(new Date()); user.setContactId(idContact); user.setCreateDate(new Date()); user.setModifiedDate(new Date()); user.setLanguageId("sv_SE"); user.setTimeZoneId("Europe/Paris"); user.setActive(true); user.setAgreedToTermsOfUse(true); userLocalService.addUser(user); userLocalService.addDefaultGroups(user.getUserId()); userLocalService.addDefaultRoles(user.getUserId()); contact.setCreateDate(new Date()); contact.setUserName(ideaPersonVgrId); contact.setUserId(user.getUserId());
public static User createUser( final com.liferay.portal.model.User liferayUser, final String imagePath, final String userLink, final boolean isFemale, final boolean isBanned) { final User entity = new User(); entity.setId(liferayUser.getUserId()); entity.setDisplayedName(liferayUser.getFullName()); if (usesScreennameOnTori(liferayUser)) { entity.setDisplayedName(liferayUser.getScreenName()); } entity.setAvatarUrl(getAvatarUrl(liferayUser.getPortraitId(), imagePath, isFemale)); entity.setBanned(isBanned); entity.setOriginalUserObject(liferayUser); entity.setUserLink(userLink); return entity; }
User user = UserLocalServiceUtil.getUserById(companyId, userId); logger.info(">>> LOGIN : " + user.getScreenName() + " / " + user.getFullName() + " / " + user.getEmailAddress() + " / " + request.getRemoteAddr());
private long[] toIdArray(User... users) { long[] userIds = new long[users.length]; for (int i = 0; i < users.length; i++) { userIds[i] = users[i].getUserId(); } return userIds; }
@Override public boolean isMember(UserGroup userGroup, User user) { try { return userLocalService.hasUserGroupUser(userGroup.getUserGroupId(), user.getUserId()); } catch (Exception e) { String msg = String.format("Failed to lookup if user belongs to group [%s, %s]", user.getScreenName(), userGroup.getName()); log(msg, e); } return false; }
private String toScreenNames(User... users) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < users.length; i++) { if (sb.length() > 0) { sb.append(", "); } sb.append(users[i].getScreenName()); } return sb.toString(); }
private User getUser(final long userId) throws PortalException, SystemException { if (userId == 0) { return LiferayEntityFactoryUtil .createAnonymousUser(imagePath); } else { try { final com.liferay.portal.model.User liferayUser = UserLocalServiceUtil .getUser(userId); if (liferayUser.isDefaultUser()) { return LiferayEntityFactoryUtil .createAnonymousUser(imagePath); } else { final boolean isBanned = MBBanLocalServiceUtil.hasBan( scopeGroupId, liferayUser.getUserId()); String userLink = null; if (liferayUser.getGroup() != null && liferayUser.getPublicLayoutsPageCount() > 0) { userLink = liferayUser.getDisplayURL(themeDisplay); } return LiferayEntityFactoryUtil.createUser( liferayUser, imagePath, userLink, liferayUser.isFemale(), isBanned); } } catch (NoSuchUserException e) { return LiferayEntityFactoryUtil .createAnonymousUser(imagePath); } } }
user = UserLocalServiceUtil.getUser(mbMessage.getUserId()); String userAvatarUrl = LiferayEntityFactoryUtil.getAvatarUrl( user.getPortraitId(), imagePath, user.isFemale()); if (userAvatarUrl != null) { avatarUrl = mbMessageServiceContext.getPortalURL() threadTopic = stripTags(threadTopic); String userDisplayName = user != null ? user.getFullName() : "Anonymous"; if (user != null && LiferayEntityFactoryUtil.usesScreennameOnTori(user)) { userDisplayName = user.getScreenName();
@Override public String getEmail() { return getUser().getEmailAddress(); }
List<UserGroup> allUserGroups = userGroupLocalService.getUserGroups(0, cnt); List<UserGroup> allInternalUserGroups = internalOnlyGroups(allUserGroups); List<UserGroup> userGroups = user.getUserGroups(); List<UserGroup> userInternalOnlyGroups = internalOnlyGroups(userGroups); "restrictions [%s] for [%s]", internalAccess, user.getScreenName()); log(msg, e); throw new RuntimeException(msg, e);
private boolean isInvalid(User... users) { if (users.length <= 0) return true; if (users.length > 1) { long companyId = users[0].getCompanyId(); for (User user : users) { if (user.getCompanyId() != companyId) { LOGGER.error("Users are from different Liferay instances (they have different companyId)"); return true; } } } return false; }
if (user.isActive()) { InternetAddress userAddress = new InternetAddress( user.getEmailAddress(), user.getFullName());
List<UserGroup> allUserGroups = userGroupLocalService.getUserGroups(0, cnt); List<UserGroup> allExternallySithsOnlyGroups = externallySithsOnlyGroups(allUserGroups); List<UserGroup> userGroups = user.getUserGroups(); List<UserGroup> userExternallySithsOnlyGroups = externallySithsOnlyGroups(userGroups);
public static Collection<String> getLiferayUserRoles(PortletRequest request) { try { User user = PortalUtil.getUser(request); if (user == null) { return null; } return new Mapcar<Role, String>(user.getRoles()) { @Override public String lambda(Role x) { return x.getName(); } }.go(); } catch (Exception e) { throw new LiferayBridge.LiferayBridgeException(e); } }