use of org.apache.ranger.entity.XXPolicyLabel in project ranger by apache.
the class ServiceDBStore method getPolicyLabels.
public List<String> getPolicyLabels(SearchFilter searchFilter) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> ServiceDBStore.getPolicyLabels()");
}
VXPolicyLabelList vxPolicyLabelList = new VXPolicyLabelList();
List<XXPolicyLabel> xPolList = (List<XXPolicyLabel>) policyLabelsService.searchResources(searchFilter, policyLabelsService.searchFields, policyLabelsService.sortFields, vxPolicyLabelList);
List<String> result = new ArrayList<String>();
for (XXPolicyLabel xPolicyLabel : xPolList) {
result.add(xPolicyLabel.getPolicyLabel());
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== ServiceDBStore.getPolicyLabels()");
}
return result;
}
use of org.apache.ranger.entity.XXPolicyLabel 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