summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common
diff options
context:
space:
mode:
authorst782s <statta@research.att.com>2017-07-14 14:19:22 -0400
committerst782s <statta@research.att.com>2017-07-14 14:29:49 -0400
commit3aec9d2ab7f373a12e052d5e2c1c59b2a19770dc (patch)
treefd13e4b474891a3efa1320524026d7ddad757297 /ecomp-sdk/epsdk-app-common
parent30b8e1fd4328ea37fc5599f8a9723ea79ae0e369 (diff)
[Portal 21] Role management
This push includes continuation of the changes required to handle cetralized roles,user management Change-Id: I38e9dc946ff53ac61dd3b580c335f4ad52b372f7 Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-app-common')
-rw-r--r--ecomp-sdk/epsdk-app-common/pom.xml8
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java42
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java6
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java8
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java12
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java2
6 files changed, 39 insertions, 39 deletions
diff --git a/ecomp-sdk/epsdk-app-common/pom.xml b/ecomp-sdk/epsdk-app-common/pom.xml
index 90d9a7a2..f315974a 100644
--- a/ecomp-sdk/epsdk-app-common/pom.xml
+++ b/ecomp-sdk/epsdk-app-common/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId> org.openecomp.ecompsdkos</groupId>
+ <groupId>org.openecomp.ecompsdkos</groupId>
<artifactId>epsdk-project</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
@@ -156,17 +156,17 @@
<dependencies>
<!-- SDK components -->
<dependency>
- <groupId> org.openecomp.ecompsdkos</groupId>
+ <groupId>org.openecomp.ecompsdkos</groupId>
<artifactId>epsdk-core</artifactId>
<version>${epsdk.version}</version>
</dependency>
<dependency>
- <groupId> org.openecomp.ecompsdkos</groupId>
+ <groupId>org.openecomp.ecompsdkos</groupId>
<artifactId>epsdk-analytics</artifactId>
<version>${epsdk.version}</version>
</dependency>
<dependency>
- <groupId> org.openecomp.ecompsdkos</groupId>
+ <groupId>org.openecomp.ecompsdkos</groupId>
<artifactId>epsdk-workflow</artifactId>
<version>${epsdk.version}</version>
</dependency>
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 a40b20ac..f4132a9e 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
@@ -36,6 +36,7 @@ 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.service.UserProfileService;
+import org.openecomp.portalsdk.core.service.UserService;
import org.openecomp.portalsdk.core.web.support.AppUtils;
import org.openecomp.portalsdk.core.web.support.JsonMessage;
import org.openecomp.portalsdk.core.web.support.UserUtils;
@@ -59,12 +60,15 @@ public class ProfileController extends RestrictedBaseController {
UserProfileService service;
@Autowired
+ UserService userService;
+
+ @Autowired
RoleService roleService;
private String viewName;
@RequestMapping(value = { "/profile" }, method = RequestMethod.GET)
- public ModelAndView profile(HttpServletRequest request, HttpServletResponse response) {
+ public ModelAndView profile(HttpServletRequest request, HttpServletResponse response) throws Exception{
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
User user = UserUtils.getUserSession(request);
@@ -77,7 +81,7 @@ public class ProfileController extends RestrictedBaseController {
profileId = profile.getId();
} else {
profileId = Long.parseLong(request.getParameter("profile_id"));
- profile = (User) service.getUser(request.getParameter("profile_id"));
+ profile = (User) userService.getUser(String.valueOf(profileId));
}
try {
@@ -94,7 +98,7 @@ public class ProfileController extends RestrictedBaseController {
}
@RequestMapping(value = { "/self_profile" }, method = RequestMethod.GET)
- public ModelAndView self_profile(HttpServletRequest request) {
+ public ModelAndView self_profile(HttpServletRequest request) throws Exception{
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
@@ -103,9 +107,6 @@ public class ProfileController extends RestrictedBaseController {
User user = UserUtils.getUserSession(request);
profile = UserUtils.getUserSession(request);
- profileId = profile.getId();
- profile = (User) service.getUser(profileId.toString());
-
try {
model.put("stateList", mapper.writeValueAsString(getStates()));
model.put("countries", mapper.writeValueAsString(getCountries()));
@@ -120,7 +121,7 @@ public class ProfileController extends RestrictedBaseController {
}
@RequestMapping(value = { "/get_self_profile" }, method = RequestMethod.GET)
- public void getSelfProfile(HttpServletRequest request, HttpServletResponse response) {
+ public void getSelfProfile(HttpServletRequest request, HttpServletResponse response) throws Exception{
Map<String, Object> model = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
User user = UserUtils.getUserSession(request);
@@ -128,10 +129,7 @@ public class ProfileController extends RestrictedBaseController {
User profile = null;
Long profileId = null;
- profile = UserUtils.getUserSession(request);
- profileId = profile.getId();
- profile = (User) service.getUser(profileId.toString());
-
+ profile = (User) UserUtils.getUserSession(request);
try {
model.put("stateList", mapper.writeValueAsString(getStates()));
model.put("countries", mapper.writeValueAsString(getCountries()));
@@ -161,7 +159,8 @@ public class ProfileController extends RestrictedBaseController {
profileId = profile.getId();
} else {
profileId = Long.parseLong(request.getParameter("profile_id"));
- profile = (User) service.getUser(request.getParameter("profile_id"));
+ profile = (User) userService.getUser(String.valueOf(profileId));
+
}
model.put("stateList", mapper.writeValueAsString(getStates()));
model.put("countries", mapper.writeValueAsString(getCountries()));
@@ -194,7 +193,7 @@ public class ProfileController extends RestrictedBaseController {
Long profileId = Long.parseLong(request.getParameter("profile_id"));
- User domainUser = (User) service.getUser(request.getParameter("profile_id"));
+ User domainUser = (User) userService.getUser(String.valueOf(profileId));
// user.setRoles(domainUser.getRoles());
user.setPseudoRoles(domainUser.getPseudoRoles());
user.setUserApps(domainUser.getUserApps());
@@ -248,14 +247,14 @@ public class ProfileController extends RestrictedBaseController {
JsonNode root = mapper.readTree(request.getReader());
Role role = mapper.readValue(root.get("role").toString(), Role.class);
- // Long profileId = Long.parseLong(request.getParameter("profile_id"));
+ String profileId = request.getParameter("profile_id");
- User domainUser = (User) service.getUser(request.getParameter("profile_id"));
+ User domainUser = (User) userService.getUser(profileId);
domainUser.removeRole(role.getId());
service.saveUser(domainUser);
- logger.info(EELFLoggerDelegate.auditLogger, "Remove role " + role.getId() + " from user " + request.getParameter("profile_id"));
+ logger.info(EELFLoggerDelegate.auditLogger, "Remove role " + role.getId() + " from user " + profileId);
response.setCharacterEncoding("UTF-8");
response.setContentType("application / json");
@@ -291,22 +290,17 @@ public class ProfileController extends RestrictedBaseController {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
Role role = mapper.readValue(root.get("role").toString(), Role.class);
-
- // Long profileId = Long.parseLong(request.getParameter("profile_id"));
-
- User domainUser = (User) service.getUser(request.getParameter("profile_id"));
-
+ String profileId = request.getParameter("profile_id");
+ User domainUser = (User) userService.getUser(profileId);
domainUser.addRole(role);
-
service.saveUser(domainUser);
- logger.info(EELFLoggerDelegate.auditLogger, "Add new role " + role.getName() + " to user " + request.getParameter("profile_id"));
+ logger.info(EELFLoggerDelegate.auditLogger, "Add new role " + role.getName() + " to user " + profileId);
response.setCharacterEncoding("UTF-8");
response.setContentType("application / json");
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
-
Map<String, Object> model = new HashMap<String, Object>();
model.put("profile", mapper.writeValueAsString(domainUser));
JSONObject j = new JSONObject(mapper.writeValueAsString(domainUser));
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java
index e44aef8b..1e600a30 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java
@@ -38,6 +38,7 @@ import org.openecomp.portalsdk.core.domain.User;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.service.FnMenuService;
import org.openecomp.portalsdk.core.service.UserProfileService;
+import org.openecomp.portalsdk.core.service.UserService;
import org.openecomp.portalsdk.core.util.SystemProperties;
import org.openecomp.portalsdk.core.web.support.JsonMessage;
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,6 +59,9 @@ public class ProfileSearchController extends RestrictedBaseController {
private UserProfileService service;
@Autowired
+ UserService userService;
+
+ @Autowired
private FnMenuService fnMenuService;
@RequestMapping(value = { "/profile_search" }, method = RequestMethod.GET)
@@ -142,7 +146,7 @@ public class ProfileSearchController extends RestrictedBaseController {
logger.info(EELFLoggerDelegate.applicationLogger,
"Initiating toggleProfileActive in ProfileSearchController");
String userId = request.getParameter("profile_id");
- User user = (User) service.getUser(userId);
+ User user = (User) userService.getUser(userId);
user.setActive(!user.getActive());
service.saveUser(user);
logger.info(EELFLoggerDelegate.auditLogger,
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 0fc4edc4..5d12f4aa 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
@@ -149,15 +149,19 @@ public class RoleController extends RestrictedBaseController {
domainRole = new Role();
domainRole.setName(role.getName());
domainRole.setPriority(role.getPriority());
- if (role.getChildRoles().size() > 0) {
+ if(role.getChildRoles() != null && role.getChildRoles().size() > 0 ){
+// if (role.getChildRoles().size() > 0 ) {
for (Object childRole : childRoles) {
domainRole.addChildRole((Role) childRole);
}
+// }
}
- if (role.getRoleFunctions().size() > 0) {
+ if(role.getRoleFunctions() != null && role.getRoleFunctions().size() > 0){
+// if (role.getRoleFunctions().size() > 0) {
for (Object roleFunction : roleFunctions) {
domainRole.addRoleFunction((RoleFunction) roleFunction);
}
+// }
}
}
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 0014d0a5..0b8fb8c8 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
@@ -76,8 +76,6 @@ public class RoleFunctionListController extends RestrictedBaseController {
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(user.getOrgUserId())));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
@@ -108,6 +106,7 @@ public class RoleFunctionListController extends RestrictedBaseController {
} catch (Exception e) {
restCallStatus="fail";
logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction failed", e);
+ throw new Exception("failed while Saving RoleFunction");
}
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(restCallStatus));
JSONObject j = new JSONObject(msg);
@@ -125,10 +124,7 @@ public class RoleFunctionListController extends RestrictedBaseController {
try {
String data = roleFunc;
RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class);
- String code = availableRoleFunction.getCode();
- RoleFunction domainRoleFunction = service.getRoleFunction(user.getOrgUserId(),code);
- domainRoleFunction.setName(availableRoleFunction.getName());
- domainRoleFunction.setCode(code);
+ String code = availableRoleFunction.getCode();
List<RoleFunction> currentRoleFunction = service.getRoleFunctions(user.getOrgUserId());
restCallStatus="success";
for(RoleFunction roleF:currentRoleFunction){
@@ -139,10 +135,11 @@ public class RoleFunctionListController extends RestrictedBaseController {
}
}
if(canSave)
- service.saveRoleFunction(user.getOrgUserId(),domainRoleFunction);
+ service.saveRoleFunction(user.getOrgUserId(),availableRoleFunction);
} catch (Exception e) {
restCallStatus="fail";
logger.error(EELFLoggerDelegate.errorLogger, "addRoleFunction failed", e);
+ throw new Exception(e.getMessage());
}
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(restCallStatus));
JSONObject j = new JSONObject(msg);
@@ -169,6 +166,7 @@ public class RoleFunctionListController extends RestrictedBaseController {
} catch (Exception e) {
restCallStatus="fail";
logger.error(EELFLoggerDelegate.errorLogger, "removeRoleFunction failed", e);
+ throw new Exception(e.getMessage());
}
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(restCallStatus));
JSONObject j = new JSONObject(msg);
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 64ff160e..766d9eb9 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
@@ -108,7 +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());
+ List<RoleFunction> roleFunctionList= roleService.getRoleFunctions(userId);
if (commandBean.getUser() == null) {
String loginErrorMessage = (commandBean.getLoginErrorMessage() != null)
? commandBean.getLoginErrorMessage()