Browse Source

REPORT-114391 【微服务适配】远程&本地设计器能够正常启动 跑通模板锁定流程,合并部分请求

mss/2.0
Destiny.Lin 6 months ago
parent
commit
fa1398307f
  1. 17
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  2. 18
      designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java
  3. 5
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 6
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  5. 7
      designer-base/src/main/java/com/fr/env/TestConnectionResult.java
  6. 6
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java

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

@ -236,21 +236,20 @@ public class TemplateTreePane extends JPanel implements FileOperations {
String reportPath = reportletsTree.getSelectedTemplatePath(); String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
String lock = node.getLock(); String lock = node.getLock();
boolean showLockInfo = LockInfoUtils.isCompatibleOperator()
|| LockInfoUtils.unableGetLockInfo() if (!LockInfoUtils.unableGetLockInfo()) {
|| WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath) // 这边额外的请求数量缩减到一个,但是还是可以再合并,后续再看看怎么合并,现在先这样
? (lock != null && !lock.equals(node.getUserID())) UserInfo info = TemplateRepository.getInstance().showLockInfo(selectedFilePath);
: WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath); boolean showLockInfo = info.getTplUnLocked() ? (lock != null && !lock.equals(node.getUserID())) : info.getTplLocked();
if (showLockInfo) { if (showLockInfo) {
UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath);
node.setLock(UUID.randomUUID().toString()); node.setLock(UUID.randomUUID().toString());
// 对于开发者预览占位锁定 定位到tab中 // 对于开发者预览占位锁定 定位到tab中
checkDevelopForBiddenTemplate(selectedFilePath); checkDevelopForBiddenTemplate(selectedFilePath);
LockInfoDialog.show(userInfo); LockInfoDialog.show(info);
return; return;
} else {
node.setLock(null);
} }
}
node.setLock(null);
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
} }

18
designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java

@ -3,9 +3,16 @@ package com.fr.design.file.impl;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator; import com.fr.workspace.server.lock.TplOperator;
import com.fr.workspace.server.repository.template.TemplateRepository;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import static com.fr.workspace.server.repository.template.AbstractTemplateSource.FROM_KEY;
import static com.fr.workspace.server.repository.template.AbstractTemplateSource.TO_KEY;
/** /**
* @author hades * @author hades
@ -16,7 +23,7 @@ public class DefaultTemplateResource extends AbstractTemplateResource {
@Override @Override
public InputStream readTemplate(String path) throws Exception { public InputStream readTemplate(String path) throws Exception {
return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path)); return new ByteArrayInputStream(TemplateRepository.getInstance().open(path));
} }
@Override @Override
@ -26,17 +33,20 @@ public class DefaultTemplateResource extends AbstractTemplateResource {
@Override @Override
public boolean closeTemplate(String path) { public boolean closeTemplate(String path) {
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path); return TemplateRepository.getInstance().close(path);
} }
@Override @Override
public boolean delete(FILE file) { public boolean delete(FILE file) {
return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath()); return TemplateRepository.getInstance().delete(file.getPath());
} }
@Override @Override
public boolean rename(String from, String to) { public boolean rename(String from, String to) {
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to); Map<String, String> fromTo = new HashMap<>();
fromTo.put(FROM_KEY, from);
fromTo.put(TO_KEY, to);
return TemplateRepository.getInstance().rename(fromTo);
} }
@Override @Override

5
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -62,6 +62,8 @@ import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.report.lock.LockInfoOperator; import com.fr.report.lock.LockInfoOperator;
import com.fr.workspace.server.repository.template.TemplateRepository;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -622,8 +624,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
&& !ComparatorUtils.equals(fileNode.getLock(), fileNode.getUserID()); && !ComparatorUtils.equals(fileNode.getLock(), fileNode.getUserID());
boolean visible = locked boolean visible = locked
&& WorkContext.getCurrent().isRoot() && WorkContext.getCurrent().isRoot()
&& WorkContext.getCurrent().get(LockInfoOperator.class).isUnLockable() && TemplateRepository.getInstance().isRootUnlockAble(fileNode.getEnvPath());
&& !WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(fileNode.getEnvPath());
rightToolBar.setVisible(visible); rightToolBar.setVisible(visible);
} }
} }

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

@ -1044,11 +1044,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
protected void checkBeforeSave() throws Exception { protected void checkBeforeSave() throws Exception {
// 过滤掉本地文件 // 判断需要再看下
boolean localFile = getEditingFILE() instanceof FileFILE;
if (!localFile && getEditingFILE().exists()) {
throw new InconsistentLockException();
}
} }
public byte[] exportData() throws Exception { public byte[] exportData() throws Exception {

7
designer-base/src/main/java/com/fr/env/TestConnectionResult.java vendored

@ -1,7 +1,5 @@
package com.fr.env; package com.fr.env;
import com.fr.decision.webservice.exception.login.UserLoginLockException;
import com.fr.decision.webservice.exception.login.UserPasswordNeedUpdateException;
import com.fr.decision.webservice.exception.user.UserPasswordStrengthLimitException; import com.fr.decision.webservice.exception.user.UserPasswordStrengthLimitException;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.exception.RemoteDesignPermissionDeniedException; import com.fr.exception.RemoteDesignPermissionDeniedException;
@ -100,7 +98,7 @@ public enum TestConnectionResult {
@Override @Override
public String errorCode() { public String errorCode() {
return UserLoginLockException.ERROR_CODE; return "UserLoginLockException.ERROR_CODE";
} }
@Override @Override
@ -175,7 +173,8 @@ public enum TestConnectionResult {
@Override @Override
public String errorCode() { public String errorCode() {
return UserPasswordNeedUpdateException.ERROR_CODE; // todo result具体逻辑需要同产品确认
return "UserPasswordNeedUpdateException.ERROR_CODE";
} }
@Override @Override

6
designer-base/src/main/java/com/fr/file/FileNodeFILE.java

@ -428,9 +428,9 @@ public class FileNodeFILE implements FILE {
if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return; return;
} }
// 看上去好像没用了
FRContext.getCommonOperator().unlockTemplate( //FRContext.getCommonOperator().unlockTemplate(
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)); // envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1));
} }
/** /**

Loading…
Cancel
Save