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();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
String lock = node.getLock();
boolean showLockInfo = LockInfoUtils.isCompatibleOperator()
|| LockInfoUtils.unableGetLockInfo()
|| WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath)
? (lock != null && !lock.equals(node.getUserID()))
: WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath);
if (!LockInfoUtils.unableGetLockInfo()) {
// 这边额外的请求数量缩减到一个,但是还是可以再合并,后续再看看怎么合并,现在先这样
UserInfo info = TemplateRepository.getInstance().showLockInfo(selectedFilePath);
boolean showLockInfo = info.getTplUnLocked() ? (lock != null && !lock.equals(node.getUserID())) : info.getTplLocked();
if (showLockInfo) {
UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath);
node.setLock(UUID.randomUUID().toString());
// 对于开发者预览占位锁定 定位到tab中
checkDevelopForBiddenTemplate(selectedFilePath);
LockInfoDialog.show(userInfo);
LockInfoDialog.show(info);
return;
} else {
node.setLock(null);
}
}
node.setLock(null);
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.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import com.fr.workspace.server.repository.template.TemplateRepository;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
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
@ -16,7 +23,7 @@ public class DefaultTemplateResource extends AbstractTemplateResource {
@Override
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
@ -26,17 +33,20 @@ public class DefaultTemplateResource extends AbstractTemplateResource {
@Override
public boolean closeTemplate(String path) {
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path);
return TemplateRepository.getInstance().close(path);
}
@Override
public boolean delete(FILE file) {
return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath());
return TemplateRepository.getInstance().delete(file.getPath());
}
@Override
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

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.report.lock.LockInfoOperator;
import com.fr.workspace.server.repository.template.TemplateRepository;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
@ -622,8 +624,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
&& !ComparatorUtils.equals(fileNode.getLock(), fileNode.getUserID());
boolean visible = locked
&& WorkContext.getCurrent().isRoot()
&& WorkContext.getCurrent().get(LockInfoOperator.class).isUnLockable()
&& !WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(fileNode.getEnvPath());
&& TemplateRepository.getInstance().isRootUnlockAble(fileNode.getEnvPath());
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 {
// 过滤掉本地文件
boolean localFile = getEditingFILE() instanceof FileFILE;
if (!localFile && getEditingFILE().exists()) {
throw new InconsistentLockException();
}
// 判断需要再看下
}
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;
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.design.i18n.Toolkit;
import com.fr.exception.RemoteDesignPermissionDeniedException;
@ -100,7 +98,7 @@ public enum TestConnectionResult {
@Override
public String errorCode() {
return UserLoginLockException.ERROR_CODE;
return "UserLoginLockException.ERROR_CODE";
}
@Override
@ -175,7 +173,8 @@ public enum TestConnectionResult {
@Override
public String errorCode() {
return UserPasswordNeedUpdateException.ERROR_CODE;
// todo result具体逻辑需要同产品确认
return "UserPasswordNeedUpdateException.ERROR_CODE";
}
@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)) {
return;
}
FRContext.getCommonOperator().unlockTemplate(
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1));
// 看上去好像没用了
//FRContext.getCommonOperator().unlockTemplate(
// envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1));
}
/**

Loading…
Cancel
Save