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;
}
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);
}
}
}
Aggregations