Search in sources :

Example 1 with Album

use of org.apache.shindig.social.opensocial.model.Album in project liferay-ide by liferay.

the class LiferayAlbumService method doGetAlbums.

protected RestfulCollection<Album> doGetAlbums(UserId userId, String appId, Set<String> fields, CollectionOptions collectionOptions, Set<String> albumIds, SecurityToken securityToken) throws Exception {
    List<Album> albums = new ArrayList<Album>();
    for (String albumId : albumIds) {
        Folder folder = DLAppServiceUtil.getFolder(GetterUtil.getLong(albumId));
        Album album = toAlbum(folder, fields, securityToken);
        albums.add(album);
    }
    return new RestfulCollection<Album>(albums, collectionOptions.getFirst(), albums.size(), collectionOptions.getMax());
}
Also used : 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)

Example 2 with Album

use of org.apache.shindig.social.opensocial.model.Album 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 3 with Album

use of org.apache.shindig.social.opensocial.model.Album in project liferay-ide by liferay.

the class LiferayAlbumService method toAlbum.

protected Album toAlbum(Folder folder, Set<String> fields, SecurityToken securityToken) throws JSONException {
    Album album = new AlbumImpl();
    album.setDescription(folder.getDescription());
    album.setId(String.valueOf(folder.getFolderId()));
    album.setOwnerId(String.valueOf(folder.getUserId()));
    album.setTitle(folder.getName());
    SerializerUtil.copyProperties(folder.getAttributes(), album, _ALBUM_FIELDS);
    return album;
}
Also used : AlbumImpl(org.apache.shindig.social.core.model.AlbumImpl) Album(org.apache.shindig.social.opensocial.model.Album)

Aggregations

Album (org.apache.shindig.social.opensocial.model.Album)3 Folder (com.liferay.portal.kernel.repository.model.Folder)2 DLFolder (com.liferay.portlet.documentlibrary.model.DLFolder)2 ArrayList (java.util.ArrayList)2 RestfulCollection (org.apache.shindig.protocol.RestfulCollection)2 Group (com.liferay.portal.model.Group)1 User (com.liferay.portal.model.User)1 AlbumImpl (org.apache.shindig.social.core.model.AlbumImpl)1 GroupId (org.apache.shindig.social.opensocial.spi.GroupId)1 UserId (org.apache.shindig.social.opensocial.spi.UserId)1