import org.onap.portalsdk.core.domain.RoleFunction;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
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.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
-import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
String action = "";
if (roleFunc.getCode().contains(FUNCTION_PIPE)) {
code = EcompPortalUtils.getFunctionCode(roleFunc.getCode());
- type = getFunctionType(roleFunc.getCode());
- action = getFunctionAction(roleFunc.getCode());
+ type = getFunctionCodeType(roleFunc.getCode());
+ action = getFunctionCodeAction(roleFunc.getCode());
} else {
code = roleFunc.getCode();
type = roleFunc.getCode().contains("menu") ? "menu" : "url";
String action = "";
if (addFunction.getCode().contains(FUNCTION_PIPE)) {
code = EcompPortalUtils.getFunctionCode(addFunction.getCode());
- type = getFunctionType(addFunction.getCode());
- action = getFunctionAction(addFunction.getCode());
+ type = getFunctionCodeType(addFunction.getCode());
+ action = getFunctionCodeAction(addFunction.getCode());
} else {
code = addFunction.getCode();
type = addFunction.getCode().contains("menu") ? "menu" : "url";
String action = "";
if (roleFunc.getCode().contains(FUNCTION_PIPE)) {
code = EcompPortalUtils.getFunctionCode(roleFunc.getCode());
- type = getFunctionType(roleFunc.getCode());
- action = getFunctionAction(roleFunc.getCode());
+ type = getFunctionCodeType(roleFunc.getCode());
+ action = getFunctionCodeAction(roleFunc.getCode());
} else {
code = roleFunc.getCode();
type = roleFunc.getCode().contains("menu") ? "menu" : "url";
@Override
@SuppressWarnings("unchecked")
- public List<EPUser> getUser(String loginId){
+ public List<EPUser> getUser(String loginId) throws InvalidUserException{
final Map<String, String> userParams = new HashMap<>();
userParams.put("org_user_id", loginId);
- return (List<EPUser>) dataAccessService.executeNamedQuery("getEPUserByOrgUserId", userParams, null);
+ List<EPUser> userList = dataAccessService.executeNamedQuery("getEPUserByOrgUserId", userParams, null);
+ if (userList.isEmpty()) {
+ throw new InvalidUserException("User not found");
+ }
+ return userList;
}
@Override
List<CentralV2RoleFunction> getRoleFuncList = dataAccessService.executeNamedQuery("getAllRoleFunctions", params, null);
for (CentralV2RoleFunction roleFuncItem : getRoleFuncList) {
String code = EcompPortalUtils.getFunctionCode(roleFuncItem.getCode());
- String type = getFunctionType(roleFuncItem.getCode());
- String action = getFunctionAction(roleFuncItem.getCode());
+ String type = getFunctionCodeType(roleFuncItem.getCode());
+ String action = getFunctionCodeAction(roleFuncItem.getCode());
roleFuncItem.setCode(EPUserUtils.decodeFunctionCode(code));
roleFuncItem.setType(type);
roleFuncItem.setAction(action);
}
- /**
- * It return function action
- *
- * @param roleFuncItem
- * @return String action
- */
- private String getFunctionAction(String roleFuncItem) {
+ @Override
+ public String getFunctionCodeAction(String roleFuncItem) {
return (!roleFuncItem.contains(FUNCTION_PIPE)) ? "*"
: EcompPortalUtils.getFunctionAction(roleFuncItem);
}
- /**
- *
- * It check function code has any pipes, if found return function type
- *
- * @param roleFuncItem
- * @param type
- * @return function type
- */
- private String getFunctionType(String roleFuncItem) {
+ @Override
+ public String getFunctionCodeType(String roleFuncItem) {
String type = null;
if ((roleFuncItem.contains(FUNCTION_PIPE) && roleFuncItem.contains("menu"))
|| (!roleFuncItem.contains(FUNCTION_PIPE) && roleFuncItem.contains("menu"))) {
final Map<String, Long> params = new HashMap<>();
CentralV2User userAppList = new CentralV2User();
CentralV2User user1 = null;
+ final Map<String, Long> params1 = new HashMap<>();
+ List<EPRole> globalRoleList = new ArrayList<>();
+
try {
+ if (app.getId() != PortalConstants.PORTAL_APP_ID) {
+ params1.put("userId", userInfo.getId());
+ params1.put("appId", app.getId());
+ globalRoleList = dataAccessService.executeNamedQuery("userAppGlobalRoles", params1, null);
+ }
userAppList.setUserApps(new TreeSet<CentralV2UserApp>());
for (EPUserApp userApp : userAppSet) {
if (userApp.getRole().getActive()) {
epApp.getThumbnail(), epApp.getUsername(), epApp.getUebKey(), epApp.getUebSecret(),
epApp.getUebTopicName());
cua.setApp(cenApp);
+ Long appId = null;
+ if (globalRole.toLowerCase().startsWith("global_")
+ && epApp.getId().equals(PortalConstants.PORTAL_APP_ID)
+ && !epApp.getId().equals(app.getId())) {
+ appId = app.getId();
+ EPRole result = null;
+ if (globalRoleList.size() > 0)
+ result = globalRoleList.stream()
+ .filter(x -> userApp.getRole().getId().equals(x.getId())).findAny()
+ .orElse(null);
+ if (result == null)
+ continue;
+ } else {
+ appId = userApp.getApp().getId();
+ }
params.put("roleId", userApp.getRole().getId());
- params.put(APP_ID, userApp.getApp().getId());
- CentralV2Role centralRole;
- List<EPRole> globalRoleList;
- globalRoleList = getGlobalRolesOfPortal();
- EPRole result = globalRoleList.stream().filter(x -> userApp.getRole().getId().equals(x.getId()))
- .findAny().orElse(null);
- if (result != null && userApp.getApp().getId() != app.getId()) {
- userApp.getRole().setId(result.getId());
- centralRole = getGlobalRoleForRequestedApp(app.getId(), userApp.getRole().getId());
- cua.setRole(centralRole);
+ params.put(APP_ID, appId);
+ List<CentralV2RoleFunction> appRoleFunctionList = dataAccessService
+ .executeNamedQuery("getAppRoleFunctionList", params, null);
+ SortedSet<CentralV2RoleFunction> roleFunctionSet = new TreeSet<>();
+ for (CentralV2RoleFunction roleFunc : appRoleFunctionList) {
+ String functionCode = EcompPortalUtils.getFunctionCode(roleFunc.getCode());
+ String type = getFunctionCodeType(roleFunc.getCode());
+ String action = getFunctionCodeAction(roleFunc.getCode());
+ CentralV2RoleFunction cenRoleFunc = new CentralV2RoleFunction(roleFunc.getId(),
+ functionCode, roleFunc.getName(), null, type, action, null);
+ roleFunctionSet.add(cenRoleFunc);
+ }
+ Long userRoleId = null;
+ if (globalRole.toLowerCase().startsWith("global_")
+ || epApp.getId().equals(PortalConstants.PORTAL_APP_ID)) {
+ userRoleId = userApp.getRole().getId();
} else {
- List<CentralV2RoleFunction> appRoleFunctionList = dataAccessService
- .executeNamedQuery("getAppRoleFunctionList", params, null);
- SortedSet<CentralV2RoleFunction> roleFunctionSet = new TreeSet<>();
- for (CentralV2RoleFunction roleFunc : appRoleFunctionList) {
- String functionCode = EcompPortalUtils.getFunctionCode(roleFunc.getCode());
- CentralV2RoleFunction cenRoleFunc = new CentralV2RoleFunction(roleFunc.getId(),
- functionCode, roleFunc.getName(), null, null);
- roleFunctionSet.add(cenRoleFunc);
- }
- Long userRoleId = null;
- if (globalRole.toLowerCase().startsWith("global_")
- && epApp.getId().equals(PortalConstants.PORTAL_APP_ID)) {
- userRoleId = userApp.getRole().getId();
- } else {
- userRoleId = userApp.getRole().getAppRoleId();
- }
- CentralV2Role cenRole = new CentralV2Role(userRoleId, userApp.getRole().getCreated(),
- userApp.getRole().getModified(), userApp.getRole().getCreatedId(),
- userApp.getRole().getModifiedId(), userApp.getRole().getRowNum(),
- userApp.getRole().getName(), userApp.getRole().getActive(),
- userApp.getRole().getPriority(), roleFunctionSet, null, null);
- cua.setRole(cenRole);
+ userRoleId = userApp.getRole().getAppRoleId();
}
+ CentralV2Role cenRole = new CentralV2Role(userRoleId, userApp.getRole().getCreated(),
+ userApp.getRole().getModified(), userApp.getRole().getCreatedId(),
+ userApp.getRole().getModifiedId(), userApp.getRole().getRowNum(),
+ userApp.getRole().getName(), userApp.getRole().getActive(),
+ userApp.getRole().getPriority(), roleFunctionSet, null, null);
+ cua.setRole(cenRole);
+
userAppList.getUserApps().add(cua);
}
}
for (CentralV2RoleFunction roleFunc : cenRoleFuncList) {
String functionCode = EcompPortalUtils.getFunctionCode(roleFunc.getCode());
functionCode = EPUserUtils.decodeFunctionCode(functionCode);
- String type = getFunctionType(roleFunc.getCode());
- String action = getFunctionAction(roleFunc.getCode());
+ String type = getFunctionCodeType(roleFunc.getCode());
+ String action = getFunctionCodeAction(roleFunc.getCode());
CentralV2RoleFunction cenRoleFunc = new CentralV2RoleFunction(role.getId(), functionCode,
roleFunc.getName(), null, type, action, null);
roleFunctionSet.add(cenRoleFunc);
@SuppressWarnings("unchecked")
@Override
public CentralV2RoleFunction getRoleFunction(String functionCode, String uebkey) throws Exception {
- if (functionCode.contains("|"))
- functionCode = EcompPortalUtils.getFunctionCode(functionCode);
- functionCode = encodeFunctionCode(functionCode);
+ String code = EcompPortalUtils.getFunctionCode(functionCode);
+ String encodedCode = encodeFunctionCode(code);
CentralV2RoleFunction roleFunc = null;
EPApp app = getApp(uebkey).get(0);
List<CentralV2RoleFunction> getRoleFuncList = null;
params.put(APP_ID, String.valueOf(app.getId()));
getRoleFuncList = dataAccessService.executeNamedQuery(GET_ROLE_FUNCTION_QUERY, params, null);
if (getRoleFuncList.isEmpty()) {
- return roleFunc;
+ params.put(FUNCTION_CODE_PARAMS, encodedCode);
+ getRoleFuncList = dataAccessService.executeNamedQuery(GET_ROLE_FUNCTION_QUERY, params, null);
+ if (getRoleFuncList.isEmpty()) {
+ return roleFunc;
+ }
+ }
+ if (getRoleFuncList.size() > 1) {
+ CentralV2RoleFunction cenV2RoleFunction = appFunctionListFilter(encodedCode, getRoleFuncList);
+ if (cenV2RoleFunction == null)
+ return roleFunc;
+ roleFunc = checkIfPipesExitsInFunctionCode(cenV2RoleFunction);
} else {
- if (getRoleFuncList.size() > 1) {
- CentralV2RoleFunction cenV2RoleFunction = appFunctionListFilter(functionCode, getRoleFuncList);
- if(cenV2RoleFunction == null)
- return roleFunc;
- roleFunc = checkIfPipesExitsInFunctionCode(cenV2RoleFunction);
- } else {
+ // Check even if single record have pipes
+ if (!getRoleFuncList.isEmpty() && getRoleFuncList.get(0).getCode().contains(FUNCTION_PIPE)) {
roleFunc = checkIfPipesExitsInFunctionCode(getRoleFuncList.get(0));
+ } else {
+ roleFunc = getRoleFuncList.get(0);
}
}
} catch (Exception e) {
return roleFunc;
}
- @SuppressWarnings("unchecked")
@Override
public boolean saveCentralRoleFunction(CentralV2RoleFunction domainCentralRoleFunction, EPApp app) throws Exception {
boolean saveOrUpdateFunction = false;
domainCentralRoleFunction.setCode(encodeFunctionCode(domainCentralRoleFunction.getCode()));
final Map<String, String> functionParams = new HashMap<>();
functionParams.put("appId", String.valueOf(app.getId()));
- List<CentralV2RoleFunction> appRoleFuncWithPipe = new ArrayList<>();
- // If request coming from portal application we use type, instance/code and action to fetch record
- if(domainCentralRoleFunction.getType()!=null && domainCentralRoleFunction.getAction()!=null){
- functionParams.put(FUNCTION_CODE_PARAMS, domainCentralRoleFunction.getType()+FUNCTION_PIPE
- +domainCentralRoleFunction.getCode()+FUNCTION_PIPE+domainCentralRoleFunction.getAction());
- appRoleFuncWithPipe = dataAccessService.executeNamedQuery(GET_ROLE_FUNCTION_QUERY, functionParams, null);
- if(appRoleFuncWithPipe.isEmpty()){
- functionParams.put(FUNCTION_CODE_PARAMS, domainCentralRoleFunction.getCode());
- appRoleFuncWithPipe = dataAccessService.executeNamedQuery(GET_ROLE_FUNCTION_QUERY, functionParams, null);
- }
- }
- // If request coming from SDK applications we use just function code to fetch record
- else{
- functionParams.put(FUNCTION_CODE_PARAMS, domainCentralRoleFunction.getCode());
- }
- CentralV2RoleFunction appFunctionCode = null;
- if(!appRoleFuncWithPipe.isEmpty()){
- // Make sure we extract correct record if similar records are found as query uses like condition
- appFunctionCode = appFunctionListFilter(domainCentralRoleFunction.getCode(), appRoleFuncWithPipe);
- if(appFunctionCode == null){
- appFunctionCode = domainCentralRoleFunction;
- }
- } else{
- appFunctionCode = domainCentralRoleFunction;
- }
- appFunctionCode.setName(domainCentralRoleFunction.getName());
if(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) {
- addRoleFunctionInExternalSystem(appFunctionCode, app);
+ addRoleFunctionInExternalSystem(domainCentralRoleFunction, app);
}
if(domainCentralRoleFunction.getType() != null && domainCentralRoleFunction.getAction() != null){
- appFunctionCode.setCode(domainCentralRoleFunction.getType()+
+ domainCentralRoleFunction.setCode(domainCentralRoleFunction.getType()+
FUNCTION_PIPE+domainCentralRoleFunction.getCode()+FUNCTION_PIPE+domainCentralRoleFunction.getAction());
}
- appFunctionCode.setAppId(app.getId());
- dataAccessService.saveDomainObject(appFunctionCode, null);
+ domainCentralRoleFunction.setAppId(app.getId());
+ dataAccessService.saveDomainObject(domainCentralRoleFunction, null);
saveOrUpdateFunction = true;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "saveCentralRoleFunction: failed", e);
ObjectMapper mapper = new ObjectMapper();
ExternalAccessPerms extPerms = new ExternalAccessPerms();
String instanceValue = EcompPortalUtils.getFunctionCode(domainCentralRoleFunction.getCode());
- String checkType = getFunctionType(domainCentralRoleFunction.getCode());
- String actionValue = getFunctionAction(domainCentralRoleFunction.getCode());
+ String checkType = getFunctionCodeType(domainCentralRoleFunction.getCode());
+ String actionValue = getFunctionCodeAction(domainCentralRoleFunction.getCode());
HttpHeaders headers = EcompPortalUtils.base64encodeKeyForAAFBasicAuth();
extPerms.setAction(actionValue);
extPerms.setInstance(instanceValue);
extRoleParams.put(APP_ID, app.getId().toString());
roleList = dataAccessService.executeNamedQuery(GET_ROLE_TO_UPDATE_IN_EXTERNAL_AUTH_SYSTEM, extRoleParams, null);
}
- EPRole updateRoleInactive = roleList.get(0);
- updateRoleInactive.setActive(false);
- dataAccessService.saveDomainObject(updateRoleInactive, null);
+ if(!roleList.isEmpty()) {
+ EPRole updateRoleInactive = roleList.get(0);
+ updateRoleInactive.setActive(false);
+ dataAccessService.saveDomainObject(updateRoleInactive, null);
+ }
}
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,
EPAppRoleFunction checkRoleFunctionExits = roleFunctionsMap.get(externalpermission.getInstance());
if (checkRoleFunctionExits == null) {
String funcCode = externalpermission.getType().substring(app.getNameSpace().length() + 1)
- + FUNCTION_PIPE + externalAccessPerms.getInstance() + FUNCTION_PIPE
- + externalAccessPerms.getAction();
+ + FUNCTION_PIPE + externalpermission.getInstance() + FUNCTION_PIPE
+ + externalpermission.getAction();
EPAppRoleFunction checkRoleFunctionPipeExits = roleFunctionsMap.get(funcCode);
if (checkRoleFunctionPipeExits == null) {
try {
@Override
public List<String> getMenuFunctionsList(String uebkey) throws Exception {
List<String> appMenuFunctionsList = null;
+ List<String> appMenuFunctionsFinalList = new ArrayList<>();
try {
EPApp app = getApp(uebkey).get(0);
final Map<String, Long> appParams = new HashMap<>();
appParams.put(APP_ID, app.getId());
appMenuFunctionsList = dataAccessService.executeNamedQuery("getMenuFunctions", appParams, null);
+ for(String appMenuFunction : appMenuFunctionsList) {
+ if(appMenuFunction.contains(FUNCTION_PIPE)) {
+ appMenuFunctionsFinalList.add(EcompPortalUtils.getFunctionCode(appMenuFunction));
+ } else {
+ appMenuFunctionsFinalList.add(appMenuFunction);
+ }
+ }
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getMenuFunctionsList: Failed", e);
- return appMenuFunctionsList;
+ return appMenuFunctionsFinalList;
}
- return appMenuFunctionsList;
+ return appMenuFunctionsFinalList;
}
@SuppressWarnings({ "unchecked"})
@Override
public List<EcompUser> getAllAppUsers(String uebkey) throws Exception {
List<String> usersList = new ArrayList<>();
- List<EcompUser> usersfinalList = new ArrayList<>();
- try {
- EPApp app = getApp(uebkey).get(0);
- final Map<String, Long> appParams = new HashMap<>();
- appParams.put("appId", app.getId());
- List<EcompUserRoles> userList = (List<EcompUserRoles>) dataAccessService
- .executeNamedQuery("ApplicationUserRoles", appParams, null);
- for (EcompUserRoles ecompUserRole : userList) {
- boolean found = false;
- Set<EcompRole> roles = null;
- for (EcompUser user : usersfinalList) {
- if (user.getOrgUserId().equals(ecompUserRole.getOrgUserId())) {
- EcompRole ecompRole = new EcompRole();
- ecompRole.setId(ecompUserRole.getRoleId());
- ecompRole.setName(ecompUserRole.getRoleName());
- roles = user.getRoles();
- roles.add(ecompRole);
- user.setRoles(roles);
- found = true;
- break;
- }
- }
-
- if (!found) {
- EcompUser epUser = new EcompUser();
- epUser.setOrgId(ecompUserRole.getOrgId());
- epUser.setManagerId(ecompUserRole.getManagerId());
- epUser.setFirstName(ecompUserRole.getFirstName());
- epUser.setLastName(ecompUserRole.getLastName());
- epUser.setPhone(ecompUserRole.getPhone());
- epUser.setEmail(ecompUserRole.getEmail());
- epUser.setOrgUserId(ecompUserRole.getOrgUserId());
- epUser.setOrgCode(ecompUserRole.getOrgCode());
- epUser.setOrgManagerUserId(ecompUserRole.getOrgManagerUserId());
- epUser.setJobTitle(ecompUserRole.getJobTitle());
- epUser.setLoginId(ecompUserRole.getLoginId());
- epUser.setActive(true);
- roles = new HashSet<>();
- EcompRole ecompRole = new EcompRole();
- ecompRole.setId(ecompUserRole.getRoleId());
- ecompRole.setName(ecompUserRole.getRoleName());
- roles.add(ecompRole);
- epUser.setRoles(roles);
- usersfinalList.add(epUser);
- }
- }
- ObjectMapper mapper = new ObjectMapper();
+ List<EcompUser> usersfinalList = new ArrayList<>();
+ try {
+ EPApp app = getApp(uebkey).get(0);
+ final Map<String, Long> appParams = new HashMap<>();
+ appParams.put("appId", app.getId());
+ List<EcompUserRoles> userList = (List<EcompUserRoles>) dataAccessService
+ .executeNamedQuery("ApplicationUserRoles", appParams, null);
+ for (EcompUserRoles ecompUserRole : userList) {
+ boolean found = false;
+ Set<EcompRole> roles = null;
+ for (EcompUser user : usersfinalList) {
+ if (user.getOrgUserId().equals(ecompUserRole.getOrgUserId())) {
+ EcompRole ecompRole = new EcompRole();
+ ecompRole.setId(ecompUserRole.getRoleId());
+ ecompRole.setName(ecompUserRole.getRoleName());
+ roles = user.getRoles();
+ EcompRole role = roles.stream().filter(x -> x.getName().equals(ecompUserRole.getRoleName())).findAny()
+ .orElse(null);
+ SortedSet<EcompRoleFunction> roleFunctionSet = new TreeSet<>();
+ if(role != null)
+ {
+ roleFunctionSet = (SortedSet<EcompRoleFunction>) role.getRoleFunctions();
+ }
+
+ String functionCode = EcompPortalUtils.getFunctionCode(ecompUserRole.getFunctionCode());
+ functionCode = EPUserUtils.decodeFunctionCode(functionCode);
+ EcompRoleFunction epRoleFunction = new EcompRoleFunction();
+ epRoleFunction.setName(ecompUserRole.getFunctionName());
+ epRoleFunction.setCode(EPUserUtils.decodeFunctionCode(functionCode));
+ epRoleFunction.setType(getFunctionCodeType(ecompUserRole.getFunctionCode()));
+ epRoleFunction.setAction(getFunctionCodeAction(ecompUserRole.getFunctionCode()));
+ roleFunctionSet.add(epRoleFunction);
+ ecompRole.setRoleFunctions(roleFunctionSet);
+ roles.add(ecompRole);
+ user.setRoles(roles);
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ EcompUser epUser = new EcompUser();
+ epUser.setOrgId(ecompUserRole.getOrgId());
+ epUser.setManagerId(ecompUserRole.getManagerId());
+ epUser.setFirstName(ecompUserRole.getFirstName());
+ epUser.setLastName(ecompUserRole.getLastName());
+ epUser.setPhone(ecompUserRole.getPhone());
+ epUser.setEmail(ecompUserRole.getEmail());
+ epUser.setOrgUserId(ecompUserRole.getOrgUserId());
+ epUser.setOrgCode(ecompUserRole.getOrgCode());
+ epUser.setOrgManagerUserId(ecompUserRole.getOrgManagerUserId());
+ epUser.setJobTitle(ecompUserRole.getJobTitle());
+ epUser.setLoginId(ecompUserRole.getLoginId());
+ epUser.setActive(true);
+ roles = new HashSet<>();
+ EcompRole ecompRole = new EcompRole();
+ ecompRole.setId(ecompUserRole.getRoleId());
+ ecompRole.setName(ecompUserRole.getRoleName());
+ SortedSet<EcompRoleFunction> roleFunctionSet = new TreeSet<>();
+
+ String functionCode = EcompPortalUtils.getFunctionCode(ecompUserRole.getFunctionCode());
+ functionCode = EPUserUtils.decodeFunctionCode(functionCode);
+ EcompRoleFunction epRoleFunction = new EcompRoleFunction();
+ epRoleFunction.setName(ecompUserRole.getFunctionName());
+ epRoleFunction.setCode(EPUserUtils.decodeFunctionCode(functionCode));
+ epRoleFunction.setType(getFunctionCodeType(ecompUserRole.getFunctionCode()));
+ epRoleFunction.setAction(getFunctionCodeAction(ecompUserRole.getFunctionCode()));
+ roleFunctionSet.add(epRoleFunction);
+ ecompRole.setRoleFunctions(roleFunctionSet);
+ roles.add(ecompRole);
+ epUser.setRoles(roles);
+ usersfinalList.add(epUser);
+ }
+ }
+ ObjectMapper mapper = new ObjectMapper();
+
+ for (EcompUser u1 : usersfinalList) {
+ String str = mapper.writeValueAsString(u1);
+ usersList.add(str);
+ }
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getAllUsers failed", e);
+ throw e;
+ }
+ return usersfinalList;
- for (EcompUser u1 : usersfinalList) {
- String str = mapper.writeValueAsString(u1);
- usersList.add(str);
- }
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "getAllUsers failed", e);
- throw e;
- }
- return usersfinalList;
}
action = EcompPortalUtils.getFunctionAction(role.getFunctionCd());
cenRoleFun = new CentralV2RoleFunction(null, instance, role.getFunctionName(), null, type, action, null);
} else{
- type = getFunctionType(role.getFunctionCd());
- action = getFunctionAction(role.getFunctionCd());
+ type = getFunctionCodeType(role.getFunctionCd());
+ action = getFunctionCodeAction(role.getFunctionCd());
cenRoleFun = new CentralV2RoleFunction(null, role.getFunctionCd(), role.getFunctionName(), null, type, action, null);
}
return cenRoleFun;
}
@Override
- public List<RoleFunction> convertCentralRoleFunctionToRoleFunctionObject(List<CentralV2RoleFunction> answer) {
- List<RoleFunction> addRoleFuncList = new ArrayList<>();
+ public List<CentralRoleFunction> convertCentralRoleFunctionToRoleFunctionObject(List<CentralV2RoleFunction> answer) {
+ List<CentralRoleFunction> addRoleFuncList = new ArrayList<>();
for(CentralV2RoleFunction cenRoleFunc : answer){
- RoleFunction setRoleFunc = new RoleFunction();
+ CentralRoleFunction setRoleFunc = new CentralRoleFunction();
setRoleFunc.setCode(cenRoleFunc.getCode());
setRoleFunc.setName(cenRoleFunc.getName());
addRoleFuncList.add(setRoleFunc);
sendUserRoles = convertV2UserRolesToOlderVersion(cenV2User);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getUserRoles: failed", e);
+ throw e;
}
return sendUserRoles;
}
@Override
public List<CentralRole> convertV2CentralRoleListToOldVerisonCentralRoleList(List<CentralV2Role> v2CenRoleList) {
List<CentralRole> cenRoleList = new ArrayList<>();
- SortedSet<CentralRoleFunction> cenRoleFuncList = new TreeSet<>();
for(CentralV2Role v2CenRole : v2CenRoleList){
+ SortedSet<CentralRoleFunction> cenRoleFuncList = new TreeSet<>();
for(CentralV2RoleFunction v2CenRoleFunc: v2CenRole.getRoleFunctions()){
CentralRoleFunction roleFunc = new CentralRoleFunction(v2CenRoleFunc.getCode(), v2CenRoleFunc.getName());
cenRoleFuncList.add(roleFunc);