Example usage for com.liferay.portal.kernel.service UserLocalServiceUtil getUserById

List of usage examples for com.liferay.portal.kernel.service UserLocalServiceUtil getUserById

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service UserLocalServiceUtil getUserById.

Prototype

public static com.liferay.portal.kernel.model.User getUserById(long userId)
        throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Returns the user with the primary key.

Usage

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

License:Open Source License

@Override
public String formatParameterValue(String fieldName, String fieldValue) throws SearchException {

    if (fieldName.equals(Field.CREATE_DATE) || fieldName.equals(Field.MODIFIED_DATE)) {

        throw new SearchException(
                "Use the method formatDateParameterValue to format the date " + "field " + fieldName);
    } else if (fieldName.equals(Field.FOLDER_ID)) {
        try {//  w  ww . j a  v  a 2s  .co m
            long folderId = GetterUtil.getLong(fieldValue);

            return _extRepositoryAdapter.getExtRepositoryObjectKey(folderId);
        } catch (PortalException pe) {
            throw new SearchException("Unable to get folder folder " + fieldValue, pe);
        } catch (SystemException se) {
            throw new SearchException("Unable to get folder folder " + fieldValue, se);
        }
    } else if (fieldName.equals(Field.USER_ID)) {
        try {
            long userId = GetterUtil.getLong(fieldValue);

            User user = UserLocalServiceUtil.getUserById(userId);

            return user.getScreenName();
        } catch (Exception e) {
            throw new SearchException("Unable to get user user " + fieldValue, e);
        }
    } else {
        return fieldValue;
    }
}

From source file:com.liferay.dynamic.data.lists.model.impl.DDLRecordModelImpl.java

License:Open Source License

@Override
public String getVersionUserUuid() {
    try {/*  w w  w. j  a  v a  2s. c  om*/
        User user = UserLocalServiceUtil.getUserById(getVersionUserId());

        return user.getUuid();
    } catch (PortalException pe) {
        return StringPool.BLANK;
    }
}

From source file:com.liferay.dynamic.data.mapping.model.impl.DDMFormInstanceModelImpl.java

License:Open Source License

@Override
public String getVersionUserUuid() {
    try {/*from  w w w .  j  av a2s  . c o m*/
        User user = UserLocalServiceUtil.getUserById(getVersionUserId());

        return user.getUuid();
    } catch (PortalException pe) {
        return "";
    }
}

From source file:com.liferay.exportimport.messaging.BasePublisherMessageListener.java

License:Open Source License

protected void initThreadLocals(long userId, Map<String, String[]> parameterMap) throws PortalException {

    User user = UserLocalServiceUtil.getUserById(userId);

    CompanyThreadLocal.setCompanyId(user.getCompanyId());

    PrincipalThreadLocal.setName(userId);

    PermissionChecker permissionChecker = null;

    try {/*from ww  w  .j  a  v  a  2s .  c  om*/
        permissionChecker = PermissionCheckerFactoryUtil.create(user);
    } catch (Exception e) {
        throw new SystemException("Unable to initialize thread locals because an error occured "
                + "when creating a permission checker for user " + userId, e);
    }

    PermissionThreadLocal.setPermissionChecker(permissionChecker);

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setCompanyId(user.getCompanyId());
    serviceContext.setPathMain(PortalUtil.getPathMain());
    serviceContext.setSignedIn(!user.isDefaultUser());
    serviceContext.setUserId(user.getUserId());

    Map<String, Serializable> attributes = new HashMap<>();

    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
        String param = entry.getKey();
        String[] values = entry.getValue();

        if (ArrayUtil.isNotEmpty(values)) {
            if (values.length == 1) {
                attributes.put(param, values[0]);
            } else {
                attributes.put(param, values);
            }
        }
    }

    serviceContext.setAttributes(attributes);

    ServiceContextThreadLocal.pushServiceContext(serviceContext);
}

From source file:com.liferay.faces.portal.context.internal.LiferayPortletHelperImpl.java

License:Open Source License

@Override
public User getScopeGroupUser() {
    User groupUser = null;//from  w w  w. j av  a 2  s  .  c om
    Group scopeGroup = getScopeGroup();

    if (scopeGroup.isUser()) {

        try {
            groupUser = UserLocalServiceUtil.getUserById(scopeGroup.getClassPK());
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }

    return groupUser;
}

From source file:com.liferay.gs.hack.model.impl.ProjectUserModelImpl.java

License:Open Source License

@Override
public String getProjectUserUuid() {
    try {/*from  w w w .ja v  a2  s  .c  om*/
        User user = UserLocalServiceUtil.getUserById(getProjectUserId());

        return user.getUuid();
    } catch (PortalException pe) {
        return StringPool.BLANK;
    }
}

From source file:com.liferay.invitation.invite.members.model.impl.MemberRequestModelImpl.java

License:Open Source License

@Override
public String getReceiverUserUuid() {
    try {//  ww  w . j a v a 2  s  . co m
        User user = UserLocalServiceUtil.getUserById(getReceiverUserId());

        return user.getUuid();
    } catch (PortalException pe) {
        return StringPool.BLANK;
    }
}

From source file:com.liferay.message.boards.model.impl.MBBanModelImpl.java

License:Open Source License

@Override
public String getBanUserUuid() {
    try {//from   www .  j  ava 2  s  .  c o m
        User user = UserLocalServiceUtil.getUserById(getBanUserId());

        return user.getUuid();
    } catch (PortalException pe) {
        return "";
    }
}

From source file:com.liferay.micro.maintainance.analysis.model.impl.AnalysisUserModelImpl.java

License:Open Source License

@Override
public String getAnalysisUserUuid() {
    try {//from w w w .j a v  a 2 s  . c  o m
        User user = UserLocalServiceUtil.getUserById(getAnalysisUserId());

        return user.getUuid();
    } catch (PortalException pe) {
        return StringPool.BLANK;
    }
}

From source file:com.rivetlogic.services.model.impl.TipsOfTheDayUsersModelImpl.java

License:Open Source License

@Override
public String getTipUserUuid() {
    try {// w  ww. j  av  a  2  s  .co  m
        User user = UserLocalServiceUtil.getUserById(getTipUserId());

        return user.getUuid();
    } catch (PortalException pe) {
        return StringPool.BLANK;
    }
}