Search in sources :

Example 31 with User

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

the class LiferayAlbumService method doGetAlbums.

protected RestfulCollection<Album> doGetAlbums(Set<UserId> userIds, GroupId groupId, String appId, Set<String> fields, CollectionOptions collectionOptions, SecurityToken securityToken) throws Exception {
    List<Album> albums = new ArrayList<Album>();
    for (UserId userId : userIds) {
        String userIdString = userId.getUserId(securityToken);
        long userIdLong = GetterUtil.getLong(userIdString);
        User user = UserLocalServiceUtil.getUserById(userIdLong);
        if (!ShindigUtil.isValidUser(user)) {
            continue;
        }
        List<Folder> folders = new ArrayList<Folder>();
        GroupId.Type groupIdType = groupId.getType();
        if (groupIdType.equals(GroupId.Type.all) || groupIdType.equals(GroupId.Type.friends) || groupIdType.equals(GroupId.Type.groupId)) {
            List<User> socialUsers = UserLocalServiceUtil.getSocialUsers(user.getUserId(), SocialRelationConstants.TYPE_BI_FRIEND, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
            for (User socialUser : socialUsers) {
                Group group = socialUser.getGroup();
                List<Folder> friendFolders = DLAppServiceUtil.getFolders(group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
                folders.addAll(friendFolders);
            }
        } else if (groupIdType.equals(GroupId.Type.self)) {
            Group group = user.getGroup();
            folders = DLAppServiceUtil.getFolders(group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
        }
        for (Folder folder : folders) {
            Album album = toAlbum(folder, fields, securityToken);
            albums.add(album);
        }
    }
    return new RestfulCollection<Album>(albums, collectionOptions.getFirst(), albums.size(), collectionOptions.getMax());
}
Also used : Group(com.liferay.portal.model.Group) User(com.liferay.portal.model.User) ArrayList(java.util.ArrayList) Album(org.apache.shindig.social.opensocial.model.Album) RestfulCollection(org.apache.shindig.protocol.RestfulCollection) Folder(com.liferay.portal.kernel.repository.model.Folder) DLFolder(com.liferay.portlet.documentlibrary.model.DLFolder) GroupId(org.apache.shindig.social.opensocial.spi.GroupId) UserId(org.apache.shindig.social.opensocial.spi.UserId)

Example 32 with User

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

the class LiferayAlbumService method doUpdateAlbum.

protected void doUpdateAlbum(UserId userId, String appId, Album album, String albumId, SecurityToken securityToken) throws Exception {
    long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
    User user = UserLocalServiceUtil.getUserById(userIdLong);
    if (!ShindigUtil.isValidUser(user)) {
        return;
    }
    Group group = user.getGroup();
    long groupIdLong = group.getGroupId();
    ServiceContext serviceContext = new ServiceContext();
    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);
    serviceContext.setExpandoBridgeAttributes(SerializerUtil.toExpandoAttributes(album, _ALBUM_FIELDS, user.getCompanyId(), DLFolder.class.getName()));
    serviceContext.setScopeGroupId(groupIdLong);
    if (albumId == null) {
        DLAppServiceUtil.addFolder(groupIdLong, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, album.getTitle(), album.getDescription(), serviceContext);
    } else {
        Folder folder = DLAppLocalServiceUtil.getFolder(GetterUtil.getLong(albumId));
        DLAppServiceUtil.updateFolder(folder.getFolderId(), album.getTitle(), album.getDescription(), serviceContext);
    }
}
Also used : Group(com.liferay.portal.model.Group) User(com.liferay.portal.model.User) ServiceContext(com.liferay.portal.service.ServiceContext) Folder(com.liferay.portal.kernel.repository.model.Folder) DLFolder(com.liferay.portlet.documentlibrary.model.DLFolder)

Example 33 with User

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

the class OAuthTokenLocalServiceImpl method addOAuthToken.

public OAuthToken addOAuthToken(long userId, String gadgetKey, String serviceName, long moduleId, String accessToken, String tokenName, String tokenSecret, String sessionHandle, long expiration) throws PortalException, SystemException {
    User user = UserLocalServiceUtil.getUser(userId);
    Date now = new Date();
    long oAuthTokenId = counterLocalService.increment();
    OAuthToken oAuthToken = oAuthTokenPersistence.create(oAuthTokenId);
    oAuthToken.setCompanyId(user.getCompanyId());
    oAuthToken.setUserId(user.getUserId());
    oAuthToken.setUserName(user.getFullName());
    oAuthToken.setCreateDate(now);
    oAuthToken.setModifiedDate(now);
    oAuthToken.setGadgetKey(gadgetKey);
    oAuthToken.setServiceName(serviceName);
    oAuthToken.setModuleId(moduleId);
    oAuthToken.setAccessToken(accessToken);
    oAuthToken.setTokenName(tokenName);
    oAuthToken.setTokenSecret(tokenSecret);
    oAuthToken.setSessionHandle(sessionHandle);
    oAuthToken.setExpiration(expiration);
    oAuthTokenPersistence.update(oAuthToken);
    return oAuthToken;
}
Also used : OAuthToken(com.liferay.opensocial.model.OAuthToken) User(com.liferay.portal.model.User) Date(java.util.Date)

Example 34 with User

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

the class LiferayPersonService method doGetPeople.

protected RestfulCollection<Person> doGetPeople(Set<UserId> userIds, GroupId groupId, CollectionOptions collectionOptions, Set<String> fields, SecurityToken securityToken) throws Exception {
    List<Person> people = new ArrayList<Person>();
    for (UserId userId : userIds) {
        Person person = null;
        String userIdString = userId.getUserId(securityToken);
        GroupId.Type groupIdType = groupId.getType();
        if (groupIdType.equals(GroupId.Type.all) || groupIdType.equals(GroupId.Type.friends) || groupIdType.equals(GroupId.Type.groupId)) {
            long userIdLong = GetterUtil.getLong(userIdString);
            User user = UserLocalServiceUtil.getUserById(userIdLong);
            List<User> friends = UserLocalServiceUtil.getSocialUsers(user.getUserId(), SocialRelationConstants.TYPE_BI_FRIEND, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
            for (User friend : friends) {
                person = getUserPerson(friend, fields, securityToken);
                people.add(person);
            }
        } else if (groupIdType.equals(GroupId.Type.self)) {
            person = doGetPerson(userId, fields, securityToken);
            people.add(person);
        }
    }
    return new RestfulCollection<Person>(people, collectionOptions.getFirst(), people.size(), collectionOptions.getMax());
}
Also used : User(com.liferay.portal.model.User) UserId(org.apache.shindig.social.opensocial.spi.UserId) ArrayList(java.util.ArrayList) RestfulCollection(org.apache.shindig.protocol.RestfulCollection) Person(org.apache.shindig.social.opensocial.model.Person) GroupId(org.apache.shindig.social.opensocial.spi.GroupId)

Example 35 with User

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

the class LiferayPersonService method doGetPerson.

protected Person doGetPerson(UserId userId, Set<String> fields, SecurityToken securityToken) throws Exception {
    String userIdString = userId.getUserId(securityToken);
    Person person = null;
    if (userIdString.startsWith("G-")) {
        String groupId = userIdString.substring("G-".length());
        person = getGroupPerson(groupId);
    } else {
        long userIdLong = GetterUtil.getLong(userIdString);
        User user = UserLocalServiceUtil.getUserById(userIdLong);
        if (!ShindigUtil.isValidUser(user)) {
            return null;
        }
        person = getUserPerson(user, fields, securityToken);
    }
    return person;
}
Also used : User(com.liferay.portal.model.User) Person(org.apache.shindig.social.opensocial.model.Person)

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