Browse Source

无JIRA任务 组件复用的远程安装,现在是把reu文件拆分成两个xml分别传给服务端,直接给正文塞reu文件的二进制会因为tostring方法造成数据丢失

master
zack 8 years ago
parent
commit
276847ff48
  1. 60
      designer_base/src/com/fr/env/RemoteEnv.java

60
designer_base/src/com/fr/env/RemoteEnv.java vendored

@ -2114,6 +2114,7 @@ public class RemoteEnv implements Env {
StableUtils.mkdirs(target); StableUtils.mkdirs(target);
File cacheDir = null; File cacheDir = null;
File zip = null; File zip = null;
OutputStream out = null;
try { try {
HashMap<String, String> para = new HashMap<String, String>(); HashMap<String, String> para = new HashMap<String, String>();
para.put("op", "fr_remote_design"); para.put("op", "fr_remote_design");
@ -2122,16 +2123,15 @@ public class RemoteEnv implements Env {
para.put("currentUsername", this.getUser()); para.put("currentUsername", this.getUser());
HttpClient client = createHttpMethod(para); HttpClient client = createHttpMethod(para);
InputStream input = client.getResponseStream(); InputStream input = client.getResponseStream();//拿到服务端传过来的整个共享文件夹的压缩文件的文件流
zip = new File(StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath()), "share.zip"); zip = new File(StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath()), "share.zip");
cacheDir = new File(StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath()), ShareConstants.DIR_SHARE_CACHE); cacheDir = new File(StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath()), ShareConstants.DIR_SHARE_CACHE);
StableUtils.deleteFile(cacheDir); StableUtils.deleteFile(cacheDir);
StableUtils.mkdirs(cacheDir); StableUtils.mkdirs(cacheDir);
StableUtils.makesureFileExist(zip); StableUtils.makesureFileExist(zip);
FileOutputStream out = new FileOutputStream(zip); out = new FileOutputStream(zip);
IOUtils.copyBinaryTo(input, out); IOUtils.copyBinaryTo(input, out);//放到本地缓存目录下
out.flush();
out.close();
IOUtils.unzip(zip, cacheDir.getAbsolutePath(), EncodeConstants.ENCODING_GBK);//先解压到临时目录 IOUtils.unzip(zip, cacheDir.getAbsolutePath(), EncodeConstants.ENCODING_GBK);//先解压到临时目录
if (cacheDir.exists() && cacheDir.isDirectory()) { if (cacheDir.exists() && cacheDir.isDirectory()) {
return cacheDir.listFiles(new FilenameFilter() { return cacheDir.listFiles(new FilenameFilter() {
@ -2144,6 +2144,10 @@ public class RemoteEnv implements Env {
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage()); FRContext.getLogger().error(e.getMessage());
} finally { } finally {
if (out != null) {
out.flush();
out.close();
}
StableUtils.deleteFile(zip); StableUtils.deleteFile(zip);
} }
return new File[0]; return new File[0];
@ -2151,25 +2155,33 @@ public class RemoteEnv implements Env {
@Override @Override
public boolean installREUFile(File reuFile) { public boolean installREUFile(File reuFile) {
// if (reuFile == null) { if (reuFile == null) {
// return false; return false;
// } }
// try { File tempFile = new File(CacheManager.getProviderInstance().getCacheDirectory(), "temp_remote");
// HashMap<String, String> para = new HashMap<String, String>(); IOUtils.unzip(reuFile, tempFile.getAbsolutePath());
// para.put("op", "fr_remote_design"); String shareXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_MODULE);
// para.put("cmd", "design_install_reufile"); String helpXMLName = StableUtils.pathJoin(tempFile.getAbsolutePath(), ShareConstants.NAME_XML_HELP);
// para.put("current_uid", this.createUserID()); try {
// para.put("currentUsername", this.getUser()); HashMap<String, String> para = new HashMap<String, String>();
// para.put("reuFileName", reuFile.getName()); para.put("op", "fr_remote_design");
// para.put("cmd", "design_install_reufile");
// HttpClient client = createHttpMethod(para); para.put("current_uid", this.createUserID());
// client.setContent(IOUtils.inputStream2Bytes(new FileInputStream(reuFile))); para.put("currentUsername", this.getUser());
// InputStream input = execute4InputStream(client); para.put("reuFileName", reuFile.getName());
// return ComparatorUtils.equals(stream2String(input), "true");
// } catch (Exception e) { HttpClient client = createHttpMethod(para);
// return false; client.setContent(IOUtils.inputStream2Bytes(new FileInputStream(new File(shareXMLName))));
// } InputStream input = execute4InputStream(client);
return false; client.release();
para.put("isComplete", "true");
HttpClient client1 = createHttpMethod(para);
client1.setContent(IOUtils.inputStream2Bytes(new FileInputStream(new File(helpXMLName))));
InputStream input1 = execute4InputStream(client1);
return ComparatorUtils.equals(stream2String(input), "true") && ComparatorUtils.equals(stream2String(input1), "true");
} catch (Exception e) {
return false;
}
} }
@Override @Override

Loading…
Cancel
Save