|
|
|
@ -1,16 +1,7 @@
|
|
|
|
|
package com.fr.env; |
|
|
|
|
|
|
|
|
|
import com.fr.base.AbstractEnv; |
|
|
|
|
import com.fr.base.EnvException; |
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.base.FRCoreContext; |
|
|
|
|
import com.fr.base.ModifiedTable; |
|
|
|
|
import com.fr.base.Parameter; |
|
|
|
|
import com.fr.base.StoreProcedureParameter; |
|
|
|
|
import com.fr.base.TableData; |
|
|
|
|
import com.fr.base.Utils; |
|
|
|
|
import com.fr.base.*; |
|
|
|
|
import com.fr.base.remote.RemoteDeziConstants; |
|
|
|
|
import com.fr.data.TableDataSource; |
|
|
|
|
import com.fr.data.core.DataCoreUtils; |
|
|
|
|
import com.fr.data.core.db.TableProcedure; |
|
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
@ -26,34 +17,17 @@ import com.fr.design.file.HistoryTemplateListPane;
|
|
|
|
|
import com.fr.design.fun.DesignerEnvProcessor; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.mainframe.DesignerFrameFileDealerPane; |
|
|
|
|
import com.fr.design.mainframe.loghandler.DesignerLogHandler; |
|
|
|
|
import com.fr.file.CacheManager; |
|
|
|
|
import com.fr.file.DatasourceManager; |
|
|
|
|
import com.fr.file.DatasourceManagerProvider; |
|
|
|
|
import com.fr.file.filetree.FileNode; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.general.FRLogger; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.general.LogRecordTime; |
|
|
|
|
import com.fr.general.VT4FR; |
|
|
|
|
import com.fr.general.*; |
|
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
|
import com.fr.json.JSONArray; |
|
|
|
|
import com.fr.json.JSONException; |
|
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
import com.fr.plugin.Plugin; |
|
|
|
|
import com.fr.plugin.PluginLicense; |
|
|
|
|
import com.fr.plugin.PluginLicenseManager; |
|
|
|
|
import com.fr.plugin.PluginLoader; |
|
|
|
|
import com.fr.share.ShareConstants; |
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
import com.fr.stable.EncodeConstants; |
|
|
|
|
import com.fr.stable.JavaCompileInfo; |
|
|
|
|
import com.fr.stable.LicUtils; |
|
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.stable.SvgProvider; |
|
|
|
|
import com.fr.stable.*; |
|
|
|
|
import com.fr.stable.file.XMLFileManagerProvider; |
|
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
@ -62,38 +36,17 @@ import com.fr.stable.xml.XMLableReader;
|
|
|
|
|
import com.fr.web.ResourceConstants; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import javax.xml.transform.Source; |
|
|
|
|
import javax.xml.transform.Transformer; |
|
|
|
|
import javax.xml.transform.TransformerConfigurationException; |
|
|
|
|
import javax.xml.transform.TransformerException; |
|
|
|
|
import javax.xml.transform.TransformerFactory; |
|
|
|
|
import javax.xml.transform.*; |
|
|
|
|
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.FileOutputStream; |
|
|
|
|
import java.io.FilenameFilter; |
|
|
|
|
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.io.*; |
|
|
|
|
import java.net.HttpURLConnection; |
|
|
|
|
import java.net.NoRouteToHostException; |
|
|
|
|
import java.net.Socket; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Timer; |
|
|
|
|
import java.util.TimerTask; |
|
|
|
|
import java.util.logging.Level; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
@ -159,15 +112,6 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
return password; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 修复密码中包含特殊字符,无法登录的问题
|
|
|
|
|
private String getEncodedPassword() { |
|
|
|
|
try { |
|
|
|
|
return URLEncoder.encode(password, "UTF-8"); |
|
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
|
return password; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setPassword(String password) { |
|
|
|
|
this.password = password; |
|
|
|
|
clearUserID(); |
|
|
|
@ -231,12 +175,8 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
* 根据nameValuePairs,也就是参数对,生成PostMethod,不同之处在于,参数拼在path后面,不是method.addParameters |
|
|
|
|
*/ |
|
|
|
|
private HttpClient createHttpMethod2(HashMap<String, String> para) throws EnvException { |
|
|
|
|
StringBuilder sb = new StringBuilder(path); |
|
|
|
|
|
|
|
|
|
sb.append('?'); |
|
|
|
|
sb.append("id=").append(createUserID()); |
|
|
|
|
|
|
|
|
|
return new HttpClient(sb.toString(), para, true); |
|
|
|
|
String methodPath = path + '?' + "id=" + createUserID(); |
|
|
|
|
return new HttpClient(methodPath, para, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -393,7 +333,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
para.put("op", "fr_remote_design"); |
|
|
|
|
para.put("cmd", "test_server_connection"); |
|
|
|
|
para.put("user", user); |
|
|
|
|
para.put("password", getEncodedPassword()); |
|
|
|
|
para.put("password", password); |
|
|
|
|
|
|
|
|
|
if (path.startsWith("https") && (!DesignerEnvManager.getEnvManager().isHttps())) { |
|
|
|
|
return false; |
|
|
|
@ -418,7 +358,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
Inter.getLocText(new String[]{"Datasource-Connection_failed", "Registration-User_Name", "Password", "Error"}, new String[]{",", "", "", "!"}) |
|
|
|
|
, Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE); |
|
|
|
|
return false; |
|
|
|
|
} else if (res.indexOf("RegistEditionException") != -1) { |
|
|
|
|
} else if (res.contains("RegistEditionException")) { |
|
|
|
|
if (needMessage) { |
|
|
|
|
JOptionPane.showMessageDialog(parentComponent, Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); |
|
|
|
|
} else { |
|
|
|
@ -439,7 +379,6 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
|
|
|
|
|
private void extraChangeEnvPara() { |
|
|
|
|
//在env连接之前, 加载一下不依赖env的插件. 看看需不需要改变参数.
|
|
|
|
|
PluginLoader.init(); |
|
|
|
|
DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); |
|
|
|
|
if (envProcessor != null) { |
|
|
|
|
this.path = envProcessor.changeEnvPathBeforeConnect(user, password, path); |
|
|
|
@ -472,9 +411,8 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
para.put("op", "fr_remote_design"); |
|
|
|
|
para.put("cmd", "heart_beat"); |
|
|
|
|
para.put("user", user); |
|
|
|
|
para.put("userid", userID); |
|
|
|
|
|
|
|
|
|
HttpClient client = createHttpMethod(para, true); |
|
|
|
|
HttpClient client = createHttpMethod(para); |
|
|
|
|
execute4InputStream(client); |
|
|
|
|
|
|
|
|
|
//这做法不好, 30秒刷一次, 刷新的时候会重新构建树, 构建完会把子节点都收缩起来, 效果太差.
|
|
|
|
@ -516,7 +454,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
para.put("op", "fr_remote_design"); |
|
|
|
|
para.put("cmd", "r_sign_in"); |
|
|
|
|
para.put("user", user); |
|
|
|
|
para.put("password", getEncodedPassword()); |
|
|
|
|
para.put("password", password); |
|
|
|
|
|
|
|
|
|
simulaRPC(para, true); |
|
|
|
|
|
|
|
|
@ -609,7 +547,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
if (resJSON == null) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (resJSON.indexOf("RegistEditionException") != -1) { |
|
|
|
|
if (resJSON.contains("RegistEditionException")) { |
|
|
|
|
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Lic_does_not_Support_Remote")); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -1264,11 +1202,6 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
return DavXMLUtils.readXMLParameters(input); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public EmbeddedTableData previewTableData(Object tableData, Map parameterMap, int rowCount) throws Exception { |
|
|
|
|
return previewTableData(null, tableData, parameterMap, rowCount); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据指定的参数生成一个实际可预览的数据集 |
|
|
|
|
* |
|
|
|
@ -1278,7 +1211,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
* @return 实际的二维数据集 |
|
|
|
|
* @throws Exception 如果生成数据失败则抛出此异常 |
|
|
|
|
*/ |
|
|
|
|
public EmbeddedTableData previewTableData(TableDataSource dataSource, Object tableData, java.util.Map parameterMap, int rowCount) throws Exception { |
|
|
|
|
public EmbeddedTableData previewTableData(Object tableData, java.util.Map parameterMap, int rowCount) throws Exception { |
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
|
|
|
|
|
|
|
|
// 把tableData写成xml文件到out
|
|
|
|
@ -1317,11 +1250,6 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
return previewTableData(tableData, parameterMap, -1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object previewTableData(TableDataSource dataSource, Object tableData, Map parameterMap, int start, int end, String[] cols, int[] colIdx) throws Exception { |
|
|
|
|
return previewTableData(dataSource, tableData, parameterMap, -1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 |
|
|
|
|
* |
|
|
|
@ -1448,17 +1376,13 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SignIn.signIn(remoteEnv); |
|
|
|
|
resetLicenseBytes(); |
|
|
|
|
FRCoreContext.resetBytes(); |
|
|
|
|
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea(); |
|
|
|
|
} catch (Exception em) { |
|
|
|
|
FRContext.getLogger().error(em.getMessage(), em); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void resetLicenseBytes() { |
|
|
|
|
FRCoreContext.retryLicLock(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 停止连接 |
|
|
|
|
*/ |
|
|
|
@ -1858,8 +1782,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
} |
|
|
|
|
LogRecordTime[] records = DavXMLUtils.readXMLLogRecords(input); |
|
|
|
|
for (LogRecordTime logRecordTime : records) { |
|
|
|
|
DesignerLogHandler.getInstance().printRemoteLog(logRecordTime); |
|
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2011,7 +1934,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
para.put("op", "fr_remote_design"); |
|
|
|
|
para.put("cmd", "design_get_designer_version"); |
|
|
|
|
para.put("user", user); |
|
|
|
|
para.put("password", getEncodedPassword()); |
|
|
|
|
para.put("password", password); |
|
|
|
|
|
|
|
|
|
HttpClient client = createHttpMethod(para, true); |
|
|
|
|
try { |
|
|
|
@ -2059,6 +1982,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
//do nth
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取当前env的build文件路径 |
|
|
|
|
*/ |
|
|
|
@ -2095,73 +2019,7 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
return info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 将文件拷贝到插件目录 |
|
|
|
|
* |
|
|
|
|
* @param dir 要拷贝的文件 |
|
|
|
|
* @param plugin 插件 |
|
|
|
|
*/ |
|
|
|
|
public void copyFilesToPluginAndLibFolder(File dir, Plugin plugin) throws Exception { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 将文件添加到指定目录或者删除指定目录的文件 |
|
|
|
|
* |
|
|
|
|
* @param file 解压插件的临时目录 |
|
|
|
|
* @param plugin 当前处理的插件 |
|
|
|
|
*/ |
|
|
|
|
public void movePluginEmbFile(File file, Plugin plugin) throws Exception { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 将文件从插件目录删除 |
|
|
|
|
* |
|
|
|
|
* @param plugin 要删除插件 |
|
|
|
|
* @return 同上 |
|
|
|
|
*/ |
|
|
|
|
public String[] deleteFileFromPluginAndLibFolder(Plugin plugin) { |
|
|
|
|
return new String[0]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 保存插件的配置文件 |
|
|
|
|
* |
|
|
|
|
* @param plugin 插件 |
|
|
|
|
*/ |
|
|
|
|
public void writePlugin(Plugin plugin) throws Exception { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取插件的配置目录 |
|
|
|
|
* |
|
|
|
|
* @param plugin |
|
|
|
|
*/ |
|
|
|
|
public String getPluginFilePath(Plugin plugin) { |
|
|
|
|
|
|
|
|
|
return StringUtils.EMPTY; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void readPluginLicenses() throws Exception { |
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
|
|
|
HashMap<String, String> para = new HashMap<String, String>(); |
|
|
|
|
para.put("op", "fr_remote_design"); |
|
|
|
|
para.put("cmd", "design_plugin_licenses"); |
|
|
|
|
|
|
|
|
|
InputStream inputStream = postBytes2ServerB(out.toByteArray(), para); |
|
|
|
|
String pluginsLicensesStr = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); |
|
|
|
|
if (StringUtils.isNotBlank(pluginsLicensesStr) && pluginsLicensesStr.startsWith("[")) { |
|
|
|
|
JSONArray jsonArray = new JSONArray(pluginsLicensesStr); |
|
|
|
|
for (int i = 0; i < jsonArray.length(); i++) { |
|
|
|
|
PluginLicense pluginLicense = new PluginLicense(); |
|
|
|
|
pluginLicense.parseJSON(jsonArray.getJSONObject(i)); |
|
|
|
|
PluginLicenseManager.getInstance().addRemotePluginLicense(pluginLicense); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String pluginServiceAction(String serviceID, String req) throws Exception { |
|
|
|
@ -2182,12 +2040,6 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
@Override |
|
|
|
|
public void pluginServiceStart(String serviceID){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void checkAndRegisterLic(FileNode node, Plugin plugin) throws Exception { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public File[] loadREUFile() throws Exception { |
|
|
|
|
File target = new File(CacheManager.getProviderInstance().getCacheDirectory(), |
|
|
|
@ -2305,7 +2157,32 @@ public class RemoteEnv extends AbstractEnv {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void doWhenServerShutDown() { |
|
|
|
|
public boolean isLocalEnv() { |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean hasPluginServiceStarted(String key) { |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public JSONArray getPluginStatus() { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
HashMap<String, String> para = new HashMap<String, String>(); |
|
|
|
|
para.put("op", "plugin"); |
|
|
|
|
para.put("cmd", "get_status"); |
|
|
|
|
para.put("current_uid", this.createUserID()); |
|
|
|
|
para.put("currentUsername", this.getUser()); |
|
|
|
|
|
|
|
|
|
HttpClient client = createHttpMethod(para); |
|
|
|
|
InputStream input = execute4InputStream(client); |
|
|
|
|
return new JSONArray(stream2String(input)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return JSONArray.create(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |