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

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

Introduction

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

Prototype

String DL_REPOSITORY_GUEST_USERNAME

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

Click Source Link

Usage

From source file:com.liferay.document.library.repository.external.ExtRepositoryAdapter.java

License:Open Source License

private String _getLogin() {
    String login = PrincipalThreadLocal.getName();

    if (Validator.isNull(login) || _isDefaultUser(login)) {
        return PropsUtil.get(PropsKeys.DL_REPOSITORY_GUEST_USERNAME);
    }//from w w  w .  j  av  a  2s. co m

    try {
        String authType = getAuthType();

        if (!authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
            User user = userLocalService.getUser(GetterUtil.getLong(login));

            if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
                login = user.getEmailAddress();
            } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
                login = user.getScreenName();
            }
        }
    } catch (PortalException | SystemException e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to get login to connect to external repository " + _extRepository, e);
        }

        login = null;
    }

    return login;
}

From source file:com.liferay.repository.external.ExtRepositoryAdapter.java

License:Open Source License

private String _getLogin() {
    String login = PrincipalThreadLocal.getName();

    if (Validator.isNull(login)) {
        return PropsUtil.get(PropsKeys.DL_REPOSITORY_GUEST_USERNAME);
    }/*  www .  ja v  a2  s  .  c om*/

    try {
        String authType = getAuthType();

        if (!authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
            User user = userLocalService.getUser(GetterUtil.getLong(login));

            if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
                login = user.getEmailAddress();
            } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
                login = user.getScreenName();
            }
        }
    } catch (PortalException e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to get login to connect to external repository " + _extRepository, e);
        }

        login = null;
    } catch (SystemException e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to get login to connect to external repository " + _extRepository, e);
        }

        login = null;
    }

    return login;
}