use of org.apache.ranger.db.XXPolicyRefDataMaskTypeDao in project ranger by apache.
the class PatchForMigratingOldRegimePolicyJson_J10046 method addDataMaskDefRef.
private void addDataMaskDefRef(String serviceType, Long policyId, Set<String> datamasks) throws Exception {
logger.info("==> addDataMaskDefRef(id=" + policyId + ")");
// insert policy-id, datamaskName into Ref table
Map<String, Long> serviceDefDataMaskTypeIDMap = dataMaskTypeIdMap.get(serviceType);
if (serviceDefDataMaskTypeIDMap == null) {
serviceDefDataMaskTypeIDMap = new HashMap<>();
dataMaskTypeIdMap.put(serviceType, serviceDefDataMaskTypeIDMap);
XXServiceDef dbServiceDef = daoMgr.getXXServiceDef().findByName(serviceType);
for (XXDataMaskTypeDef dataMaskTypeDef : daoMgr.getXXDataMaskTypeDef().findByServiceDefId(dbServiceDef.getId())) {
serviceDefDataMaskTypeIDMap.put(dataMaskTypeDef.getName(), dataMaskTypeDef.getId());
}
}
XXPolicyRefDataMaskTypeDao policyRefDataMaskTypeDao = daoMgr.getXXPolicyRefDataMaskType();
for (String datamask : datamasks) {
Long dataMaskTypeId = serviceDefDataMaskTypeIDMap.get(datamask);
if (dataMaskTypeId == null) {
throw new Exception(datamask + ": unknown dataMaskType in policy [id=" + policyId + "; serviceType=" + serviceType + "]. Known dataMaskTypes " + serviceDefDataMaskTypeIDMap.keySet());
}
XXPolicyRefDataMaskType policyRefDataMaskType = new XXPolicyRefDataMaskType();
policyRefDataMaskType.setPolicyId(policyId);
policyRefDataMaskType.setDataMaskTypeName(datamask);
policyRefDataMaskType.setDataMaskDefId(dataMaskTypeId);
policyRefDataMaskTypeDao.create(policyRefDataMaskType);
}
logger.info("<== addDataMaskDefRef(id=" + policyId + ")");
}
use of org.apache.ranger.db.XXPolicyRefDataMaskTypeDao in project ranger by apache.
the class PatchForUpdatingPolicyJson_J10019 method addDataMaskDefRef.
private void addDataMaskDefRef(String serviceType, Long policyId, Set<String> datamasks) throws Exception {
logger.info("==> addDataMaskDefRef(id=" + policyId + ")");
// insert policy-id, datamaskName into Ref table
Map<String, Long> serviceDefDataMaskTypeIDMap = dataMaskTypeIdMap.get(serviceType);
if (serviceDefDataMaskTypeIDMap == null) {
serviceDefDataMaskTypeIDMap = new HashMap<>();
dataMaskTypeIdMap.put(serviceType, serviceDefDataMaskTypeIDMap);
XXServiceDef dbServiceDef = daoMgr.getXXServiceDef().findByName(serviceType);
for (XXDataMaskTypeDef dataMaskTypeDef : daoMgr.getXXDataMaskTypeDef().findByServiceDefId(dbServiceDef.getId())) {
serviceDefDataMaskTypeIDMap.put(dataMaskTypeDef.getName(), dataMaskTypeDef.getId());
}
}
XXPolicyRefDataMaskTypeDao policyRefDataMaskTypeDao = daoMgr.getXXPolicyRefDataMaskType();
for (String datamask : datamasks) {
Long dataMaskTypeId = serviceDefDataMaskTypeIDMap.get(datamask);
if (dataMaskTypeId == null) {
throw new Exception(datamask + ": unknown dataMaskType in policy [id=" + policyId + "; serviceType=" + serviceType + "]. Known dataMaskTypes " + serviceDefDataMaskTypeIDMap.keySet());
}
XXPolicyRefDataMaskType policyRefDataMaskType = new XXPolicyRefDataMaskType();
policyRefDataMaskType.setPolicyId(policyId);
policyRefDataMaskType.setDataMaskTypeName(datamask);
policyRefDataMaskType.setDataMaskDefId(dataMaskTypeId);
policyRefDataMaskTypeDao.create(policyRefDataMaskType);
}
logger.info("<== addDataMaskDefRef(id=" + policyId + ")");
}
Aggregations