Search in sources :

Example 6 with Group

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

the class KBArticleLocalServiceImpl method deleteGroupKBArticles.

@Override
public void deleteGroupKBArticles(long groupId) throws PortalException, SystemException {
    // KB articles
    deleteKBArticles(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID);
    // Subscriptions
    Group group = groupLocalService.getGroup(groupId);
    List<Subscription> subscriptions = subscriptionLocalService.getSubscriptions(group.getCompanyId(), KBArticle.class.getName(), groupId);
    for (Subscription subscription : subscriptions) {
        unsubscribeGroupKBArticles(subscription.getUserId(), groupId);
    }
}
Also used : Group(com.liferay.portal.model.Group) KBArticle(com.liferay.knowledgebase.model.KBArticle) Subscription(com.liferay.portal.model.Subscription)

Example 7 with Group

use of com.liferay.portal.model.Group 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 8 with Group

use of com.liferay.portal.model.Group 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 9 with Group

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

the class GadgetStagedModelDataHandler method deleteStagedModel.

@Override
public void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws PortalException, SystemException {
    Group group = GroupLocalServiceUtil.getGroup(groupId);
    Gadget gadget = GadgetLocalServiceUtil.fetchGadgetByUuidAndCompanyId(uuid, group.getCompanyId());
    if (gadget != null) {
        GadgetLocalServiceUtil.deleteGadget(gadget);
    }
}
Also used : Group(com.liferay.portal.model.Group) Gadget(com.liferay.opensocial.model.Gadget)

Example 10 with Group

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

the class LiferayPersonService method getGroupPerson.

protected Person getGroupPerson(String groupId) throws Exception {
    Person person = null;
    long groupIdLong = GetterUtil.getLong(groupId);
    Group group = GroupLocalServiceUtil.getGroup(groupIdLong);
    if (group.isOrganization()) {
        Organization organization = OrganizationLocalServiceUtil.getOrganization(group.getClassPK());
        Name name = new NameImpl(organization.getName() + " (Organization)");
        person = new PersonImpl(groupId, name.getFormatted(), name);
        List<ListField> phoneNumbers = getPhoneNumbers(Organization.class.getName(), organization.getOrganizationId());
        person.setPhoneNumbers(phoneNumbers);
    } else if (group.isRegularSite()) {
        Name name = new NameImpl(group.getName() + " (Site)");
        person = new PersonImpl(groupId, name.getFormatted(), name);
    }
    person.setGender(Gender.male);
    return person;
}
Also used : Group(com.liferay.portal.model.Group) NameImpl(org.apache.shindig.social.core.model.NameImpl) Organization(com.liferay.portal.model.Organization) PersonImpl(org.apache.shindig.social.core.model.PersonImpl) ListField(org.apache.shindig.social.opensocial.model.ListField) Person(org.apache.shindig.social.opensocial.model.Person) Name(org.apache.shindig.social.opensocial.model.Name)

Aggregations

Group (com.liferay.portal.model.Group)30 User (com.liferay.portal.model.User)15 UserGroup (com.liferay.portal.model.UserGroup)13 ArrayList (java.util.ArrayList)9 UserGroupRole (com.liferay.portal.model.UserGroupRole)6 Role (com.liferay.portal.model.Role)5 Indexer (com.liferay.portal.kernel.search.Indexer)4 Company (com.liferay.portal.model.Company)4 Contact (com.liferay.portal.model.Contact)3 ServiceContext (com.liferay.portal.service.ServiceContext)3 RestfulCollection (org.apache.shindig.protocol.RestfulCollection)3 KBArticle (com.liferay.knowledgebase.model.KBArticle)2 DuplicateUserScreenNameException (com.liferay.portal.DuplicateUserScreenNameException)2 GroupFriendlyURLException (com.liferay.portal.GroupFriendlyURLException)2 NoSuchImageException (com.liferay.portal.NoSuchImageException)2 RequiredUserException (com.liferay.portal.RequiredUserException)2 ReservedUserScreenNameException (com.liferay.portal.ReservedUserScreenNameException)2 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)2 Folder (com.liferay.portal.kernel.repository.model.Folder)2 Organization (com.liferay.portal.model.Organization)2