Example usage for com.liferay.portal.util PortalInstances getDefaultCompanyId

List of usage examples for com.liferay.portal.util PortalInstances getDefaultCompanyId

Introduction

In this page you can find the example usage for com.liferay.portal.util PortalInstances getDefaultCompanyId.

Prototype

public static long getDefaultCompanyId() 

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  ww  . ja va2 s.  com*/

    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;
    }
}

From source file:com.liferay.portlet.tags.service.impl.TagsAssetLocalServiceImpl.java

License:Open Source License

protected TagsAssetType getAssetType(String className, String languageId) {
    long companyId = PortalInstances.getDefaultCompanyId();

    long classNameId = PortalUtil.getClassNameId(className);

    String portletId = PortalUtil.getClassNamePortletId(className);
    String portletTitle = PortalUtil.getPortletTitle(portletId, companyId, languageId);

    TagsAssetType assetType = new TagsAssetType();

    assetType.setClassNameId(classNameId);
    assetType.setClassName(className);//from   w  w  w  .j  a  v  a 2 s  .  c om
    assetType.setPortletId(portletId);
    assetType.setPortletTitle(portletTitle);

    return assetType;
}