Browse Source

REPORT-62438 远程模板锁定优化 修复门槛测试用例的bug

feature/x
hades 3 years ago
parent
commit
81a4154c7c
  1. 7
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  2. 18
      designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  4. 20
      designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

7
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -12,6 +12,7 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.lock.LockInfoUtils;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.lock.LockInfoDialog;
@ -230,13 +231,15 @@ public class TemplateTreePane extends JPanel implements FileOperations {
return;
}
String lock = node.getLock();
boolean showLockInfo = (lock != null && !lock.equals(node.getUserID()))
|| WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath);
boolean showLockInfo = LockInfoUtils.isCompatibleOperator() ? (lock != null && !lock.equals(node.getUserID()))
: WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath);
if (showLockInfo) {
UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath);
node.setLock(UUID.randomUUID().toString());
LockInfoDialog.show(userInfo);
return;
} else {
node.setLock(null);
}
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
}

18
designer-base/src/main/java/com/fr/design/lock/LockInfoUtils.java

@ -0,0 +1,18 @@
package com.fr.design.lock;
import com.fr.report.lock.DefaultLockInfoOperator;
import com.fr.report.lock.LockInfoOperator;
import com.fr.workspace.WorkContext;
/**
* @author hades
* @version 11.0
* Created by hades on 2021/12/8
*/
public class LockInfoUtils {
public static boolean isCompatibleOperator() {
LockInfoOperator lockInfoOperator = WorkContext.getCurrent().get(LockInfoOperator.class);
return lockInfoOperator instanceof DefaultLockInfoOperator;
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -991,7 +991,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
throw new UnLockedException();
}
// 校验锁定信息是否一致
if (WorkContext.getCurrent().get(LockInfoOperator.class).isConsistentLock(getEditingFILE().getPath())) {
if (getEditingFILE().exists() && !WorkContext.getCurrent().get(LockInfoOperator.class).isConsistentLock(getEditingFILE().getPath())) {
throw new InconsistentLockException();
}
return this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(getEditingFILE()));

20
designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

@ -1,7 +1,8 @@
package com.fr.design.utils;
import com.fr.base.extension.FileExtension;
import com.fr.design.file.TemplateTreePane;
import com.fr.base.io.BaseBook;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
@ -15,6 +16,7 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.ProductConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import javax.swing.SwingWorker;
@ -58,7 +60,19 @@ public class TemplateUtils {
@Override
protected Void doInBackground() throws Exception {
byte[] content = WorkContext.getWorkResource().readFully(oldPath);
byte[] content = new byte[0];
if (!needOpen) {
// 从当前编辑模板中生成备份文件
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = template.getTarget();
if (target != null) {
target.export(outputStream);
content = outputStream.toByteArray();
}
} else {
content = WorkContext.getWorkResource().readFully(oldPath);
}
if (ArrayUtils.isEmpty(content)) {
throw new Exception(oldPath + " content is empty" );
}
@ -90,7 +104,7 @@ public class TemplateUtils {
DesignerContext.getDesignerFrame().openTemplate(file);
}
} catch (Exception e) {
SaveFailureHandler.Handler.FullDisk.process(e);
SaveFailureHandler.getInstance().process(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}

Loading…
Cancel
Save