Java Code Examples for org.apache.ranger.plugin.model.RangerServiceDef#RangerRowFilterDef

The following examples show how to use org.apache.ranger.plugin.model.RangerServiceDef#RangerRowFilterDef . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractServiceStore.java    From ranger with Apache License 2.0 6 votes vote down vote up
private void updateTagServiceDefForDeletingRowFilterDef(RangerServiceDef tagServiceDef, String serviceDefName) {
	if (LOG.isDebugEnabled()) {
		LOG.debug("==> AbstractServiceStore.updateTagServiceDefForDeletingRowFilterDef(" + serviceDefName + ")");
	}
	RangerServiceDef.RangerRowFilterDef tagRowFilterDef = tagServiceDef.getRowFilterDef();

	if (tagRowFilterDef == null) {
		return;
	}

	String prefix = serviceDefName + COMPONENT_ACCESSTYPE_SEPARATOR;

	List<RangerServiceDef.RangerAccessTypeDef> accessTypes = new ArrayList<>();

	for (RangerServiceDef.RangerAccessTypeDef accessType : tagRowFilterDef.getAccessTypes()) {
		if (accessType.getName().startsWith(prefix)) {
			accessTypes.add(accessType);
		}
	}

	tagRowFilterDef.getAccessTypes().removeAll(accessTypes);

	if (LOG.isDebugEnabled()) {
		LOG.debug("<== AbstractServiceStore.updateTagServiceDefForDeletingRowFilterDef(" + serviceDefName + ")");
	}
}
 
Example 2
Source File: AbstractServiceStore.java    From ranger with Apache License 2.0 5 votes vote down vote up
private boolean updateTagServiceDefForUpdatingRowFilterDef(RangerServiceDef tagServiceDef, RangerServiceDef serviceDef, long itemIdOffset, String prefix) {
	if (LOG.isDebugEnabled()) {
		LOG.debug("==> AbstractServiceStore.updateTagServiceDefForUpdatingRowFilterDef(" + serviceDef.getName() + ")");
	}
	boolean ret = false;

	boolean autopropagateRowfilterdefToTag = config.getBoolean(AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP, AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP_DEFAULT);

	if (autopropagateRowfilterdefToTag) {
		RangerServiceDef.RangerRowFilterDef svcRowFilterDef = serviceDef.getRowFilterDef();
		RangerServiceDef.RangerRowFilterDef tagRowFilterDef = tagServiceDef.getRowFilterDef();

		List<RangerServiceDef.RangerAccessTypeDef> svcDefAccessTypes = svcRowFilterDef.getAccessTypes();
		List<RangerServiceDef.RangerAccessTypeDef> tagDefAccessTypes = tagRowFilterDef.getAccessTypes();

		boolean tagRowFilterAccessTypesUpdated = updateTagAccessTypeDefs(svcDefAccessTypes, tagDefAccessTypes, itemIdOffset, prefix);

		if (tagRowFilterAccessTypesUpdated) {
			tagRowFilterDef.setAccessTypes(tagDefAccessTypes);
			ret = true;
		}
	}
	if (LOG.isDebugEnabled()) {
		LOG.debug("<== AbstractServiceStore.updateTagServiceDefForUpdatingRowFilterDef(" + serviceDef.getName() + ") : " + ret);
	}

	return ret;
}
 
Example 3
Source File: PatchForTagServiceDefUpdate_J10028.java    From ranger with Apache License 2.0 4 votes vote down vote up
private boolean updateResourceInTagServiceDef(RangerServiceDef tagServiceDef) {
	if (logger.isDebugEnabled()) {
		logger.debug("==> PatchForTagServiceDefUpdate_J10028.updateResourceInTagServiceDef(" + tagServiceDef + ")");
	}
	boolean ret = false;

	final RangerServiceDef.RangerResourceDef accessPolicyTagResource = getResourceDefForTagResource(tagServiceDef.getResources());

	if (accessPolicyTagResource != null) {

		RangerServiceDef.RangerDataMaskDef dataMaskDef = tagServiceDef.getDataMaskDef();

		if (dataMaskDef != null) {
			if (CollectionUtils.isNotEmpty(dataMaskDef.getAccessTypes())) {
				addOrUpdateResourceDefForTagResource(dataMaskDef.getResources(), accessPolicyTagResource);
				ret = true;
			} else {
				if (CollectionUtils.isNotEmpty(dataMaskDef.getResources())) {
					dataMaskDef.setResources(null);
					ret = true;
				}
			}
		}

		RangerServiceDef.RangerRowFilterDef rowFilterDef = tagServiceDef.getRowFilterDef();

		if (rowFilterDef != null) {
			boolean autopropagateRowfilterdefToTag = config.getBoolean(AbstractServiceStore.AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP, AbstractServiceStore.AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP_DEFAULT);
			if (autopropagateRowfilterdefToTag) {
				if (CollectionUtils.isNotEmpty(rowFilterDef.getAccessTypes())) {
					addOrUpdateResourceDefForTagResource(rowFilterDef.getResources(), accessPolicyTagResource);
					ret = true;
				} else {
					if (CollectionUtils.isNotEmpty(rowFilterDef.getResources())) {
						rowFilterDef.setResources(null);
						ret = true;
					}
				}
			}
		}
	} else {
		logger.warn("Resource with name :[" + RangerServiceTag.TAG_RESOURCE_NAME + "] not found in  tag-service-definition!!");
	}

	if (logger.isDebugEnabled()) {
		logger.debug("<== PatchForTagServiceDefUpdate_J10028.updateResourceInTagServiceDef(" + tagServiceDef + ") : " + ret);
	}

	return ret;
}
 
Example 4
Source File: AbstractServiceStore.java    From ranger with Apache License 2.0 4 votes vote down vote up
private boolean updateResourceInTagServiceDef(RangerServiceDef tagServiceDef) throws Exception {
	if (LOG.isDebugEnabled()) {
		LOG.debug("==> AbstractServiceStore.updateResourceInTagServiceDef(" + tagServiceDef + ")");
	}
	boolean ret = false;

	final RangerServiceDef.RangerResourceDef accessPolicyTagResource = getResourceDefForTagResource(tagServiceDef.getResources());

	final List<RangerServiceDef.RangerResourceDef> resources = new ArrayList<>();

	if (accessPolicyTagResource == null) {
		LOG.warn("Resource with name :[" + RangerServiceTag.TAG_RESOURCE_NAME + "] not found in  tag-service-definition!!");
	} else {
		resources.add(accessPolicyTagResource);
	}

	RangerServiceDef.RangerDataMaskDef dataMaskDef = tagServiceDef.getDataMaskDef();

	if (dataMaskDef != null) {
		if (CollectionUtils.isNotEmpty(dataMaskDef.getAccessTypes())) {
			if (CollectionUtils.isEmpty(dataMaskDef.getResources())) {
				dataMaskDef.setResources(resources);
				ret = true;
			}
		} else {
			if (CollectionUtils.isNotEmpty(dataMaskDef.getResources())) {
				dataMaskDef.setResources(null);
				ret = true;
			}
		}
	}

	RangerServiceDef.RangerRowFilterDef rowFilterDef = tagServiceDef.getRowFilterDef();

	if (rowFilterDef != null) {
		boolean autopropagateRowfilterdefToTag = config.getBoolean(AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP, AUTOPROPAGATE_ROWFILTERDEF_TO_TAG_PROP_DEFAULT);
		if (autopropagateRowfilterdefToTag) {
			if (CollectionUtils.isNotEmpty(rowFilterDef.getAccessTypes())) {
				if (CollectionUtils.isEmpty(rowFilterDef.getResources())) {
					rowFilterDef.setResources(resources);
					ret = true;
				}
			} else {
				if (CollectionUtils.isNotEmpty(rowFilterDef.getResources())) {
					rowFilterDef.setResources(null);
					ret = true;
				}
			}
		}
	}

	if (LOG.isDebugEnabled()) {
		LOG.debug("<== AbstractServiceStore.updateResourceInTagServiceDef(" + tagServiceDef + ") : " + ret);
	}
	return ret;
}