ju
7 years ago
24 changed files with 1033 additions and 1069 deletions
@ -0,0 +1,104 @@
|
||||
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.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.workspace.connect.WorkspaceConnection; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2018/6/15. |
||||
*/ |
||||
public class DesignerWorkspaceInfo implements XMLable { |
||||
|
||||
private static final int DEFAULT_RPC_PORT = 39999; |
||||
|
||||
public static final String XML_TAG = "DesignerWorkspace"; |
||||
|
||||
private DesignerWorkspaceType type; |
||||
|
||||
private String name; |
||||
|
||||
private String path; |
||||
|
||||
private WorkspaceConnection connection; |
||||
|
||||
public static DesignerWorkspaceInfo createLocal(String name, String path) { |
||||
|
||||
DesignerWorkspaceInfo info = new DesignerWorkspaceInfo(); |
||||
info.connection = null; |
||||
info.name = name; |
||||
info.path = path; |
||||
info.type = DesignerWorkspaceType.Local; |
||||
return info; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
|
||||
this.name = name; |
||||
} |
||||
|
||||
public DesignerWorkspaceType getType() { |
||||
|
||||
return type; |
||||
} |
||||
|
||||
public String getName() { |
||||
|
||||
return name; |
||||
} |
||||
|
||||
public String getPath() { |
||||
|
||||
return path; |
||||
} |
||||
|
||||
public WorkspaceConnection getConnection() { |
||||
|
||||
return connection; |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
|
||||
if (reader.isAttr()) { |
||||
this.name = reader.getAttrAsString("name", StringUtils.EMPTY); |
||||
this.type = DesignerWorkspaceType.valueOf(reader.getAttrAsString("name", "Local")); |
||||
this.path = reader.getAttrAsString("path", StringUtils.EMPTY); |
||||
} |
||||
if (reader.isChildNode()) { |
||||
String tagName = reader.getTagName(); |
||||
if ("Connection".equals(tagName)) { |
||||
String ip = reader.getAttrAsString("ip", StringUtils.EMPTY); |
||||
int port = reader.getAttrAsInt("port", DEFAULT_RPC_PORT); |
||||
String username = reader.getAttrAsString("username", StringUtils.EMPTY); |
||||
//密码解密
|
||||
String password = SecurityToolbox.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); |
||||
this.connection = new WorkspaceConnection(ip, port, username, password); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
|
||||
writer.attr("name", name); |
||||
writer.attr("path", path); |
||||
writer.attr("type", type.toString()); |
||||
if (this.connection != null) { |
||||
writer.startTAG("Connection"); |
||||
writer.attr("ip", connection.getIp()); |
||||
writer.attr("port", connection.getPort()); |
||||
writer.attr("username", connection.getUserName()); |
||||
writer.attr("password", SecurityToolbox.encrypt(connection.getPassword())); |
||||
writer.end(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
|
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fr.design.env; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2018/6/15. |
||||
* 设计器使用的workspace类型 |
||||
*/ |
||||
public enum DesignerWorkspaceType { |
||||
Local, |
||||
Remote |
||||
} |
@ -1,137 +0,0 @@
|
||||
package com.fr.design.env; |
||||
|
||||
import com.fr.base.env.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() { |
||||
|
||||
super(name); |
||||
} |
||||
|
||||
public RemoteEnvConfig(String host, int port, String username, String password) { |
||||
|
||||
super(name); |
||||
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; |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue