Skip to content

Commit

Permalink
KAA-1250: Rewrited method for checking of user profile.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchizhevsky committed Jul 20, 2016
1 parent a00e146 commit ce56194
Showing 1 changed file with 5 additions and 8 deletions.
Expand Up @@ -555,17 +555,13 @@ public org.kaaproject.kaa.common.dto.admin.UserDto getUserProfile() throws KaaAd
}
}

private void checkUserProfile(org.kaaproject.kaa.common.dto.admin.UserDto userDto) throws KaaAdminServiceException {
if (isEmpty(userDto.getUsername())) {
throw new IllegalArgumentException("Username is not valid.");
} else if (isEmpty(userDto.getFirstName())) {
private void checkUserProfile(UserProfileUpdateDto userProfileUpdateDto) throws KaaAdminServiceException {
if (isEmpty(userProfileUpdateDto.getFirstName())) {
throw new IllegalArgumentException("First name is not valid.");
} else if (isEmpty(userDto.getLastName())) {
} else if (isEmpty(userProfileUpdateDto.getLastName())) {
throw new IllegalArgumentException("Last name is not valid.");
} else if (isEmpty(userDto.getMail())) {
} else if (isEmpty(userProfileUpdateDto.getMail())) {
throw new IllegalArgumentException("Mail is not valid.");
} else if (userDto.getAuthority() == null) {
throw new IllegalArgumentException("Authority is not valid.");
}
}

Expand All @@ -574,6 +570,7 @@ public void editUserProfile(UserProfileUpdateDto userProfileUpdateDto)
throws KaaAdminServiceException {
checkAuthority(KaaAuthorityDto.TENANT_USER, KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.KAA_ADMIN, KaaAuthorityDto.TENANT_ADMIN);
try {
checkUserProfile(userProfileUpdateDto);
User user = userFacade.findById(Long.valueOf(getCurrentUser().getExternalUid()));
user.setFirstName(userProfileUpdateDto.getFirstName());
user.setLastName(userProfileUpdateDto.getLastName());
Expand Down

0 comments on commit ce56194

Please sign in to comment.