use of org.apache.ranger.entity.XXPolicyResource in project ranger by apache.
the class PatchForNifiResourceUpdateExclude_J10011 method updateNifiServiceDef.
private void updateNifiServiceDef() {
RangerServiceDef ret = null;
RangerServiceDef dbNifiServiceDef = null;
try {
dbNifiServiceDef = svcDBStore.getServiceDefByName(EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_NIFI_NAME);
if (dbNifiServiceDef != null) {
List<RangerResourceDef> rRDefList = null;
rRDefList = dbNifiServiceDef.getResources();
if (CollectionUtils.isNotEmpty(rRDefList)) {
for (RangerResourceDef rRDef : rRDefList) {
if (rRDef.getExcludesSupported()) {
rRDef.setExcludesSupported(false);
}
XXResourceDef sdf = daoMgr.getXXResourceDef().findByNameAndServiceDefId(rRDef.getName(), dbNifiServiceDef.getId());
long ResourceDefId = sdf.getId();
List<XXPolicyResource> RangerPolicyResourceList = daoMgr.getXXPolicyResource().findByResDefId(ResourceDefId);
if (CollectionUtils.isNotEmpty(RangerPolicyResourceList)) {
for (XXPolicyResource RangerPolicyResource : RangerPolicyResourceList) {
if (RangerPolicyResource.getIsexcludes()) {
RangerPolicy rPolicy = svcDBStore.getPolicy(RangerPolicyResource.getPolicyid());
rPolicy.setIsEnabled(false);
svcStore.updatePolicy(rPolicy);
}
}
}
}
}
RangerServiceDefValidator validator = validatorFactory.getServiceDefValidator(svcStore);
validator.validate(dbNifiServiceDef, Action.UPDATE);
ret = svcStore.updateServiceDef(dbNifiServiceDef);
}
if (ret == null) {
logger.error("Error while updating " + EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_NIFI_NAME + "service-def");
}
} catch (Exception e) {
logger.error("Error while updating " + EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_NIFI_NAME + "service-def", e);
}
}
Aggregations