X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fservice%2FExternalAccessRolesServiceImpl.java;fp=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fservice%2FExternalAccessRolesServiceImpl.java;h=39bd92d67b3eaf2792653b7210ce94f9435f24d9;hb=f59a56b7c12badbb41bb2155b6de47e9c9c48bcd;hp=b1804d8ca097133a8483f7b1a355c54bd64d8526;hpb=ad024fa2186f73cfb54ecc3cd422d57d7ea87f93;p=portal.git diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java index b1804d8c..39bd92d6 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java @@ -513,8 +513,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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"; @@ -663,8 +663,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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"; @@ -720,8 +720,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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"; @@ -1191,8 +1191,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic List 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); @@ -1202,26 +1202,14 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic } - /** - * 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"))) { @@ -1467,8 +1455,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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); @@ -1509,15 +1497,14 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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(encodedCode, getRoleFuncList); - if (cenV2RoleFunction == null) - return roleFunc; - roleFunc = checkIfPipesExitsInFunctionCode(cenV2RoleFunction); - } else { - roleFunc = checkIfPipesExitsInFunctionCode(getRoleFuncList.get(0)); - } + roleFunc = getRoleFuncList.get(0); } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "getRoleFunction: failed", e); @@ -1693,8 +1680,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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); @@ -3290,8 +3277,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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;