Search in sources :

Example 1 with NoSuchUserException

use of com.liferay.portal.NoSuchUserException in project liferay-ide by liferay.

the class UserLocalServiceImpl method getUserByUuidAndCompanyId.

/**
 * Returns the user with the UUID.
 *
 * @param  uuid the user's UUID
 * @param  companyId the primary key of the user's company
 * @return the user with the UUID
 * @throws PortalException if a user with the UUID could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public User getUserByUuidAndCompanyId(String uuid, long companyId) throws PortalException, SystemException {
    List<User> users = userPersistence.findByUuid_C(uuid, companyId);
    if (users.isEmpty()) {
        StringBundler sb = new StringBundler(5);
        sb.append("{uuid=");
        sb.append(uuid);
        sb.append(", companyId=");
        sb.append(companyId);
        sb.append("}");
        throw new NoSuchUserException(sb.toString());
    } else {
        return users.get(0);
    }
}
Also used : User(com.liferay.portal.model.User) NoSuchUserException(com.liferay.portal.NoSuchUserException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Aggregations

NoSuchUserException (com.liferay.portal.NoSuchUserException)1 StringBundler (com.liferay.portal.kernel.util.StringBundler)1 User (com.liferay.portal.model.User)1