use of org.apache.ranger.entity.XXPolicyItemDataMaskInfo in project ranger by apache.
the class ServiceDBStore method deleteExistingPolicyItems.
private Boolean deleteExistingPolicyItems(RangerPolicy policy) {
if (policy == null) {
return false;
}
XXPolicyItemDao policyItemDao = daoMgr.getXXPolicyItem();
List<XXPolicyItem> policyItems = policyItemDao.findByPolicyId(policy.getId());
for (XXPolicyItem policyItem : policyItems) {
Long polItemId = policyItem.getId();
XXPolicyItemConditionDao polCondDao = daoMgr.getXXPolicyItemCondition();
List<XXPolicyItemCondition> conditions = polCondDao.findByPolicyItemId(polItemId);
for (XXPolicyItemCondition condition : conditions) {
polCondDao.remove(condition);
}
XXPolicyItemGroupPermDao grpPermDao = daoMgr.getXXPolicyItemGroupPerm();
List<XXPolicyItemGroupPerm> groups = grpPermDao.findByPolicyItemId(polItemId);
for (XXPolicyItemGroupPerm group : groups) {
grpPermDao.remove(group);
}
XXPolicyItemUserPermDao userPermDao = daoMgr.getXXPolicyItemUserPerm();
List<XXPolicyItemUserPerm> users = userPermDao.findByPolicyItemId(polItemId);
for (XXPolicyItemUserPerm user : users) {
userPermDao.remove(user);
}
XXPolicyItemAccessDao polItemAccDao = daoMgr.getXXPolicyItemAccess();
List<XXPolicyItemAccess> accesses = polItemAccDao.findByPolicyItemId(polItemId);
for (XXPolicyItemAccess access : accesses) {
polItemAccDao.remove(access);
}
XXPolicyItemDataMaskInfoDao polItemDataMaskInfoDao = daoMgr.getXXPolicyItemDataMaskInfo();
List<XXPolicyItemDataMaskInfo> dataMaskInfos = polItemDataMaskInfoDao.findByPolicyItemId(polItemId);
for (XXPolicyItemDataMaskInfo dataMaskInfo : dataMaskInfos) {
polItemDataMaskInfoDao.remove(dataMaskInfo);
}
XXPolicyItemRowFilterInfoDao polItemRowFilterInfoDao = daoMgr.getXXPolicyItemRowFilterInfo();
List<XXPolicyItemRowFilterInfo> rowFilterInfos = polItemRowFilterInfoDao.findByPolicyItemId(polItemId);
for (XXPolicyItemRowFilterInfo rowFilterInfo : rowFilterInfos) {
polItemRowFilterInfoDao.remove(rowFilterInfo);
}
policyItemDao.remove(policyItem);
}
return true;
}
use of org.apache.ranger.entity.XXPolicyItemDataMaskInfo in project ranger by apache.
the class ServiceDBStore method createNewDataMaskPolicyItemsForPolicy.
private void createNewDataMaskPolicyItemsForPolicy(RangerPolicy policy, XXPolicy xPolicy, List<RangerDataMaskPolicyItem> policyItems, XXServiceDef xServiceDef, int policyItemType) throws Exception {
if (CollectionUtils.isNotEmpty(policyItems)) {
for (int itemOrder = 0; itemOrder < policyItems.size(); itemOrder++) {
RangerDataMaskPolicyItem policyItem = policyItems.get(itemOrder);
XXPolicyItem xPolicyItem = createNewPolicyItemForPolicy(policy, xPolicy, policyItem, xServiceDef, itemOrder, policyItemType);
RangerPolicyItemDataMaskInfo dataMaskInfo = policyItem.getDataMaskInfo();
if (dataMaskInfo != null) {
XXDataMaskTypeDef dataMaskDef = daoMgr.getXXDataMaskTypeDef().findByNameAndServiceId(dataMaskInfo.getDataMaskType(), xPolicy.getService());
if (dataMaskDef == null) {
throw new Exception(dataMaskInfo.getDataMaskType() + ": is not a valid datamask-type. policy='" + policy.getName() + "' service='" + policy.getService() + "'");
}
XXPolicyItemDataMaskInfo xxDataMaskInfo = new XXPolicyItemDataMaskInfo();
xxDataMaskInfo.setPolicyItemId(xPolicyItem.getId());
xxDataMaskInfo.setType(dataMaskDef.getId());
xxDataMaskInfo.setConditionExpr(dataMaskInfo.getConditionExpr());
xxDataMaskInfo.setValueExpr(dataMaskInfo.getValueExpr());
daoMgr.getXXPolicyItemDataMaskInfo().create(xxDataMaskInfo);
}
}
}
}
Aggregations