diff options
author | 2018-03-06 09:44:53 -0500 | |
---|---|---|
committer | 2018-03-06 17:43:16 -0500 | |
commit | cfb69f44f841338e1f208225ec006388e986bd2c (patch) | |
tree | e8b7e982637a5b27f3383a793fcdcee50f7e0057 /ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support | |
parent | 724ff8f8b22d6503ce5070ebc13f6f5fbc48c8cf (diff) |
Added Junits & AAF attributes Support
Issue-ID: PORTAL-136
Includes JUNITS, AAF attributes support
Change-Id: Id4cc9f64268017665d7245d0a10369c9b498ba2f
Signed-off-by: Kotta, Shireesha (sk434m) <sk434m@att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support')
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java index bd7d5ed5..a6ed1e95 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/support/UserUtils.java @@ -60,9 +60,12 @@ import org.onap.portalsdk.core.exception.SessionExpiredException; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.menu.MenuBuilder; import org.onap.portalsdk.core.restful.domain.EcompRole; +import org.onap.portalsdk.core.restful.domain.EcompRoleFunction; import org.onap.portalsdk.core.restful.domain.EcompUser; import org.onap.portalsdk.core.util.SystemProperties; +import com.fasterxml.jackson.databind.ObjectMapper; + @SuppressWarnings("rawtypes") public class UserUtils { @@ -333,6 +336,8 @@ public class UserUtils { * @return EcompUser with a subset of fields. */ public static EcompUser convertToEcompUser(User user) { + ObjectMapper mapper = new ObjectMapper(); + EcompUser userJson = new EcompUser(); userJson.setEmail(user.getEmail()); userJson.setFirstName(user.getFirstName()); @@ -348,7 +353,12 @@ public class UserUtils { userJson.setOrgUserId(user.getOrgUserId()); userJson.setActive(user.getActive()); Set<EcompRole> ecompRoles = new TreeSet<>(); - for (Role role : user.getRoles()) { + Set<Role> roles = user.getRoles(); + Iterator<Role> roleIter = roles.iterator(); + + while (roleIter.hasNext()) { + Object nextValue = roleIter.next(); + Role role = mapper.convertValue(nextValue, Role.class); ecompRoles.add(convertToEcompRole(role)); } userJson.setRoles(ecompRoles); @@ -362,11 +372,35 @@ public class UserUtils { * @param role * @return EcompRole with a subset of fields: ID and name */ - public static EcompRole convertToEcompRole(Role role) { - EcompRole ecompRole = new EcompRole(); - ecompRole.setId(role.getId()); - ecompRole.setName(role.getName()); - return ecompRole; - } + public static EcompRole convertToEcompRole(Role role) { + ObjectMapper mapper = new ObjectMapper(); + + EcompRole ecompRole = new EcompRole(); + ecompRole.setId(role.getId()); + ecompRole.setName(role.getName()); + Set<EcompRoleFunction> ecompRolefunctions = new TreeSet<>(); + @SuppressWarnings("unchecked") + Set<RoleFunction> rolefunctions = role.getRoleFunctions(); + Iterator<RoleFunction> roleFnIter = rolefunctions.iterator(); + while (roleFnIter.hasNext()) { + Object nextValue = roleFnIter.next(); + RoleFunction roleFunction = mapper.convertValue(nextValue, RoleFunction.class); + ecompRolefunctions.add(convertToEcompRoleFunction(roleFunction)); + } + ecompRole.setRoleFunctions(ecompRolefunctions); + return ecompRole; + } + + public static EcompRoleFunction convertToEcompRoleFunction(RoleFunction rolefun) + { + EcompRoleFunction ecompRoleFunction = new EcompRoleFunction(); + ecompRoleFunction.setName(rolefun.getName()); + ecompRoleFunction.setCode(rolefun.getCode()); + ecompRoleFunction.setType(rolefun.getType()); + ecompRoleFunction.setAction(rolefun.getAction()); + return ecompRoleFunction; + } + + } |