use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.
the class XUserMgr method deleteXGroupPermission.
public void deleteXGroupPermission(Long id, boolean force) {
XXGroupPermission xGrpPerm = daoManager.getXXGroupPermission().getById(id);
if (xGrpPerm == null) {
throw restErrorUtil.createRESTException("No GroupPermission object with ID: [" + id + "found.", MessageEnums.DATA_NOT_FOUND);
}
xGroupPermissionService.deleteResource(id);
List<XXGroupUser> grpUsers = daoManager.getXXGroupUser().findByGroupId(xGrpPerm.getGroupId());
for (XXGroupUser xGrpUser : grpUsers) {
Set<UserSessionBase> userSessions = sessionMgr.getActiveUserSessionsForXUserId(xGrpUser.getUserId());
if (!CollectionUtils.isEmpty(userSessions)) {
for (UserSessionBase userSession : userSessions) {
logger.info("deleting permission of the group whose one of the user found logged in into system, so updating permission in session of that user");
sessionMgr.resetUserModulePermission(userSession);
}
}
}
}
use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.
the class XGroupUserService method createXGroupUserWithOutLogin.
public VXGroupUser createXGroupUserWithOutLogin(VXGroupUser vxGroupUser) {
boolean groupUserMappingExists = true;
XXGroupUser xxGroupUser = daoManager.getXXGroupUser().findByGroupNameAndUserId(vxGroupUser.getName(), vxGroupUser.getUserId());
if (xxGroupUser == null) {
xxGroupUser = new XXGroupUser();
groupUserMappingExists = false;
}
XXGroup xGroup = daoManager.getXXGroup().findByGroupName(vxGroupUser.getName());
vxGroupUser.setParentGroupId(xGroup.getId());
xxGroupUser = mapViewToEntityBean(vxGroupUser, xxGroupUser, 0);
XXPortalUser xXPortalUser = daoManager.getXXPortalUser().getById(createdByUserId);
if (xXPortalUser != null) {
xxGroupUser.setAddedByUserId(createdByUserId);
xxGroupUser.setUpdatedByUserId(createdByUserId);
}
if (groupUserMappingExists) {
xxGroupUser = getDao().update(xxGroupUser);
} else {
xxGroupUser = getDao().create(xxGroupUser);
}
vxGroupUser = postCreate(xxGroupUser);
return vxGroupUser;
}
use of org.apache.ranger.entity.XXGroupUser in project ranger by apache.
the class TestXUserMgr method test17UpdateXGroup.
@Test
public void test17UpdateXGroup() {
XXGroupDao xxGroupDao = Mockito.mock(XXGroupDao.class);
XXGroupUserDao xxGroupUserDao = Mockito.mock(XXGroupUserDao.class);
List<XXGroupUser> grpUsers = new ArrayList<XXGroupUser>();
setup();
VXGroup vXGroup = new VXGroup();
vXGroup.setId(userId);
vXGroup.setDescription("group test");
vXGroup.setName("grouptest");
XXGroup xxGroup = new XXGroup();
Mockito.when(daoManager.getXXGroup()).thenReturn(xxGroupDao);
Mockito.when(xxGroupDao.getById(vXGroup.getId())).thenReturn(xxGroup);
Mockito.when(xGroupService.updateResource(vXGroup)).thenReturn(vXGroup);
Mockito.when(daoManager.getXXGroupUser()).thenReturn(xxGroupUserDao);
Mockito.when(xxGroupUserDao.findByGroupId(vXGroup.getId())).thenReturn(grpUsers);
VXGroup dbvxGroup = xUserMgr.updateXGroup(vXGroup);
Assert.assertNotNull(dbvxGroup);
userId = dbvxGroup.getId();
Assert.assertEquals(userId, dbvxGroup.getId());
Assert.assertEquals(vXGroup.getDescription(), dbvxGroup.getDescription());
Assert.assertEquals(vXGroup.getName(), dbvxGroup.getName());
Mockito.verify(daoManager).getXXGroup();
Mockito.verify(daoManager).getXXGroupUser();
Mockito.verify(xGroupService).updateResource(vXGroup);
Mockito.verify(xxGroupUserDao).findByGroupId(vXGroup.getId());
}
Aggregations