X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FPolicyRolesController.java;h=daf3d6c973167094d771cce2dd6929afae9024d3;hb=52bd8ad44218a047284f1233984c514009feeb22;hp=6f8b3de8e64bb6350396b78e850fa08fdb3be221;hpb=073cc188efe9abb4c010cf674e34e2cf46ef1c52;p=policy%2Fengine.git diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java index 6f8b3de8e..daf3d6c97 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java @@ -37,8 +37,9 @@ import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.PolicyEditorScopes; import org.onap.policy.rest.jpa.PolicyRoles; import org.onap.policy.rest.jpa.UserInfo; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.web.support.JsonMessage; +import org.onap.portalsdk.core.controller.RestrictedBaseController; +import org.onap.portalsdk.core.web.support.JsonMessage; +import org.onap.portalsdk.core.web.support.UserUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; @@ -60,6 +61,10 @@ public class PolicyRolesController extends RestrictedBaseController{ @Autowired CommonClassDao commonClassDao; + public void setCommonClassDao(CommonClassDao commonClassDao) { + this.commonClassDao = commonClassDao; + } + List scopelist; @RequestMapping(value={"/get_RolesData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE) @@ -80,23 +85,27 @@ public class PolicyRolesController extends RestrictedBaseController{ @RequestMapping(value={"/save_NonSuperRolesData"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView SaveRolesEntityData(HttpServletRequest request, HttpServletResponse response){ try{ - String scopeName = null; + StringBuilder scopeName = new StringBuilder(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + String userId = UserUtils.getUserSession(request).getOrgUserId(); JsonNode root = mapper.readTree(request.getReader()); ReadScopes adapter = mapper.readValue(root.get("editRoleData").toString(), ReadScopes.class); for(int i = 0; i < adapter.getScope().size(); i++){ if(i == 0){ - scopeName = adapter.getScope().get(0); + scopeName.append(adapter.getScope().get(0)); }else{ - scopeName = scopeName + "," + adapter.getScope().get(i); + scopeName.append("," + adapter.getScope().get(i)); } } + LOGGER.info("****************************************Logging UserID for Roles Function********************************************************"); + LOGGER.info("UserId: " + userId + "Updating the Scope for following user" + adapter.getLoginId() + "ScopeNames" + adapter.getScope()); + LOGGER.info("*********************************************************************************************************************************"); PolicyRoles roles = new PolicyRoles(); roles.setId(adapter.getId()); roles.setLoginId(adapter.getLoginId()); roles.setRole(adapter.getRole()); - roles.setScope(scopeName); + roles.setScope(scopeName.toString()); commonClassDao.update(roles); response.setCharacterEncoding("UTF-8"); response.setContentType("application / json"); @@ -137,7 +146,7 @@ class ReadScopes{ private int id; private UserInfo loginId; private String role; - private ArrayList scope; + private List scope; public int getId() { return id; @@ -157,10 +166,10 @@ class ReadScopes{ public void setRole(String role) { this.role = role; } - public ArrayList getScope() { + public List getScope() { return scope; } - public void setScope(ArrayList scope) { + public void setScope(List scope) { this.scope = scope; }