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