From 1888af55de60ced48624ba7d61357fa7505825a7 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 8 Jun 2018 23:32:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E4=B8=80=E6=B3=A2=E5=88=A0=E5=87=8F=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListPane.java | 9 +- .../com/fr/design/file/TemplateTreePane.java | 6 +- .../com/fr/design/formula/JavaEditorPane.java | 2 +- .../gui/itree/filetree/TemplateFileTree.java | 5 +- .../com/fr/design/mainframe/JTemplate.java | 21 ++- .../design/roleAuthority/RoleDataWrapper.java | 2 +- designer-base/src/com/fr/env/RemoteEnv.java | 132 +----------------- .../src/com/fr/file/FILEChooserPane.java | 50 +++---- 8 files changed, 59 insertions(+), 168 deletions(-) diff --git a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java index 92a27b7605..daa851c668 100644 --- a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -1,5 +1,6 @@ package com.fr.design.file; +import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.dav.LocalEnv; @@ -18,9 +19,11 @@ import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; +import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import javax.swing.*; @@ -363,8 +366,10 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C */ public void openContainerFolder() { FileNode fileNode = new FileNode(((JTemplate) list.getSelectedValue()).getEditingFILE().getPath(), false); - LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv(); - localEnv.openContainerFolder(fileNode); + Env env = FRContext.getCurrentEnv(); + if (env.isLocalEnv()) { + IOUtils.openWindowsFolder(StableUtils.pathJoin(env.getEnvConfig().getPath(), fileNode.getEnvPath())); + } } /** diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index 21cc6824a7..afb2a006ad 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/com/fr/design/file/TemplateTreePane.java @@ -3,6 +3,7 @@ */ package com.fr.design.file; +import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.io.FileAssistUtils; import com.fr.dav.LocalEnv; @@ -15,6 +16,7 @@ import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.file.filetree.IOFileNodeFilter; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; @@ -139,13 +141,13 @@ public class TemplateTreePane extends JPanel implements FileOperations { */ public void openContainerFolder() { FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode(); - LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv(); + Env localEnv = FRContext.getCurrentEnv(); String filePath = StableUtils.pathJoin(localEnv.getPath(), fn.getEnvPath()); filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR)); try { Desktop.getDesktop().open(new File(filePath)); } catch (Exception e) { - localEnv.openContainerFolder(fn); + IOUtils.openWindowsFolder(StableUtils.pathJoin(localEnv.getEnvConfig().getPath(), fn.getEnvPath())); } } diff --git a/designer-base/src/com/fr/design/formula/JavaEditorPane.java b/designer-base/src/com/fr/design/formula/JavaEditorPane.java index 10195acbd9..48d3b02d80 100644 --- a/designer-base/src/com/fr/design/formula/JavaEditorPane.java +++ b/designer-base/src/com/fr/design/formula/JavaEditorPane.java @@ -176,7 +176,7 @@ public class JavaEditorPane extends BasicPane { @Override protected JavaCompileInfo doInBackground() throws Exception { Env env = FRContext.getCurrentEnv(); - return env.compilerSourceCode(javaText.getText()); + return env.getCommonOperator().compile(javaText.getText()); } public void done() { diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java index 0ee011e22b..31325dd0f1 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -2,6 +2,7 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.Env; import com.fr.base.FRContext; +import com.fr.base.extension.FileExtension; import com.fr.base.operator.file.FileOperator; import com.fr.core.env.proxy.EnvProxy; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; @@ -104,7 +105,9 @@ public class TemplateFileTree extends EnvFileTree { } public FileNode[] listFile(String path) throws Exception { - return FRContext.getCurrentEnv().getFileOperator().list(path); + return FRContext.getCurrentEnv().getFileOperator().list( + path, + new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CPTX, FileExtension.FRMX}); } /* diff --git a/designer-base/src/com/fr/design/mainframe/JTemplate.java b/designer-base/src/com/fr/design/mainframe/JTemplate.java index df970d1b3e..f31fc74914 100644 --- a/designer-base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/com/fr/design/mainframe/JTemplate.java @@ -45,8 +45,8 @@ import com.fr.file.MemFILE; import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.stable.ArrayUtils; @@ -539,7 +539,14 @@ public abstract class JTemplate> if (!editingFILE.exists()) { return saveAsTemplate(isShowLoc); } - if (!FRContext.getCurrentEnv().hasFileFolderAllow(this.getEditingFILE().getPath())) { + boolean access = false; + + try { + access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(this.getEditingFILE().getPath()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (!access) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); return false; } @@ -579,18 +586,22 @@ public abstract class JTemplate> int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix()); if (isCancelOperation(chooseResult)) { - fileChooser = null; return false; } if (isOkOperation(chooseResult)) { - if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath()) ) { + boolean access = false; + try { + access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (!access) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); return false; } editingFILE = fileChooser.getSelectedFILE(); mkNewFile(editingFILE); - fileChooser = null; } return saveNewFile(editingFILE, oldName); diff --git a/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java b/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java index 5dc9c2aef3..253f6d8c27 100644 --- a/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java +++ b/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java @@ -1 +1 @@ -package com.fr.design.roleAuthority; import com.fr.base.FRContext; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.loader.ChildrenNodesLoader; import com.fr.general.Inter; import java.util.ArrayList; import java.util.List; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 *

* Author : daisy * Date: 13-8-30 * Time: 下午3:42 */ public class RoleDataWrapper implements ChildrenNodesLoader { List rolelist = new ArrayList(); private String roleTypename = null; public RoleDataWrapper(String roleName) { roleTypename = roleName; } /** * 在此计算并获得与管理类型相对应的 */ private void calculateRoleList() { this.rolelist.addAll(FRContext.getCurrentEnv().getAllRole4Privilege( roleTypename != Inter.getLocText("M_Server-Platform_Manager"))); } //加载所有的角色列表 public ExpandMutableTreeNode[] load() { calculateRoleList(); return this.load(this.rolelist); } //从workbook中读取的角色列表 public ExpandMutableTreeNode[] load(List rolelist) { this.rolelist = rolelist; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[rolelist.size()]; for (int i = 0; i < res.length; i++) { res[i] = new ExpandMutableTreeNode(rolelist.get(i)); } return res; } public String getRoleTypename(){ return roleTypename; } } \ No newline at end of file +package com.fr.design.roleAuthority; import com.fr.base.FRContext; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.loader.ChildrenNodesLoader; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 *

* Author : daisy * Date: 13-8-30 * Time: 下午3:42 */ public class RoleDataWrapper implements ChildrenNodesLoader { private List rolelist = new ArrayList(); private String roleTypename = null; public RoleDataWrapper(String roleName) { roleTypename = roleName; } /** * 在此计算并获得与管理类型相对应的 */ private void calculateRoleList() { try { Collections.addAll(rolelist, FRContext.getCurrentEnv().getOrganizationOperator().getRoleGroup()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } //加载所有的角色列表 public ExpandMutableTreeNode[] load() { calculateRoleList(); return this.load(this.rolelist); } //从workbook中读取的角色列表 public ExpandMutableTreeNode[] load(List rolelist) { this.rolelist = rolelist; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[rolelist.size()]; for (int i = 0; i < res.length; i++) { res[i] = new ExpandMutableTreeNode(rolelist.get(i)); } return res; } public String getRoleTypename(){ return roleTypename; } } \ No newline at end of file diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 12bf84e3bd..9034d6c36a 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -5,6 +5,7 @@ import com.fr.base.TableData; import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.file.FileOperator; +import com.fr.base.operator.org.OrganizationOperator; import com.fr.base.remote.RemoteDeziConstants; import com.fr.common.rpc.RemoteCallServerConfig; import com.fr.common.rpc.netty.MessageSendExecutor; @@ -20,8 +21,6 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.env.RemoteEnvConfig; import com.fr.design.mainframe.DesignerContext; import com.fr.file.CacheManager; -import com.fr.file.ConnectionConfig; -import com.fr.file.TableDataConfig; import com.fr.general.CommonIOUtils; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; @@ -37,7 +36,6 @@ import com.fr.share.ShareConstants; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; import com.fr.stable.Filter; -import com.fr.stable.JavaCompileInfo; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -56,20 +54,17 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.awt.*; -import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import static com.fr.third.guava.base.Preconditions.checkArgument; @@ -126,6 +121,11 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return MessageSendExecutor.getInstance().execute(CommonOperator.class); } + @Override + public OrganizationOperator getOrganizationOperator() throws Exception { + return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); + } + @Override public RemoteEnvConfig getEnvConfig() { return config; @@ -427,45 +427,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); } - /** - * DataSource中去除当前角色没有权限访问的数据源 - */ - @Override - public void removeNoPrivilegeConnection() { - refreshHttpSProperty(); - TableDataConfig dm = TableDataConfig.getInstance(); - - try { - HashMap para = new HashMap<>(); - para.put("op", "fs_remote_design"); - para.put("cmd", "env_get_role"); - para.put("currentUsername", this.getUser()); - para.put("currentPwd", this.getPassword()); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - JSONArray ja = new JSONArray(stream2String(input)); - ArrayList toBeRemoveTDName = new ArrayList<>(); - for (int i = 0; i < ja.length(); i++) { - String toBeRemoveConnName = (String) ((JSONObject) ja.get(i)).get("name"); - ConnectionConfig.getInstance().removeConnection(toBeRemoveConnName); - Iterator it = dm.getTableDatas().keySet().iterator(); - while (it.hasNext()) { - String tdName = (String) it.next(); - TableData td = dm.getTableData(tdName); - td.registerNoPrivilege(toBeRemoveTDName, toBeRemoveConnName, tdName); - } - } - - for (int i = 0; i < toBeRemoveTDName.size(); i++) { - dm.removeTableData(toBeRemoveTDName.get(i)); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - @Override public EmbeddedTableData previewTableData(Object tableData, Map parameterMap, int rowCount) throws Exception { return previewTableData(null, tableData, parameterMap, rowCount); @@ -713,63 +674,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return FILE_TYPE; } - - /** - * 判断是否有文件夹权限 - * - * @param path 路径 - * @return 有权限则返回true - */ - @Override - public boolean hasFileFolderAllow(String path) { - refreshHttpSProperty(); - try { - HashMap para = new HashMap<>(); - para.put("op", "fs_remote_design"); - para.put("cmd", "design_filefolder_allow"); - para.put("current_uid", this.getUserID()); - para.put(RemoteDeziConstants.TEMPLATE_PATH, path); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - - if (input == null) { - return false; - } - return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - return false; - } - - } - - @Override - public ArrayList getAllRole4Privilege(boolean isFS) { - refreshHttpSProperty(); - ArrayList allRoleList = new ArrayList<>(); - try { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "get_all_role"); - para.put("isFS", String.valueOf(isFS)); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - JSONArray ja = new JSONArray(stream2String(input)); - for (int i = 0; i < ja.length(); i++) { - String roleName = (String) ((JSONObject) ja.get(i)).get("name"); - allRoleList.add(roleName); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - return allRoleList; - } - - /** * 获取当前env的build文件路径 */ @@ -786,30 +690,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut this.buildFilePath = buildFilePath; } - /** - * 编译Java源代码,方便二次开发的进行 - * - * @param sourceText 源代码 - * @return 编译信息,有可能是成功信息,也有可能是出错或者警告信息 - */ - @Override - public JavaCompileInfo compilerSourceCode(String sourceText) throws Exception { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_compile_source_code"); - InputStream in = postBytes2ServerB(sourceText.getBytes(EncodeConstants.ENCODING_UTF_8), para); - BufferedReader br = new BufferedReader(new InputStreamReader(in, EncodeConstants.ENCODING_UTF_8)); - StringBuilder sb = new StringBuilder(); - String line; - while ((line = br.readLine()) != null) { - sb.append(line); - } - JSONObject jo = new JSONObject(sb.toString()); - JavaCompileInfo info = new JavaCompileInfo(); - info.parseJSON(jo); - return info; - } - @Override public String[] loadREUFile() { refreshHttpSProperty(); diff --git a/designer-base/src/com/fr/file/FILEChooserPane.java b/designer-base/src/com/fr/file/FILEChooserPane.java index 3b5f71a60c..d5e6d8e559 100644 --- a/designer-base/src/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/com/fr/file/FILEChooserPane.java @@ -1,8 +1,8 @@ package com.fr.file; import com.fr.base.BaseUtils; -import com.fr.base.extension.FileExtension; import com.fr.base.FRContext; +import com.fr.base.extension.FileExtension; import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; @@ -26,6 +26,7 @@ import com.fr.file.filter.FILEFilter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; @@ -33,38 +34,13 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; -import javax.swing.AbstractAction; -import javax.swing.AbstractListModel; -import javax.swing.ActionMap; -import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.Icon; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.KeyStroke; -import javax.swing.ListCellRenderer; -import javax.swing.ListModel; -import javax.swing.ListSelectionModel; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.filechooser.FileSystemView; import javax.swing.plaf.basic.BasicArrowButton; import javax.swing.plaf.basic.BasicButtonUI; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.Window; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -707,7 +683,14 @@ public class FILEChooserPane extends BasicPane { } returnValue = OK_OPTION; FILE selectedFile = this.getSelectedFILE(); - if (!FRContext.getCurrentEnv().hasFileFolderAllow(selectedFile.getPath())) { + boolean access = false; + + try { + access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(selectedFile.getPath()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (!access) { JOptionPane.showMessageDialog(FILEChooserPane.this, Inter.getLocText("FR-App-Privilege_No") + "!", Inter.getLocText("FR-App-File_Message"), JOptionPane.WARNING_MESSAGE); return; } @@ -1418,7 +1401,14 @@ public class FILEChooserPane extends BasicPane { if (currentDirectory == null) { return; } - if (!FRContext.getCurrentEnv().hasFileFolderAllow(currentDirectory.getPath() + "/")) { + + boolean access = false; + try { + access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(currentDirectory.getPath()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (!access) { JOptionPane.showMessageDialog(FILEChooserPane.this, Inter.getLocText("FR-App-Privilege_No") + "!", Inter.getLocText("FR-App-File_Message"), JOptionPane.WARNING_MESSAGE); return; }