Search in sources :

Example 1 with XXPolicyLabelMap

use of org.apache.ranger.entity.XXPolicyLabelMap in project ranger by apache.

the class ServiceDBStore method deleteExistingPolicyLabel.

private Boolean deleteExistingPolicyLabel(RangerPolicy policy) {
    if (policy == null) {
        return false;
    }
    List<XXPolicyLabelMap> xxPolicyLabelMaps = daoMgr.getXXPolicyLabelMap().findByPolicyId(policy.getId());
    XXPolicyLabelMapDao policyLabelMapDao = daoMgr.getXXPolicyLabelMap();
    for (XXPolicyLabelMap xxPolicyLabelMap : xxPolicyLabelMaps) {
        policyLabelMapDao.remove(xxPolicyLabelMap);
    }
    return true;
}
Also used : XXPolicyLabelMapDao(org.apache.ranger.db.XXPolicyLabelMapDao) XXPolicyLabelMap(org.apache.ranger.entity.XXPolicyLabelMap)

Example 2 with XXPolicyLabelMap

use of org.apache.ranger.entity.XXPolicyLabelMap in project ranger by apache.

the class ServiceDBStore method createNewLabelsForPolicy.

private void createNewLabelsForPolicy(XXPolicy xPolicy, List<String> policyLabels) throws Exception {
    for (String policyLabel : policyLabels) {
        XXPolicyLabel xXPolicyLabel = daoMgr.getXXPolicyLabels().findByName(policyLabel);
        if (xXPolicyLabel == null) {
            xXPolicyLabel = new XXPolicyLabel();
            if (StringUtils.isNotEmpty(policyLabel)) {
                xXPolicyLabel.setPolicyLabel(policyLabel);
                xXPolicyLabel = rangerAuditFields.populateAuditFieldsForCreate(xXPolicyLabel);
                xXPolicyLabel = daoMgr.getXXPolicyLabels().create(xXPolicyLabel);
            }
        }
        if (xXPolicyLabel.getId() != null) {
            XXPolicyLabelMap xxPolicyLabelMap = new XXPolicyLabelMap();
            xxPolicyLabelMap.setPolicyId(xPolicy.getId());
            xxPolicyLabelMap.setPolicyLabelId(xXPolicyLabel.getId());
            xxPolicyLabelMap = rangerAuditFields.populateAuditFieldsForCreate(xxPolicyLabelMap);
            xxPolicyLabelMap = daoMgr.getXXPolicyLabelMap().create(xxPolicyLabelMap);
        }
    }
}
Also used : XXPolicyLabel(org.apache.ranger.entity.XXPolicyLabel) XXPolicyLabelMap(org.apache.ranger.entity.XXPolicyLabelMap) VXString(org.apache.ranger.view.VXString)

Aggregations

XXPolicyLabelMap (org.apache.ranger.entity.XXPolicyLabelMap)2 XXPolicyLabelMapDao (org.apache.ranger.db.XXPolicyLabelMapDao)1 XXPolicyLabel (org.apache.ranger.entity.XXPolicyLabel)1 VXString (org.apache.ranger.view.VXString)1