Search in sources :

Example 1 with UserId

use of org.apache.shindig.social.opensocial.spi.UserId in project liferay-ide by liferay.

the class LiferayActivityService method doGetActivities.

public RestfulCollection<Activity> doGetActivities(Set<UserId> userIds, GroupId groupId, String appId, Set<String> fields, CollectionOptions collectionOptions, SecurityToken securityToken) throws Exception {
    ThemeDisplay themeDisplay = getThemeDisplay(securityToken);
    List<Activity> activities = new ArrayList<Activity>();
    for (UserId userId : userIds) {
        long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
        List<Activity> personActivities = getActivities(themeDisplay, userIdLong);
        activities.addAll(personActivities);
    }
    return new RestfulCollection<Activity>(activities, collectionOptions.getFirst(), activities.size(), collectionOptions.getMax());
}
Also used : UserId(org.apache.shindig.social.opensocial.spi.UserId) ArrayList(java.util.ArrayList) SocialActivity(com.liferay.portlet.social.model.SocialActivity) Activity(org.apache.shindig.social.opensocial.model.Activity) RestfulCollection(org.apache.shindig.protocol.RestfulCollection) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 2 with UserId

use of org.apache.shindig.social.opensocial.spi.UserId 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 UserId

use of org.apache.shindig.social.opensocial.spi.UserId in project liferay-ide by liferay.

the class LiferayAppDataService method doGetPersonData.

protected DataCollection doGetPersonData(Set<UserId> userIds, GroupId groupId, String appId, Set<String> fields, SecurityToken securityToken) throws Exception {
    long companyId = getCompanyId(securityToken);
    Map<String, Map<String, String>> peopleAppData = new HashMap<String, Map<String, String>>();
    List<ExpandoColumn> expandoColumns = getExpandoColumns(companyId, appId);
    if (expandoColumns == null) {
        return null;
    }
    if (fields.isEmpty()) {
        fields = new LinkedHashSet<String>();
        for (ExpandoColumn expandoColumn : expandoColumns) {
            fields.add(expandoColumn.getName());
        }
    }
    for (UserId userId : userIds) {
        String userIdString = userId.getUserId(securityToken);
        long userIdLong = GetterUtil.getLong(userIdString);
        Map<String, String> personAppData = new HashMap<String, String>();
        for (String field : fields) {
            String value = getExpandoValue(companyId, appId, userIdLong, getColumnName(appId, field));
            personAppData.put(field, value);
        }
        peopleAppData.put(userIdString, personAppData);
    }
    return new DataCollection(peopleAppData);
}
Also used : HashMap(java.util.HashMap) DataCollection(org.apache.shindig.protocol.DataCollection) ExpandoColumn(com.liferay.portlet.expando.model.ExpandoColumn) UserId(org.apache.shindig.social.opensocial.spi.UserId) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with UserId

use of org.apache.shindig.social.opensocial.spi.UserId 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 5 with UserId

use of org.apache.shindig.social.opensocial.spi.UserId in project liferay-ide by liferay.

the class LiferayMediaItemService method doGetMediaItems.

protected RestfulCollection<MediaItem> doGetMediaItems(Set<UserId> userIds, GroupId groupId, String appId, Set<String> fields, CollectionOptions collectionOptions, SecurityToken securityToken) throws Exception {
    List<MediaItem> mediaItems = new ArrayList<MediaItem>();
    for (UserId userId : userIds) {
        long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
        User user = UserLocalServiceUtil.getUserById(userIdLong);
        if (!ShindigUtil.isValidUser(user)) {
            continue;
        }
        List<FileEntry> fileEntries = new ArrayList<FileEntry>();
        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<FileEntry> friendFileEntries = DLAppServiceUtil.getGroupFileEntries(group.getGroupId(), socialUser.getUserId(), collectionOptions.getFirst(), collectionOptions.getMax());
                fileEntries.addAll(friendFileEntries);
            }
        } else if (groupIdType.equals(GroupId.Type.self)) {
            Group group = user.getGroup();
            fileEntries = DLAppServiceUtil.getGroupFileEntries(group.getGroupId(), user.getUserId(), collectionOptions.getFirst(), collectionOptions.getMax());
        }
        for (FileEntry fileEntry : fileEntries) {
            MediaItem.Type mediaItemType = toMediaItemType(StringPool.PERIOD.concat(fileEntry.getExtension()));
            if (mediaItemType == null) {
                continue;
            }
            MediaItem mediaItem = toMediaItem(fileEntry, fields, securityToken);
            mediaItems.add(mediaItem);
        }
    }
    return new RestfulCollection<MediaItem>(mediaItems, collectionOptions.getFirst(), mediaItems.size(), collectionOptions.getMax());
}
Also used : Group(com.liferay.portal.model.Group) User(com.liferay.portal.model.User) ArrayList(java.util.ArrayList) RestfulCollection(org.apache.shindig.protocol.RestfulCollection) GroupId(org.apache.shindig.social.opensocial.spi.GroupId) Type(org.apache.shindig.social.opensocial.model.MediaItem.Type) MediaItem(org.apache.shindig.social.opensocial.model.MediaItem) UserId(org.apache.shindig.social.opensocial.spi.UserId) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) DLFileEntry(com.liferay.portlet.documentlibrary.model.DLFileEntry)

Aggregations

UserId (org.apache.shindig.social.opensocial.spi.UserId)5 ArrayList (java.util.ArrayList)4 RestfulCollection (org.apache.shindig.protocol.RestfulCollection)4 User (com.liferay.portal.model.User)3 GroupId (org.apache.shindig.social.opensocial.spi.GroupId)3 Group (com.liferay.portal.model.Group)2 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)1 Folder (com.liferay.portal.kernel.repository.model.Folder)1 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)1 DLFileEntry (com.liferay.portlet.documentlibrary.model.DLFileEntry)1 DLFolder (com.liferay.portlet.documentlibrary.model.DLFolder)1 ExpandoColumn (com.liferay.portlet.expando.model.ExpandoColumn)1 SocialActivity (com.liferay.portlet.social.model.SocialActivity)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DataCollection (org.apache.shindig.protocol.DataCollection)1 Activity (org.apache.shindig.social.opensocial.model.Activity)1 Album (org.apache.shindig.social.opensocial.model.Album)1 MediaItem (org.apache.shindig.social.opensocial.model.MediaItem)1 Type (org.apache.shindig.social.opensocial.model.MediaItem.Type)1