use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class PermissionServiceImpl method findUserPermissionsForSubject.
@Override
public List<String> findUserPermissionsForSubject(String optionalDomainName, String userUuid, String optionalSubjectId) {
Preconditions.checkArgument(StringUtils.hasText(userUuid));
String domainName = getOptionalParamValue(optionalDomainName);
String subjectId = getOptionalParamValue(optionalSubjectId);
try {
return permissionDao.getUserPermissionsForSubject(domainName, userUuid, subjectId);
} catch (Throwable t) {
String msg = String.format("Failed to get user '%s' permissions for subject '%s' in domain '%s'", userUuid, subjectId, domainName);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class PermissionServiceImpl method findSubjectsUserHasPermissionsFor.
@Override
public List<String> findSubjectsUserHasPermissionsFor(String optionalDomainName, String userUuid, String optionalRequiredPermission) {
Preconditions.checkArgument(StringUtils.hasText(userUuid));
String domainName = getOptionalParamValue(optionalDomainName);
try {
if (!StringUtils.hasText(optionalRequiredPermission)) {
return permissionDao.getSubjectsUserHasPermissionFor(domainName, userUuid);
} else {
return permissionDao.getSubjectsUserHasPermissionForFiltered(domainName, userUuid, optionalRequiredPermission);
}
} catch (Throwable t) {
String msg = String.format("Failed to get subject list user '%s' has permissions (optional = '%s') for in domain '%s'", userUuid, optionalRequiredPermission, domainName);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class UserServiceImpl method getUserByEmail.
@Override
public User getUserByEmail(String userEmail) throws FieldValidationException, UserNotFoundException {
Assert.notNull(userEmail, "user email must be provided");
validateEmail(userEmail);
User foundUser;
try {
foundUser = userDao.findUserByEmail(userEmail);
} catch (Throwable t) {
String msg = String.format("Failed to find user by email '%s'", userEmail);
throw new UserServiceUnexpectedException(msg, t);
}
if (foundUser == null) {
throw new UserNotFoundException(userEmail);
}
return foundUser;
}
use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class UsersServiceFacadeImpl method resetPassword.
@Transactional(rollbackFor = Throwable.class)
@Override
public void resetPassword(String email, String passwordResetToken, PasswordReset resetPasswordRequest) throws UserNotFoundException, FieldValidationException {
try {
String userUuid = assertPasswordResetOperationValid(email, passwordResetToken, resetPasswordRequest);
passwordService.setUserPassword(userUuid, resetPasswordRequest.getPassword());
// generate new token in order to invalidate current
passwordService.getNewRestorationTokenForUser(userUuid);
// If account requires activation, do it
if (isAccountRequiresActivation(userUuid)) {
activateAccount(userUuid);
}
} catch (Throwable e) {
Throwables.throwIfInstanceOf(e, FieldValidationException.class);
throw new UserServiceUnexpectedException("Failed to arrange password reset", e);
}
}
use of org.summerb.microservices.users.api.exceptions.UserServiceUnexpectedException in project summerb by skarpushin.
the class UsersServiceFacadeImpl method changePassword.
@Override
public void changePassword(String email, PasswordChange passwordChange) throws UserNotFoundException, FieldValidationException {
try {
User user = validatePasswordChangeRequestValid(email, passwordChange);
passwordService.setUserPassword(user.getUuid(), passwordChange.getPassword());
} catch (Throwable e) {
Throwables.throwIfInstanceOf(e, FieldValidationException.class);
throw new UserServiceUnexpectedException("Failed to arrange password reset", e);
}
}
Aggregations