List of usage examples for com.liferay.portal.kernel.model User isActive
public boolean isActive();
From source file:com.liferay.asset.publisher.web.internal.messaging.AssetEntriesCheckerUtil.java
License:Open Source License
private static void _notifySubscribers(List<Subscription> subscriptions, PortletPreferences portletPreferences, List<AssetEntry> assetEntries) { if (!_assetPublisherWebUtil.getEmailAssetEntryAddedEnabled(portletPreferences)) { return;/* w w w. j av a2s . co m*/ } Map<List<AssetEntry>, List<User>> assetEntriesToUsersMap = new HashMap<>(); for (Subscription subscription : subscriptions) { long userId = subscription.getUserId(); User user = _userLocalService.fetchUser(userId); if ((user == null) || !user.isActive()) { continue; } List<AssetEntry> filteredAssetEntries = _filterAssetEntries(userId, assetEntries); if (filteredAssetEntries.isEmpty()) { continue; } List<User> users = assetEntriesToUsersMap.get(filteredAssetEntries); if (users == null) { users = new LinkedList<>(); assetEntriesToUsersMap.put(filteredAssetEntries, users); } users.add(user); } for (Map.Entry<List<AssetEntry>, List<User>> entry : assetEntriesToUsersMap.entrySet()) { List<AssetEntry> filteredAssetEntries = entry.getKey(); List<User> users = entry.getValue(); SubscriptionSender subscriptionSender = _getSubscriptionSender(portletPreferences, filteredAssetEntries); if (subscriptionSender == null) { continue; } for (User user : users) { subscriptionSender.addRuntimeSubscribers(user.getEmailAddress(), user.getFullName()); } subscriptionSender.flushNotificationsAsync(); } }
From source file:com.liferay.calendar.notification.impl.NotificationUtil.java
License:Open Source License
private static List<NotificationRecipient> _getNotificationRecipients(CalendarBooking calendarBooking) throws Exception { List<NotificationRecipient> notificationRecipients = new ArrayList<>(); CalendarResource calendarResource = calendarBooking.getCalendarResource(); Set<User> users = new HashSet<>(); if (calendarBooking.isMasterBooking()) { users.add(UserLocalServiceUtil.fetchUser(calendarBooking.getUserId())); }/*from w w w . j a v a 2s . c o m*/ users.add(UserLocalServiceUtil.fetchUser(calendarResource.getUserId())); for (User user : users) { if (user == null) { continue; } if (!user.isActive()) { if (_log.isDebugEnabled()) { _log.debug("Skip inactive user " + user.getUserId()); } continue; } notificationRecipients.add(new NotificationRecipient(user)); } return notificationRecipients; }
From source file:com.liferay.login.authentication.facebook.connect.web.internal.portlet.action.FacebookConnectAction.java
License:Open Source License
protected User setFacebookCredentials(HttpSession session, long companyId, String token) throws Exception { JSONObject jsonObject = _facebookConnect.getGraphResources(companyId, "/me", token, "id,email,first_name,last_name,gender,verified"); if ((jsonObject == null) || (jsonObject.getJSONObject("error") != null)) { return null; }/*from www . j a v a 2 s . c o m*/ if (_facebookConnect.isVerifiedAccountRequired(companyId) && !jsonObject.getBoolean("verified")) { return null; } User user = null; long facebookId = jsonObject.getLong("id"); if (facebookId > 0) { session.setAttribute(FacebookConnectWebKeys.FACEBOOK_ACCESS_TOKEN, token); user = _userLocalService.fetchUserByFacebookId(companyId, facebookId); if ((user != null) && !user.isActive()) { return null; } else if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { session.setAttribute(FacebookConnectWebKeys.FACEBOOK_USER_ID, String.valueOf(facebookId)); } } String emailAddress = jsonObject.getString("email"); if ((user == null) && Validator.isNotNull(emailAddress)) { user = _userLocalService.fetchUserByEmailAddress(companyId, emailAddress); if ((user != null) && !user.isActive()) { return null; } else if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { session.setAttribute(WebKeys.FACEBOOK_USER_EMAIL_ADDRESS, emailAddress); } } if (user != null) { if (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE) { session.setAttribute(WebKeys.FACEBOOK_INCOMPLETE_USER_ID, facebookId); user.setEmailAddress(jsonObject.getString("email")); user.setFirstName(jsonObject.getString("first_name")); user.setLastName(jsonObject.getString("last_name")); return user; } user = updateUser(user, jsonObject); } else { user = addUser(session, companyId, jsonObject); } return user; }
From source file:com.liferay.login.web.internal.portlet.action.ForgotPasswordMVCActionCommand.java
License:Open Source License
protected User getUser(ActionRequest actionRequest) throws Exception { PortletSession portletSession = actionRequest.getPortletSession(); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String sessionEmailAddress = (String) portletSession .getAttribute(WebKeys.FORGOT_PASSWORD_REMINDER_USER_EMAIL_ADDRESS); User user = null; if (Validator.isNotNull(sessionEmailAddress)) { user = _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), sessionEmailAddress); } else {/* www . j av a2 s .c o m*/ long userId = ParamUtil.getLong(actionRequest, "userId"); String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); if (Validator.isNotNull(emailAddress)) { user = _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); } else if (Validator.isNotNull(screenName)) { user = _userLocalService.getUserByScreenName(themeDisplay.getCompanyId(), screenName); } else if (userId > 0) { user = _userLocalService.getUserById(userId); } else { throw new NoSuchUserException("User does not exist"); } } if (!user.isActive()) { throw new UserActiveException("Inactive user " + user.getUuid()); } _userLocalService.checkLockout(user); return user; }
From source file:com.liferay.pokedex.web.sampledata.AddDefaultPokemonsPortalInstanceLifecycleListener.java
License:Open Source License
@Override public void portalInstanceRegistered(Company company) throws Exception { List<User> users = _userLocalService.getCompanyUsers(company.getCompanyId(), 0, 10); for (User user : users) { if (!user.isActive() || user.isDefaultUser()) { continue; }/*from w w w .j a v a 2 s . c o m*/ Group group = user.getGroup(); if (group == null) { continue; } List<Pokemon> pokemons = _pokemonLocalService.getPokemons(user.getGroupId()); if (!pokemons.isEmpty()) { continue; } addDefaultPokemons(user); } }
From source file:com.liferay.sync.internal.model.listener.UserModelListener.java
License:Open Source License
@Override public void onBeforeUpdate(User user) throws ModelListenerException { try {/* w w w .ja v a 2s .c o m*/ User originalUser = _userLocalService.getUser(user.getUserId()); if (originalUser.isActive() && !user.isActive()) { List<SyncDevice> syncDevices = _syncDeviceLocalService.getSyncDevices(user.getUserId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); for (SyncDevice syncDevice : syncDevices) { _syncDeviceLocalService.updateStatus(syncDevice.getSyncDeviceId(), SyncDeviceConstants.STATUS_INACTIVE); } } else if (!originalUser.isActive() && user.isActive()) { List<SyncDevice> syncDevices = _syncDeviceLocalService.getSyncDevices(user.getUserId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); for (SyncDevice syncDevice : syncDevices) { _syncDeviceLocalService.updateStatus(syncDevice.getSyncDeviceId(), SyncDeviceConstants.STATUS_ACTIVE); } } } catch (Exception e) { throw new ModelListenerException(e); } }