Search in sources :

Example 96 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class LiferayPersonService method getEmails.

protected List<ListField> getEmails(User user) throws Exception {
    List<ListField> emails = new ArrayList<ListField>();
    ListField email = new ListFieldImpl(Field.PRIMARY.toString(), user.getEmailAddress());
    emails.add(email);
    List<EmailAddress> emailAddresses = EmailAddressLocalServiceUtil.getEmailAddresses(user.getCompanyId(), User.class.getName(), user.getUserId());
    for (EmailAddress emailAddress : emailAddresses) {
        email = new ListFieldImpl(emailAddress.getType().getName(), emailAddress.getAddress());
        emails.add(email);
    }
    return emails;
}
Also used : ListFieldImpl(org.apache.shindig.social.core.model.ListFieldImpl) User(com.liferay.portal.model.User) ArrayList(java.util.ArrayList) ListField(org.apache.shindig.social.opensocial.model.ListField) EmailAddress(com.liferay.portal.model.EmailAddress)

Example 97 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class ShindigFilter method setPermissionChecker.

protected boolean setPermissionChecker(ServletRequest servletRequest) {
    String companyIdString = CookieKeys.getCookie((HttpServletRequest) servletRequest, CookieKeys.COMPANY_ID);
    if (Validator.isNull(companyIdString)) {
        return false;
    }
    long companyId = GetterUtil.getLong(companyIdString);
    String userUUID = StringPool.BLANK;
    try {
        Company company = CompanyLocalServiceUtil.fetchCompany(companyId);
        if (company == null) {
            return false;
        }
        String userUUIDString = CookieKeys.getCookie((HttpServletRequest) servletRequest, CookieKeys.USER_UUID);
        if (Validator.isNull(userUUIDString)) {
            return false;
        }
        userUUID = GetterUtil.getString(Encryptor.decrypt(company.getKeyObj(), userUUIDString));
    } catch (EncryptorException ee) {
        return false;
    } catch (Exception e) {
        _log.error(e, e);
        return false;
    }
    if (!AuthenticatedUserUUIDStoreUtil.exists(userUUID)) {
        return false;
    }
    String userIdString = userUUID.substring(0, userUUID.indexOf(StringPool.PERIOD));
    long userId = GetterUtil.getLong(userIdString);
    try {
        User user = UserLocalServiceUtil.getUserById(userId);
        PrincipalThreadLocal.setName(userIdString);
        PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user);
        PermissionThreadLocal.setPermissionChecker(permissionChecker);
    } catch (Exception e) {
        _log.error(e, e);
        return false;
    }
    return true;
}
Also used : Company(com.liferay.portal.model.Company) User(com.liferay.portal.model.User) EncryptorException(com.liferay.util.EncryptorException) PermissionChecker(com.liferay.portal.security.permission.PermissionChecker) ServletException(javax.servlet.ServletException) EncryptorException(com.liferay.util.EncryptorException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException)

Aggregations

User (com.liferay.portal.model.User)97 Date (java.util.Date)22 SystemException (com.liferay.portal.kernel.exception.SystemException)17 Group (com.liferay.portal.model.Group)15 PortalException (com.liferay.portal.kernel.exception.PortalException)13 Company (com.liferay.portal.model.Company)11 ServiceContext (com.liferay.portal.service.ServiceContext)11 Indexable (com.liferay.portal.kernel.search.Indexable)10 UserGroup (com.liferay.portal.model.UserGroup)10 IOException (java.io.IOException)9 DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)8 EncryptorException (com.liferay.util.EncryptorException)7 Song (org.liferay.jukebox.model.Song)7 Contact (com.liferay.portal.model.Contact)6 PrincipalException (com.liferay.portal.security.auth.PrincipalException)6 Album (org.liferay.jukebox.model.Album)6 DuplicateUserScreenNameException (com.liferay.portal.DuplicateUserScreenNameException)5 GroupFriendlyURLException (com.liferay.portal.GroupFriendlyURLException)5 NoSuchImageException (com.liferay.portal.NoSuchImageException)5 NoSuchOrganizationException (com.liferay.portal.NoSuchOrganizationException)5