Search in sources :

Example 1 with RangerServiceTag

use of org.apache.ranger.services.tag.RangerServiceTag in project ranger by apache.

the class ServiceMgr method getRangerServiceByService.

public RangerBaseService getRangerServiceByService(RangerService service, ServiceStore svcStore) throws Exception {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> ServiceMgr.getRangerServiceByService(" + service + ")");
    }
    RangerBaseService ret = null;
    String serviceType = service == null ? null : service.getType();
    if (!StringUtils.isEmpty(serviceType)) {
        RangerServiceDef serviceDef = svcStore == null ? null : svcStore.getServiceDefByName(serviceType);
        if (serviceDef != null) {
            Class<RangerBaseService> cls = getClassForServiceType(serviceDef);
            if (cls != null) {
                ret = cls.newInstance();
                ret.init(serviceDef, service);
                if (ret instanceof RangerServiceTag) {
                    ((RangerServiceTag) ret).setTagStore(tagStore);
                }
            } else {
                LOG.warn("ServiceMgr.getRangerServiceByService(" + service + "): could not find service class '" + serviceDef.getImplClass() + "' for the service type '" + serviceType + "'");
            }
        } else {
            LOG.warn("ServiceMgr.getRangerServiceByService(" + service + "): could not find the service-def for the service type '" + serviceType + "'");
        }
    } else {
        LOG.warn("ServiceMgr.getRangerServiceByService(" + service + "): could not find the service-type '" + serviceType + "'");
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== ServiceMgr.getRangerServiceByService(" + service + "): " + ret);
    }
    return ret;
}
Also used : RangerBaseService(org.apache.ranger.plugin.service.RangerBaseService) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerServiceTag(org.apache.ranger.services.tag.RangerServiceTag)

Aggregations

RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)1 RangerBaseService (org.apache.ranger.plugin.service.RangerBaseService)1 RangerServiceTag (org.apache.ranger.services.tag.RangerServiceTag)1