summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java')
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java51
1 files changed, 28 insertions, 23 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java
index 879b2a9a..979d6658 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserServiceCentalizedImpl.java
@@ -44,16 +44,36 @@ public class UserServiceCentalizedImpl implements UserService {
@Override
public User getUser(String id) throws Exception {
- ObjectMapper mapper = new ObjectMapper();
- User user = new User();
- HashSet<RoleFunction> rolefun = null;
+ User user = null;
String orgUserId = getUserByProfileId(id);
String responseString = restApiRequestBuilder.getViaREST("/user/" + orgUserId, true, id);
- user = mapper.readValue(responseString, User.class);
-
+ user = userMapper(responseString);
+ return user;
+ }
+
+ public String getUserByProfileId(String id) {
+ Map<String, Long> params = new HashMap<String, Long>();
+ params.put("user_id", new Long(id));
+ @SuppressWarnings("rawtypes")
+ List list = getDataAccessService().executeNamedQuery("getUserByProfileId", params, null);
+ String orgUserId = "";
+ if (list != null && !list.isEmpty())
+ orgUserId = (String) list.get(0);
+ return orgUserId;
+ }
+
+ @Override
+ public User userMapper(String res) throws Exception
+ {
+ User user= new User();
+ ObjectMapper mapper = new ObjectMapper();
+ HashSet<RoleFunction> rolefun = null;
+ user = mapper.readValue(res, User.class);
+ Set<RoleFunction> roleFunctionListNew = new HashSet<>();
+ Set<RoleFunction> roleFunctionList = new HashSet<>();
+ SortedSet<UserApp> UserAppSet = new TreeSet<>();
@SuppressWarnings("unchecked")
Set<UserApp> setAppsObj = user.getUserApps();
-
Iterator<UserApp> it = setAppsObj.iterator();
while (it.hasNext()) {
Object next = it.next();
@@ -61,36 +81,21 @@ public class UserServiceCentalizedImpl implements UserService {
UserApp nextApp = mapper.convertValue(next, UserApp.class);
rolefun = new HashSet<>();
Role role = nextApp.getRole();
-
- Set<RoleFunction> roleFunctionList = role.getRoleFunctions();
- Set<RoleFunction> roleFunctionListNew = new HashSet<>();
+ roleFunctionList = role.getRoleFunctions();
Iterator<RoleFunction> itetaror = roleFunctionList.iterator();
while (itetaror.hasNext()) {
Object nextValue = itetaror.next();
RoleFunction roleFunction = mapper.convertValue(nextValue, RoleFunction.class);
roleFunctionListNew.add(roleFunction);
}
-
role.setRoleFunctions(roleFunctionListNew);
nextApp.setRole(role);
nextApp.getRole().getRoleFunctions();
- SortedSet<UserApp> UserAppSet = new TreeSet<>();
+
UserAppSet.add(nextApp);
user.setUserApps(UserAppSet);
}
-
return user;
}
- public String getUserByProfileId(String id) {
- Map<String, Long> params = new HashMap<String, Long>();
- params.put("user_id", new Long(id));
- @SuppressWarnings("rawtypes")
- List list = getDataAccessService().executeNamedQuery("getUserByProfileId", params, null);
- String orgUserId = "";
- if (list != null && !list.isEmpty())
- orgUserId = (String) list.get(0);
- return orgUserId;
- }
-
}