Example usage for com.liferay.portal.util PropsValues OMNIADMIN_USERS

List of usage examples for com.liferay.portal.util PropsValues OMNIADMIN_USERS

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues OMNIADMIN_USERS.

Prototype

null OMNIADMIN_USERS

To view the source code for com.liferay.portal.util PropsValues OMNIADMIN_USERS.

Click Source Link

Usage

From source file:com.liferay.portlet.admin.util.OmniadminUtil.java

License:Open Source License

public static boolean isOmniadmin(long userId) {
    if (CompanyThreadLocal.getCompanyId() != PortalInstances.getDefaultCompanyId()) {

        return false;
    }/*from w  w w  .  j  a  va 2 s.c  o m*/

    if (userId <= 0) {
        return false;
    }

    try {
        if (PropsValues.OMNIADMIN_USERS.length > 0) {
            for (int i = 0; i < PropsValues.OMNIADMIN_USERS.length; i++) {
                if (PropsValues.OMNIADMIN_USERS[i] == userId) {
                    User user = UserLocalServiceUtil.getUserById(userId);

                    if (user.getCompanyId() != PortalInstances.getDefaultCompanyId()) {

                        return false;
                    }

                    return true;
                }
            }

            return false;
        } else {
            User user = UserLocalServiceUtil.getUserById(userId);

            if (user.getCompanyId() != PortalInstances.getDefaultCompanyId()) {

                return false;
            }

            return RoleLocalServiceUtil.hasUserRole(userId, user.getCompanyId(), RoleConstants.ADMINISTRATOR,
                    true);
        }
    } catch (Exception e) {
        _log.error(e);

        return false;
    }
}