summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src/main')
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/BootstrapSampleController.java43
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java2
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java18
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java56
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java34
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java30
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java9
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java2
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java6
9 files changed, 143 insertions, 57 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/BootstrapSampleController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/BootstrapSampleController.java
new file mode 100644
index 00000000..794af760
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/BootstrapSampleController.java
@@ -0,0 +1,43 @@
+/*-
+ * ================================================================================
+ * ECOMP Portal SDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalapp.controller.core;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ * Controller for welcome view. The view is restricted to authenticated users.
+ * The view name defaults to the request name with no suffix, "bootstrap_sample", which
+ * resolves to page welcome.jsp.
+ */
+@Controller
+@RequestMapping("/")
+public class BootstrapSampleController extends RestrictedBaseController {
+ @RequestMapping(value = { "/bootstrap_sample" }, method = RequestMethod.GET)
+ public ModelAndView welcome(HttpServletRequest request) {
+ final String defaultViewName = null;
+ return new ModelAndView(defaultViewName);
+ }
+}
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java
index 2da1e6a6..39fae4f5 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java
@@ -111,7 +111,7 @@ public class PostSearchController extends RestrictedBaseController {
}
@SuppressWarnings({ "unchecked", "rawtypes" })
- private HashMap getExistingUsers() {
+ private HashMap getExistingUsers() throws Exception {
HashMap existingUsers = new HashMap();
// get the list of user ids in the system
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java
index a774274c..a40b20ac 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java
@@ -64,9 +64,10 @@ public class ProfileController extends RestrictedBaseController {
private String viewName;
@RequestMapping(value = { "/profile" }, method = RequestMethod.GET)
- public ModelAndView profile(HttpServletRequest request) {
+ public ModelAndView profile(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
User profile = null;
Long profileId = null;
@@ -83,7 +84,7 @@ public class ProfileController extends RestrictedBaseController {
model.put("stateList", mapper.writeValueAsString(getStates()));
model.put("countries", mapper.writeValueAsString(getCountries()));
model.put("timeZones", mapper.writeValueAsString(getTimeZones()));
- model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles()));
+ model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles(user.getOrgUserId())));
model.put("profile", mapper.writeValueAsString(profile));
model.put("profileId", mapper.writeValueAsString(profileId));
} catch (Exception e) {
@@ -99,6 +100,7 @@ public class ProfileController extends RestrictedBaseController {
User profile = null;
Long profileId = null;
+ User user = UserUtils.getUserSession(request);
profile = UserUtils.getUserSession(request);
profileId = profile.getId();
@@ -108,7 +110,7 @@ public class ProfileController extends RestrictedBaseController {
model.put("stateList", mapper.writeValueAsString(getStates()));
model.put("countries", mapper.writeValueAsString(getCountries()));
model.put("timeZones", mapper.writeValueAsString(getTimeZones()));
- model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles()));
+ model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles(user.getOrgUserId())));
model.put("profile", mapper.writeValueAsString(profile));
model.put("profileId", mapper.writeValueAsString(profileId));
} catch (Exception e) {
@@ -121,6 +123,7 @@ public class ProfileController extends RestrictedBaseController {
public void getSelfProfile(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
User profile = null;
Long profileId = null;
@@ -133,7 +136,7 @@ public class ProfileController extends RestrictedBaseController {
model.put("stateList", mapper.writeValueAsString(getStates()));
model.put("countries", mapper.writeValueAsString(getCountries()));
model.put("timeZones", mapper.writeValueAsString(getTimeZones()));
- model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles()));
+ model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles(user.getOrgUserId())));
model.put("profile", mapper.writeValueAsString(profile));
model.put("profileId", mapper.writeValueAsString(profileId));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -148,6 +151,7 @@ public class ProfileController extends RestrictedBaseController {
@RequestMapping(value = { "/get_profile" }, method = RequestMethod.GET)
public void GetUser(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> model = new HashMap<String, Object>();
+ User user = UserUtils.getUserSession(request);
ObjectMapper mapper = new ObjectMapper();
try {
User profile = null;
@@ -162,7 +166,7 @@ public class ProfileController extends RestrictedBaseController {
model.put("stateList", mapper.writeValueAsString(getStates()));
model.put("countries", mapper.writeValueAsString(getCountries()));
model.put("timeZones", mapper.writeValueAsString(getTimeZones()));
- model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles()));
+ model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles(user.getOrgUserId())));
model.put("profile", mapper.writeValueAsString(profile));
model.put("profileId", mapper.writeValueAsString(profileId));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -345,8 +349,8 @@ public class ProfileController extends RestrictedBaseController {
}
@SuppressWarnings("rawtypes")
- public List getAvailableRoles() {
- return roleService.getAvailableRoles();
+ public List getAvailableRoles(String requestedLoginId) throws Exception {
+ return roleService.getAvailableRoles(requestedLoginId);
}
} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java
index ca902c49..0fc4edc4 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java
@@ -32,11 +32,13 @@ import org.json.JSONObject;
import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.openecomp.portalsdk.core.domain.Role;
import org.openecomp.portalsdk.core.domain.RoleFunction;
+import org.openecomp.portalsdk.core.domain.User;
import org.openecomp.portalsdk.core.logging.aspect.EELFLoggerAdvice;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.service.RoleService;
import org.openecomp.portalsdk.core.util.SystemProperties;
import org.openecomp.portalsdk.core.web.support.JsonMessage;
+import org.openecomp.portalsdk.core.web.support.UserUtils;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -53,23 +55,26 @@ import com.fasterxml.jackson.databind.type.TypeFactory;
@Controller
@RequestMapping("/")
public class RoleController extends RestrictedBaseController {
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleController.class);
@Autowired
RoleService roleService;
private String viewName;
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleController.class);
+
@RequestMapping(value = { "/role" }, method = RequestMethod.GET)
- public ModelAndView role(HttpServletRequest request) {
+ public ModelAndView role(HttpServletRequest request) throws Exception {
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
- Role role = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+ Role role = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
logger.info("role_id" + role.getId());
try {
- model.put("availableRoleFunctions", mapper.writeValueAsString(roleService.getRoleFunctions()));
- model.put("availableRoles", mapper.writeValueAsString(roleService.getAvailableChildRoles(role.getId())));
+ model.put("availableRoleFunctions", mapper.writeValueAsString(roleService.getRoleFunctions(user.getOrgUserId())));
+ model.put("availableRoles", mapper.writeValueAsString(roleService.getAvailableChildRoles(user.getOrgUserId(),role.getId())));
model.put("role", mapper.writeValueAsString(role));
} catch (Exception e) {
logger.error("role: failed", e);
@@ -79,15 +84,16 @@ public class RoleController extends RestrictedBaseController {
}
@RequestMapping(value = { "/get_role" }, method = RequestMethod.GET)
- public void getRole(HttpServletRequest request, HttpServletResponse response) {
+ public void getRole(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
- Role role = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+ Role role = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
logger.info(EELFLoggerDelegate.applicationLogger, "role_id" + role.getId());
try {
- model.put("availableRoleFunctions", mapper.writeValueAsString(roleService.getRoleFunctions()));
- model.put("availableRoles", mapper.writeValueAsString(roleService.getAvailableChildRoles(role.getId())));
+ model.put("availableRoleFunctions", mapper.writeValueAsString(roleService.getRoleFunctions(user.getOrgUserId())));
+ model.put("availableRoles", mapper.writeValueAsString(roleService.getAvailableChildRoles(user.getOrgUserId(),role.getId())));
model.put("role", mapper.writeValueAsString(role));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -111,6 +117,7 @@ public class RoleController extends RestrictedBaseController {
@RequestMapping(value = { "/role/saveRole" }, method = RequestMethod.POST)
public ModelAndView saveRole(HttpServletRequest request, HttpServletResponse response) throws IOException {
JSONObject j = null;
+ User user = UserUtils.getUserSession(request);
logger.debug(EELFLoggerDelegate.debugLogger, "RoleController.save");
try {
ObjectMapper mapper = new ObjectMapper();
@@ -127,14 +134,14 @@ public class RoleController extends RestrictedBaseController {
Role domainRole = null;
if (role.getId() != null) {
doAuditLog("saveRole: updating existing role {}", role.getId());
- domainRole = roleService.getRole(role.getId());
+ domainRole = roleService.getRole(user.getOrgUserId(),role.getId());
domainRole.setName(role.getName());
domainRole.setPriority(role.getPriority());
} else {
doAuditLog("saveRole: creating new role", role.getName());
// check for existing role of same name
- List<Role> roles = roleService.getAvailableRoles();
+ List<Role> roles = roleService.getAvailableRoles(user.getOrgUserId());
for (Role existRole : roles)
if (existRole.getName().equalsIgnoreCase(role.getName()))
throw new Exception("role already exists: " + existRole.getName());
@@ -154,7 +161,7 @@ public class RoleController extends RestrictedBaseController {
}
}
- roleService.saveRole(domainRole);
+ roleService.saveRole(user.getOrgUserId(),domainRole);
String responseString = mapper.writeValueAsString(domainRole);
j = new JSONObject("{role: " + responseString + "}");
@@ -173,7 +180,7 @@ public class RoleController extends RestrictedBaseController {
@RequestMapping(value = { "/role/removeRoleFunction" }, method = RequestMethod.POST)
public ModelAndView removeRoleFunction(HttpServletRequest request, HttpServletResponse response) throws Exception {
-
+ User user = UserUtils.getUserSession(request);
logger.info(EELFLoggerDelegate.applicationLogger, "RoleController.removeRoleFunction");
try {
@@ -182,13 +189,13 @@ public class RoleController extends RestrictedBaseController {
JsonNode root = mapper.readTree(request.getReader());
RoleFunction roleFunction = mapper.readValue(root.get("roleFunction").toString(), RoleFunction.class);
- Role domainRole = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+ Role domainRole = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
doAuditLog("Remove role function {} from role {}", roleFunction.getCode(),
ServletRequestUtils.getIntParameter(request, "role_id", 0));
domainRole.removeRoleFunction(roleFunction.getCode());
- roleService.saveRole(domainRole);
+ roleService.saveRole(user.getOrgUserId(),domainRole);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
@@ -209,7 +216,7 @@ public class RoleController extends RestrictedBaseController {
@RequestMapping(value = { "/role/addRoleFunction" }, method = RequestMethod.POST)
public ModelAndView addRoleFunction(HttpServletRequest request, HttpServletResponse response) throws Exception {
-
+ User user = UserUtils.getUserSession(request);
logger.info(EELFLoggerDelegate.applicationLogger, "RoleController.removeRoleFunction");
try {
@@ -218,11 +225,11 @@ public class RoleController extends RestrictedBaseController {
JsonNode root = mapper.readTree(request.getReader());
RoleFunction roleFunction = mapper.readValue(root.get("roleFunction").toString(), RoleFunction.class);
- Role domainRole = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+ Role domainRole = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
domainRole.addRoleFunction(roleFunction);
- roleService.saveRole(domainRole);
+ roleService.saveRole(user.getOrgUserId(),domainRole);
doAuditLog("Add role function {} to role {}", roleFunction.getCode(),
ServletRequestUtils.getIntParameter(request, "role_id", 0));
@@ -245,7 +252,7 @@ public class RoleController extends RestrictedBaseController {
@RequestMapping(value = { "/role/removeChildRole" }, method = RequestMethod.POST)
public ModelAndView removeChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception {
-
+ User user = UserUtils.getUserSession(request);
logger.info(EELFLoggerDelegate.applicationLogger, "RoleController.removeChileRole");
try {
ObjectMapper mapper = new ObjectMapper();
@@ -253,13 +260,13 @@ public class RoleController extends RestrictedBaseController {
JsonNode root = mapper.readTree(request.getReader());
Role childRole = mapper.readValue(root.get("childRole").toString(), Role.class);
- Role domainRole = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+ Role domainRole = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
domainRole.removeChildRole(childRole.getId());
doAuditLog("remove child role {} from role {}", childRole.getId(),
ServletRequestUtils.getIntParameter(request, "role_id", 0));
- roleService.saveRole(domainRole);
+ roleService.saveRole(user.getOrgUserId(),domainRole);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
@@ -280,7 +287,7 @@ public class RoleController extends RestrictedBaseController {
@RequestMapping(value = { "/role/addChildRole" }, method = RequestMethod.POST)
public ModelAndView addChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception {
-
+ User user = UserUtils.getUserSession(request);
logger.info(EELFLoggerDelegate.applicationLogger, "RoleController.addChileRole");
try {
@@ -288,12 +295,13 @@ public class RoleController extends RestrictedBaseController {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
Role childRole = mapper.readValue(root.get("childRole").toString(), Role.class);
+ long role_id = new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0));
- Role domainRole = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+ Role domainRole = roleService.getRole(user.getOrgUserId(),role_id );
domainRole.addChildRole(childRole);
- roleService.saveRole(domainRole);
+ roleService.saveRole(user.getOrgUserId(),domainRole);
doAuditLog("Add child role {} to role {}", childRole.getId(),
ServletRequestUtils.getIntParameter(request, "role_id", 0));
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java
index 13b3a7c8..0014d0a5 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java
@@ -29,9 +29,11 @@ import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.openecomp.portalsdk.core.domain.RoleFunction;
+import org.openecomp.portalsdk.core.domain.User;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.service.RoleService;
import org.openecomp.portalsdk.core.web.support.JsonMessage;
+import org.openecomp.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
@@ -44,6 +46,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Controller
@RequestMapping("/")
public class RoleFunctionListController extends RestrictedBaseController {
+
+
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleFunctionListController.class);
@Autowired
@@ -54,10 +58,12 @@ public class RoleFunctionListController extends RestrictedBaseController {
@RequestMapping(value = {"/role_function_list" }, method = RequestMethod.GET)
public ModelAndView welcome(HttpServletRequest request) {
Map<String, Object> model = new HashMap<String, Object>();
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
try {
- model.put("availableRoleFunctions", mapper.writeValueAsString(service.getRoleFunctions()));
+ model.put("availableRoleFunctions", mapper.writeValueAsString(service.getRoleFunctions(user.getOrgUserId())));
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "welcome failed", e);
}
@@ -69,9 +75,11 @@ public class RoleFunctionListController extends RestrictedBaseController {
public void getRoleFunctionList(HttpServletRequest request,HttpServletResponse response) {
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
try {
- model.put("availableRoleFunctions", mapper.writeValueAsString(service.getRoleFunctions()));
+ model.put("availableRoleFunctions", mapper.writeValueAsString(service.getRoleFunctions(user.getOrgUserId())));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
@@ -85,16 +93,18 @@ public class RoleFunctionListController extends RestrictedBaseController {
public void saveRoleFunction(HttpServletRequest request,
HttpServletResponse response, @RequestBody String roleFunc) throws Exception {
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
String restCallStatus = "";
try {
String data = roleFunc;
RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class);
String code = availableRoleFunction.getCode();
- RoleFunction domainRoleFunction = service.getRoleFunction(code);
+ RoleFunction domainRoleFunction = service.getRoleFunction(user.getOrgUserId(),code);
domainRoleFunction.setName(availableRoleFunction.getName());
domainRoleFunction.setCode(code);
restCallStatus="success";
- service.saveRoleFunction(domainRoleFunction);
+ service.saveRoleFunction(user.getOrgUserId(),domainRoleFunction);
} catch (Exception e) {
restCallStatus="fail";
logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction failed", e);
@@ -108,16 +118,18 @@ public class RoleFunctionListController extends RestrictedBaseController {
public void addRoleFunction(HttpServletRequest request,
HttpServletResponse response, @RequestBody String roleFunc) throws Exception {
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
String restCallStatus = "";
boolean canSave=true;
try {
String data = roleFunc;
RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class);
String code = availableRoleFunction.getCode();
- RoleFunction domainRoleFunction = service.getRoleFunction(code);
+ RoleFunction domainRoleFunction = service.getRoleFunction(user.getOrgUserId(),code);
domainRoleFunction.setName(availableRoleFunction.getName());
domainRoleFunction.setCode(code);
- List<RoleFunction> currentRoleFunction = service.getRoleFunctions();
+ List<RoleFunction> currentRoleFunction = service.getRoleFunctions(user.getOrgUserId());
restCallStatus="success";
for(RoleFunction roleF:currentRoleFunction){
if(roleF.getCode().equals(code)){
@@ -127,7 +139,7 @@ public class RoleFunctionListController extends RestrictedBaseController {
}
}
if(canSave)
- service.saveRoleFunction(domainRoleFunction);
+ service.saveRoleFunction(user.getOrgUserId(),domainRoleFunction);
} catch (Exception e) {
restCallStatus="fail";
logger.error(EELFLoggerDelegate.errorLogger, "addRoleFunction failed", e);
@@ -141,15 +153,17 @@ public class RoleFunctionListController extends RestrictedBaseController {
public void removeRoleFunction(HttpServletRequest request,
HttpServletResponse response, @RequestBody String roleFunc) throws Exception {
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
String restCallStatus = "";
try {
String data = roleFunc;
RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class);
- RoleFunction domainRoleFunction = service.getRoleFunction(availableRoleFunction.getCode());
+ RoleFunction domainRoleFunction = service.getRoleFunction(user.getOrgUserId(),availableRoleFunction.getCode());
- service.deleteRoleFunction(domainRoleFunction);
+ service.deleteRoleFunction(user.getOrgUserId(),domainRoleFunction);
logger.info(EELFLoggerDelegate.auditLogger, "Remove role function " + domainRoleFunction.getName());
restCallStatus="success";
} catch (Exception e) {
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java
index be08d4e9..9ccff764 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java
@@ -29,9 +29,11 @@ import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.openecomp.portalsdk.core.domain.Role;
+import org.openecomp.portalsdk.core.domain.User;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.service.RoleService;
import org.openecomp.portalsdk.core.web.support.JsonMessage;
+import org.openecomp.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -46,6 +48,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RequestMapping("/")
public class RoleListController extends RestrictedBaseController {
+
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleListController.class);
@Autowired
RoleService service;
@@ -56,9 +59,11 @@ public class RoleListController extends RestrictedBaseController {
public ModelAndView getRoleList(HttpServletRequest request) {
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
try {
- model.put("availableRoles", mapper.writeValueAsString(service.getAvailableRoles()));
+ model.put("availableRoles", mapper.writeValueAsString(service.getAvailableRoles(user.getOrgUserId())));
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getRoleList failed", e);
}
@@ -69,10 +74,12 @@ public class RoleListController extends RestrictedBaseController {
@RequestMapping(value = {"/get_roles" }, method = RequestMethod.GET)
public void getRoles(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> model = new HashMap<String, Object>();
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
try {
- model.put("availableRoles", mapper.writeValueAsString(service.getAvailableRoles()));
+ model.put("availableRoles", mapper.writeValueAsString(service.getAvailableRoles(user.getOrgUserId())));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
@@ -85,6 +92,8 @@ public class RoleListController extends RestrictedBaseController {
@RequestMapping(value = {"/role_list/toggleRole" }, method = RequestMethod.POST)
public ModelAndView toggleRole(HttpServletRequest request,
HttpServletResponse response) throws Exception {
+ User user = UserUtils.getUserSession(request);
+
try {
ObjectMapper mapper = new ObjectMapper();
@@ -92,12 +101,12 @@ public class RoleListController extends RestrictedBaseController {
JsonNode root = mapper.readTree(request.getReader());
Role role = mapper.readValue(root.get("role").toString(), Role.class);
- Role domainRole = service.getRole(role.getId());
+ Role domainRole = service.getRole(user.getOrgUserId(),role.getId());
//role. toggle active ind
boolean active = domainRole.getActive();
domainRole.setActive(!active);
- service.saveRole(domainRole);
+ service.saveRole(user.getOrgUserId(),domainRole);
logger.info(EELFLoggerDelegate.auditLogger, "Toggle active status for role " + domainRole.getId());
response.setCharacterEncoding("UTF-8");
@@ -105,7 +114,7 @@ public class RoleListController extends RestrictedBaseController {
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
- String responseString = mapper.writeValueAsString(service.getAvailableRoles());
+ String responseString = mapper.writeValueAsString(service.getAvailableRoles(user.getOrgUserId()));
JSONObject j = new JSONObject("{availableRoles: "+responseString+"}");
out.write(j.toString());
@@ -125,6 +134,7 @@ public class RoleListController extends RestrictedBaseController {
@RequestMapping(value = {"/role_list/removeRole" }, method = RequestMethod.POST)
public ModelAndView removeRole(HttpServletRequest request,
HttpServletResponse response) throws Exception {
+ User user = UserUtils.getUserSession(request);
try {
@@ -133,10 +143,10 @@ public class RoleListController extends RestrictedBaseController {
JsonNode root = mapper.readTree(request.getReader());
Role role = mapper.readValue(root.get("role").toString(), Role.class);
- Role domainRole = service.getRole(role.getId());
+ Role domainRole = service.getRole(user.getOrgUserId(),role.getId());
- service.deleteDependcyRoleRecord(role.getId());
- service.deleteRole(domainRole);
+ service.deleteDependcyRoleRecord(user.getOrgUserId(),role.getId());
+ service.deleteRole(user.getOrgUserId(),domainRole);
logger.info(EELFLoggerDelegate.auditLogger, "Remove role " + domainRole.getId());
response.setCharacterEncoding("UTF-8");
@@ -145,7 +155,7 @@ public class RoleListController extends RestrictedBaseController {
PrintWriter out = response.getWriter();
- String responseString = mapper.writeValueAsString(service.getAvailableRoles());
+ String responseString = mapper.writeValueAsString(service.getAvailableRoles(user.getOrgUserId()));
JSONObject j = new JSONObject("{availableRoles: "+responseString+"}");
out.write(j.toString());
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java
index 9ffa1d1d..64ff160e 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java
@@ -22,6 +22,7 @@ package org.openecomp.portalapp.controller.core;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
@@ -31,6 +32,7 @@ import javax.servlet.http.HttpSession;
import org.openecomp.portalsdk.core.auth.LoginStrategy;
import org.openecomp.portalsdk.core.command.LoginBean;
import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
+import org.openecomp.portalsdk.core.domain.RoleFunction;
import org.openecomp.portalsdk.core.domain.User;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.menu.MenuProperties;
@@ -38,6 +40,7 @@ import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler;
import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
import org.openecomp.portalsdk.core.service.LoginService;
+import org.openecomp.portalsdk.core.service.RoleService;
import org.openecomp.portalsdk.core.util.SystemProperties;
import org.openecomp.portalsdk.core.web.support.AppUtils;
import org.openecomp.portalsdk.core.web.support.UserUtils;
@@ -70,6 +73,9 @@ public class SingleSignOnController extends UnRestrictedBaseController {
public void setWelcomeView(String welcomeView) {
this.welcomeView = welcomeView;
}
+
+ @Autowired
+ RoleService roleService;
/**
* Handles requests directed to the single sign-on page by the session
@@ -102,6 +108,7 @@ public class SingleSignOnController extends UnRestrictedBaseController {
commandBean = getLoginService().findUser(commandBean,
(String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY),
additionalParamsMap);
+ List<RoleFunction> roleFunctionList= roleService.getRoleFunctions(user.getLoginId());
if (commandBean.getUser() == null) {
String loginErrorMessage = (commandBean.getLoginErrorMessage() != null)
? commandBean.getLoginErrorMessage()
@@ -123,7 +130,7 @@ public class SingleSignOnController extends UnRestrictedBaseController {
loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_WEB_JUNCTION);
}
UserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(),
- commandBean.getBusinessDirectMenu(), loginMethod);
+ commandBean.getBusinessDirectMenu(), loginMethod, roleFunctionList);
initateSessionMgtHandler(request);
logger.debug(EELFLoggerDelegate.debugLogger,
"singleSignOnLogin: create new user session for expired user {}; user {} exists in the system",
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java
index cee60e48..cb67c93d 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java
@@ -52,7 +52,7 @@ public class UserProfileController extends RestrictedBaseController {
ProfileService service;
@RequestMapping(value = { "/user_profile" }, method = RequestMethod.GET)
- public ModelAndView userProfile(HttpServletRequest request) {
+ public ModelAndView userProfile(HttpServletRequest request) throws Exception {
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
List<Profile> profileList = service.findAll();
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java
index cb822494..7303cfc4 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java
@@ -222,9 +222,9 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService {
}
@Override
- public List<EcompRole> getAvailableRoles() throws PortalAPIException {
+ public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException {
try {
- List<Role> roles = roleService.getActiveRoles();
+ List<Role> roles = roleService.getActiveRoles(requestedLoginId);
List<EcompRole> ecompRoles = new ArrayList<EcompRole>();
for (Role role : roles)
ecompRoles.add(UserUtils.convertToEcompRole(role));
@@ -251,7 +251,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService {
*/
SortedSet<Role> roles = new TreeSet<Role>();
for (EcompRole role : rolesJson) {
- roles.add(roleService.getRole(role.getId()));
+ roles.add(roleService.getRole(loginId,role.getId()));
}
// Replace existing roles with new ones
replaceExistingRoles(roles, user);