Example usage for com.liferay.portal.kernel.model Company isStrangersWithMx

List of usage examples for com.liferay.portal.kernel.model Company isStrangersWithMx

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Company isStrangersWithMx.

Prototype

public boolean isStrangersWithMx();

Source Link

Usage

From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java

License:Open Source License

protected void validateEmail(String emailAddress, User user) throws PortalException {

    if (user != null && !user.hasCompanyMx() && user.hasCompanyMx(emailAddress)) {
        Company company = CompanyLocalServiceUtil.getCompany(user.getCompanyId());

        if (!company.isStrangersWithMx()) {
            throw new UserEmailAddressException.MustNotUseCompanyMx(emailAddress);
        }// w  w  w  .  j  a  v a2 s . co m
    }
}

From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java

License:Open Source License

protected void checkAddUserPermission(long creatorUserId, long companyId, String emailAddress, long[] groupIds,
        long[] organizationIds, long[] roleIds, long[] userGroupIds, ServiceContext serviceContext)
        throws PortalException {

    Company company = CompanyLocalServiceUtil.getCompany(companyId);

    // Check if user has an according right assigned with add user permission; Either he owns the right itself, by his roles or by his user roles
    User creator = this.getGuestOrUser();

    long[] userIds = new long[] { creatorUserId };

    // Adding user must be member of everything he adds
    ServicePermissionUtil.checkMembership(userIds, groupIds, organizationIds, roleIds, userGroupIds);

    if (groupIds != null && groupIds.length > 0) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_TO_PAGE);
        angularGroupService.checkGroups(0, groupIds);
    }//from  ww w . ja  va 2  s .c o m

    if (organizationIds != null && organizationIds.length > 0) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ORGANIZATION);
        angularOrganizationService.checkOrganizations(0, organizationIds);
    }

    if (roleIds != null && roleIds.length > 0) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ROLE);
        angularRoleService.checkRoles(0, roleIds);
    }

    if (userGroupIds != null && userGroupIds.length > 0) {
        PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_USER_GROUP);
        angularUserGroupService.checkUserGroupIds(0, userGroupIds);
    }

    boolean anonymousUser = ParamUtil.getBoolean(serviceContext, "anonymousUser");

    long defaultUserId = userLocalService.getDefaultUserId(companyId);

    if (((creatorUserId != 0) && (creatorUserId != defaultUserId))
            || (!company.isStrangers() && !anonymousUser)) {
        ServicePermissionUtil.checkAllPersonalPermissions(creator, ActionKeys.ADD_USER, companyId,
                getPermissionChecker(), User.class.getName());
    }

    if ((creatorUserId == 0) || (creatorUserId == defaultUserId)) {
        if (!company.isStrangersWithMx() && company.hasCompanyMx(emailAddress)) {

            throw new UserEmailAddressException.MustNotUseCompanyMx(emailAddress);
        }
    }
}