use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerPluginInfoService method searchRangerPluginInfo.
public PList<RangerPluginInfo> searchRangerPluginInfo(SearchFilter searchFilter) {
PList<RangerPluginInfo> retList = new PList<RangerPluginInfo>();
List<RangerPluginInfo> objList = new ArrayList<RangerPluginInfo>();
List<XXService> servicesWithTagService = daoManager.getXXService().getAllServicesWithTagService();
List<XXPluginInfo> xObjList = searchRangerObjects(searchFilter, searchFields, sortFields, retList);
List<Object[]> objectsList = null;
if (CollectionUtils.isNotEmpty(xObjList)) {
objectsList = daoManager.getXXServiceVersionInfo().getAllWithServiceNames();
}
for (XXPluginInfo xObj : xObjList) {
XXServiceVersionInfo xxServiceVersionInfo = null;
boolean hasAssociatedTagService = false;
if (CollectionUtils.isNotEmpty(objectsList)) {
for (Object[] objects : objectsList) {
if (objects.length == 2) {
if (xObj.getServiceName().equals(objects[1])) {
if (objects[0] instanceof XXServiceVersionInfo) {
xxServiceVersionInfo = (XXServiceVersionInfo) objects[0];
for (XXService service : servicesWithTagService) {
if (service.getName().equals(xObj.getServiceName())) {
hasAssociatedTagService = true;
break;
}
}
} else {
LOG.warn("Expected first object to be XXServiceVersionInfo, got " + objects[0]);
}
break;
}
} else {
LOG.warn("Expected 2 objects in the list returned by getAllWithServiceNames(), received " + objects.length);
}
}
}
RangerPluginInfo obj = populateViewObjectWithServiceVersionInfo(xObj, xxServiceVersionInfo, hasAssociatedTagService);
objList.add(obj);
}
retList.setList(objList);
return retList;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerPolicyServiceBase 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);
xObj.setVersion(vObj.getVersion());
XXService xService = daoMgr.getXXService().findByName(vObj.getService());
if (xService == null) {
throw restErrorUtil.createRESTException("No corresponding service found for policyName: " + vObj.getName() + "Service Not Found : " + vObj.getService(), MessageEnums.INVALID_INPUT_DATA);
}
xObj.setService(xService.getId());
xObj.setName(StringUtils.trim(vObj.getName()));
xObj.setPolicyType(vObj.getPolicyType() == null ? RangerPolicy.POLICY_TYPE_ACCESS : vObj.getPolicyType());
xObj.setPolicyPriority(vObj.getPolicyPriority() == null ? RangerPolicy.POLICY_PRIORITY_NORMAL : vObj.getPolicyPriority());
xObj.setDescription(vObj.getDescription());
xObj.setResourceSignature(vObj.getResourceSignature());
xObj.setIsAuditEnabled(vObj.getIsAuditEnabled());
xObj.setIsEnabled(vObj.getIsEnabled());
String validitySchedules = JsonUtils.listToJson(vObj.getValiditySchedules());
Map<String, Object> options = vObj.getOptions();
if (options == null) {
options = new HashMap<>();
}
if (StringUtils.isNotBlank(validitySchedules)) {
options.put(OPTION_POLICY_VALIDITY_SCHEDULES, validitySchedules);
} else {
options.remove(OPTION_POLICY_VALIDITY_SCHEDULES);
}
xObj.setOptions(JsonUtils.mapToJson(options));
return xObj;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerPolicyServiceBase method mapEntityToViewBean.
@Override
protected V mapEntityToViewBean(V vObj, T xObj) {
XXService xService = daoMgr.getXXService().getById(xObj.getService());
vObj.setGuid(xObj.getGuid());
vObj.setVersion(xObj.getVersion());
vObj.setService(xService.getName());
vObj.setName(StringUtils.trim(xObj.getName()));
vObj.setPolicyType(xObj.getPolicyType() == null ? RangerPolicy.POLICY_TYPE_ACCESS : xObj.getPolicyType());
vObj.setPolicyPriority(xObj.getPolicyPriority() == null ? RangerPolicy.POLICY_PRIORITY_NORMAL : xObj.getPolicyPriority());
vObj.setDescription(xObj.getDescription());
vObj.setResourceSignature(xObj.getResourceSignature());
vObj.setIsEnabled(xObj.getIsEnabled());
vObj.setIsAuditEnabled(xObj.getIsAuditEnabled());
Map<String, Object> options = JsonUtils.jsonToObject(xObj.getOptions(), Map.class);
if (MapUtils.isNotEmpty(options)) {
String optionPolicyValiditySchedule = (String) options.remove(OPTION_POLICY_VALIDITY_SCHEDULES);
if (StringUtils.isNotBlank(optionPolicyValiditySchedule)) {
List<RangerValiditySchedule> validitySchedules = JsonUtils.jsonToRangerValiditySchedule(optionPolicyValiditySchedule);
vObj.setValiditySchedules(validitySchedules);
}
}
vObj.setOptions(options);
return vObj;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerServiceResourceServiceBase method mapViewToEntityBean.
@Override
protected T mapViewToEntityBean(V vObj, T xObj, int operationContext) {
String guid = (StringUtils.isEmpty(vObj.getGuid())) ? guidUtil.genGUID() : vObj.getGuid();
xObj.setGuid(guid);
xObj.setVersion(vObj.getVersion());
xObj.setIsEnabled(vObj.getIsEnabled());
xObj.setResourceSignature(vObj.getResourceSignature());
XXService xService = daoMgr.getXXService().findByName(vObj.getServiceName());
if (xService == null) {
throw restErrorUtil.createRESTException("Error Populating XXServiceResource. No Service found with name: " + vObj.getServiceName(), MessageEnums.INVALID_INPUT_DATA);
}
xObj.setServiceId(xService.getId());
return xObj;
}
use of org.apache.ranger.entity.XXService in project ranger by apache.
the class RangerServiceResourceServiceBase method mapEntityToViewBean.
@Override
protected V mapEntityToViewBean(V vObj, T xObj) {
vObj.setGuid(xObj.getGuid());
vObj.setVersion(xObj.getVersion());
vObj.setIsEnabled(xObj.getIsEnabled());
vObj.setResourceSignature(xObj.getResourceSignature());
XXService xService = daoMgr.getXXService().getById(xObj.getServiceId());
vObj.setServiceName(xService.getName());
List<XXServiceResourceElement> resElementList = daoMgr.getXXServiceResourceElement().findByResourceId(xObj.getId());
Map<String, RangerPolicy.RangerPolicyResource> resourceElements = new HashMap<String, RangerPolicy.RangerPolicyResource>();
for (XXServiceResourceElement resElement : resElementList) {
List<String> resValueMapList = daoMgr.getXXServiceResourceElementValue().findValuesByResElementId(resElement.getId());
XXResourceDef xResDef = daoMgr.getXXResourceDef().getById(resElement.getResDefId());
RangerPolicyResource policyRes = new RangerPolicyResource();
policyRes.setIsExcludes(resElement.getIsExcludes());
policyRes.setIsRecursive(resElement.getIsRecursive());
policyRes.setValues(resValueMapList);
resourceElements.put(xResDef.getName(), policyRes);
}
vObj.setResourceElements(resourceElements);
return vObj;
}
Aggregations