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;
}
Aggregations