use of org.apache.ranger.db.XXPolicyRefAccessTypeDao in project ranger by apache.
the class PatchForMigratingOldRegimePolicyJson_J10046 method addAccessDefRef.
private void addAccessDefRef(String serviceType, Long policyId, Set<String> accesses) throws Exception {
logger.info("==> addAccessDefRef(id=" + policyId + ")");
// insert policy-id, accessName into Ref table
Map<String, Long> serviceDefAccessTypeIDMap = accessTypeIdMap.get(serviceType);
if (serviceDefAccessTypeIDMap == null) {
serviceDefAccessTypeIDMap = new HashMap<>();
accessTypeIdMap.put(serviceType, serviceDefAccessTypeIDMap);
XXServiceDef dbServiceDef = daoMgr.getXXServiceDef().findByName(serviceType);
for (XXAccessTypeDef accessTypeDef : daoMgr.getXXAccessTypeDef().findByServiceDefId(dbServiceDef.getId())) {
serviceDefAccessTypeIDMap.put(accessTypeDef.getName(), accessTypeDef.getId());
}
}
XXPolicyRefAccessTypeDao policyRefAccessTypeDao = daoMgr.getXXPolicyRefAccessType();
for (String access : accesses) {
Long accessTypeDefId = serviceDefAccessTypeIDMap.get(access);
if (accessTypeDefId == null) {
throw new Exception(access + ": unknown accessType in policy [id=" + policyId + "; serviceType=" + serviceType + "]. Known accessTypes: " + serviceDefAccessTypeIDMap.keySet());
}
XXPolicyRefAccessType policyRefAccessType = new XXPolicyRefAccessType();
policyRefAccessType.setPolicyId(policyId);
policyRefAccessType.setAccessTypeName(access);
policyRefAccessType.setAccessDefId(accessTypeDefId);
policyRefAccessTypeDao.create(policyRefAccessType);
}
logger.info("<== addAccessDefRef(id=" + policyId + ")");
}
use of org.apache.ranger.db.XXPolicyRefAccessTypeDao in project ranger by apache.
the class PatchForUpdatingPolicyJson_J10019 method addAccessDefRef.
private void addAccessDefRef(String serviceType, Long policyId, Set<String> accesses) throws Exception {
logger.info("==> addAccessDefRef(id=" + policyId + ")");
// insert policy-id, accessName into Ref table
Map<String, Long> serviceDefAccessTypeIDMap = accessTypeIdMap.get(serviceType);
if (serviceDefAccessTypeIDMap == null) {
serviceDefAccessTypeIDMap = new HashMap<>();
accessTypeIdMap.put(serviceType, serviceDefAccessTypeIDMap);
XXServiceDef dbServiceDef = daoMgr.getXXServiceDef().findByName(serviceType);
for (XXAccessTypeDef accessTypeDef : daoMgr.getXXAccessTypeDef().findByServiceDefId(dbServiceDef.getId())) {
serviceDefAccessTypeIDMap.put(accessTypeDef.getName(), accessTypeDef.getId());
}
}
XXPolicyRefAccessTypeDao policyRefAccessTypeDao = daoMgr.getXXPolicyRefAccessType();
for (String access : accesses) {
Long accessTypeDefId = serviceDefAccessTypeIDMap.get(access);
if (accessTypeDefId == null) {
throw new Exception(access + ": unknown accessType in policy [id=" + policyId + "; serviceType=" + serviceType + "]. Known accessTypes: " + serviceDefAccessTypeIDMap.keySet());
}
XXPolicyRefAccessType policyRefAccessType = new XXPolicyRefAccessType();
policyRefAccessType.setPolicyId(policyId);
policyRefAccessType.setAccessTypeName(access);
policyRefAccessType.setAccessDefId(accessTypeDefId);
policyRefAccessTypeDao.create(policyRefAccessType);
}
logger.info("<== addAccessDefRef(id=" + policyId + ")");
}
Aggregations