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);
}
}
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());
}
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);
}
}
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);
}
}
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;
}
Aggregations