From 2cb8f0b3139881b0c60a01373b13569affafde7c Mon Sep 17 00:00:00 2001 From: harshanl Date: Tue, 16 Aug 2016 18:02:30 +0530 Subject: [PATCH] Fixed EMM-1392 --- .../impl/UserManagementServiceImpl.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index eda434e2f8..9734c9622d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -134,14 +134,14 @@ public class UserManagementServiceImpl implements UserManagementService { public Response updateUser(@PathParam("username") String username, UserInfo userInfo) { try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); - if (!userStoreManager.isExistingUser(userInfo.getUsername())) { + if (!userStoreManager.isExistingUser(username)) { if (log.isDebugEnabled()) { - log.debug("User by username: " + userInfo.getUsername() + - " doesn't exists. Therefore, request made to update user was refused."); + log.debug("User by username: " + username + + " doesn't exists. Therefore, request made to update user was refused."); } return Response.status(Response.Status.NOT_FOUND).entity( new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + - userInfo.getUsername() + " doesn't exist.").build()).build(); + username + " doesn't exist.").build()).build(); } Map defaultUserClaims = @@ -149,11 +149,11 @@ public class UserManagementServiceImpl implements UserManagementService { userInfo.getEmailAddress()); if (StringUtils.isNotEmpty(userInfo.getPassword())) { // Decoding Base64 encoded password - userStoreManager.updateCredentialByAdmin(userInfo.getUsername(), - userInfo.getPassword()); - log.debug("User credential of username: " + userInfo.getUsername() + " has been changed"); + userStoreManager.updateCredentialByAdmin(username, + userInfo.getPassword()); + log.debug("User credential of username: " + username + " has been changed"); } - List currentRoles = this.getFilteredRoles(userStoreManager, userInfo.getUsername()); + List currentRoles = this.getFilteredRoles(userStoreManager, username); List newRoles = Arrays.asList(userInfo.getRoles()); List rolesToAdd = new ArrayList<>(newRoles); @@ -167,19 +167,19 @@ public class UserManagementServiceImpl implements UserManagementService { } } rolesToDelete.remove(ROLE_EVERYONE); - userStoreManager.updateRoleListOfUser(userInfo.getUsername(), - rolesToDelete.toArray(new String[rolesToDelete.size()]), - rolesToAdd.toArray(new String[rolesToAdd.size()])); - userStoreManager.setUserClaimValues(userInfo.getUsername(), defaultUserClaims, null); + userStoreManager.updateRoleListOfUser(username, + rolesToDelete.toArray(new String[rolesToDelete.size()]), + rolesToAdd.toArray(new String[rolesToAdd.size()])); + userStoreManager.setUserClaimValues(username, defaultUserClaims, null); // Outputting debug message upon successful addition of user if (log.isDebugEnabled()) { - log.debug("User by username: " + userInfo.getUsername() + " was successfully updated."); + log.debug("User by username: " + username + " was successfully updated."); } BasicUserInfo updatedUserInfo = this.getBasicUserInfo(username); return Response.ok().entity(updatedUserInfo).build(); } catch (UserStoreException e) { - String msg = "Error occurred while trying to update user '" + userInfo.getUsername() + "'"; + String msg = "Error occurred while trying to update user '" + username + "'"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();