@Test public void test92searchXPermMap() { SearchCriteria testSearchCriteria = createsearchCriteria(); testSearchCriteria.addParam("xUserId", userId); VXResource vxresource=new VXResource(); VXPermMap vXPermMap=getVXPermMap(); List<VXPermMap> vXPermMapList=new ArrayList<VXPermMap>(); vXPermMapList.add(vXPermMap); VXPermMapList permMapList=new VXPermMapList(); permMapList.setVXPermMaps(vXPermMapList); Mockito.when(xPermMapService.searchXPermMaps((SearchCriteria) Mockito.any())).thenReturn(permMapList); List<XXResource> xResourceList = new ArrayList<XXResource>(); XXResource xRes = new XXResource(); xRes.setId(userId); xRes.setName("hadoopdev"); xRes.setIsRecursive(AppConstants.BOOL_TRUE); xRes.setResourceStatus(AppConstants.STATUS_ENABLED); xResourceList.add(xRes); XXResourceDao xxResourceDao = Mockito.mock(XXResourceDao.class); Mockito.when(daoManager.getXXResource()).thenReturn(xxResourceDao); Mockito.when(xxResourceDao.getById(Mockito.anyLong())).thenReturn(xRes); Mockito.when(xResourceService.populateViewBean(xRes)).thenReturn(vxresource); VXResponse vXResponse = new VXResponse(); vXResponse.setStatusCode(VXResponse.STATUS_SUCCESS); Mockito.when(msBizUtil.hasPermission(vxresource, AppConstants.XA_PERM_TYPE_ADMIN)).thenReturn(vXResponse); VXPermMapList returnList=xUserMgr.searchXPermMaps(testSearchCriteria); Assert.assertNotNull(returnList); Assert.assertEquals(permMapList.getListSize(), returnList.getListSize()); }
public VXPermMapList searchXPermMaps(SearchCriteria searchCriteria) { VXPermMapList returnList = null; UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession(); if (currentUserSession != null && currentUserSession.isUserAdmin()) { returnList = super.searchXPermMaps(searchCriteria); } else { returnList = new VXPermMapList(); int startIndex = searchCriteria.getStartIndex(); int pageSize = searchCriteria.getMaxRows(); searchCriteria.setStartIndex(0); searchCriteria.setMaxRows(Integer.MAX_VALUE); List<VXPermMap> resultList = xPermMapService.searchXPermMaps(searchCriteria).getVXPermMaps(); List<VXPermMap> adminPermResourceList = new ArrayList<VXPermMap>(); for (VXPermMap xXPermMap : resultList) { XXResource xRes = daoManager.getXXResource().getById(xXPermMap.getResourceId()); VXResponse vXResponse = msBizUtil.hasPermission(xResourceService.populateViewBean(xRes), AppConstants.XA_PERM_TYPE_ADMIN); if (vXResponse.getStatusCode() == VXResponse.STATUS_SUCCESS) { adminPermResourceList.add(xXPermMap); } } if (adminPermResourceList.size() > 0) { populatePageList(adminPermResourceList, startIndex, pageSize, returnList); } } return returnList; }
XUserMgr extends XUserMgrBase { public VXPermMapList searchXPermMaps(SearchCriteria searchCriteria) { VXPermMapList returnList = null; UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession(); if (currentUserSession != null && currentUserSession.isUserAdmin()) { returnList = super.searchXPermMaps(searchCriteria); } else { returnList = new VXPermMapList(); int startIndex = searchCriteria.getStartIndex(); int pageSize = searchCriteria.getMaxRows(); searchCriteria.setStartIndex(0); searchCriteria.setMaxRows(Integer.MAX_VALUE); List<VXPermMap> resultList = xPermMapService.searchXPermMaps(searchCriteria).getVXPermMaps(); List<VXPermMap> adminPermResourceList = new ArrayList<VXPermMap>(); for (VXPermMap xXPermMap : resultList) { XXResource xRes = daoManager.getXXResource().getById(xXPermMap.getResourceId()); VXResponse vXResponse = msBizUtil.hasPermission(xResourceService.populateViewBean(xRes), AppConstants.XA_PERM_TYPE_ADMIN); if (vXResponse.getStatusCode() == VXResponse.STATUS_SUCCESS) { adminPermResourceList.add(xXPermMap); } } if (adminPermResourceList.size() > 0) { populatePageList(adminPermResourceList, startIndex, pageSize, returnList); } } return returnList; } }
XUserMgr extends XUserMgrBase { public VXPermMapList searchXPermMaps(SearchCriteria searchCriteria) { VXPermMapList returnList = null; UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession(); if (currentUserSession != null && currentUserSession.isUserAdmin()) { returnList = super.searchXPermMaps(searchCriteria); } else { returnList = new VXPermMapList(); int startIndex = searchCriteria.getStartIndex(); int pageSize = searchCriteria.getMaxRows(); searchCriteria.setStartIndex(0); searchCriteria.setMaxRows(Integer.MAX_VALUE); List<VXPermMap> resultList = xPermMapService.searchXPermMaps(searchCriteria).getVXPermMaps(); List<VXPermMap> adminPermResourceList = new ArrayList<VXPermMap>(); for (VXPermMap xXPermMap : resultList) { XXResource xRes = daoManager.getXXResource().getById(xXPermMap.getResourceId()); VXResponse vXResponse = msBizUtil.hasPermission(xResourceService.populateViewBean(xRes), AppConstants.XA_PERM_TYPE_ADMIN); if (vXResponse.getStatusCode() == VXResponse.STATUS_SUCCESS) { adminPermResourceList.add(xXPermMap); } } if (adminPermResourceList.size() > 0) { populatePageList(adminPermResourceList, startIndex, pageSize, returnList); } } return returnList; }  }
XUserMgr extends XUserMgrBase { public VXPermMapList searchXPermMaps(SearchCriteria searchCriteria) { VXPermMapList returnList = null; UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession(); if (currentUserSession != null && currentUserSession.isUserAdmin()) { returnList = super.searchXPermMaps(searchCriteria); } else { returnList = new VXPermMapList(); int startIndex = searchCriteria.getStartIndex(); int pageSize = searchCriteria.getMaxRows(); searchCriteria.setStartIndex(0); searchCriteria.setMaxRows(Integer.MAX_VALUE); List<VXPermMap> resultList = xPermMapService.searchXPermMaps(searchCriteria).getVXPermMaps(); List<VXPermMap> adminPermResourceList = new ArrayList<VXPermMap>(); for (VXPermMap xXPermMap : resultList) { XXResource xRes = daoManager.getXXResource().getById(xXPermMap.getResourceId()); VXResponse vXResponse = msBizUtil.hasPermission(xResourceService.populateViewBean(xRes), AppConstants.XA_PERM_TYPE_ADMIN); if (vXResponse.getStatusCode() == VXResponse.STATUS_SUCCESS) { adminPermResourceList.add(xXPermMap); } } if (adminPermResourceList.size() > 0) { populatePageList(adminPermResourceList, startIndex, pageSize, returnList); } } return returnList; }  VXUser getXUserByUserName(String userName); VXGroup getGroupByGroupName(String groupName); VXUser createXUser(VXUser vXUser); void assignPermissionToUser(VXPortalUser vXPortalUser, boolean isCreate); void createOrUpdateUserPermisson(VXPortalUser portalUser, Long moduleId, boolean isCreate); HashMap<String, Long> getAllModuleNameAndIdMap(); VXUser updateXUser(VXUser vXUser); VXUserGroupInfo createXUserGroupFromMap(VXUserGroupInfo vXUserGroupInfo); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) VXGroupUserInfo createXGroupUserFromMap(
			VXGroupUserInfo vXGroupUserInfo); VXGroupUserInfo getXGroupUserFromMap(
			String groupName); VXUser createXUserWithOutLogin(VXUser vXUser); VXUser createExternalUser(String userName); VXGroup createXGroup(VXGroup vXGroup); VXGroup createXGroupWithoutLogin(VXGroup vXGroup); VXGroupUser createXGroupUser(VXGroupUser vXGroupUser); VXUser getXUser(Long id); VXGroupUser getXGroupUser(Long id); VXGroup getXGroup(Long id); void deleteXGroupAndXUser(String groupName, String userName); VXGroupList getXUserGroups(Long xUserId); Set<String> getGroupsForUser(String userName); VXUserList getXGroupUsers(SearchCriteria searchCriteria); @Override VXGroup updateXGroup(VXGroup vXGroup); VXGroupUser updateXGroupUser(VXGroupUser vXGroupUser); void deleteXGroupUser(Long id, boolean force); VXGroupGroup createXGroupGroup(VXGroupGroup vXGroupGroup); VXGroupGroup updateXGroupGroup(VXGroupGroup vXGroupGroup); void deleteXGroupGroup(Long id, boolean force); void deleteXPermMap(Long id, boolean force); VXLong getXPermMapSearchCount(SearchCriteria searchCriteria); void deleteXAuditMap(Long id, boolean force); VXLong getXAuditMapSearchCount(SearchCriteria searchCriteria); void modifyUserVisibility(HashMap<Long, Integer> visibilityMap); void modifyGroupsVisibility(HashMap<Long, Integer> groupVisibilityMap); VXModuleDef createXModuleDefPermission(VXModuleDef vXModuleDef); VXModuleDef getXModuleDefPermission(Long id); VXModuleDef updateXModuleDefPermission(VXModuleDef vXModuleDef); void deleteXModuleDefPermission(Long id, boolean force); VXUserPermission createXUserPermission(VXUserPermission vXUserPermission); VXUserPermission getXUserPermission(Long id); VXUserPermission updateXUserPermission(VXUserPermission vXUserPermission); void deleteXUserPermission(Long id, boolean force); VXGroupPermission createXGroupPermission(VXGroupPermission vXGroupPermission); VXGroupPermission getXGroupPermission(Long id); VXGroupPermission updateXGroupPermission(VXGroupPermission vXGroupPermission); void deleteXGroupPermission(Long id, boolean force); void modifyUserActiveStatus(HashMap<Long, Integer> statusMap); void checkAdminAccess(); void checkAccess(String loginID); VXPermMapList searchXPermMaps(SearchCriteria searchCriteria); VXAuditMapList searchXAuditMaps(SearchCriteria searchCriteria); void checkAccessRoles(List<String> stringRolesList); VXStringList setUserRolesByExternalID(Long userId, List<VXString> vStringRolesList); VXStringList setUserRolesByName(String userName, List<VXString> vStringRolesList); List<String> updateUserRoleAssignments(VXUsersGroupRoleAssignments ugRoleAssignments); VXStringList getUserRolesByExternalID(Long userId); VXStringList getUserRolesByName(String userName); void updateUserRolesPermissions(VXPortalUser oldUserProfile,List<String> roleListNewProfile); VXStringList getStringListFromUserRoleList(
			List<XXPortalUserRole> listXXPortalUserRole); boolean hasAccess(String loginID); VXUser getMaskedVXUser(VXUser vXUser); VXGroup getMaskedVXGroup(VXGroup vXGroup); @Override VXUserList searchXUsers(SearchCriteria searchCriteria); @Override VXGroupList searchXGroups(SearchCriteria searchCriteria); VXGroupList lookupXGroups(SearchCriteria searchCriteria); Collection<String> getMaskedCollection(Collection<String> listunMasked); boolean hasAccessToModule(String moduleName); void deleteXGroup(Long id, boolean force); synchronized void deleteXUser(Long id, boolean force); void restrictSelfAccountDeletion(String loginID); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) VXUser createServiceConfigUser(String userName); void denySelfRoleChange(String userName); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) synchronized VXUgsyncAuditInfo postUserGroupAuditInfo(
			VXUgsyncAuditInfo vxUgsyncAuditInfo); Long getUserStoreVersion(); Set<UserInfo> getUsers(); Set<GroupInfo> getGroups(); Map<String, Set<String>> getUserGroups(); RangerUserStore getRangerUserStore(Long lastKnownUserStoreVersion); }
XUserMgr extends XUserMgrBase { public VXPermMapList searchXPermMaps(SearchCriteria searchCriteria) { VXPermMapList returnList = null; UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession(); if (currentUserSession != null && currentUserSession.isUserAdmin()) { returnList = super.searchXPermMaps(searchCriteria); } else { returnList = new VXPermMapList(); int startIndex = searchCriteria.getStartIndex(); int pageSize = searchCriteria.getMaxRows(); searchCriteria.setStartIndex(0); searchCriteria.setMaxRows(Integer.MAX_VALUE); List<VXPermMap> resultList = xPermMapService.searchXPermMaps(searchCriteria).getVXPermMaps(); List<VXPermMap> adminPermResourceList = new ArrayList<VXPermMap>(); for (VXPermMap xXPermMap : resultList) { XXResource xRes = daoManager.getXXResource().getById(xXPermMap.getResourceId()); VXResponse vXResponse = msBizUtil.hasPermission(xResourceService.populateViewBean(xRes), AppConstants.XA_PERM_TYPE_ADMIN); if (vXResponse.getStatusCode() == VXResponse.STATUS_SUCCESS) { adminPermResourceList.add(xXPermMap); } } if (adminPermResourceList.size() > 0) { populatePageList(adminPermResourceList, startIndex, pageSize, returnList); } } return returnList; }  VXUser getXUserByUserName(String userName); VXGroup getGroupByGroupName(String groupName); VXUser createXUser(VXUser vXUser); void assignPermissionToUser(VXPortalUser vXPortalUser, boolean isCreate); void createOrUpdateUserPermisson(VXPortalUser portalUser, Long moduleId, boolean isCreate); HashMap<String, Long> getAllModuleNameAndIdMap(); VXUser updateXUser(VXUser vXUser); VXUserGroupInfo createXUserGroupFromMap(VXUserGroupInfo vXUserGroupInfo); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) VXGroupUserInfo createXGroupUserFromMap(
			VXGroupUserInfo vXGroupUserInfo); VXGroupUserInfo getXGroupUserFromMap(
			String groupName); VXUser createXUserWithOutLogin(VXUser vXUser); VXUser createExternalUser(String userName); VXGroup createXGroup(VXGroup vXGroup); VXGroup createXGroupWithoutLogin(VXGroup vXGroup); VXGroupUser createXGroupUser(VXGroupUser vXGroupUser); VXUser getXUser(Long id); VXGroupUser getXGroupUser(Long id); VXGroup getXGroup(Long id); void deleteXGroupAndXUser(String groupName, String userName); VXGroupList getXUserGroups(Long xUserId); Set<String> getGroupsForUser(String userName); VXUserList getXGroupUsers(SearchCriteria searchCriteria); @Override VXGroup updateXGroup(VXGroup vXGroup); VXGroupUser updateXGroupUser(VXGroupUser vXGroupUser); void deleteXGroupUser(Long id, boolean force); VXGroupGroup createXGroupGroup(VXGroupGroup vXGroupGroup); VXGroupGroup updateXGroupGroup(VXGroupGroup vXGroupGroup); void deleteXGroupGroup(Long id, boolean force); void deleteXPermMap(Long id, boolean force); VXLong getXPermMapSearchCount(SearchCriteria searchCriteria); void deleteXAuditMap(Long id, boolean force); VXLong getXAuditMapSearchCount(SearchCriteria searchCriteria); void modifyUserVisibility(HashMap<Long, Integer> visibilityMap); void modifyGroupsVisibility(HashMap<Long, Integer> groupVisibilityMap); VXModuleDef createXModuleDefPermission(VXModuleDef vXModuleDef); VXModuleDef getXModuleDefPermission(Long id); VXModuleDef updateXModuleDefPermission(VXModuleDef vXModuleDef); void deleteXModuleDefPermission(Long id, boolean force); VXUserPermission createXUserPermission(VXUserPermission vXUserPermission); VXUserPermission getXUserPermission(Long id); VXUserPermission updateXUserPermission(VXUserPermission vXUserPermission); void deleteXUserPermission(Long id, boolean force); VXGroupPermission createXGroupPermission(VXGroupPermission vXGroupPermission); VXGroupPermission getXGroupPermission(Long id); VXGroupPermission updateXGroupPermission(VXGroupPermission vXGroupPermission); void deleteXGroupPermission(Long id, boolean force); void modifyUserActiveStatus(HashMap<Long, Integer> statusMap); void checkAdminAccess(); void checkAccess(String loginID); VXPermMapList searchXPermMaps(SearchCriteria searchCriteria); VXAuditMapList searchXAuditMaps(SearchCriteria searchCriteria); void checkAccessRoles(List<String> stringRolesList); VXStringList setUserRolesByExternalID(Long userId, List<VXString> vStringRolesList); VXStringList setUserRolesByName(String userName, List<VXString> vStringRolesList); List<String> updateUserRoleAssignments(VXUsersGroupRoleAssignments ugRoleAssignments); VXStringList getUserRolesByExternalID(Long userId); VXStringList getUserRolesByName(String userName); void updateUserRolesPermissions(VXPortalUser oldUserProfile,List<String> roleListNewProfile); VXStringList getStringListFromUserRoleList(
			List<XXPortalUserRole> listXXPortalUserRole); boolean hasAccess(String loginID); VXUser getMaskedVXUser(VXUser vXUser); VXGroup getMaskedVXGroup(VXGroup vXGroup); @Override VXUserList searchXUsers(SearchCriteria searchCriteria); @Override VXGroupList searchXGroups(SearchCriteria searchCriteria); VXGroupList lookupXGroups(SearchCriteria searchCriteria); Collection<String> getMaskedCollection(Collection<String> listunMasked); boolean hasAccessToModule(String moduleName); void deleteXGroup(Long id, boolean force); synchronized void deleteXUser(Long id, boolean force); void restrictSelfAccountDeletion(String loginID); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) VXUser createServiceConfigUser(String userName); void denySelfRoleChange(String userName); @Transactional(readOnly = false, propagation = Propagation.REQUIRED) synchronized VXUgsyncAuditInfo postUserGroupAuditInfo(
			VXUgsyncAuditInfo vxUgsyncAuditInfo); Long getUserStoreVersion(); Set<UserInfo> getUsers(); Set<GroupInfo> getGroups(); Map<String, Set<String>> getUserGroups(); RangerUserStore getRangerUserStore(Long lastKnownUserStoreVersion);  }