Search in sources :

Example 1 with Organization

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

the class UserLocalServiceImpl method unsetOrganizationUsers.

/**
 * Removes the users from the organization.
 *
 * @param  organizationId the primary key of the organization
 * @param  userIds the primary keys of the users
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public void unsetOrganizationUsers(long organizationId, final long[] userIds) throws PortalException, SystemException {
    Organization organization = organizationPersistence.findByPrimaryKey(organizationId);
    final Group group = organization.getGroup();
    userGroupRoleLocalService.deleteUserGroupRoles(userIds, group.getGroupId());
    organizationPersistence.removeUsers(organizationId, userIds);
    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
    indexer.reindex(userIds);
    PermissionCacheUtil.clearCache();
    Callable<Void> callable = new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            Message message = new Message();
            message.put("groupId", group.getGroupId());
            message.put("userIds", userIds);
            MessageBusUtil.sendMessage(DestinationNames.SUBSCRIPTION_CLEAN_UP, message);
            return null;
        }
    };
    TransactionCommitCallbackRegistryUtil.registerCallback(callable);
}
Also used : Group(com.liferay.portal.model.Group) UserGroup(com.liferay.portal.model.UserGroup) Organization(com.liferay.portal.model.Organization) Indexer(com.liferay.portal.kernel.search.Indexer) MBMessage(com.liferay.portlet.messageboards.model.MBMessage) Message(com.liferay.portal.kernel.messaging.Message) ShardCallable(com.liferay.portal.kernel.dao.shard.ShardCallable) Callable(java.util.concurrent.Callable)

Example 2 with Organization

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

the class UserLocalServiceImpl method updateUserGroupRoles.

protected void updateUserGroupRoles(User user, long[] groupIds, long[] organizationIds, List<UserGroupRole> userGroupRoles, List<UserGroupRole> previousUserGroupRoles) throws PortalException, SystemException {
    if (userGroupRoles == null) {
        return;
    }
    userGroupRoles = new ArrayList<UserGroupRole>(userGroupRoles);
    for (UserGroupRole userGroupRole : previousUserGroupRoles) {
        if (userGroupRoles.contains(userGroupRole)) {
            userGroupRoles.remove(userGroupRole);
        } else {
            userGroupRoleLocalService.deleteUserGroupRole(userGroupRole);
        }
    }
    if (userGroupRoles.isEmpty()) {
        return;
    }
    long[] validGroupIds = null;
    if (groupIds != null) {
        validGroupIds = ArrayUtil.clone(groupIds);
    } else {
        validGroupIds = user.getGroupIds();
    }
    if (organizationIds == null) {
        organizationIds = user.getOrganizationIds();
    }
    long[] organizationGroupIds = new long[organizationIds.length];
    for (int i = 0; i < organizationIds.length; i++) {
        long organizationId = organizationIds[i];
        Organization organization = organizationPersistence.findByPrimaryKey(organizationId);
        organizationGroupIds[i] = organization.getGroupId();
    }
    validGroupIds = ArrayUtil.append(validGroupIds, organizationGroupIds);
    Arrays.sort(validGroupIds);
    for (UserGroupRole userGroupRole : userGroupRoles) {
        if (Arrays.binarySearch(validGroupIds, userGroupRole.getGroupId()) >= 0) {
            userGroupRoleLocalService.addUserGroupRole(userGroupRole);
        }
    }
}
Also used : UserGroupRole(com.liferay.portal.model.UserGroupRole) Organization(com.liferay.portal.model.Organization)

Example 3 with Organization

use of com.liferay.portal.model.Organization 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)

Example 4 with Organization

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

the class UserLocalServiceImpl method validate.

protected void validate(long companyId, long userId, boolean autoPassword, String password1, String password2, boolean autoScreenName, String screenName, String emailAddress, String openId, String firstName, String middleName, String lastName, long[] organizationIds) throws PortalException, SystemException {
    validateCompanyMaxUsers(companyId);
    if (!autoScreenName) {
        validateScreenName(companyId, userId, screenName);
    }
    if (!autoPassword) {
        PasswordPolicy passwordPolicy = passwordPolicyLocalService.getDefaultPasswordPolicy(companyId);
        PwdToolkitUtil.validate(companyId, 0, password1, password2, passwordPolicy);
    }
    validateEmailAddress(companyId, emailAddress);
    if (Validator.isNotNull(emailAddress)) {
        User user = userPersistence.fetchByC_EA(companyId, emailAddress);
        if ((user != null) && (user.getUserId() != userId)) {
            throw new DuplicateUserEmailAddressException("{userId=" + userId + "}");
        }
    }
    validateOpenId(companyId, userId, openId);
    validateFullName(companyId, firstName, middleName, lastName);
    if (organizationIds != null) {
        for (long organizationId : organizationIds) {
            Organization organization = organizationPersistence.fetchByPrimaryKey(organizationId);
            if (organization == null) {
                throw new NoSuchOrganizationException("{organizationId=" + organizationId + "}");
            }
        }
    }
}
Also used : User(com.liferay.portal.model.User) Organization(com.liferay.portal.model.Organization) DuplicateUserEmailAddressException(com.liferay.portal.DuplicateUserEmailAddressException) PasswordPolicy(com.liferay.portal.model.PasswordPolicy) NoSuchOrganizationException(com.liferay.portal.NoSuchOrganizationException)

Example 5 with Organization

use of com.liferay.portal.model.Organization in project sw360portal by sw360.

the class ModerationPortlet method renderUserModeration.

public void renderUserModeration(RenderRequest request, RenderResponse response, ModerationRequest moderationRequest, User user) throws IOException, PortletException, TException {
    User changedUser = null;
    try {
        UserService.Iface client = thriftClients.makeUserClient();
        changedUser = client.getByEmail(moderationRequest.getUser().getEmail());
        request.setAttribute(PortalConstants.USER, changedUser);
    } catch (TException e) {
        log.error("Could not retrieve user", e);
    }
    if (changedUser == null) {
        renderNextModeration(request, response, user, "Ignored unretrievable target", thriftClients.makeModerationClient(), moderationRequest);
        return;
    }
    List<Organization> organizations = UserUtils.getOrganizations(request);
    request.setAttribute(PortalConstants.ORGANIZATIONS, organizations);
    include("/html/moderation/users/merge.jsp", request, response);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) Organization(com.liferay.portal.model.Organization) UserService(org.eclipse.sw360.datahandler.thrift.users.UserService)

Aggregations

Organization (com.liferay.portal.model.Organization)7 Indexer (com.liferay.portal.kernel.search.Indexer)2 Group (com.liferay.portal.model.Group)2 DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)1 NoSuchOrganizationException (com.liferay.portal.NoSuchOrganizationException)1 ShardCallable (com.liferay.portal.kernel.dao.shard.ShardCallable)1 Message (com.liferay.portal.kernel.messaging.Message)1 PasswordPolicy (com.liferay.portal.model.PasswordPolicy)1 User (com.liferay.portal.model.User)1 UserGroup (com.liferay.portal.model.UserGroup)1 UserGroupRole (com.liferay.portal.model.UserGroupRole)1 MBMessage (com.liferay.portlet.messageboards.model.MBMessage)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Callable (java.util.concurrent.Callable)1 NameImpl (org.apache.shindig.social.core.model.NameImpl)1 PersonImpl (org.apache.shindig.social.core.model.PersonImpl)1 ListField (org.apache.shindig.social.opensocial.model.ListField)1 Name (org.apache.shindig.social.opensocial.model.Name)1 Person (org.apache.shindig.social.opensocial.model.Person)1