diff options
Diffstat (limited to 'ecomp-portal-BE-common/src/main')
6 files changed, 138 insertions, 130 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java index ff254e85..1e955c8b 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java @@ -146,7 +146,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl @ApiOperation(value = "Gets user roles for an application which is upgraded to newer version.", response = String.class, responseContainer="List") @RequestMapping(value = { - "/v2/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") + "/v1/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") public String getV2UserList(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) throws Exception { String answer = null; @@ -186,7 +186,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl @ApiOperation(value = "Gets roles for an application which is upgraded to newer version.", response = CentralV2Role.class, responseContainer="Json") @RequestMapping(value = { - "/v2/roles" }, method = RequestMethod.GET, produces = "application/json") + "/v1/roles" }, method = RequestMethod.GET, produces = "application/json") public List<CentralV2Role> getV2RolesForApp(HttpServletRequest request, HttpServletResponse response) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "Request received for getV2RolesForApp"); List<CentralV2Role> answer = null; @@ -233,7 +233,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl @ApiOperation(value = "Gets all role functions for an application which is upgraded to newer version.", response = CentralV2RoleFunction.class, responseContainer="Json") @RequestMapping(value = { - "/v2/functions" }, method = RequestMethod.GET, produces = "application/json") + "/v1/functions" }, method = RequestMethod.GET, produces = "application/json") public List<CentralV2RoleFunction> getV2RoleFunctionsList(HttpServletRequest request, HttpServletResponse response) throws Exception { List<CentralV2RoleFunction> cenRoleFuncList = null; @@ -276,7 +276,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl @ApiOperation(value = "Gets v2 role information for an application which is upgraded to newer version.", response = CentralV2Role.class, responseContainer="Json") @RequestMapping(value = { - "/v2/role/{role_id}" }, method = RequestMethod.GET, produces = "application/json") + "/v1/role/{role_id}" }, method = RequestMethod.GET, produces = "application/json") public CentralV2Role getV2RoleInfo(HttpServletRequest request, HttpServletResponse response, @PathVariable("role_id") Long roleId) throws Exception { CentralV2Role answer = null; @@ -312,7 +312,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets role information for an application provided by function code.", response = CentralV2RoleFunction.class, responseContainer = "Json") - @RequestMapping(value = { "/v2/function/{code}" }, method = RequestMethod.GET, produces = "application/json") + @RequestMapping(value = { "/v1/function/{code}" }, method = RequestMethod.GET, produces = "application/json") public CentralV2RoleFunction getV2RoleFunction(HttpServletRequest request, HttpServletResponse response, @PathVariable("code") String code) throws Exception { CentralV2RoleFunction centralV2RoleFunction = null; @@ -341,10 +341,20 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl EPApp requestedApp = applicationList.get(0); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); CentralV2RoleFunction availableRoleFunction = mapper.readValue(data, CentralV2RoleFunction.class); - CentralV2RoleFunction domainRoleFunction = externalAccessRolesService.getRoleFunction(availableRoleFunction.getCode(), - requestedApp.getUebKey()); + CentralV2RoleFunction domainRoleFunction = null; + if(availableRoleFunction.getType()!=null && availableRoleFunction.getAction()!= null) { + String code = availableRoleFunction.getType()+"|"+availableRoleFunction.getCode()+"|"+availableRoleFunction.getAction(); + domainRoleFunction = externalAccessRolesService.getRoleFunction(code, + requestedApp.getUebKey()); + } else { + domainRoleFunction = externalAccessRolesService.getRoleFunction(availableRoleFunction.getCode(), + requestedApp.getUebKey()); + } + boolean saveOrUpdateResponse = false; - if (domainRoleFunction != null) { + if (domainRoleFunction != null && domainRoleFunction.getCode().equals(availableRoleFunction.getCode()) + && domainRoleFunction.getType().equals(availableRoleFunction.getType()) + && domainRoleFunction.getAction().equals(availableRoleFunction.getAction())) { domainRoleFunction.setName(availableRoleFunction.getName()); saveOrUpdateResponse = externalAccessRolesService.saveCentralRoleFunction(domainRoleFunction, requestedApp); @@ -760,11 +770,11 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl public List<EcompUser> getUsersOfApplication(HttpServletRequest request, HttpServletResponse response) throws Exception { List<EcompUser> users = null; try { + fieldsValidation(request); users = externalAccessRolesService.getAllAppUsers(request.getHeader(UEBKEY)); } catch (Exception e) { - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + sendErrorResponse(response, e); logger.error(EELFLoggerDelegate.errorLogger, "getUsersOfApplication failed", e); - throw new Exception(e.getMessage()); } return users; } @@ -816,10 +826,10 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl } @ApiOperation(value = "Gets ecompUser of an application.", response = CentralUser.class, responseContainer = "List") - @RequestMapping(value = { "/ecompUser/{loginId}" }, method = RequestMethod.GET, produces = "application/json") + @RequestMapping(value = { "/v2/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json") public String getEcompUser(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) throws Exception { - EcompUser user = new EcompUser(); + EcompUser user = null; ObjectMapper mapper = new ObjectMapper(); CentralUser answer = null; try { @@ -831,33 +841,38 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl user = UserUtils.convertToEcompUser(ecompUser); } } catch (Exception e) { + sendErrorResponse(response, e); logger.error(EELFLoggerDelegate.errorLogger, "getEcompUser failed", e); - throw e; } - return mapper.writeValueAsString(user); + if (user != null) { + return mapper.writeValueAsString(user); + } + return null; } @ApiOperation(value = "Gets user ecomp role for an application.", response = CentralUser.class, responseContainer = "List") - @RequestMapping(value = { "/ecompRoles" }, method = RequestMethod.GET, produces = "application/json") + @RequestMapping(value = { "/v2/roles" }, method = RequestMethod.GET, produces = "application/json") public List<EcompRole> getEcompRolesOfApplication(HttpServletRequest request, HttpServletResponse response) throws Exception { - List<EcompRole> ecompRoles = new ArrayList<EcompRole>(); + List<EcompRole> ecompRoles = null; ObjectMapper mapper = new ObjectMapper(); List<CentralV2Role> cenRole = null; try { fieldsValidation(request); EPApp app = externalAccessRolesService.getApp(request.getHeader(UEBKEY)).get(0); // Sync all roles from external system into Ecomp portal DB - logger.debug(EELFLoggerDelegate.debugLogger, "getRolesForApp: Entering into syncApplicationRolesWithEcompDB"); - externalAccessRolesService.syncApplicationRolesWithEcompDB(app); + logger.debug(EELFLoggerDelegate.debugLogger, + "getRolesForApp: Entering into syncApplicationRolesWithEcompDB"); + externalAccessRolesService.syncApplicationRolesWithEcompDB(app); logger.debug(EELFLoggerDelegate.debugLogger, "getRolesForApp: Finished syncApplicationRolesWithEcompDB"); cenRole = externalAccessRolesService.getActiveRoles(request.getHeader(UEBKEY)); } catch (Exception e) { sendErrorResponse(response, e); logger.error(EELFLoggerDelegate.errorLogger, "getActiveRoles failed", e); } - String res = mapper.writeValueAsString(cenRole); - if (res != null) { + if (cenRole != null) { + String res = mapper.writeValueAsString(cenRole); + ecompRoles = new ArrayList<>(); List<Role> roles = mapper.readValue(res, TypeFactory.defaultInstance().constructCollectionType(List.class, Role.class)); for (Role role : roles) diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java index 1433fb21..c9a6f5d1 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java @@ -500,7 +500,19 @@ public class RoleManageController extends EPRestrictedBaseController { if (isAuthorizedUser(user, requestedApp)) { fieldsValidation(requestedApp); if (requestedApp.getCentralAuth()) { - saveOrUpdateResponse = externalAccessRolesService.saveCentralRoleFunction(roleFunc, requestedApp); + CentralV2RoleFunction domainRoleFunction = externalAccessRolesService.getRoleFunction(roleFunc.getCode(), + requestedApp.getUebKey()); + if (domainRoleFunction != null && domainRoleFunction.getCode().equals(roleFunc.getCode()) + && domainRoleFunction.getType().equals(roleFunc.getType()) + && domainRoleFunction.getAction().equals(roleFunc.getAction())) { + domainRoleFunction.setName(roleFunc.getName()); + saveOrUpdateResponse = externalAccessRolesService.saveCentralRoleFunction(domainRoleFunction, + requestedApp); + } else { + roleFunc.setAppId(requestedApp.getId()); + saveOrUpdateResponse = externalAccessRolesService.saveCentralRoleFunction(roleFunc, + requestedApp); + } if (saveOrUpdateResponse) { EPUser requestedUser = externalAccessRolesService.getUser(user.getOrgUserId()).get(0); EPApp app = externalAccessRolesService.getApp(requestedApp.getUebKey()).get(0); @@ -557,11 +569,19 @@ public class RoleManageController extends EPRestrictedBaseController { if (requestedApp.getCentralAuth()) { ObjectMapper mapper = new ObjectMapper(); String data = roleFunc; + boolean getDelFuncResponse = false; CentralV2RoleFunction availableRoleFunction = mapper.readValue(data, CentralV2RoleFunction.class); - CentralV2RoleFunction domainRoleFunction = externalAccessRolesService - .getRoleFunction(availableRoleFunction.getCode(), requestedApp.getUebKey()); - boolean getDelFuncResponse = externalAccessRolesService - .deleteCentralRoleFunction(domainRoleFunction.getCode(), requestedApp); + String code = availableRoleFunction.getType() + "|" + availableRoleFunction.getCode() + "|" + + availableRoleFunction.getAction(); + CentralV2RoleFunction domainRoleFunction = externalAccessRolesService.getRoleFunction(code, + requestedApp.getUebKey()); + if (domainRoleFunction.getCode().contains("|")) { + getDelFuncResponse = externalAccessRolesService + .deleteCentralRoleFunction(code, requestedApp); + } else { + getDelFuncResponse = externalAccessRolesService + .deleteCentralRoleFunction(domainRoleFunction.getCode(), requestedApp); + } if (getDelFuncResponse) { logger.info(EELFLoggerDelegate.applicationLogger, "deleteRoleFunction: succeeded for app {}, role {}", requestedApp.getId(), diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java index 653e974b..e0ce086e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java @@ -251,6 +251,7 @@ public class AdminRolesServiceImpl implements AdminRolesService { if (EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { // Add user admin role for list of centralized applications in external system addAdminRoleInExternalSystem(user, localSession, newAppsWhereUserIsAdmin); + result = true; } } catch (Exception e) { EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); @@ -409,7 +410,7 @@ public class AdminRolesServiceImpl implements AdminRolesService { @SuppressWarnings("unchecked") @Override public boolean isSuperAdmin(EPUser user) { - if ((user != null) /* && (user.getId() == null) */ && (user.getOrgUserId() != null)) { + if ((user != null) && (user.getOrgUserId() != null)) { String sql = "SELECT user.USER_ID, user.org_user_id, userrole.ROLE_ID, userrole.APP_ID FROM fn_user_role userrole " + "INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID " + "WHERE user.org_user_id = '" + user.getOrgUserId() + "' " + "AND userrole.ROLE_ID = '" + SYS_ADMIN_ROLE_ID + "' " @@ -425,21 +426,6 @@ public class AdminRolesServiceImpl implements AdminRolesService { "Exception occurred while executing isSuperAdmin operation", e); } } - // else - // { - // User currentUser = user != null ? (User) - // dataAccessService.getDomainObject(User.class, user.getId(), null) : - // null; - // if (currentUser != null && currentUser.getId() != null) { - // for (UserApp userApp : currentUser.getUserApps()) { - // if (userApp.getApp().getId().equals(ECOMP_APP_ID) && - // userApp.getRole().getId().equals(SYS_ADMIN_ROLE_ID)) { - // // Super Administrator role is global, no need to keep iterating - // return true; - // } - // } - // } - // } return false; } @@ -450,9 +436,7 @@ public class AdminRolesServiceImpl implements AdminRolesService { : null; if (currentUser != null && currentUser.getId() != null) { for (EPUserApp userApp : currentUser.getEPUserApps()) { - if (// !userApp.getApp().getId().equals(ECOMP_APP_ID) - // && - userApp.getRole().getId().equals(ACCOUNT_ADMIN_ROLE_ID)) { + if (userApp.getRole().getId().equals(ACCOUNT_ADMIN_ROLE_ID)) { // Account Administrator sees only the applications // he/she is Administrator return true; 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 af5b5001..b1804d8c 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 @@ -1285,7 +1285,15 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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()) { @@ -1306,41 +1314,46 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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()); + 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 { - 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); } } @@ -1480,9 +1493,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic @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; @@ -1492,11 +1504,15 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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; + } } else { if (getRoleFuncList.size() > 1) { - CentralV2RoleFunction cenV2RoleFunction = appFunctionListFilter(functionCode, getRoleFuncList); - if(cenV2RoleFunction == null) + CentralV2RoleFunction cenV2RoleFunction = appFunctionListFilter(encodedCode, getRoleFuncList); + if (cenV2RoleFunction == null) return roleFunc; roleFunc = checkIfPipesExitsInFunctionCode(cenV2RoleFunction); } else { @@ -1528,7 +1544,6 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic return roleFunc; } - @SuppressWarnings("unchecked") @Override public boolean saveCentralRoleFunction(CentralV2RoleFunction domainCentralRoleFunction, EPApp app) throws Exception { boolean saveOrUpdateFunction = false; @@ -1536,41 +1551,15 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic 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); diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml index 2488a2e5..5968b3ce 100644 --- a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml @@ -2106,10 +2106,12 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y from fn_user fu, fn_role fr, fn_user_role fur where fu.user_id = fur.user_id and fu.active_yn='Y' and fur.role_id = fr.role_id and fr.app_id =:appId and fr.active_yn='Y' union - select distinct fu.org_id, fu.manager_id, fu.first_name, fu.middle_name, fu.last_name, fu.phone, fu.email, fu.hrid, fu.org_user_id, fu.org_code, fu.org_manager_userid, fu.job_title, fu.login_id, fu.active_yn , fr.role_id, fr.role_name - from fn_user fu, fn_role fr, fn_user_role fur - where fu.user_id = fur.user_id and fu.active_yn='Y' and fur.app_id=:appId and fr.role_name like 'global%' and fr.active_yn='Y' - ; + select distinct fu.org_id, fu.manager_id, fu.first_name, fu.middle_name, fu.last_name, fu.phone, + fu.email, fu.hrid, fu.org_user_id, fu.org_code, fu.org_manager_userid, fu.job_title, + fu.login_id, fu.active_yn , fr.role_id, fr.role_name + from fn_user_role a, fn_role fr, fn_user fu + where a.role_id in (select b.role_id from ep_app_role_function b where b.role_app_id = 1 and b.app_id =:appId) and a.user_id =fu.user_id and a.role_id = fr.role_id and fr.active_yn='Y' and fu.active_yn='Y' + ; ]]> </sql-query> @@ -2347,14 +2349,16 @@ where fn_role.app_id = fn_app.app_id and fn_app.enabled='Y' and fn_role.active_y ; ]]> - </sql-query> - - <query name="getBasicauthAccount"> - select id,password from BasicAuthCredentials - </query> + </sql-query> + + <sql-query name="userAppGlobalRoles"> + <return alias="userAppGlobalRoles" class="org.onap.portalapp.portal.domain.EPRole" /> + <![CDATA[ + select fr.role_id , fr.role_name ,fr.active_yn, fr.priority, fr.app_id, fr.app_role_id + from fn_user_role a, fn_role fr, fn_user fu + where a.role_id in (select b.role_id from ep_app_role_function b where b.role_app_id = 1 and b.app_id =:appId) and a.user_id =fu.user_id and a.role_id = fr.role_id and fr.active_yn='Y' and fu.active_yn='Y' and fu.user_id =:userId + ; + ]]> + </sql-query> - <query name="getMicroserviceInfo"> - select id,password from MicroserviceData - </query> - </hibernate-mapping> diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml index d197bc5f..0487006d 100644 --- a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml +++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/Fusion.hbm.xml @@ -353,9 +353,5 @@ Portal app mappings and features are in EP.hbm.xml. select sum(total_lines) TOTAL_LINES from demo_kpi_sourcecode_stats group by category1 ]]> </sql-query> - - <query name="getAppPassword"> - select id,appPassword from App - </query> </hibernate-mapping> |