10 changed files with 239 additions and 154 deletions
@ -1,117 +1,14 @@ |
|||||||
package com.fr.design.env; |
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.XMLable; |
||||||
import com.fr.stable.xml.XMLableReader; |
|
||||||
import com.fr.workspace.connect.WorkspaceConnection; |
import com.fr.workspace.connect.WorkspaceConnection; |
||||||
|
|
||||||
/** |
public interface DesignerWorkspaceInfo extends XMLable { |
||||||
* Created by juhaoyu on 2018/6/15. |
DesignerWorkspaceType getType(); |
||||||
*/ |
|
||||||
public class DesignerWorkspaceInfo implements XMLable { |
|
||||||
|
|
||||||
private static final int DEFAULT_RPC_PORT = 39999; |
String getName(); |
||||||
|
|
||||||
public static final String XML_TAG = "DesignerWorkspace"; |
String getPath(); |
||||||
|
|
||||||
private DesignerWorkspaceType type; |
WorkspaceConnection getConnection(); |
||||||
|
|
||||||
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; |
|
||||||
} |
|
||||||
|
|
||||||
public void setType(DesignerWorkspaceType type) { |
|
||||||
|
|
||||||
this.type = type; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPath(String path) { |
|
||||||
|
|
||||||
this.path = path; |
|
||||||
} |
|
||||||
|
|
||||||
public void setConnection(WorkspaceConnection connection) { |
|
||||||
|
|
||||||
this.connection = connection; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void readXML(XMLableReader reader) { |
|
||||||
|
|
||||||
if (reader.isAttr()) { |
|
||||||
this.name = reader.getAttrAsString("name", StringUtils.EMPTY); |
|
||||||
this.type = DesignerWorkspaceType.valueOf(reader.getAttrAsString("type", "Local")); |
|
||||||
this.path = reader.getAttrAsString("path", 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.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); |
|
||||||
this.connection = new WorkspaceConnection(url, 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("url", connection.getUrl()); |
|
||||||
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,70 @@ |
|||||||
|
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 { |
||||||
|
|
||||||
|
public static final String XML_TAG = "LocalDesignerWorkspaceInfo"; |
||||||
|
|
||||||
|
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,83 @@ |
|||||||
|
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 { |
||||||
|
|
||||||
|
public static final String XML_TAG = "RemoteDesignerWorkspaceInfo"; |
||||||
|
|
||||||
|
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.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY)); |
||||||
|
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.encrypt(connection.getPassword())); |
||||||
|
writer.end(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object clone() throws CloneNotSupportedException { |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue