Search in sources :

Example 6 with XXPolicyResource

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);
    }
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) XXPolicyResource(org.apache.ranger.entity.XXPolicyResource) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) XXResourceDef(org.apache.ranger.entity.XXResourceDef) RangerServiceDefValidator(org.apache.ranger.plugin.model.validation.RangerServiceDefValidator) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Aggregations

XXPolicyResource (org.apache.ranger.entity.XXPolicyResource)6 XXResourceDef (org.apache.ranger.entity.XXResourceDef)4 XXPolicyResourceMap (org.apache.ranger.entity.XXPolicyResourceMap)2 RangerResourceDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)2 VXString (org.apache.ranger.view.VXString)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 LinkedHashSet (java.util.LinkedHashSet)1 XXAccessTypeDefDao (org.apache.ranger.db.XXAccessTypeDefDao)1 XXAccessTypeDefGrantsDao (org.apache.ranger.db.XXAccessTypeDefGrantsDao)1 XXContextEnricherDefDao (org.apache.ranger.db.XXContextEnricherDefDao)1 XXDataMaskTypeDefDao (org.apache.ranger.db.XXDataMaskTypeDefDao)1 XXEnumDefDao (org.apache.ranger.db.XXEnumDefDao)1 XXEnumElementDefDao (org.apache.ranger.db.XXEnumElementDefDao)1 XXPolicyConditionDefDao (org.apache.ranger.db.XXPolicyConditionDefDao)1 XXPolicyResourceDao (org.apache.ranger.db.XXPolicyResourceDao)1 XXPolicyResourceMapDao (org.apache.ranger.db.XXPolicyResourceMapDao)1 XXResourceDefDao (org.apache.ranger.db.XXResourceDefDao)1 XXServiceConfigDefDao (org.apache.ranger.db.XXServiceConfigDefDao)1 XXAccessTypeDef (org.apache.ranger.entity.XXAccessTypeDef)1