- EPUser currentUser = user != null
- ? (EPUser) dataAccessService.getDomainObject(EPUser.class, user.getId(), null) : null;
- if (currentUser != null && currentUser.getId() != null) {
- SortedSet<EPUserApp> userApps = currentUser.getEPUserApps();
- EPUserApp userApp = userApps.stream()
- .filter(x -> x.getRole().getId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)
- && x.getApp().getId().equals(app.getId()))
- .findAny().orElse(null);
- if (userApp != null) {
- return true;
- }
+ final Map<String, Long> userParams = new HashMap<>();
+ userParams.put("userId", user.getId());
+ logger.debug(EELFLoggerDelegate.debugLogger, ADMIN_ACCOUNT, user.getId());
+ List<Integer> userAdminApps = new ArrayList<>();
+ userAdminApps =dataAccessService.executeNamedQuery("getAdminAppsForTheUser", userParams, null);
+ if(!userAdminApps.isEmpty()){
+ isApplicationAccountAdmin=userAdminApps.contains((int) (long) app.getId());
+ logger.debug(EELFLoggerDelegate.debugLogger, "Is account admin for user is true{} ,appId {}", user.getId(),app.getId());
+ }
+ } catch (Exception e) {
+ EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e);
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "Exception occurred while executing isAccountAdminOfApplication operation", e);
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, "In AdminRolesServiceImpl() - isAccountAdminOfApplication = {} and userId ={} ", isApplicationAccountAdmin, user.getOrgUserId());
+ return isApplicationAccountAdmin;
+
+ }
+
+ @Override
+ public Set<String> getAllAppsFunctionsOfUser(String OrgUserId) throws RoleFunctionException {
+ final Map<String, String> params = new HashMap<>();
+ params.put("userId", OrgUserId);
+ List getRoleFuncListOfPortal = dataAccessService.executeNamedQuery("getAllAppsFunctionsOfUser", params, null);
+ Set<String> getRoleFuncListOfPortalSet = new HashSet<>(getRoleFuncListOfPortal);
+ Set<String> roleFunSet = new HashSet<>();
+ roleFunSet = getRoleFuncListOfPortalSet.stream().filter(x -> x.contains("|")).collect(Collectors.toSet());
+ if (!roleFunSet.isEmpty())
+ for (String roleFunction : roleFunSet) {
+ String roleFun = EcompPortalUtils.getFunctionCode(roleFunction);
+ getRoleFuncListOfPortalSet.remove(roleFunction);
+ getRoleFuncListOfPortalSet.add(roleFun);