Example usage for com.liferay.portal.kernel.util PropsKeys COMPANY_DEFAULT_WEB_ID

List of usage examples for com.liferay.portal.kernel.util PropsKeys COMPANY_DEFAULT_WEB_ID

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropsKeys COMPANY_DEFAULT_WEB_ID.

Prototype

String COMPANY_DEFAULT_WEB_ID

To view the source code for com.liferay.portal.kernel.util PropsKeys COMPANY_DEFAULT_WEB_ID.

Click Source Link

Usage

From source file:com.liferay.push.hooks.DDLRecordModelListener.java

License:Open Source License

private List<User> findSomeUsers(int from, int to) throws PortalException, SystemException {
    Company company = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
    long companyId = company.getCompanyId();
    return UserLocalServiceUtil.getCompanyUsers(companyId, from, to);
}

From source file:controllers.MultiscaleController.java

License:Open Source License

public String getLiferayUser(String userID) {
    Company company = null;// w w  w  .  j a  va 2 s  .co  m
    long companyId = 1;
    String userString = "";
    try {
        String webId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID);
        company = CompanyLocalServiceUtil.getCompanyByWebId(webId);
        companyId = company.getCompanyId();
        LOGGER.debug(String.format("Using webId %s and companyId %d to get Portal User", webId, companyId));
    } catch (PortalException | SystemException e) {
        LOGGER.error(
                "liferay error, could not retrieve companyId. Trying default companyId, which is " + companyId,
                e.getStackTrace());
    }

    User user = null;
    try {
        user = UserLocalServiceUtil.getUserByScreenName(companyId, userID);
    } catch (PortalException | SystemException e) {
    }

    if (user == null) {
        LOGGER.warn(String.format("Openbis user %s appears to not exist in Portal", userID));
        userString = userID;
    } else {
        String fullname = user.getFullName();
        String email = user.getEmailAddress();
        userString += ("<a href=\"mailto:");
        userString += (email);
        userString += ("\" style=\"color: #0068AA; text-decoration: none\">");
        userString += (fullname);
        userString += ("</a>");
    }
    return userString;
}

From source file:helpers.Utils.java

License:Open Source License

public static String usernameToFullName(String username) {
    Company company = null;/*  w ww . j  a v a  2  s.  c  o m*/

    String res = username;
    long companyId = 1;
    try {
        String webId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID);
        company = CompanyLocalServiceUtil.getCompanyByWebId(webId);
        companyId = company.getCompanyId();
    } catch (PortalException | SystemException e) {
        LOGGER.error(
                "liferay error, could not retrieve companyId. Trying default companyId, which is " + companyId,
                e.getStackTrace());
    }
    User user = null;
    try {
        user = UserLocalServiceUtil.getUserByScreenName(companyId, username);
    } catch (PortalException | SystemException e) {
        LOGGER.warn("got this error while trying to fetch full name of user:");
        LOGGER.warn(e.getMessage());
        LOGGER.info("returning username instead.");
    }
    if (user == null) {
        LOGGER.warn(String.format("Openbis user %s appears to not exist in Portal", username));
    } else {
        String firstName = user.getFirstName();
        String lastName = user.getLastName();
        res = firstName + " " + lastName;
    }
    return res;
}