Example usage for com.liferay.portal.kernel.security.permission PermissionChecker isCompanyAdmin

List of usage examples for com.liferay.portal.kernel.security.permission PermissionChecker isCompanyAdmin

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.security.permission PermissionChecker isCompanyAdmin.

Prototype

public boolean isCompanyAdmin(long companyId);

Source Link

Document

Returns true if the user is an administrator of the company.

Usage

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

License:Open Source License

protected void crossCompanyCheck(long targetCompany) throws PortalException {

    long userCompanyId = this.getGuestOrUser().getCompanyId();

    PermissionChecker permissionChecker = getPermissionChecker();

    if (permissionChecker.isSignedIn()) {

        if (userCompanyId != targetCompany
                && (!permissionChecker.isOmniadmin() || !permissionChecker.isCompanyAdmin(targetCompany))) {
            throw new PrincipalException.MustBeOmniadmin(this.getGuestOrUserId());
        }/*from w  w w  .j  a va2 s .  c  o m*/

    } else {

        throw new PrincipalException.MustBeAuthenticated(this.getGuestOrUserId());
    }
}