Browse Source

REPORT-89957 数据脱敏-本地规则无法保存

【问题原因】还是本地规则这边的问题,有好几个
1. 修改规则触发的updateRule方法,只传入了修改后的规则,修改前的规则未被移除
2. 规则无法保存,ResourceIOUtils.tryWrite接口在远程环境下有问题,会写到服务器上去
3. 所有规则展示的页面,因为之前改动性能,将规则缓存在了页面中,但是没有给刷新缓存的相关逻辑,实际上这个规则展示页面,是可以对本地规则做编辑等操作的,是需要刷新的
【改动思路】
1. updateRule做正确的更新逻辑,删除旧规则,添加新规则
2. ResourceIOUtils.tryWrite换成本地文件系统的IO方法
3. 每次打开所有规则展示的页面之前,刷新一下本地规则缓存
【review建议】
new-design
Yvan-欧阳帆 2 years ago
parent
commit
9eb4939bac
  1. 13
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java
  2. 10
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java

13
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java

@ -275,18 +275,25 @@ public class DesensitizationRuleChoosePane extends JPanel {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// 获取当前选中规则 // 获取当前选中规则的副本
DesensitizationRule selectedValue = getSelectedValue(); DesensitizationRule selectedValue = null;
try {
selectedValue = (DesensitizationRule) getSelectedValue().clone();
} catch (CloneNotSupportedException ex) {
throw new RuntimeException(ex);
}
DesensitizationRuleEditPane editPane = new DesensitizationRuleEditPane(getCurrentExistRuleNames(selectedValue.getRuleName())); DesensitizationRuleEditPane editPane = new DesensitizationRuleEditPane(getCurrentExistRuleNames(selectedValue.getRuleName()));
editPane.populateBean(selectedValue); editPane.populateBean(selectedValue);
final DesensitizationRule finalRule = selectedValue;
BasicDialog basicDialog = editPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() { BasicDialog basicDialog = editPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
DesensitizationRule rule = editPane.updateBean(); DesensitizationRule rule = editPane.updateBean();
// 修改同步到RuleManager中 // 修改同步到RuleManager中
if (DesensitizationRule.valid(rule)) { if (DesensitizationRule.valid(rule)) {
DesensitizationRuleManager.getInstance().updateRule(rule); DesensitizationRuleManager.getInstance().updateRule(finalRule, rule);
} }
setSelectedValue(rule);
fireTableDataChanged(); fireTableDataChanged();
} }

10
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java

@ -250,6 +250,8 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
private ActionListener chooseRuleListener = new ActionListener() { private ActionListener chooseRuleListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// 重新获取一下本地规则缓存
refreshCustomRuleCache();
DesensitizationRulePane rulePane = new DesensitizationRulePane(latestRules); DesensitizationRulePane rulePane = new DesensitizationRulePane(latestRules);
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean(); TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
int selectedRow = table.getSelectedRow(); int selectedRow = table.getSelectedRow();
@ -606,4 +608,12 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
DesensitizationRuleManager.getInstance().getRuleStatus(rule, latestRules) != DesensitizationRuleStatus.NORMAL; DesensitizationRuleManager.getInstance().getRuleStatus(rule, latestRules) != DesensitizationRuleStatus.NORMAL;
} }
/**
* 刷新当前页面的本地规则缓存查询最新本地规则的逻辑也是使用了缓存因此无需考虑耗时
*/
private void refreshCustomRuleCache() {
Map<String, DesensitizationRule> customRules = DesensitizationRuleManager.getInstance().getRulesBySource(DesensitizationRuleSource.CUSTOM);
latestRules.put(DesensitizationRuleSource.CUSTOM, customRules);
}
} }

Loading…
Cancel
Save