Skip to content

Commit

Permalink
Minor refactor for EncryptRule build RuleAttributes (#33184)
Browse files Browse the repository at this point in the history
  • Loading branch information
strongduanmu authored Oct 9, 2024
1 parent 13daacc commit b6e035d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public EncryptRule(final String databaseName, final EncryptRuleConfiguration rul
each.getColumns().forEach(this::checkEncryptorType);
tables.put(each.getName(), new EncryptTable(each, encryptors));
}
attributes.set(new RuleAttributes(new EncryptTableMapperRuleAttribute(tables.keySet())));
attributes.set(buildRuleAttributes());
}

private RuleAttributes buildRuleAttributes() {
return new RuleAttributes(new EncryptTableMapperRuleAttribute(tables.keySet()));
}

private Map<String, EncryptAlgorithm> createEncryptors(final EncryptRuleConfiguration ruleConfig) {
Expand Down Expand Up @@ -156,13 +160,13 @@ public boolean partialUpdate(final EncryptRuleConfiguration toBeUpdatedRuleConfi
Collection<String> toBeAddedTableNames = toBeUpdatedTablesNames.stream().filter(each -> !tables.containsKey(each)).collect(Collectors.toList());
if (!toBeAddedTableNames.isEmpty()) {
toBeAddedTableNames.forEach(each -> addTableRule(each, toBeUpdatedRuleConfig));
attributes.set(new RuleAttributes(new EncryptTableMapperRuleAttribute(tables.keySet())));
attributes.set(buildRuleAttributes());
return true;
}
Collection<String> toBeRemovedTableNames = tables.keySet().stream().filter(each -> !toBeUpdatedTablesNames.contains(each)).collect(Collectors.toList());
if (!toBeRemovedTableNames.isEmpty()) {
toBeRemovedTableNames.forEach(tables::remove);
attributes.set(new RuleAttributes(new EncryptTableMapperRuleAttribute(tables.keySet())));
attributes.set(buildRuleAttributes());
// TODO check and remove unused INLINE encryptors
return true;
}
Expand Down

0 comments on commit b6e035d

Please sign in to comment.