@Test public void test97updateXModuleDefPermission() { XXModuleDefDao xModuleDefDao = Mockito.mock(XXModuleDefDao.class); XXModuleDef xModuleDef = xxModuleDef(); XXUserPermissionDao xUserPermissionDao = Mockito.mock(XXUserPermissionDao.class); XXGroupPermissionDao xGroupPermissionDao = Mockito.mock(XXGroupPermissionDao.class); VXModuleDef vXModuleDef = vxModuleDef(); Mockito.when(xModuleDefService.updateResource(vXModuleDef)).thenReturn(vXModuleDef); Mockito.when(daoManager.getXXModuleDef()).thenReturn(xModuleDefDao); Mockito.when(xModuleDefDao.getById(userId)).thenReturn(xModuleDef); Mockito.when(xModuleDefService.populateViewBean(xModuleDef)).thenReturn(vXModuleDef); Mockito.when(daoManager.getXXUserPermission()).thenReturn(xUserPermissionDao); Mockito.when(daoManager.getXXGroupPermission()).thenReturn(xGroupPermissionDao); List<XXGroupPermission> xXGroupPermissions=new ArrayList<XXGroupPermission>(); XXGroupPermission xGroupPermissionObj = xxGroupPermission(); xXGroupPermissions.add(xGroupPermissionObj); List<VXGroupPermission> vXGroupPermissions=new ArrayList<VXGroupPermission>(); VXGroupPermission vXGroupPermission=vxGroupPermission(); vXGroupPermission.setIsAllowed(0); Mockito.when(xGroupPermissionDao.findByModuleId(vXModuleDef.getId(),true)).thenReturn(xXGroupPermissions); List<XXUserPermission> xXUserPermissions=new ArrayList<XXUserPermission>(); XXUserPermission xUserPermissionObj=xxUserPermission(); xXUserPermissions.add(xUserPermissionObj); VXUserPermission vxUserPermission=vxUserPermission(); vxUserPermission.setIsAllowed(0); Mockito.when(xUserPermissionDao.findByModuleId(vXModuleDef.getId(),true)).thenReturn(xXUserPermissions); UserSessionBase userSession = Mockito.mock(UserSessionBase.class); Set<UserSessionBase> userSessions = new HashSet<UserSessionBase>(); userSessions.add(userSession); Map<Long, XXGroup> xXGroupMap =new HashMap<Long, XXGroup>(); VXGroup vxGroup=vxGroup(); XXGroup xxGroup = new XXGroup(); xxGroup.setId(vxGroup.getId()); xxGroup.setName(vxGroup.getName()); xxGroup.setDescription(vxGroup.getDescription()); xxGroup.setIsVisible(vxGroup.getIsVisible()); xXGroupMap.put(xGroupPermissionObj.getGroupId(), xxGroup); Mockito.when(xGroupService.getXXGroupIdXXGroupMap()).thenReturn(xXGroupMap); Map<Long, XXUser> xXUserMap =new HashMap<Long, XXUser>(); VXUser vxUser=vxUser(); XXUser xXUser=xxUser(vxUser); xXUserMap.put(xXUser.getId(), xXUser); Mockito.when(xUserService.getXXPortalUserIdXXUserMap()).thenReturn(xXUserMap); Mockito.when(xGroupPermissionService.getPopulatedVXGroupPermissionList(xXGroupPermissions,xXGroupMap,vXModuleDef)).thenReturn(vXGroupPermissions); XXGroupUserDao xxGroupUserDao = Mockito.mock(XXGroupUserDao.class); Mockito.when(daoManager.getXXGroupUser()).thenReturn(xxGroupUserDao); List<XXGroupUser> grpUsers =new ArrayList<XXGroupUser>(); Mockito.when(xxGroupUserDao.findByGroupId(vXGroupPermission.getGroupId())).thenReturn(grpUsers); List<VXUserPermission> userPermListOld = new ArrayList<VXUserPermission>(); Mockito.when(xUserPermissionService.getPopulatedVXUserPermissionList(xXUserPermissions,xXUserMap,vXModuleDef)).thenReturn(userPermListOld); Mockito.when(sessionMgr.getActiveUserSessionsForPortalUserId(vxUserPermission.getUserId())).thenReturn(userSessions); Mockito.when(xGroupPermissionService.createResource((VXGroupPermission) Mockito.any())).thenReturn(vXGroupPermission); Mockito.when(xUserPermissionService.createResource((VXUserPermission) Mockito.any())).thenReturn(vxUserPermission); VXModuleDef dbMuduleDef = xUserMgr.updateXModuleDefPermission(vXModuleDef); Assert.assertEquals(dbMuduleDef, vXModuleDef); Assert.assertNotNull(dbMuduleDef); Assert.assertEquals(dbMuduleDef, vXModuleDef); Assert.assertEquals(dbMuduleDef.getId(), vXModuleDef.getId()); Assert.assertEquals(dbMuduleDef.getOwner(), vXModuleDef.getOwner()); Assert.assertEquals(dbMuduleDef.getUpdatedBy(),vXModuleDef.getUpdatedBy()); Assert.assertEquals(dbMuduleDef.getUrl(), vXModuleDef.getUrl()); Assert.assertEquals(dbMuduleDef.getAddedById(),vXModuleDef.getAddedById()); Assert.assertEquals(dbMuduleDef.getCreateDate(),vXModuleDef.getCreateDate()); Assert.assertEquals(dbMuduleDef.getCreateTime(),vXModuleDef.getCreateTime()); Assert.assertEquals(dbMuduleDef.getUserPermList(),vXModuleDef.getUserPermList()); Assert.assertEquals(dbMuduleDef.getGroupPermList(),vXModuleDef.getGroupPermList()); Mockito.verify(xModuleDefService).updateResource(vXModuleDef); Mockito.verify(daoManager).getXXModuleDef(); Mockito.verify(xModuleDefService).populateViewBean(xModuleDef); Mockito.verify(daoManager).getXXUserPermission(); Mockito.verify(daoManager).getXXGroupPermission(); }
public VXModuleDef updateXModuleDefPermission(VXModuleDef vXModuleDef) { List<VXGroupPermission> groupPermListNew = vXModuleDef.getGroupPermList(); List<VXUserPermission> userPermListNew = vXModuleDef.getUserPermList(); List<VXGroupPermission> groupPermListOld = new ArrayList<VXGroupPermission>(); List<VXUserPermission> userPermListOld = new ArrayList<VXUserPermission>(); XXModuleDef xModuleDef = daoManager.getXXModuleDef().getById(vXModuleDef.getId()); if(!StringUtils.equals(xModuleDef.getModule(), vXModuleDef.getModule())) { throw restErrorUtil.createRESTException("Module name change is not allowed!", MessageEnums.DATA_NOT_UPDATABLE); } VXModuleDef vModuleDefPopulateOld = xModuleDefService.populateViewBean(xModuleDef); List<XXGroupPermission> xgroupPermissionList = daoManager.getXXGroupPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXGroup> xXGroupMap=xGroupService.getXXGroupIdXXGroupMap(); if(xXGroupMap==null || xXGroupMap.isEmpty()){ for (XXGroupPermission xGrpPerm : xgroupPermissionList) { VXGroupPermission vXGrpPerm = xGroupPermissionService.populateViewBean(xGrpPerm); groupPermListOld.add(vXGrpPerm); } }else{ groupPermListOld=xGroupPermissionService.getPopulatedVXGroupPermissionList(xgroupPermissionList,xXGroupMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setGroupPermList(groupPermListOld); List<XXUserPermission> xuserPermissionList = daoManager.getXXUserPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXUser> xXPortalUserIdXXUserMap=xUserService.getXXPortalUserIdXXUserMap(); if(xXPortalUserIdXXUserMap==null || xXPortalUserIdXXUserMap.isEmpty()){ for (XXUserPermission xUserPerm : xuserPermissionList) { VXUserPermission vUserPerm = xUserPermissionService.populateViewBean(xUserPerm); userPermListOld.add(vUserPerm); } }else{ userPermListOld=xUserPermissionService.getPopulatedVXUserPermissionList(xuserPermissionList,xXPortalUserIdXXUserMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setUserPermList(userPermListOld); if (groupPermListOld != null && groupPermListNew != null) { for (VXGroupPermission newVXGroupPerm : groupPermListNew) { boolean isExist = false; for (VXGroupPermission oldVXGroupPerm : groupPermListOld) { if (newVXGroupPerm.getModuleId().equals(oldVXGroupPerm.getModuleId()) && newVXGroupPerm.getGroupId().equals(oldVXGroupPerm.getGroupId())) { if (!newVXGroupPerm.getIsAllowed().equals(oldVXGroupPerm.getIsAllowed())) { oldVXGroupPerm.setIsAllowed(newVXGroupPerm.getIsAllowed()); oldVXGroupPerm = this.updateXGroupPermission(oldVXGroupPerm); } isExist = true; } } if (!isExist) { newVXGroupPerm = this.createXGroupPermission(newVXGroupPerm); } } } if (userPermListOld != null && userPermListNew != null) { for (VXUserPermission newVXUserPerm : userPermListNew) { boolean isExist = false; for (VXUserPermission oldVXUserPerm : userPermListOld) { if (newVXUserPerm.getModuleId().equals(oldVXUserPerm.getModuleId()) && newVXUserPerm.getUserId().equals(oldVXUserPerm.getUserId())) { if (!newVXUserPerm.getIsAllowed().equals(oldVXUserPerm.getIsAllowed())) { oldVXUserPerm.setIsAllowed(newVXUserPerm.getIsAllowed()); oldVXUserPerm = this.updateXUserPermission(oldVXUserPerm); } isExist = true; } } if (!isExist) { newVXUserPerm = this.createXUserPermission(newVXUserPerm); } } } vXModuleDef = xModuleDefService.updateResource(vXModuleDef); return vXModuleDef; }
XUserMgr extends XUserMgrBase { public VXModuleDef updateXModuleDefPermission(VXModuleDef vXModuleDef) { List<VXGroupPermission> groupPermListNew = vXModuleDef.getGroupPermList(); List<VXUserPermission> userPermListNew = vXModuleDef.getUserPermList(); List<VXGroupPermission> groupPermListOld = new ArrayList<VXGroupPermission>(); List<VXUserPermission> userPermListOld = new ArrayList<VXUserPermission>(); XXModuleDef xModuleDef = daoManager.getXXModuleDef().getById(vXModuleDef.getId()); if(!StringUtils.equals(xModuleDef.getModule(), vXModuleDef.getModule())) { throw restErrorUtil.createRESTException("Module name change is not allowed!", MessageEnums.DATA_NOT_UPDATABLE); } VXModuleDef vModuleDefPopulateOld = xModuleDefService.populateViewBean(xModuleDef); List<XXGroupPermission> xgroupPermissionList = daoManager.getXXGroupPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXGroup> xXGroupMap=xGroupService.getXXGroupIdXXGroupMap(); if(xXGroupMap==null || xXGroupMap.isEmpty()){ for (XXGroupPermission xGrpPerm : xgroupPermissionList) { VXGroupPermission vXGrpPerm = xGroupPermissionService.populateViewBean(xGrpPerm); groupPermListOld.add(vXGrpPerm); } }else{ groupPermListOld=xGroupPermissionService.getPopulatedVXGroupPermissionList(xgroupPermissionList,xXGroupMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setGroupPermList(groupPermListOld); List<XXUserPermission> xuserPermissionList = daoManager.getXXUserPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXUser> xXPortalUserIdXXUserMap=xUserService.getXXPortalUserIdXXUserMap(); if(xXPortalUserIdXXUserMap==null || xXPortalUserIdXXUserMap.isEmpty()){ for (XXUserPermission xUserPerm : xuserPermissionList) { VXUserPermission vUserPerm = xUserPermissionService.populateViewBean(xUserPerm); userPermListOld.add(vUserPerm); } }else{ userPermListOld=xUserPermissionService.getPopulatedVXUserPermissionList(xuserPermissionList,xXPortalUserIdXXUserMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setUserPermList(userPermListOld); if (groupPermListOld != null && groupPermListNew != null) { for (VXGroupPermission newVXGroupPerm : groupPermListNew) { boolean isExist = false; for (VXGroupPermission oldVXGroupPerm : groupPermListOld) { if (newVXGroupPerm.getModuleId().equals(oldVXGroupPerm.getModuleId()) && newVXGroupPerm.getGroupId().equals(oldVXGroupPerm.getGroupId())) { if (!newVXGroupPerm.getIsAllowed().equals(oldVXGroupPerm.getIsAllowed())) { oldVXGroupPerm.setIsAllowed(newVXGroupPerm.getIsAllowed()); oldVXGroupPerm = this.updateXGroupPermission(oldVXGroupPerm); } isExist = true; } } if (!isExist) { newVXGroupPerm = this.createXGroupPermission(newVXGroupPerm); } } } if (userPermListOld != null && userPermListNew != null) { for (VXUserPermission newVXUserPerm : userPermListNew) { boolean isExist = false; for (VXUserPermission oldVXUserPerm : userPermListOld) { if (newVXUserPerm.getModuleId().equals(oldVXUserPerm.getModuleId()) && newVXUserPerm.getUserId().equals(oldVXUserPerm.getUserId())) { if (!newVXUserPerm.getIsAllowed().equals(oldVXUserPerm.getIsAllowed())) { oldVXUserPerm.setIsAllowed(newVXUserPerm.getIsAllowed()); oldVXUserPerm = this.updateXUserPermission(oldVXUserPerm); } isExist = true; } } if (!isExist) { newVXUserPerm = this.createXUserPermission(newVXUserPerm); } } } vXModuleDef = xModuleDefService.updateResource(vXModuleDef); return vXModuleDef; } }
XUserMgr extends XUserMgrBase { public VXModuleDef updateXModuleDefPermission(VXModuleDef vXModuleDef) { List<VXGroupPermission> groupPermListNew = vXModuleDef.getGroupPermList(); List<VXUserPermission> userPermListNew = vXModuleDef.getUserPermList(); List<VXGroupPermission> groupPermListOld = new ArrayList<VXGroupPermission>(); List<VXUserPermission> userPermListOld = new ArrayList<VXUserPermission>(); XXModuleDef xModuleDef = daoManager.getXXModuleDef().getById(vXModuleDef.getId()); if(!StringUtils.equals(xModuleDef.getModule(), vXModuleDef.getModule())) { throw restErrorUtil.createRESTException("Module name change is not allowed!", MessageEnums.DATA_NOT_UPDATABLE); } VXModuleDef vModuleDefPopulateOld = xModuleDefService.populateViewBean(xModuleDef); List<XXGroupPermission> xgroupPermissionList = daoManager.getXXGroupPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXGroup> xXGroupMap=xGroupService.getXXGroupIdXXGroupMap(); if(xXGroupMap==null || xXGroupMap.isEmpty()){ for (XXGroupPermission xGrpPerm : xgroupPermissionList) { VXGroupPermission vXGrpPerm = xGroupPermissionService.populateViewBean(xGrpPerm); groupPermListOld.add(vXGrpPerm); } }else{ groupPermListOld=xGroupPermissionService.getPopulatedVXGroupPermissionList(xgroupPermissionList,xXGroupMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setGroupPermList(groupPermListOld); List<XXUserPermission> xuserPermissionList = daoManager.getXXUserPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXUser> xXPortalUserIdXXUserMap=xUserService.getXXPortalUserIdXXUserMap(); if(xXPortalUserIdXXUserMap==null || xXPortalUserIdXXUserMap.isEmpty()){ for (XXUserPermission xUserPerm : xuserPermissionList) { VXUserPermission vUserPerm = xUserPermissionService.populateViewBean(xUserPerm); userPermListOld.add(vUserPerm); } }else{ userPermListOld=xUserPermissionService.getPopulatedVXUserPermissionList(xuserPermissionList,xXPortalUserIdXXUserMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setUserPermList(userPermListOld); if (groupPermListOld != null && groupPermListNew != null) { for (VXGroupPermission newVXGroupPerm : groupPermListNew) { boolean isExist = false; for (VXGroupPermission oldVXGroupPerm : groupPermListOld) { if (newVXGroupPerm.getModuleId().equals(oldVXGroupPerm.getModuleId()) && newVXGroupPerm.getGroupId().equals(oldVXGroupPerm.getGroupId())) { if (!newVXGroupPerm.getIsAllowed().equals(oldVXGroupPerm.getIsAllowed())) { oldVXGroupPerm.setIsAllowed(newVXGroupPerm.getIsAllowed()); oldVXGroupPerm = this.updateXGroupPermission(oldVXGroupPerm); } isExist = true; } } if (!isExist) { newVXGroupPerm = this.createXGroupPermission(newVXGroupPerm); } } } if (userPermListOld != null && userPermListNew != null) { for (VXUserPermission newVXUserPerm : userPermListNew) { boolean isExist = false; for (VXUserPermission oldVXUserPerm : userPermListOld) { if (newVXUserPerm.getModuleId().equals(oldVXUserPerm.getModuleId()) && newVXUserPerm.getUserId().equals(oldVXUserPerm.getUserId())) { if (!newVXUserPerm.getIsAllowed().equals(oldVXUserPerm.getIsAllowed())) { oldVXUserPerm.setIsAllowed(newVXUserPerm.getIsAllowed()); oldVXUserPerm = this.updateXUserPermission(oldVXUserPerm); } isExist = true; } } if (!isExist) { newVXUserPerm = this.createXUserPermission(newVXUserPerm); } } } vXModuleDef = xModuleDefService.updateResource(vXModuleDef); return vXModuleDef; }  }
XUserMgr extends XUserMgrBase { public VXModuleDef updateXModuleDefPermission(VXModuleDef vXModuleDef) { List<VXGroupPermission> groupPermListNew = vXModuleDef.getGroupPermList(); List<VXUserPermission> userPermListNew = vXModuleDef.getUserPermList(); List<VXGroupPermission> groupPermListOld = new ArrayList<VXGroupPermission>(); List<VXUserPermission> userPermListOld = new ArrayList<VXUserPermission>(); XXModuleDef xModuleDef = daoManager.getXXModuleDef().getById(vXModuleDef.getId()); if(!StringUtils.equals(xModuleDef.getModule(), vXModuleDef.getModule())) { throw restErrorUtil.createRESTException("Module name change is not allowed!", MessageEnums.DATA_NOT_UPDATABLE); } VXModuleDef vModuleDefPopulateOld = xModuleDefService.populateViewBean(xModuleDef); List<XXGroupPermission> xgroupPermissionList = daoManager.getXXGroupPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXGroup> xXGroupMap=xGroupService.getXXGroupIdXXGroupMap(); if(xXGroupMap==null || xXGroupMap.isEmpty()){ for (XXGroupPermission xGrpPerm : xgroupPermissionList) { VXGroupPermission vXGrpPerm = xGroupPermissionService.populateViewBean(xGrpPerm); groupPermListOld.add(vXGrpPerm); } }else{ groupPermListOld=xGroupPermissionService.getPopulatedVXGroupPermissionList(xgroupPermissionList,xXGroupMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setGroupPermList(groupPermListOld); List<XXUserPermission> xuserPermissionList = daoManager.getXXUserPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXUser> xXPortalUserIdXXUserMap=xUserService.getXXPortalUserIdXXUserMap(); if(xXPortalUserIdXXUserMap==null || xXPortalUserIdXXUserMap.isEmpty()){ for (XXUserPermission xUserPerm : xuserPermissionList) { VXUserPermission vUserPerm = xUserPermissionService.populateViewBean(xUserPerm); userPermListOld.add(vUserPerm); } }else{ userPermListOld=xUserPermissionService.getPopulatedVXUserPermissionList(xuserPermissionList,xXPortalUserIdXXUserMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setUserPermList(userPermListOld); if (groupPermListOld != null && groupPermListNew != null) { for (VXGroupPermission newVXGroupPerm : groupPermListNew) { boolean isExist = false; for (VXGroupPermission oldVXGroupPerm : groupPermListOld) { if (newVXGroupPerm.getModuleId().equals(oldVXGroupPerm.getModuleId()) && newVXGroupPerm.getGroupId().equals(oldVXGroupPerm.getGroupId())) { if (!newVXGroupPerm.getIsAllowed().equals(oldVXGroupPerm.getIsAllowed())) { oldVXGroupPerm.setIsAllowed(newVXGroupPerm.getIsAllowed()); oldVXGroupPerm = this.updateXGroupPermission(oldVXGroupPerm); } isExist = true; } } if (!isExist) { newVXGroupPerm = this.createXGroupPermission(newVXGroupPerm); } } } if (userPermListOld != null && userPermListNew != null) { for (VXUserPermission newVXUserPerm : userPermListNew) { boolean isExist = false; for (VXUserPermission oldVXUserPerm : userPermListOld) { if (newVXUserPerm.getModuleId().equals(oldVXUserPerm.getModuleId()) && newVXUserPerm.getUserId().equals(oldVXUserPerm.getUserId())) { if (!newVXUserPerm.getIsAllowed().equals(oldVXUserPerm.getIsAllowed())) { oldVXUserPerm.setIsAllowed(newVXUserPerm.getIsAllowed()); oldVXUserPerm = this.updateXUserPermission(oldVXUserPerm); } isExist = true; } } if (!isExist) { newVXUserPerm = this.createXUserPermission(newVXUserPerm); } } } vXModuleDef = xModuleDefService.updateResource(vXModuleDef); return vXModuleDef; }  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 VXModuleDef updateXModuleDefPermission(VXModuleDef vXModuleDef) { List<VXGroupPermission> groupPermListNew = vXModuleDef.getGroupPermList(); List<VXUserPermission> userPermListNew = vXModuleDef.getUserPermList(); List<VXGroupPermission> groupPermListOld = new ArrayList<VXGroupPermission>(); List<VXUserPermission> userPermListOld = new ArrayList<VXUserPermission>(); XXModuleDef xModuleDef = daoManager.getXXModuleDef().getById(vXModuleDef.getId()); if(!StringUtils.equals(xModuleDef.getModule(), vXModuleDef.getModule())) { throw restErrorUtil.createRESTException("Module name change is not allowed!", MessageEnums.DATA_NOT_UPDATABLE); } VXModuleDef vModuleDefPopulateOld = xModuleDefService.populateViewBean(xModuleDef); List<XXGroupPermission> xgroupPermissionList = daoManager.getXXGroupPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXGroup> xXGroupMap=xGroupService.getXXGroupIdXXGroupMap(); if(xXGroupMap==null || xXGroupMap.isEmpty()){ for (XXGroupPermission xGrpPerm : xgroupPermissionList) { VXGroupPermission vXGrpPerm = xGroupPermissionService.populateViewBean(xGrpPerm); groupPermListOld.add(vXGrpPerm); } }else{ groupPermListOld=xGroupPermissionService.getPopulatedVXGroupPermissionList(xgroupPermissionList,xXGroupMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setGroupPermList(groupPermListOld); List<XXUserPermission> xuserPermissionList = daoManager.getXXUserPermission().findByModuleId(vXModuleDef.getId(), true); Map<Long, XXUser> xXPortalUserIdXXUserMap=xUserService.getXXPortalUserIdXXUserMap(); if(xXPortalUserIdXXUserMap==null || xXPortalUserIdXXUserMap.isEmpty()){ for (XXUserPermission xUserPerm : xuserPermissionList) { VXUserPermission vUserPerm = xUserPermissionService.populateViewBean(xUserPerm); userPermListOld.add(vUserPerm); } }else{ userPermListOld=xUserPermissionService.getPopulatedVXUserPermissionList(xuserPermissionList,xXPortalUserIdXXUserMap,vModuleDefPopulateOld); } vModuleDefPopulateOld.setUserPermList(userPermListOld); if (groupPermListOld != null && groupPermListNew != null) { for (VXGroupPermission newVXGroupPerm : groupPermListNew) { boolean isExist = false; for (VXGroupPermission oldVXGroupPerm : groupPermListOld) { if (newVXGroupPerm.getModuleId().equals(oldVXGroupPerm.getModuleId()) && newVXGroupPerm.getGroupId().equals(oldVXGroupPerm.getGroupId())) { if (!newVXGroupPerm.getIsAllowed().equals(oldVXGroupPerm.getIsAllowed())) { oldVXGroupPerm.setIsAllowed(newVXGroupPerm.getIsAllowed()); oldVXGroupPerm = this.updateXGroupPermission(oldVXGroupPerm); } isExist = true; } } if (!isExist) { newVXGroupPerm = this.createXGroupPermission(newVXGroupPerm); } } } if (userPermListOld != null && userPermListNew != null) { for (VXUserPermission newVXUserPerm : userPermListNew) { boolean isExist = false; for (VXUserPermission oldVXUserPerm : userPermListOld) { if (newVXUserPerm.getModuleId().equals(oldVXUserPerm.getModuleId()) && newVXUserPerm.getUserId().equals(oldVXUserPerm.getUserId())) { if (!newVXUserPerm.getIsAllowed().equals(oldVXUserPerm.getIsAllowed())) { oldVXUserPerm.setIsAllowed(newVXUserPerm.getIsAllowed()); oldVXUserPerm = this.updateXUserPermission(oldVXUserPerm); } isExist = true; } } if (!isExist) { newVXUserPerm = this.createXUserPermission(newVXUserPerm); } } } vXModuleDef = xModuleDefService.updateResource(vXModuleDef); return vXModuleDef; }  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);  }