diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 36de6a75e3..306ce0f886 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/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 (showLockInfo) { - UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath); - node.setLock(UUID.randomUUID().toString()); - // 对于开发者预览占位锁定 定位到tab中 - checkDevelopForBiddenTemplate(selectedFilePath); - LockInfoDialog.show(userInfo); - return; - } else { - node.setLock(null); + + if (!LockInfoUtils.unableGetLockInfo()) { + // 这边额外的请求数量缩减到一个,但是还是可以再合并,后续再看看怎么合并,现在先这样 + UserInfo info = TemplateRepository.getInstance().showLockInfo(selectedFilePath); + boolean showLockInfo = info.getTplUnLocked() ? (lock != null && !lock.equals(node.getUserID())) : info.getTplLocked(); + if (showLockInfo) { + node.setLock(UUID.randomUUID().toString()); + // 对于开发者预览占位锁定 定位到tab中 + checkDevelopForBiddenTemplate(selectedFilePath); + LockInfoDialog.show(info); + return; + } } + node.setLock(null); DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false))); } diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java index 8c54cc8cc3..96f01f231f 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java +++ b/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 fromTo = new HashMap<>(); + fromTo.put(FROM_KEY, from); + fromTo.put(TO_KEY, to); + return TemplateRepository.getInstance().rename(fromTo); } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 8cfd263421..f3ab77cf4d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/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); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 74ec97605f..24c543a00a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1044,11 +1044,7 @@ public abstract class JTemplate> } protected void checkBeforeSave() throws Exception { - // 过滤掉本地文件 - boolean localFile = getEditingFILE() instanceof FileFILE; - if (!localFile && getEditingFILE().exists()) { - throw new InconsistentLockException(); - } + // 判断需要再看下 } public byte[] exportData() throws Exception { diff --git a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java index 1dee557980..b7a0ba795b 100644 --- a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java +++ b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java @@ -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 diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index 0c3d33bcc0..438e9c6b17 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/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)); } /**