Browse Source
* commit '5546bb4461b45793baf34ac4ff000383f7464515': fix fix f f f f f f f f f f f f auth f f f REPORT-8790 改动太多了,先commit一次 REPORT-8790 改动太多了,先commit一次master
richie
6 years ago
80 changed files with 2202 additions and 2286 deletions
@ -0,0 +1,32 @@ |
|||||||
|
package com.fr.design.env; |
||||||
|
|
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
import com.fr.workspace.Workspace; |
||||||
|
import com.fr.workspace.connect.WorkspaceClient; |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据配置生成运行环境 |
||||||
|
*/ |
||||||
|
public class DesignerWorkspaceGenerator { |
||||||
|
|
||||||
|
public static Workspace generate(DesignerWorkspaceInfo config) { |
||||||
|
|
||||||
|
if (config == null || config.getType() == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
Workspace workspace = null; |
||||||
|
switch (config.getType()) { |
||||||
|
case Local: { |
||||||
|
workspace = WorkContext.getFactory().build(config.getPath()); |
||||||
|
break; |
||||||
|
} |
||||||
|
case Remote: { |
||||||
|
WorkspaceClient client = WorkContext.getConnector().connect(config.getConnection()); |
||||||
|
workspace = new RemoteWorkspace(client, config.getConnection()); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
return workspace; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
package com.fr.design.env; |
||||||
|
|
||||||
|
import com.fr.stable.xml.XMLable; |
||||||
|
import com.fr.workspace.connect.WorkspaceConnection; |
||||||
|
|
||||||
|
public interface DesignerWorkspaceInfo extends XMLable { |
||||||
|
DesignerWorkspaceType getType(); |
||||||
|
|
||||||
|
String getName(); |
||||||
|
|
||||||
|
String getPath(); |
||||||
|
|
||||||
|
WorkspaceConnection getConnection(); |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
package com.fr.design.env; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by juhaoyu on 2018/6/15. |
||||||
|
* 设计器使用的workspace类型 |
||||||
|
*/ |
||||||
|
public enum DesignerWorkspaceType { |
||||||
|
Local, |
||||||
|
Remote |
||||||
|
} |
@ -1,22 +0,0 @@ |
|||||||
package com.fr.design.env; |
|
||||||
|
|
||||||
import com.fr.base.Env; |
|
||||||
import com.fr.core.env.EnvConfig; |
|
||||||
import com.fr.core.env.impl.LocalEnvConfig; |
|
||||||
import com.fr.dav.LocalEnv; |
|
||||||
import com.fr.env.RemoteEnv; |
|
||||||
|
|
||||||
/** |
|
||||||
* 根据配置生成运行环境 |
|
||||||
*/ |
|
||||||
public class EnvGenerator { |
|
||||||
public static Env generate(EnvConfig config) { |
|
||||||
Env env = null; |
|
||||||
if (config instanceof LocalEnvConfig) { |
|
||||||
env = new LocalEnv((LocalEnvConfig)config); |
|
||||||
} else if (config instanceof RemoteEnvConfig) { |
|
||||||
env = new RemoteEnv((RemoteEnvConfig) config); |
|
||||||
} |
|
||||||
return env; |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,68 @@ |
|||||||
|
package com.fr.design.env; |
||||||
|
|
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
import com.fr.workspace.connect.WorkspaceConnection; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by juhaoyu on 2018/6/15. |
||||||
|
*/ |
||||||
|
public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
private String path; |
||||||
|
|
||||||
|
public static LocalDesignerWorkspaceInfo create(String name, String path) { |
||||||
|
|
||||||
|
LocalDesignerWorkspaceInfo info = new LocalDesignerWorkspaceInfo(); |
||||||
|
info.name = name; |
||||||
|
info.path = path; |
||||||
|
return info; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DesignerWorkspaceType getType() { |
||||||
|
|
||||||
|
return DesignerWorkspaceType.Local; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
|
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getPath() { |
||||||
|
|
||||||
|
return path; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public WorkspaceConnection getConnection() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
|
||||||
|
if (reader.isAttr()) { |
||||||
|
this.name = reader.getAttrAsString("name", StringUtils.EMPTY); |
||||||
|
this.path = reader.getAttrAsString("path", StringUtils.EMPTY); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
|
||||||
|
writer.attr("name", name); |
||||||
|
writer.attr("path", path); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object clone() throws CloneNotSupportedException { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,81 @@ |
|||||||
|
package com.fr.design.env; |
||||||
|
|
||||||
|
import com.fr.security.SecurityToolbox; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
import com.fr.workspace.connect.WorkspaceConnection; |
||||||
|
|
||||||
|
public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
private WorkspaceConnection connection; |
||||||
|
|
||||||
|
public static RemoteDesignerWorkspaceInfo create(WorkspaceConnection connection) { |
||||||
|
RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); |
||||||
|
info.connection = connection; |
||||||
|
return info; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DesignerWorkspaceType getType() { |
||||||
|
|
||||||
|
return DesignerWorkspaceType.Remote; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
|
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getPath() { |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public WorkspaceConnection getConnection() { |
||||||
|
|
||||||
|
return connection; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
|
||||||
|
if (reader.isAttr()) { |
||||||
|
this.name = reader.getAttrAsString("name", StringUtils.EMPTY); |
||||||
|
} |
||||||
|
if (reader.isChildNode()) { |
||||||
|
String tagName = reader.getTagName(); |
||||||
|
if ("Connection".equals(tagName)) { |
||||||
|
String url = reader.getAttrAsString("url", StringUtils.EMPTY); |
||||||
|
String username = reader.getAttrAsString("username", StringUtils.EMPTY); |
||||||
|
//密码解密
|
||||||
|
String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ","\r\n")); |
||||||
|
this.connection = new WorkspaceConnection(url, username, password); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
|
||||||
|
writer.attr("name", name); |
||||||
|
if (this.connection != null) { |
||||||
|
writer.startTAG("Connection"); |
||||||
|
writer.attr("url", connection.getUrl()); |
||||||
|
writer.attr("username", connection.getUserName()); |
||||||
|
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); |
||||||
|
writer.end(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object clone() throws CloneNotSupportedException { |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -1,134 +0,0 @@ |
|||||||
package com.fr.design.env; |
|
||||||
|
|
||||||
import com.fr.core.env.impl.AbstractEnvConfig; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.security.SecurityToolbox; |
|
||||||
import com.fr.stable.AssistUtils; |
|
||||||
import com.fr.stable.StableUtils; |
|
||||||
import com.fr.stable.StringUtils; |
|
||||||
import com.fr.stable.xml.XMLPrintWriter; |
|
||||||
import com.fr.stable.xml.XMLableReader; |
|
||||||
|
|
||||||
|
|
||||||
public class RemoteEnvConfig extends AbstractEnvConfig { |
|
||||||
|
|
||||||
public static final int DEFAULT_RPC_PORT = 39999; |
|
||||||
|
|
||||||
private String host; |
|
||||||
private int port; |
|
||||||
private String username; |
|
||||||
private String password; |
|
||||||
|
|
||||||
public RemoteEnvConfig() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public RemoteEnvConfig(String host, int port, String username, String password) { |
|
||||||
this.host = host; |
|
||||||
this.port = port; |
|
||||||
this.username = username; |
|
||||||
this.password = password; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPath() { |
|
||||||
return StableUtils.join(new Object[]{host, port}, ":"); |
|
||||||
} |
|
||||||
|
|
||||||
public String getHost() { |
|
||||||
return host; |
|
||||||
} |
|
||||||
|
|
||||||
public void setHost(String host) { |
|
||||||
this.host = host; |
|
||||||
} |
|
||||||
|
|
||||||
public int getPort() { |
|
||||||
return port; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPort(int port) { |
|
||||||
this.port = port; |
|
||||||
} |
|
||||||
|
|
||||||
public String getUsername() { |
|
||||||
return username; |
|
||||||
} |
|
||||||
|
|
||||||
public void setUsername(String username) { |
|
||||||
this.username = username; |
|
||||||
} |
|
||||||
|
|
||||||
public String getPassword() { |
|
||||||
return password; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPassword(String password) { |
|
||||||
this.password = password; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getDescription(String name) { |
|
||||||
return username + "@" + name + "[" + Inter.getLocText("Fine-Designer_Basic_Remote_Env") + "]"; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void readXML(XMLableReader reader) { |
|
||||||
super.readXML(reader); |
|
||||||
if (reader.isChildNode()) { |
|
||||||
String tagName = reader.getTagName(); |
|
||||||
if ("Attr".equals(tagName)) { |
|
||||||
this.host = reader.getAttrAsString("host", StringUtils.EMPTY); |
|
||||||
this.port = reader.getAttrAsInt("port", DEFAULT_RPC_PORT); |
|
||||||
this.username = reader.getAttrAsString("username", StringUtils.EMPTY); |
|
||||||
String password = reader.getAttrAsString("password", StringUtils.EMPTY); |
|
||||||
if (StringUtils.isNotEmpty(password)) { |
|
||||||
this.password = SecurityToolbox.decrypt(password); |
|
||||||
} |
|
||||||
} else if ("Username".equals(tagName)) { |
|
||||||
this.username = reader.getElementValue(); |
|
||||||
} else if ("Password".equals(tagName)) { |
|
||||||
String txt = reader.getElementValue(); |
|
||||||
this.password = SecurityToolbox.decrypt(txt); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void writeXML(XMLPrintWriter writer) { |
|
||||||
super.writeXML(writer); |
|
||||||
writer.startTAG("Attr") |
|
||||||
.attr("host", host) |
|
||||||
.attr("port", port); |
|
||||||
writer.end(); |
|
||||||
writer.startTAG("Username").textNode(username).end(); |
|
||||||
if (StringUtils.isNotEmpty(password)) { |
|
||||||
writer.startTAG("Password").textNode(SecurityToolbox.encrypt(password)).end(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean equals(Object o) { |
|
||||||
return o instanceof RemoteEnvConfig |
|
||||||
&& AssistUtils.equals(((RemoteEnvConfig) o).host, host) |
|
||||||
&& AssistUtils.equals(((RemoteEnvConfig) o).port, port) |
|
||||||
&& AssistUtils.equals(((RemoteEnvConfig) o).username, username) |
|
||||||
&& AssistUtils.equals(((RemoteEnvConfig) o).password, password); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public int hashCode() { |
|
||||||
return AssistUtils.hashCode(host, port, username, password); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Object clone() throws CloneNotSupportedException { |
|
||||||
RemoteEnvConfig cloned = (RemoteEnvConfig) super.clone(); |
|
||||||
cloned.host = host; |
|
||||||
cloned.port = port; |
|
||||||
cloned.username = username; |
|
||||||
cloned.password = password; |
|
||||||
return cloned; |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,74 @@ |
|||||||
|
package com.fr.design.env; |
||||||
|
|
||||||
|
import com.fr.env.operator.decision.DecisionOperator; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.report.util.RemoteDesignAuthenticateUtils; |
||||||
|
import com.fr.workspace.WorkContext; |
||||||
|
import com.fr.workspace.Workspace; |
||||||
|
import com.fr.workspace.connect.WorkspaceClient; |
||||||
|
import com.fr.workspace.connect.WorkspaceConnection; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by juhaoyu on 2018/6/14. |
||||||
|
* 远程工作目录 |
||||||
|
*/ |
||||||
|
public class RemoteWorkspace implements Workspace { |
||||||
|
|
||||||
|
private final WorkspaceClient client; |
||||||
|
|
||||||
|
private final String address; |
||||||
|
|
||||||
|
private final String userName; |
||||||
|
|
||||||
|
RemoteWorkspace(WorkspaceClient client, WorkspaceConnection connection) { |
||||||
|
|
||||||
|
this.client = client; |
||||||
|
this.address = connection.getUrl(); |
||||||
|
this.userName = connection.getUserName(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
|
||||||
|
return userName; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getPath() { |
||||||
|
|
||||||
|
return address; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getDescription() { |
||||||
|
|
||||||
|
return userName + "@" + "[" + Inter.getLocText("Fine-Designer_Basic_Remote_Env") + "]"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isWarDeploy() { |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isLocal() { |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isRoot() { |
||||||
|
try { |
||||||
|
return WorkContext.getCurrent().get(DecisionOperator.class).isRoot(WorkContext.getConnector().currentUser()); |
||||||
|
} catch (Exception e) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public <T> T get(Class<T> type) { |
||||||
|
|
||||||
|
return client.getPool().get(type); |
||||||
|
} |
||||||
|
} |
@ -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 com.fr.log.FineLoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色
* <p/>
* Author : daisy
* Date: 13-8-30
* Time: 下午3:42
*/
public class RoleDataWrapper implements ChildrenNodesLoader {
private List<String> rolelist = new ArrayList<String>();
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<String> 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;
}
} |
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;
/**
* 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色
* <p/>
* Author : daisy
* Date: 13-8-30
* Time: 下午3:42
*/
public class RoleDataWrapper implements ChildrenNodesLoader {
private List<String> rolelist = new ArrayList<String>();
private String roleTypename = null;
public RoleDataWrapper(String roleName) {
roleTypename = roleName;
}
/**
* 在此计算并获得与管理类型相对应的
*/
private void calculateRoleList() {
try {
Collections.addAll(rolelist, FRContext.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<String> 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;
}
} |
File diff suppressed because it is too large
Load Diff
@ -1,185 +1,185 @@ |
|||||||
package com.fr.env; |
//package com.fr.env;
|
||||||
|
//
|
||||||
import com.fr.design.env.RemoteEnvConfig; |
//import com.fr.design.beans.BasicBeanPane;
|
||||||
import com.fr.design.beans.BasicBeanPane; |
//import com.fr.design.border.UITitledBorder;
|
||||||
import com.fr.design.border.UITitledBorder; |
//import com.fr.design.env.DesignerWorkspaceInfo;
|
||||||
import com.fr.design.gui.ibutton.UIButton; |
//import com.fr.design.env.DesignerWorkspaceType;
|
||||||
import com.fr.design.gui.ilable.UILabel; |
//import com.fr.design.gui.ibutton.UIButton;
|
||||||
import com.fr.design.gui.ipasswordfield.UIPassWordField; |
//import com.fr.design.gui.ilable.UILabel;
|
||||||
import com.fr.design.gui.itextfield.UIIntNumberField; |
//import com.fr.design.gui.ipasswordfield.UIPassWordField;
|
||||||
import com.fr.design.gui.itextfield.UITextField; |
//import com.fr.design.gui.itextfield.UIIntNumberField;
|
||||||
import com.fr.design.layout.TableLayout; |
//import com.fr.design.gui.itextfield.UITextField;
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
//import com.fr.design.layout.TableLayout;
|
||||||
import com.fr.design.utils.gui.GUICoreUtils; |
//import com.fr.design.layout.TableLayoutHelper;
|
||||||
import com.fr.general.Inter; |
//import com.fr.design.utils.gui.GUICoreUtils;
|
||||||
|
//import com.fr.general.Inter;
|
||||||
import javax.swing.*; |
//import com.fr.workspace.WorkContext;
|
||||||
import javax.swing.border.EmptyBorder; |
//import com.fr.workspace.connect.WorkspaceConnection;
|
||||||
import java.awt.*; |
//
|
||||||
import java.awt.event.ActionEvent; |
//import javax.swing.*;
|
||||||
import java.awt.event.ActionListener; |
//import javax.swing.border.EmptyBorder;
|
||||||
import java.awt.event.WindowAdapter; |
//import java.awt.*;
|
||||||
import java.awt.event.WindowEvent; |
//import java.awt.event.ActionEvent;
|
||||||
|
//import java.awt.event.ActionListener;
|
||||||
/** |
//import java.awt.event.WindowAdapter;
|
||||||
* 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane |
//import java.awt.event.WindowEvent;
|
||||||
*/ |
//
|
||||||
public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> { |
///**
|
||||||
|
// * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane
|
||||||
private UITextField hostTextField; |
// */
|
||||||
private UIIntNumberField portTextField; |
//public class RemoteEnvPane2 extends BasicBeanPane<DesignerWorkspaceInfo> {
|
||||||
private UITextField usernameTextField; |
//
|
||||||
private UIPassWordField passwordTextField; |
// private UITextField urlTextField;
|
||||||
private JDialog dialog; |
// private UITextField usernameTextField;
|
||||||
private UILabel message; |
// private UIPassWordField passwordTextField;
|
||||||
private UIButton okButton; |
// private JDialog dialog;
|
||||||
private UIButton cancelButton; |
// private UILabel message;
|
||||||
|
// private UIButton okButton;
|
||||||
public RemoteEnvPane2() { |
// private UIButton cancelButton;
|
||||||
initComponents(); |
//
|
||||||
} |
// public RemoteEnvPane2() {
|
||||||
|
// initComponents();
|
||||||
private void initComponents() { |
// }
|
||||||
setLayout(new BorderLayout()); |
//
|
||||||
|
// private void initComponents() {
|
||||||
JPanel contentPanel = new JPanel(new BorderLayout()); |
// setLayout(new BorderLayout());
|
||||||
add(contentPanel, BorderLayout.CENTER); |
//
|
||||||
|
// JPanel contentPanel = new JPanel(new BorderLayout());
|
||||||
contentPanel.setBorder( |
// add(contentPanel, BorderLayout.CENTER);
|
||||||
BorderFactory.createCompoundBorder( |
//
|
||||||
new EmptyBorder(6, 0, 0, 0), |
// contentPanel.setBorder(
|
||||||
UITitledBorder.createBorderWithTitle(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Config"))) |
// BorderFactory.createCompoundBorder(
|
||||||
); |
// new EmptyBorder(6, 0, 0, 0),
|
||||||
|
// UITitledBorder.createBorderWithTitle(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Config")))
|
||||||
double p = TableLayout.PREFERRED; |
// );
|
||||||
double f = TableLayout.FILL; |
//
|
||||||
double[] rowSize = new double[]{p, p, p, p, p}; |
// double p = TableLayout.PREFERRED;
|
||||||
double[] columnSize = new double[]{p, f}; |
// double f = TableLayout.FILL;
|
||||||
UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try")); |
// double[] rowSize = new double[]{p, p, p, p};
|
||||||
hostTextField = new UITextField(); |
// double[] columnSize = new double[]{p, f};
|
||||||
hostTextField.setPlaceholder("192.168.100.200"); |
// UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try"));
|
||||||
portTextField = new UIIntNumberField(); |
// urlTextField = new UITextField();
|
||||||
portTextField.setPlaceholder("39999"); |
// urlTextField.setPlaceholder("http://192.168.100.200/webroot/decision");
|
||||||
JPanel valuePane = TableLayoutHelper.createTableLayoutPane( |
// JPanel valuePane = TableLayoutHelper.createTableLayoutPane(
|
||||||
new Component[][]{ |
// new Component[][]{
|
||||||
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), hostTextField}, |
// {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), urlTextField},
|
||||||
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Port") + ":", SwingConstants.RIGHT),portTextField}, |
// {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()},
|
||||||
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()}, |
// {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()},
|
||||||
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()}, |
// {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)}
|
||||||
{null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)} |
// },
|
||||||
}, |
// rowSize, columnSize
|
||||||
rowSize, columnSize |
// );
|
||||||
); |
// testConnectionButton.addActionListener(new ActionListener() {
|
||||||
testConnectionButton.addActionListener(new ActionListener() { |
// @Override
|
||||||
@Override |
// public void actionPerformed(ActionEvent e) {
|
||||||
public void actionPerformed(ActionEvent e) { |
// tryConnectRemoteEnv();
|
||||||
tryConnectRemoteEnv(); |
// }
|
||||||
} |
// });
|
||||||
}); |
// contentPanel.add(valuePane, BorderLayout.CENTER);
|
||||||
contentPanel.add(valuePane, BorderLayout.CENTER); |
//
|
||||||
|
// message = new UILabel();
|
||||||
message = new UILabel(); |
// okButton = new UIButton(Inter.getLocText("OK"));
|
||||||
okButton = new UIButton(Inter.getLocText("OK")); |
// cancelButton = new UIButton(Inter.getLocText("Cancel"));
|
||||||
cancelButton = new UIButton(Inter.getLocText("Cancel")); |
// }
|
||||||
} |
//
|
||||||
|
// private void tryConnectRemoteEnv() {
|
||||||
private void tryConnectRemoteEnv() { |
// final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
|
||||||
final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { |
//
|
||||||
|
// @Override
|
||||||
@Override |
// protected Void doInBackground() throws Exception {
|
||||||
protected Void doInBackground() throws Exception { |
//
|
||||||
final RemoteEnv remoteEnv = new RemoteEnv(updateBean()); |
// final DesignerWorkspaceInfo remoteEnv = updateBean();
|
||||||
remoteEnv.connectOnce(); |
// WorkContext.getConnector().testConnection(remoteEnv.getConnection());
|
||||||
return null; |
// return null;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
@Override |
// @Override
|
||||||
protected void done() { |
// protected void done() {
|
||||||
okButton.setEnabled(true); |
// okButton.setEnabled(true);
|
||||||
try { |
// try {
|
||||||
get(); |
// get();
|
||||||
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); |
// message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful"));
|
||||||
} catch (Exception e) { |
// } catch (Exception e) {
|
||||||
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); |
// message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed"));
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
}; |
// };
|
||||||
worker.execute(); |
// worker.execute();
|
||||||
initMessageDialog(); |
// initMessageDialog();
|
||||||
okButton.addActionListener(new ActionListener() { |
// okButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) { |
// public void actionPerformed(ActionEvent e) {
|
||||||
dialog.dispose(); |
// dialog.dispose();
|
||||||
} |
// }
|
||||||
}); |
// });
|
||||||
cancelButton.addActionListener(new ActionListener() { |
// cancelButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) { |
// public void actionPerformed(ActionEvent e) {
|
||||||
dialog.dispose(); |
// dialog.dispose();
|
||||||
worker.cancel(true); |
// worker.cancel(true);
|
||||||
} |
// }
|
||||||
}); |
// });
|
||||||
|
//
|
||||||
dialog.addWindowListener(new WindowAdapter() { |
// dialog.addWindowListener(new WindowAdapter() {
|
||||||
public void windowClosed(WindowEvent e) { |
// public void windowClosed(WindowEvent e) {
|
||||||
worker.cancel(true); |
// worker.cancel(true);
|
||||||
} |
// }
|
||||||
}); |
// });
|
||||||
|
//
|
||||||
dialog.setVisible(true); |
// dialog.setVisible(true);
|
||||||
dialog.dispose(); |
// dialog.dispose();
|
||||||
} |
// }
|
||||||
|
//
|
||||||
private void initMessageDialog() { |
// private void initMessageDialog() {
|
||||||
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try") + "..."); |
// message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try") + "...");
|
||||||
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); |
// message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
|
||||||
okButton.setEnabled(false); |
// okButton.setEnabled(false);
|
||||||
|
//
|
||||||
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true); |
// dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true);
|
||||||
|
//
|
||||||
dialog.setSize(new Dimension(268, 118)); |
// dialog.setSize(new Dimension(268, 118));
|
||||||
okButton.setEnabled(false); |
// okButton.setEnabled(false);
|
||||||
JPanel jp = new JPanel(); |
// JPanel jp = new JPanel();
|
||||||
JPanel upPane = new JPanel(); |
// JPanel upPane = new JPanel();
|
||||||
JPanel downPane = new JPanel(); |
// JPanel downPane = new JPanel();
|
||||||
UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); |
// UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
|
||||||
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); |
// upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
|
||||||
upPane.add(uiLabel); |
// upPane.add(uiLabel);
|
||||||
upPane.add(message); |
// upPane.add(message);
|
||||||
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); |
// downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
|
||||||
downPane.add(okButton); |
// downPane.add(okButton);
|
||||||
downPane.add(cancelButton); |
// downPane.add(cancelButton);
|
||||||
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); |
// jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
|
||||||
jp.add(upPane); |
// jp.add(upPane);
|
||||||
jp.add(downPane); |
// jp.add(downPane);
|
||||||
dialog.add(jp); |
// dialog.add(jp);
|
||||||
dialog.setResizable(false); |
// dialog.setResizable(false);
|
||||||
dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this)); |
// dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this));
|
||||||
} |
// }
|
||||||
|
//
|
||||||
@Override |
// @Override
|
||||||
protected String title4PopupWindow() { |
// protected String title4PopupWindow() {
|
||||||
return "RemoteEnv"; |
// return "RemoteEnv";
|
||||||
} |
// }
|
||||||
|
//
|
||||||
@Override |
// @Override
|
||||||
public void populateBean(RemoteEnvConfig config) { |
// public void populateBean(DesignerWorkspaceInfo config) {
|
||||||
if (config == null) { |
// if (config == null) {
|
||||||
return; |
// return;
|
||||||
} |
// }
|
||||||
hostTextField.setText(config.getHost()); |
// WorkspaceConnection connection = config.getConnection();
|
||||||
if (config.getPort() != 0) { |
// if (connection != null) {
|
||||||
portTextField.setValue(config.getPort()); |
// urlTextField.setText(connection.getUrl());
|
||||||
} |
// usernameTextField.setText(connection.getUserName());
|
||||||
usernameTextField.setText(config.getUsername()); |
// passwordTextField.setText(connection.getPassword());
|
||||||
passwordTextField.setText(config.getPassword()); |
// }
|
||||||
} |
// }
|
||||||
|
//
|
||||||
@Override |
// @Override
|
||||||
public RemoteEnvConfig updateBean() { |
// public DesignerWorkspaceInfo updateBean() {
|
||||||
RemoteEnvConfig config = new RemoteEnvConfig(); |
//
|
||||||
config.setHost(hostTextField.getText()); |
// DesignerWorkspaceInfo config = new DesignerWorkspaceInfo();
|
||||||
config.setPort((int) portTextField.getValue()); |
// WorkspaceConnection connection = new WorkspaceConnection(urlTextField.getText(), usernameTextField.getText(), passwordTextField.getText());
|
||||||
config.setUsername(usernameTextField.getText()); |
// config.setConnection(connection);
|
||||||
config.setPassword(passwordTextField.getText()); |
// config.setType(DesignerWorkspaceType.Remote);
|
||||||
return config; |
// return config;
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
@ -1,167 +1,167 @@ |
|||||||
package com.fr.env; |
//package com.fr.env;
|
||||||
|
//
|
||||||
import com.fr.base.EnvException; |
//import com.fr.base.EnvException;
|
||||||
import com.fr.base.FRContext; |
//import com.fr.base.FRContext;
|
||||||
import com.fr.report.DesignAuthority; |
//import com.fr.report.DesignAuthority;
|
||||||
import com.fr.report.util.AuthorityXMLUtils; |
//import com.fr.report.util.AuthorityXMLUtils;
|
||||||
import com.fr.stable.EncodeConstants; |
//import com.fr.stable.EncodeConstants;
|
||||||
import com.fr.third.org.apache.commons.io.IOUtils; |
//import com.fr.third.org.apache.commons.io.IOUtils;
|
||||||
import com.fr.third.org.apache.http.HttpResponse; |
//import com.fr.third.org.apache.http.HttpResponse;
|
||||||
import com.fr.third.org.apache.http.HttpStatus; |
//import com.fr.third.org.apache.http.HttpStatus;
|
||||||
import com.fr.third.org.apache.http.client.ClientProtocolException; |
//import com.fr.third.org.apache.http.client.ClientProtocolException;
|
||||||
import com.fr.third.org.apache.http.client.ResponseHandler; |
//import com.fr.third.org.apache.http.client.ResponseHandler;
|
||||||
import com.fr.third.org.apache.http.client.methods.HttpUriRequest; |
//import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
|
||||||
import com.fr.third.org.apache.http.client.methods.RequestBuilder; |
//import com.fr.third.org.apache.http.client.methods.RequestBuilder;
|
||||||
import com.fr.third.org.apache.http.entity.ContentType; |
//import com.fr.third.org.apache.http.entity.ContentType;
|
||||||
import com.fr.third.org.apache.http.entity.InputStreamEntity; |
//import com.fr.third.org.apache.http.entity.InputStreamEntity;
|
||||||
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; |
//import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import com.fr.third.org.apache.http.impl.client.HttpClients; |
//import com.fr.third.org.apache.http.impl.client.HttpClients;
|
||||||
|
//
|
||||||
import java.io.ByteArrayInputStream; |
//import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream; |
//import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException; |
//import java.io.IOException;
|
||||||
import java.io.InputStream; |
//import java.io.InputStream;
|
||||||
import java.net.URLEncoder; |
//import java.net.URLEncoder;
|
||||||
import java.util.Map; |
//import java.util.Map;
|
||||||
|
//
|
||||||
public class RemoteEnvUtils { |
//public class RemoteEnvUtils {
|
||||||
|
//
|
||||||
private RemoteEnvUtils() { |
// private RemoteEnvUtils() {
|
||||||
} |
// }
|
||||||
|
//
|
||||||
private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() { |
// private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() {
|
||||||
@Override |
// @Override
|
||||||
public InputStream handleResponse(HttpResponse response) throws IOException { |
// public InputStream handleResponse(HttpResponse response) throws IOException {
|
||||||
int statusCode = response.getStatusLine().getStatusCode(); |
// int statusCode = response.getStatusLine().getStatusCode();
|
||||||
if (statusCode != HttpStatus.SC_OK) { |
// if (statusCode != HttpStatus.SC_OK) {
|
||||||
throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString()); |
// throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString());
|
||||||
} |
// }
|
||||||
InputStream in = response.getEntity().getContent(); |
// InputStream in = response.getEntity().getContent();
|
||||||
if (in == null) { |
// if (in == null) {
|
||||||
return null; |
// return null;
|
||||||
} |
// }
|
||||||
// 读取并返回
|
// // 读取并返回
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
// ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
IOUtils.copy(in, out); |
// IOUtils.copy(in, out);
|
||||||
return new ByteArrayInputStream(out.toByteArray()); |
// return new ByteArrayInputStream(out.toByteArray());
|
||||||
} |
// }
|
||||||
}; |
// };
|
||||||
|
//
|
||||||
public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException { |
// public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
|
||||||
String path = env.getPath(); |
// String path = env.getPath();
|
||||||
RequestBuilder builder = RequestBuilder.post(path); |
// RequestBuilder builder = RequestBuilder.post(path);
|
||||||
|
//
|
||||||
InputStream inputStream = null; |
// InputStream inputStream = null;
|
||||||
|
//
|
||||||
for (Map.Entry<String, String> entry : parameters.entrySet()) { |
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||||
builder.addParameter(entry.getKey(), entry.getValue()); |
// builder.addParameter(entry.getKey(), entry.getValue());
|
||||||
} |
// }
|
||||||
if (!isSignIn) { |
// if (!isSignIn) {
|
||||||
builder.addParameter("id", env.getUserID()); |
// builder.addParameter("id", env.getUserID());
|
||||||
} |
// }
|
||||||
InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes)); |
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes));
|
||||||
|
//
|
||||||
try (CloseableHttpClient httpClient = HttpClients.createSystem()) { |
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
|
||||||
HttpUriRequest request = builder |
// HttpUriRequest request = builder
|
||||||
.setEntity(reqEntity) |
// .setEntity(reqEntity)
|
||||||
.build(); |
// .build();
|
||||||
inputStream = httpClient.execute(request, responseHandler); |
// inputStream = httpClient.execute(request, responseHandler);
|
||||||
} catch (IOException e) { |
// } catch (IOException e) {
|
||||||
FRContext.getLogger().error(e.getMessage()); |
// FRContext.getLogger().error(e.getMessage());
|
||||||
} |
// }
|
||||||
return inputStream; |
// return inputStream;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException { |
// public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
|
||||||
String path = env.getPath(); |
// String path = env.getPath();
|
||||||
RequestBuilder builder = RequestBuilder.post(path); |
// RequestBuilder builder = RequestBuilder.post(path);
|
||||||
|
//
|
||||||
InputStream inputStream = null; |
// InputStream inputStream = null;
|
||||||
|
//
|
||||||
for (Map.Entry<String, String> entry : parameters.entrySet()) { |
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||||
builder.addParameter(entry.getKey(), entry.getValue()); |
// builder.addParameter(entry.getKey(), entry.getValue());
|
||||||
} |
// }
|
||||||
if (!isSignIn) { |
// if (!isSignIn) {
|
||||||
builder.addParameter("id", env.getUserID()); |
// builder.addParameter("id", env.getUserID());
|
||||||
} |
// }
|
||||||
|
//
|
||||||
try (CloseableHttpClient httpClient = HttpClients.createSystem()) { |
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
|
||||||
HttpUriRequest request = builder |
// HttpUriRequest request = builder
|
||||||
.build(); |
// .build();
|
||||||
inputStream = httpClient.execute(request, responseHandler); |
// inputStream = httpClient.execute(request, responseHandler);
|
||||||
} catch (IOException e) { |
// } catch (IOException e) {
|
||||||
FRContext.getLogger().error(e.getMessage()); |
// FRContext.getLogger().error(e.getMessage());
|
||||||
} |
// }
|
||||||
return inputStream; |
// return inputStream;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException { |
// public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
|
||||||
String path = env.getPath(); |
// String path = env.getPath();
|
||||||
RequestBuilder builder = RequestBuilder.get(path); |
// RequestBuilder builder = RequestBuilder.get(path);
|
||||||
|
//
|
||||||
InputStream inputStream = null; |
// InputStream inputStream = null;
|
||||||
|
//
|
||||||
for (Map.Entry<String, String> entry : parameters.entrySet()) { |
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||||
builder.addParameter(entry.getKey(), entry.getValue()); |
// builder.addParameter(entry.getKey(), entry.getValue());
|
||||||
} |
// }
|
||||||
if (!isSignIn) { |
// if (!isSignIn) {
|
||||||
builder.addParameter("id", env.getUserID()); |
// builder.addParameter("id", env.getUserID());
|
||||||
} |
// }
|
||||||
try (CloseableHttpClient httpClient = HttpClients.createSystem()) { |
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
|
||||||
HttpUriRequest request = builder.build(); |
// HttpUriRequest request = builder.build();
|
||||||
inputStream = httpClient.execute(request, responseHandler); |
// inputStream = httpClient.execute(request, responseHandler);
|
||||||
|
//
|
||||||
} catch (IOException e) { |
// } catch (IOException e) {
|
||||||
FRContext.getLogger().error(e.getMessage()); |
// FRContext.getLogger().error(e.getMessage());
|
||||||
} |
// }
|
||||||
return inputStream; |
// return inputStream;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) { |
// public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) {
|
||||||
String path = env.getPath(); |
// String path = env.getPath();
|
||||||
// 远程设计临时用户id
|
// // 远程设计临时用户id
|
||||||
String userID = env.getUserID(); |
// String userID = env.getUserID();
|
||||||
InputStream inputStream = null; |
// InputStream inputStream = null;
|
||||||
|
//
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream); |
// AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream);
|
||||||
InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML); |
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML);
|
||||||
|
//
|
||||||
try (CloseableHttpClient httpClient = HttpClients.createSystem()) { |
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
|
||||||
HttpUriRequest request = RequestBuilder.post(path) |
// HttpUriRequest request = RequestBuilder.post(path)
|
||||||
.addParameter("id", userID) |
// .addParameter("id", userID)
|
||||||
.addParameter("op", "remote_design_authority") |
// .addParameter("op", "remote_design_authority")
|
||||||
.addParameter("cmd", "update_authorities") |
// .addParameter("cmd", "update_authorities")
|
||||||
.setEntity(reqEntity) |
// .setEntity(reqEntity)
|
||||||
.build(); |
// .build();
|
||||||
inputStream = httpClient.execute(request, responseHandler); |
// inputStream = httpClient.execute(request, responseHandler);
|
||||||
} catch (IOException e) { |
// } catch (IOException e) {
|
||||||
FRContext.getLogger().error(e.getMessage()); |
// FRContext.getLogger().error(e.getMessage());
|
||||||
} |
// }
|
||||||
|
//
|
||||||
return inputStream; |
// return inputStream;
|
||||||
|
//
|
||||||
} |
// }
|
||||||
|
//
|
||||||
public static InputStream getAuthorities(RemoteEnv env) throws EnvException { |
// public static InputStream getAuthorities(RemoteEnv env) throws EnvException {
|
||||||
String path = env.getPath(); |
// String path = env.getPath();
|
||||||
// 远程设计临时用户id
|
// // 远程设计临时用户id
|
||||||
String userID = env.getUserID(); |
// String userID = env.getUserID();
|
||||||
InputStream inputStream = null; |
// InputStream inputStream = null;
|
||||||
|
//
|
||||||
try (CloseableHttpClient httpClient = HttpClients.createSystem();) { |
// try (CloseableHttpClient httpClient = HttpClients.createSystem();) {
|
||||||
HttpUriRequest request = RequestBuilder.get(path) |
// HttpUriRequest request = RequestBuilder.get(path)
|
||||||
.addParameter("id", userID) |
// .addParameter("id", userID)
|
||||||
.addParameter("op", "remote_design_authority") |
// .addParameter("op", "remote_design_authority")
|
||||||
.addParameter("cmd", "get_authorities") |
// .addParameter("cmd", "get_authorities")
|
||||||
.build(); |
// .build();
|
||||||
inputStream = httpClient.execute(request, responseHandler); |
// inputStream = httpClient.execute(request, responseHandler);
|
||||||
} catch (IOException e) { |
// } catch (IOException e) {
|
||||||
FRContext.getLogger().error(e.getMessage()); |
// FRContext.getLogger().error(e.getMessage());
|
||||||
} |
// }
|
||||||
return inputStream; |
// return inputStream;
|
||||||
} |
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
} |
//}
|
||||||
|
@ -1,46 +0,0 @@ |
|||||||
package com.fr.env; |
|
||||||
|
|
||||||
|
|
||||||
import com.fr.base.Env; |
|
||||||
import com.fr.base.FRContext; |
|
||||||
import com.fr.core.env.EnvConfig; |
|
||||||
import com.fr.core.env.EnvContext; |
|
||||||
import com.fr.core.env.EnvEvent; |
|
||||||
import com.fr.design.mainframe.DesignerContext; |
|
||||||
import com.fr.design.utils.DesignUtils; |
|
||||||
import com.fr.event.Event; |
|
||||||
import com.fr.event.EventDispatcher; |
|
||||||
import com.fr.event.Listener; |
|
||||||
import com.fr.event.Null; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.stable.AssistUtils; |
|
||||||
|
|
||||||
import javax.swing.*; |
|
||||||
|
|
||||||
|
|
||||||
public class SignIn { |
|
||||||
|
|
||||||
static { |
|
||||||
EventDispatcher.listen(EnvEvent.CONNECTION_ERROR, new Listener<Null>() { |
|
||||||
@Override |
|
||||||
public void on(Event event, Null param) { |
|
||||||
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Datasource-Connection_failed")); |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 注册入环境 |
|
||||||
* |
|
||||||
* @param selectedEnv 选择的环境 |
|
||||||
* @throws Exception 异常 |
|
||||||
*/ |
|
||||||
public static void signIn(EnvConfig selectedEnv) throws Exception { |
|
||||||
Env env = FRContext.getCurrentEnv(); |
|
||||||
if (env != null && AssistUtils.equals(env.getEnvConfig(), selectedEnv)) { |
|
||||||
env.disconnect(); |
|
||||||
} |
|
||||||
//DesignUtils.switchToEnv(selectedEnv);
|
|
||||||
} |
|
||||||
} |
|
@ -1,234 +0,0 @@ |
|||||||
package com.fr.start.module; |
|
||||||
|
|
||||||
import com.fr.base.Env; |
|
||||||
import com.fr.base.ModifiedTable; |
|
||||||
import com.fr.base.Parameter; |
|
||||||
import com.fr.base.StoreProcedureParameter; |
|
||||||
import com.fr.base.TableData; |
|
||||||
import com.fr.base.env.EnvUpdater; |
|
||||||
import com.fr.base.env.serializer.OldSerializerAdapter; |
|
||||||
import com.fr.base.env.serializer.ProcedureDataModelSerializer; |
|
||||||
import com.fr.core.env.EnvConfig; |
|
||||||
import com.fr.core.env.EnvEvent; |
|
||||||
import com.fr.core.env.proxy.EnvProxy; |
|
||||||
import com.fr.data.core.db.TableProcedure; |
|
||||||
import com.fr.data.impl.Connection; |
|
||||||
import com.fr.data.impl.storeproc.ProcedureDataModel; |
|
||||||
import com.fr.data.impl.storeproc.StoreProcedure; |
|
||||||
import com.fr.dav.DavXMLUtils; |
|
||||||
import com.fr.design.DesignerEnvManager; |
|
||||||
import com.fr.design.env.EnvGenerator; |
|
||||||
import com.fr.event.Event; |
|
||||||
import com.fr.event.EventDispatcher; |
|
||||||
import com.fr.event.Listener; |
|
||||||
import com.fr.file.filetree.FileNode; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.module.Activator; |
|
||||||
import com.fr.start.EnvSwitcher; |
|
||||||
import com.fr.start.ServerStarter; |
|
||||||
|
|
||||||
import java.io.InputStream; |
|
||||||
import java.io.OutputStream; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by juhaoyu on 2018/1/8. |
|
||||||
* 设计器启动时的环境相关模块activator |
|
||||||
*/ |
|
||||||
public class DesignerEnvProvider extends Activator { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void start() { |
|
||||||
|
|
||||||
String[] args = getModule().upFindSingleton(StartupArgs.class).get(); |
|
||||||
if (args != null) { |
|
||||||
for (String arg : args) { |
|
||||||
if (ComparatorUtils.equals(arg, "demo")) { |
|
||||||
DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); |
|
||||||
ServerStarter.browserDemoURL(); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
initDesignerEnv(); |
|
||||||
|
|
||||||
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher()); |
|
||||||
//设置好环境即可,具体跟环境有关的模块会自动调用
|
|
||||||
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); |
|
||||||
} |
|
||||||
|
|
||||||
private void initDesignerEnv() { |
|
||||||
addSerializers(); |
|
||||||
EventDispatcher.listen(EnvEvent.BEFORE_SIGN_IN, new Listener<EnvConfig>() { |
|
||||||
@Override |
|
||||||
public void on(Event event, EnvConfig envConfig) { |
|
||||||
Env env = EnvGenerator.generate(envConfig); |
|
||||||
EnvUpdater.updateEnv(env); |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
private void addSerializers() { |
|
||||||
|
|
||||||
EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer()); |
|
||||||
|
|
||||||
EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter<ModifiedTable>( |
|
||||||
new OldSerializerAdapter.OldSerializer<ModifiedTable>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void serializer(ModifiedTable obj, OutputStream out) throws Exception { |
|
||||||
|
|
||||||
DavXMLUtils.writeXMLModifiedTables(obj, out); |
|
||||||
} |
|
||||||
}, |
|
||||||
new OldSerializerAdapter.OldDeserializer<ModifiedTable>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public ModifiedTable deserializer(InputStream in) throws Exception { |
|
||||||
|
|
||||||
return DavXMLUtils.readXMLModifiedTables(in); |
|
||||||
} |
|
||||||
} |
|
||||||
)); |
|
||||||
|
|
||||||
EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter<com.fr.data.impl.Connection>( |
|
||||||
new OldSerializerAdapter.OldSerializer<Connection>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void serializer(Connection obj, OutputStream out) { |
|
||||||
|
|
||||||
DavXMLUtils.writeXMLFileDatabaseConnection(obj, out); |
|
||||||
} |
|
||||||
}, |
|
||||||
new OldSerializerAdapter.OldDeserializer<Connection>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public Connection deserializer(InputStream in) throws Exception { |
|
||||||
|
|
||||||
return DavXMLUtils.readXMLDatabaseConnection(in); |
|
||||||
} |
|
||||||
} |
|
||||||
)); |
|
||||||
|
|
||||||
EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter<FileNode[]>( |
|
||||||
new OldSerializerAdapter.OldSerializer<FileNode[]>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void serializer(FileNode[] obj, OutputStream out) { |
|
||||||
|
|
||||||
DavXMLUtils.writeXMLFileNodes(obj, out); |
|
||||||
} |
|
||||||
}, |
|
||||||
new OldSerializerAdapter.OldDeserializer<FileNode[]>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public FileNode[] deserializer(InputStream in) { |
|
||||||
|
|
||||||
return DavXMLUtils.readXMLFileNodes(in); |
|
||||||
} |
|
||||||
} |
|
||||||
)); |
|
||||||
|
|
||||||
EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter<TableProcedure[]>( |
|
||||||
new OldSerializerAdapter.OldSerializer<TableProcedure[]>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void serializer(TableProcedure[] obj, OutputStream out) { |
|
||||||
|
|
||||||
DavXMLUtils.writeXMLFileSQLTable(obj, out); |
|
||||||
} |
|
||||||
}, |
|
||||||
new OldSerializerAdapter.OldDeserializer<TableProcedure[]>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public TableProcedure[] deserializer(InputStream in) throws Exception { |
|
||||||
|
|
||||||
return DavXMLUtils.readXMLSQLTables(in); |
|
||||||
} |
|
||||||
} |
|
||||||
)); |
|
||||||
|
|
||||||
EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter<TableData>( |
|
||||||
new OldSerializerAdapter.OldSerializer<TableData>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void serializer(TableData obj, OutputStream out) { |
|
||||||
|
|
||||||
DavXMLUtils.writeXMLFileTableData(obj, out); |
|
||||||
} |
|
||||||
}, |
|
||||||
new OldSerializerAdapter.OldDeserializer<TableData>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public TableData deserializer(InputStream in) throws Exception { |
|
||||||
|
|
||||||
return DavXMLUtils.readXMLTableData(in); |
|
||||||
} |
|
||||||
} |
|
||||||
)); |
|
||||||
|
|
||||||
EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter<Parameter[]>( |
|
||||||
new OldSerializerAdapter.OldSerializer<Parameter[]>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void serializer(Parameter[] obj, OutputStream out) { |
|
||||||
|
|
||||||
DavXMLUtils.writeXMLFileParameters(obj, out); |
|
||||||
} |
|
||||||
}, |
|
||||||
new OldSerializerAdapter.OldDeserializer<Parameter[]>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public Parameter[] deserializer(InputStream in) throws Exception { |
|
||||||
|
|
||||||
return DavXMLUtils.readXMLParameters(in); |
|
||||||
} |
|
||||||
} |
|
||||||
)); |
|
||||||
|
|
||||||
EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter<StoreProcedure>( |
|
||||||
new OldSerializerAdapter.OldSerializer<StoreProcedure>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void serializer(StoreProcedure obj, OutputStream out) { |
|
||||||
|
|
||||||
DavXMLUtils.writeXMLFileStoreProcedure(obj, out); |
|
||||||
} |
|
||||||
}, |
|
||||||
new OldSerializerAdapter.OldDeserializer<StoreProcedure>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public StoreProcedure deserializer(InputStream in) throws Exception { |
|
||||||
|
|
||||||
return DavXMLUtils.readXMLStoreProcedure(in); |
|
||||||
} |
|
||||||
} |
|
||||||
)); |
|
||||||
|
|
||||||
EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter<StoreProcedureParameter[]>( |
|
||||||
new OldSerializerAdapter.OldSerializer<StoreProcedureParameter[]>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void serializer(StoreProcedureParameter[] obj, OutputStream out) { |
|
||||||
|
|
||||||
DavXMLUtils.writeXMLFileParameters(obj, out); |
|
||||||
} |
|
||||||
}, |
|
||||||
new OldSerializerAdapter.OldDeserializer<StoreProcedureParameter[]>() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public StoreProcedureParameter[] deserializer(InputStream in) throws Exception { |
|
||||||
|
|
||||||
return DavXMLUtils.readXMLStoreProcedureParameters(in); |
|
||||||
} |
|
||||||
} |
|
||||||
)); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void stop() { |
|
||||||
//清空模块
|
|
||||||
getRoot().removeSingleton(EnvSwitcher.class); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,41 @@ |
|||||||
|
package com.fr.start.module; |
||||||
|
|
||||||
|
import com.fr.design.DesignerEnvManager; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.module.Activator; |
||||||
|
import com.fr.start.EnvSwitcher; |
||||||
|
import com.fr.start.ServerStarter; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by juhaoyu on 2018/1/8. |
||||||
|
* 设计器启动时的环境相关模块activator |
||||||
|
*/ |
||||||
|
public class DesignerWorkspaceProvider extends Activator { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void start() { |
||||||
|
|
||||||
|
String[] args = getModule().upFindSingleton(StartupArgs.class).get(); |
||||||
|
if (args != null) { |
||||||
|
for (String arg : args) { |
||||||
|
if (ComparatorUtils.equals(arg, "demo")) { |
||||||
|
DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); |
||||||
|
ServerStarter.browserDemoURL(); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher()); |
||||||
|
//设置好环境即可,具体跟环境有关的模块会自动调用
|
||||||
|
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void stop() { |
||||||
|
//清空模块
|
||||||
|
getRoot().removeSingleton(EnvSwitcher.class); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue