use of org.apache.ranger.entity.XXService in project ranger by apache.
the class ServiceDBStore method getPaginatedServicePolicies.
public PList<RangerPolicy> getPaginatedServicePolicies(Long serviceId, SearchFilter filter) throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("==> ServiceDBStore.getPaginatedServicePolicies(" + serviceId + ")");
}
XXService service = daoMgr.getXXService().getById(serviceId);
if (service == null) {
throw new Exception("service does not exist - id='" + serviceId);
}
PList<RangerPolicy> ret = getPaginatedServicePolicies(service.getName(), filter);
if (LOG.isDebugEnabled()) {
LOG.debug("<== ServiceDBStore.getPaginatedServicePolicies(" + serviceId + ")");
}
return ret;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class ServiceDBStore method getServicePoliciesIfUpdated.
@Override
public ServicePolicies getServicePoliciesIfUpdated(String serviceName, Long lastKnownVersion) throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("==> ServiceDBStore.getServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + ")");
}
ServicePolicies ret = null;
XXService serviceDbObj = daoMgr.getXXService().findByName(serviceName);
if (serviceDbObj == null) {
throw new Exception("service does not exist. name=" + serviceName);
}
XXServiceVersionInfo serviceVersionInfoDbObj = daoMgr.getXXServiceVersionInfo().findByServiceName(serviceName);
if (serviceVersionInfoDbObj == null) {
LOG.warn("serviceVersionInfo does not exist. name=" + serviceName);
}
if (lastKnownVersion == null || serviceVersionInfoDbObj == null || serviceVersionInfoDbObj.getPolicyVersion() == null || !lastKnownVersion.equals(serviceVersionInfoDbObj.getPolicyVersion())) {
ret = RangerServicePoliciesCache.getInstance().getServicePolicies(serviceName, serviceDbObj.getId(), this);
}
if (ret != null && lastKnownVersion != null && lastKnownVersion.equals(ret.getPolicyVersion())) {
// ServicePolicies are not changed
ret = null;
}
if (LOG.isDebugEnabled()) {
RangerServicePoliciesCache.getInstance().dump();
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== ServiceDBStore.getServicePoliciesIfUpdated(" + serviceName + ", " + lastKnownVersion + "): count=" + ((ret == null || ret.getPolicies() == null) ? 0 : ret.getPolicies().size()));
}
return ret;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerServiceService method getAllServices.
public List<RangerService> getAllServices() {
List<XXService> xxServiceList = daoMgr.getXXService().getAll();
List<RangerService> serviceList = new ArrayList<RangerService>();
for (XXService xxService : xxServiceList) {
RangerService service = populateViewBean(xxService);
serviceList.add(service);
}
return serviceList;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerServiceServiceBase method mapViewToEntityBean.
@Override
protected T mapViewToEntityBean(V vObj, T xObj, int OPERATION_CONTEXT) {
String guid = (StringUtils.isEmpty(vObj.getGuid())) ? guidUtil.genGUID() : vObj.getGuid();
xObj.setGuid(guid);
XXServiceDef xServiceDef = daoMgr.getXXServiceDef().findByName(vObj.getType());
if (xServiceDef == null) {
throw restErrorUtil.createRESTException("No ServiceDefinition found with name :" + vObj.getType(), MessageEnums.INVALID_INPUT_DATA);
}
Long tagServiceId = null;
String tagServiceName = vObj.getTagService();
if (!StringUtils.isEmpty(tagServiceName)) {
XXService xTagService = daoMgr.getXXService().findByName(tagServiceName);
if (xTagService == null) {
throw restErrorUtil.createRESTException("No Service found with name :" + tagServiceName, MessageEnums.INVALID_INPUT_DATA);
}
tagServiceId = xTagService.getId();
}
xObj.setType(xServiceDef.getId());
xObj.setName(vObj.getName());
xObj.setTagService(tagServiceId);
if (OPERATION_CONTEXT == OPERATION_CREATE_CONTEXT) {
xObj.setTagVersion(vObj.getTagVersion());
}
xObj.setDescription(vObj.getDescription());
xObj.setIsEnabled(vObj.getIsEnabled());
return xObj;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class XAccessAuditService method mapEntityToViewBean.
protected VXAccessAudit mapEntityToViewBean(VXAccessAudit vObj, XXAccessAudit mObj) {
vObj.setAuditType(mObj.getAuditType());
vObj.setAccessResult(mObj.getAccessResult());
vObj.setAccessType(mObj.getAccessType());
vObj.setAclEnforcer(mObj.getAclEnforcer());
vObj.setAgentId(mObj.getAgentId());
vObj.setPolicyId(mObj.getPolicyId());
vObj.setRepoName(mObj.getRepoName());
vObj.setRepoType(mObj.getRepoType());
vObj.setResultReason(mObj.getResultReason());
vObj.setSessionId(mObj.getSessionId());
vObj.setEventTime(mObj.getEventTime());
vObj.setRequestUser(mObj.getRequestUser());
vObj.setRequestData(mObj.getRequestData());
vObj.setResourcePath(mObj.getResourcePath());
vObj.setResourceType(mObj.getResourceType());
vObj.setClientIP(mObj.getClientIP());
vObj.setClientType(mObj.getClientType());
vObj.setSequenceNumber(mObj.getSequenceNumber());
vObj.setEventCount(mObj.getEventCount());
vObj.setEventDuration(mObj.getEventDuration());
vObj.setTags(mObj.getTags());
XXService xService = daoManager.getXXService().findByName(mObj.getRepoName());
if (xService != null) {
XXServiceDef xServiceDef = daoManager.getXXServiceDef().getById(xService.getType());
vObj.setServiceType(xServiceDef.getName());
}
return vObj;
}
Aggregations