use of org.apache.ranger.view.VXPermMap in project ranger by apache.
the class XResourceService method createResource.
@Override
public VXResource createResource(VXResource vXResource) {
VXResource resource = super.createResource(vXResource);
List<VXAuditMap> newAuditMapList = new ArrayList<VXAuditMap>();
List<VXAuditMap> vxAuditMapList = vXResource.getAuditList();
if (vxAuditMapList != null) {
for (VXAuditMap vxAuditMap : vxAuditMapList) {
vxAuditMap.setResourceId(resource.getId());
vxAuditMap = xAuditMapService.createResource(vxAuditMap);
newAuditMapList.add(vxAuditMap);
}
}
List<VXPermMap> newPermMapList = new ArrayList<VXPermMap>();
List<VXPermMap> vxPermMapList = vXResource.getPermMapList();
if (vxPermMapList != null) {
for (VXPermMap permMap : vxPermMapList) {
if (permMap.getUserId() == null && permMap.getGroupId() == null && vxAuditMapList == null) {
if (vxAuditMapList == null) {
throw restErrorUtil.createRESTException("Please provide" + " valid group/user permissions for policy.", MessageEnums.INVALID_INPUT_DATA);
}
} else {
permMap.setResourceId(resource.getId());
permMap = xPermMapService.createResource(permMap);
newPermMapList.add(permMap);
}
}
}
resource.setPermMapList(newPermMapList);
resource.setAuditList(newAuditMapList);
return resource;
}
use of org.apache.ranger.view.VXPermMap in project ranger by apache.
the class XResourceService method populatePermList.
private void populatePermList(VXResource vXResource) {
List<XXPermMap> xPermMapList = daoManager.getXXPermMap().findByResourceId(vXResource.getId());
List<VXPermMap> vXPermMapList = new ArrayList<VXPermMap>();
for (XXPermMap xPermMap : xPermMapList) {
vXPermMapList.add(xPermMapService.populateViewBean(xPermMap));
}
vXResource.setPermMapList(vXPermMapList);
}
use of org.apache.ranger.view.VXPermMap in project ranger by apache.
the class TestXUserREST method test46updateXPermMap.
@Test
public void test46updateXPermMap() {
VXPermMap permMap = testcreateXPermMap();
Mockito.when(xResourceService.readResource(permMap.getResourceId())).thenReturn(null);
Mockito.when(restErrorUtil.createRESTException(Mockito.anyString())).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
VXPermMap retVxGroup = xUserRest.updateXPermMap(permMap);
assertEquals(permMap.getId(), retVxGroup.getId());
assertEquals(permMap.getClass(), retVxGroup.getClass());
assertNotNull(retVxGroup);
Mockito.verify(xUserMgr).updateXPermMap(permMap);
Mockito.verify(xResourceService).readResource(permMap.getResourceId());
Mockito.verify(restErrorUtil).createRESTException(Mockito.anyString());
}
use of org.apache.ranger.view.VXPermMap in project ranger by apache.
the class TestXUserREST method test45updateXPermMap.
@Test
public void test45updateXPermMap() {
Mockito.when(xUserMgr.updateXPermMap(null)).thenReturn(null);
VXPermMap retVxGroup = xUserRest.updateXPermMap(null);
assertNull(retVxGroup);
Mockito.verify(xUserMgr).updateXPermMap(null);
}
use of org.apache.ranger.view.VXPermMap in project ranger by apache.
the class TestXUserREST method test41createXPermMap.
@Test
public void test41createXPermMap() {
VXPermMap permMap = testcreateXPermMap();
permMap.setResourceId(null);
Mockito.when(xResourceService.readResource(permMap.getResourceId())).thenReturn(null);
Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any())).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
VXPermMap retVxGroup = xUserRest.createXPermMap(permMap);
assertEquals(permMap.getId(), retVxGroup.getId());
assertEquals(permMap.getClass(), retVxGroup.getClass());
assertNotNull(retVxGroup);
Mockito.verify(xUserMgr).createXPermMap(permMap);
Mockito.verify(xResourceService).readResource(permMap.getResourceId());
Mockito.verify(restErrorUtil).createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any());
}
Aggregations