fix #490: align vpd policy apply hierarchy
This commit is contained in:
@@ -139,6 +139,7 @@ public class VpdPolicyService {
|
||||
String schemaOwner,
|
||||
boolean includeTables,
|
||||
boolean includeViews,
|
||||
String policyNameValue,
|
||||
String functionKey,
|
||||
String functionOwnerValue,
|
||||
String functionNameValue,
|
||||
@@ -160,6 +161,9 @@ public class VpdPolicyService {
|
||||
throw new AppException("선택한 스키마에서 VPD 적용 대상 TABLE/VIEW를 찾을 수 없습니다: " + owner);
|
||||
}
|
||||
|
||||
String bulkPolicyName = policyNameValue == null || policyNameValue.isBlank()
|
||||
? COMMON_POLICY_NAME
|
||||
: requiredIdentifier(policyNameValue, "Policy name");
|
||||
FunctionRef functionRef = parseFunctionRef(defaultFunctionKey(functionKey));
|
||||
String filterPredicate = filterPredicateValue == null ? "" : filterPredicateValue.trim();
|
||||
if (functionRef == null && filterPredicate.isBlank()) {
|
||||
@@ -197,8 +201,7 @@ public class VpdPolicyService {
|
||||
int skipped = 0;
|
||||
int failed = 0;
|
||||
for (VpdSchemaObjectOption target : targets) {
|
||||
String policyName = generatedPolicyName(target.objectName());
|
||||
if (mapper.findAnyPolicy(target.owner(), target.objectName(), policyName) != null) {
|
||||
if (mapper.findAnyPolicy(target.owner(), target.objectName(), bulkPolicyName) != null) {
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
@@ -206,7 +209,7 @@ public class VpdPolicyService {
|
||||
addPolicy(
|
||||
target.owner(),
|
||||
target.objectName(),
|
||||
policyName,
|
||||
bulkPolicyName,
|
||||
functionOwner,
|
||||
packageName == null ? functionName : packageName + "." + functionName,
|
||||
statementTypes,
|
||||
@@ -538,10 +541,6 @@ public class VpdPolicyService {
|
||||
return generated.length() > 128 ? generated.substring(0, 128) : generated;
|
||||
}
|
||||
|
||||
private String generatedPolicyName(String objectName) {
|
||||
return COMMON_POLICY_NAME;
|
||||
}
|
||||
|
||||
private FunctionRef parseFunctionRef(String functionKey) {
|
||||
if (functionKey == null || functionKey.isBlank()) {
|
||||
return null;
|
||||
|
||||
@@ -184,6 +184,7 @@ public class VpdPolicyController {
|
||||
@RequestParam String schemaOwner,
|
||||
@RequestParam(defaultValue = "false") boolean includeTables,
|
||||
@RequestParam(defaultValue = "false") boolean includeViews,
|
||||
@RequestParam(required = false) String policyName,
|
||||
@RequestParam(required = false) String functionKey,
|
||||
@RequestParam(required = false) String functionOwner,
|
||||
@RequestParam(required = false) String functionName,
|
||||
@@ -193,7 +194,7 @@ public class VpdPolicyController {
|
||||
@RequestParam(required = false) String filterPredicate,
|
||||
RedirectAttributes redirectAttributes
|
||||
) {
|
||||
bulkApplyPolicyInternal(schemaOwner, includeTables, includeViews, functionKey, functionOwner, functionName,
|
||||
bulkApplyPolicyInternal(schemaOwner, includeTables, includeViews, policyName, functionKey, functionOwner, functionName,
|
||||
statementTypes, enabled, updateCheck, filterPredicate, redirectAttributes);
|
||||
return "redirect:/vpd-policies";
|
||||
}
|
||||
@@ -202,6 +203,7 @@ public class VpdPolicyController {
|
||||
String schemaOwner,
|
||||
boolean includeTables,
|
||||
boolean includeViews,
|
||||
String policyName,
|
||||
String functionKey,
|
||||
String functionOwner,
|
||||
String functionName,
|
||||
@@ -216,6 +218,7 @@ public class VpdPolicyController {
|
||||
schemaOwner,
|
||||
includeTables,
|
||||
includeViews,
|
||||
policyName,
|
||||
functionKey,
|
||||
functionOwner,
|
||||
functionName,
|
||||
|
||||
Reference in New Issue
Block a user