Search in sources :

Example 1 with XXPolicyLabel

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;
}
Also used : XXPolicyLabel(org.apache.ranger.entity.XXPolicyLabel) ArrayList(java.util.ArrayList) RangerServiceList(org.apache.ranger.view.RangerServiceList) ArrayList(java.util.ArrayList) VXPolicyLabelList(org.apache.ranger.view.VXPolicyLabelList) List(java.util.List) RangerExportPolicyList(org.apache.ranger.view.RangerExportPolicyList) RangerPolicyList(org.apache.ranger.view.RangerPolicyList) RangerServiceDefList(org.apache.ranger.view.RangerServiceDefList) PList(org.apache.ranger.plugin.store.PList) VXString(org.apache.ranger.view.VXString) VXPolicyLabelList(org.apache.ranger.view.VXPolicyLabelList)

Example 2 with XXPolicyLabel

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);
        }
    }
}
Also used : XXPolicyLabel(org.apache.ranger.entity.XXPolicyLabel) XXPolicyLabelMap(org.apache.ranger.entity.XXPolicyLabelMap) VXString(org.apache.ranger.view.VXString)

Aggregations

XXPolicyLabel (org.apache.ranger.entity.XXPolicyLabel)2 VXString (org.apache.ranger.view.VXString)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 XXPolicyLabelMap (org.apache.ranger.entity.XXPolicyLabelMap)1 PList (org.apache.ranger.plugin.store.PList)1 RangerExportPolicyList (org.apache.ranger.view.RangerExportPolicyList)1 RangerPolicyList (org.apache.ranger.view.RangerPolicyList)1 RangerServiceDefList (org.apache.ranger.view.RangerServiceDefList)1 RangerServiceList (org.apache.ranger.view.RangerServiceList)1 VXPolicyLabelList (org.apache.ranger.view.VXPolicyLabelList)1