Search in sources :

Example 61 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class RangerServiceService method preDelete.

protected XXService preDelete(Long id) {
    XXService ret = super.preDelete(id);
    if (ret != null) {
        XXServiceVersionInfoDao serviceVersionInfoDao = daoMgr.getXXServiceVersionInfo();
        XXServiceVersionInfo serviceVersionInfo = serviceVersionInfoDao.findByServiceId(id);
        if (serviceVersionInfo != null) {
            serviceVersionInfoDao.remove(serviceVersionInfo.getId());
        }
    }
    return ret;
}
Also used : XXService(org.apache.ranger.entity.XXService) XXServiceVersionInfo(org.apache.ranger.entity.XXServiceVersionInfo) XXServiceVersionInfoDao(org.apache.ranger.db.XXServiceVersionInfoDao)

Example 62 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class RangerServiceServiceBase method mapEntityToViewBean.

@Override
protected V mapEntityToViewBean(V vObj, T xObj) {
    XXServiceDef xServiceDef = daoMgr.getXXServiceDef().getById(xObj.getType());
    XXService xTagService = xObj.getTagService() != null ? daoMgr.getXXService().getById(xObj.getTagService()) : null;
    vObj.setType(xServiceDef.getName());
    vObj.setGuid(xObj.getGuid());
    vObj.setVersion(xObj.getVersion());
    vObj.setName(xObj.getName());
    vObj.setDescription(xObj.getDescription());
    vObj.setTagService(xTagService != null ? xTagService.getName() : null);
    XXServiceVersionInfo versionInfoObj = daoMgr.getXXServiceVersionInfo().findByServiceId(xObj.getId());
    if (versionInfoObj != null) {
        vObj.setPolicyVersion(versionInfoObj.getPolicyVersion());
        vObj.setTagVersion(versionInfoObj.getTagVersion());
        vObj.setPolicyUpdateTime(versionInfoObj.getPolicyUpdateTime());
        vObj.setTagUpdateTime(versionInfoObj.getTagUpdateTime());
    } else {
        vObj.setPolicyVersion(xObj.getPolicyVersion());
        vObj.setTagVersion(xObj.getTagVersion());
        vObj.setPolicyUpdateTime(xObj.getPolicyUpdateTime());
        vObj.setTagUpdateTime(xObj.getTagUpdateTime());
    }
    vObj.setIsEnabled(xObj.getIsenabled());
    return vObj;
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) XXService(org.apache.ranger.entity.XXService) XXServiceVersionInfo(org.apache.ranger.entity.XXServiceVersionInfo)

Example 63 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class TestRangerPolicyService method test8getTransactionLog.

@Test
public void test8getTransactionLog() {
    XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
    RangerPolicy rangerPolicy = rangerPolicy();
    XXService xService = xService();
    Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
    Mockito.when(xServiceDao.findByName(rangerPolicy.getService())).thenReturn(xService);
    List<XXTrxLog> dbXXTrxLogList = policyService.getTransactionLog(rangerPolicy, 1);
    Assert.assertNotNull(dbXXTrxLogList);
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) XXTrxLog(org.apache.ranger.entity.XXTrxLog) XXServiceDao(org.apache.ranger.db.XXServiceDao) XXService(org.apache.ranger.entity.XXService) Test(org.junit.Test)

Example 64 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class TestRangerPolicyServiceBase method test1mapViewToEntityBean.

@Test
public void test1mapViewToEntityBean() {
    XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
    XXService xService = Mockito.mock(XXService.class);
    RangerPolicy rangerPolicy = rangerPolicy();
    XXPolicy policy = policy();
    int OPERATION_CONTEXT = 0;
    Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
    Mockito.when(xServiceDao.findByName(rangerPolicy.getService())).thenReturn(xService);
    XXPolicy dbPolicy = policyService.mapViewToEntityBean(rangerPolicy, policy, OPERATION_CONTEXT);
    Assert.assertNotNull(dbPolicy);
    Assert.assertEquals(dbPolicy.getId(), policy.getId());
    Assert.assertEquals(dbPolicy.getGuid(), policy.getGuid());
    Assert.assertEquals(dbPolicy.getName(), policy.getName());
    Assert.assertEquals(dbPolicy.getAddedByUserId(), policy.getAddedByUserId());
    Assert.assertEquals(dbPolicy.getIsEnabled(), policy.getIsEnabled());
    Assert.assertEquals(dbPolicy.getVersion(), policy.getVersion());
    Assert.assertEquals(dbPolicy.getDescription(), policy.getDescription());
    Mockito.verify(daoManager).getXXService();
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) XXServiceDao(org.apache.ranger.db.XXServiceDao) XXService(org.apache.ranger.entity.XXService) XXPolicy(org.apache.ranger.entity.XXPolicy) Test(org.junit.Test)

Example 65 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class TestRangerServiceService method test4GetPopulatedViewObject.

@Test
public void test4GetPopulatedViewObject() {
    XXServiceConfigMapDao xServiceConfigMapDao = Mockito.mock(XXServiceConfigMapDao.class);
    XXPortalUserDao xPortalUserDao = Mockito.mock(XXPortalUserDao.class);
    XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
    XXService xService = xService();
    String name = "fdfdfds";
    List<XXServiceConfigMap> svcConfigMapList = new ArrayList<XXServiceConfigMap>();
    XXServiceConfigMap xConfMap = new XXServiceConfigMap();
    xConfMap.setAddedByUserId(null);
    xConfMap.setConfigkey(name);
    xConfMap.setConfigvalue(name);
    xConfMap.setCreateTime(new Date());
    xConfMap.setServiceId(null);
    xConfMap.setUpdatedByUserId(null);
    xConfMap.setUpdateTime(new Date());
    svcConfigMapList.add(xConfMap);
    XXPortalUser tUser = new XXPortalUser();
    tUser.setAddedByUserId(userId);
    tUser.setCreateTime(new Date());
    tUser.setEmailAddress("test@gmail.com");
    tUser.setFirstName(name);
    tUser.setId(userId);
    tUser.setLastName(name);
    XXServiceDef xServiceDef = new XXServiceDef();
    xServiceDef.setAddedByUserId(userId);
    xServiceDef.setCreateTime(new Date());
    xServiceDef.setDescription("test");
    xServiceDef.setGuid("1427365526516_835_0");
    xServiceDef.setId(userId);
    XXServiceVersionInfoDao xServiceVersionInfoDao = Mockito.mock(XXServiceVersionInfoDao.class);
    XXServiceVersionInfo serviceVersionInfo = new XXServiceVersionInfo();
    serviceVersionInfo.setServiceId(xService.getId());
    serviceVersionInfo.setPolicyVersion(xService.getPolicyVersion());
    serviceVersionInfo.setPolicyUpdateTime(xService.getPolicyUpdateTime());
    serviceVersionInfo.setTagVersion(xService.getTagVersion());
    serviceVersionInfo.setTagUpdateTime(xService.getTagUpdateTime());
    Mockito.when(daoManager.getXXServiceVersionInfo()).thenReturn(xServiceVersionInfoDao);
    Mockito.when(xServiceVersionInfoDao.findByServiceId(xService.getId())).thenReturn(serviceVersionInfo);
    Mockito.when(daoManager.getXXPortalUser()).thenReturn(xPortalUserDao);
    Mockito.when(xPortalUserDao.getById(userId)).thenReturn(tUser);
    Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
    Mockito.when(xServiceDefDao.getById(xService.getType())).thenReturn(xServiceDef);
    Mockito.when(daoManager.getXXServiceConfigMap()).thenReturn(xServiceConfigMapDao);
    Mockito.when(xServiceConfigMapDao.findByServiceId(xService.getId())).thenReturn(svcConfigMapList);
    RangerService dbService = serviceService.getPopulatedViewObject(xService);
    Assert.assertNotNull(dbService);
    Assert.assertEquals(userId, dbService.getId());
    Assert.assertEquals(xService.getAddedByUserId(), dbService.getId());
    Assert.assertEquals(xService.getId(), dbService.getId());
    Assert.assertEquals(xService.getDescription(), dbService.getDescription());
    Assert.assertEquals(xService.getGuid(), dbService.getGuid());
    Assert.assertEquals(xService.getName(), dbService.getName());
    Assert.assertEquals(xService.getPolicyUpdateTime(), dbService.getPolicyUpdateTime());
    Assert.assertEquals(xService.getPolicyVersion(), dbService.getPolicyVersion());
    Assert.assertEquals(xService.getVersion(), dbService.getVersion());
    Mockito.verify(daoManager).getXXServiceDef();
    Mockito.verify(daoManager).getXXServiceConfigMap();
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) ArrayList(java.util.ArrayList) XXServiceConfigMapDao(org.apache.ranger.db.XXServiceConfigMapDao) Date(java.util.Date) XXServiceConfigMap(org.apache.ranger.entity.XXServiceConfigMap) XXPortalUser(org.apache.ranger.entity.XXPortalUser) XXServiceDefDao(org.apache.ranger.db.XXServiceDefDao) XXPortalUserDao(org.apache.ranger.db.XXPortalUserDao) RangerService(org.apache.ranger.plugin.model.RangerService) XXService(org.apache.ranger.entity.XXService) XXServiceVersionInfo(org.apache.ranger.entity.XXServiceVersionInfo) XXServiceVersionInfoDao(org.apache.ranger.db.XXServiceVersionInfoDao) Test(org.junit.Test)

Aggregations

XXService (org.apache.ranger.entity.XXService)73 XXServiceDef (org.apache.ranger.entity.XXServiceDef)34 RangerService (org.apache.ranger.plugin.model.RangerService)23 Test (org.junit.Test)21 XXServiceDao (org.apache.ranger.db.XXServiceDao)19 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)19 VXString (org.apache.ranger.view.VXString)19 XXServiceDefDao (org.apache.ranger.db.XXServiceDefDao)17 ArrayList (java.util.ArrayList)14 XXServiceVersionInfo (org.apache.ranger.entity.XXServiceVersionInfo)14 Date (java.util.Date)13 WebApplicationException (javax.ws.rs.WebApplicationException)11 IOException (java.io.IOException)9 ServiceTags (org.apache.ranger.plugin.util.ServiceTags)9 XXServiceVersionInfoDao (org.apache.ranger.db.XXServiceVersionInfoDao)7 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)7 UnknownHostException (java.net.UnknownHostException)6 XXServiceConfigMap (org.apache.ranger.entity.XXServiceConfigMap)6 JSONException (org.codehaus.jettison.json.JSONException)6 HashMap (java.util.HashMap)5