X-Git-Url: https://gerrit.onap.org/r/gitweb?p=portal.git;a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fcontroller%2FUserController.java;h=571ab20ac78266000f272990ce2f86e2c6cb0265;hp=abc918555e40ac247babe334dda834cd32cbed8d;hb=ffd9af970318c1f5a0bad46d7aad5d4611414aae;hpb=2eaf7baff879929156699033bf62d29c0fd0040f diff --git a/portal-BE/src/main/java/org/onap/portal/controller/UserController.java b/portal-BE/src/main/java/org/onap/portal/controller/UserController.java index abc91855..571ab20a 100644 --- a/portal-BE/src/main/java/org/onap/portal/controller/UserController.java +++ b/portal-BE/src/main/java/org/onap/portal/controller/UserController.java @@ -50,10 +50,11 @@ import org.onap.portal.validation.DataValidator; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @@ -61,7 +62,7 @@ import org.springframework.web.bind.annotation.RestController; public class UserController { private static final String HIDDEN_DEFAULT_PASSWORD = "*****"; - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserController.class); + private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserController.class); private final FnUserService userService; private final DataValidator dataValidator; @@ -73,7 +74,7 @@ public class UserController { this.dataValidator = dataValidator; } - @RequestMapping(value = {"/portalApi/loggedinUser"}, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = {"/portalApi/loggedinUser"}, produces = MediaType.APPLICATION_JSON_VALUE) public PortalRestResponse getLoggedinUser(Principal principal) { PortalRestResponse portalRestResponse = null; try { @@ -90,8 +91,7 @@ public class UserController { return portalRestResponse; } - @RequestMapping(value = { - "/portalApi/modifyLoggedinUser"}, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = {"/portalApi/modifyLoggedinUser"}, produces = MediaType.APPLICATION_JSON_VALUE) public PortalRestResponse modifyLoggedinUser(Principal principal, @RequestBody ProfileDetail profileDetail) { PortalRestResponse portalRestResponse = null; @@ -99,7 +99,8 @@ public class UserController { String errorMsg = ""; if (!dataValidator.isValid(profileDetail)) { errorMsg = "Required field(s) is missing"; - portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.ERROR, dataValidator.getConstraintViolationsString(profileDetail), null); + portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.ERROR, + dataValidator.getConstraintViolationsString(profileDetail), null); logger.error(EELFLoggerDelegate.errorLogger, "modifyLoggedinUser failed", errorMsg); } else { FnUser user = userService.loadUserByUsername(principal.getName()); @@ -109,9 +110,10 @@ public class UserController { user.setMiddleName(profileDetail.getMiddleName()); user.setLoginId(profileDetail.getLoginId()); if (!HIDDEN_DEFAULT_PASSWORD.equals(profileDetail.getLoginPassword())) { - user.setLoginPwd(CipherUtil.encryptPKC(profileDetail.getLoginPassword(), "AGLDdG4D04BKm2IxIWEr8o==!")); + user.setLoginPwd(CipherUtil + .encryptPKC(profileDetail.getLoginPassword(), "AGLDdG4D04BKm2IxIWEr8o==!")); } - userService.saveFnUser(principal, user); + userService.saveFnUser(user); // Update user info in the session portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", null); }