Browse Source

REPORT-51958 远程环境检测及同步

feature/10.0
pengda 3 years ago
parent
commit
da6bb600f1
  1. 21
      designer-base/src/main/java/com/fr/design/VersionCheckUtils.java

21
designer-base/src/main/java/com/fr/design/VersionCheckUtils.java

@ -52,6 +52,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
/** /**
* @author pengda * @author pengda
@ -287,6 +288,7 @@ public class VersionCheckUtils {
@Override @Override
public void updateProgress(String description, double progress) { public void updateProgress(String description, double progress) {
} }
@Override @Override
public void done(PluginTaskResult result) { public void done(PluginTaskResult result) {
latch.countDown(); latch.countDown();
@ -295,9 +297,9 @@ public class VersionCheckUtils {
} }
} }
try { try {
latch.await(); latch.await(5000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
} }
@ -314,6 +316,7 @@ public class VersionCheckUtils {
} }
syncFailedPlugins.add(plugin); syncFailedPlugins.add(plugin);
} }
CommonIOUtils.deleteFile(new File(SYNCLIB));
return syncFailedPlugins; return syncFailedPlugins;
} }
@ -378,7 +381,7 @@ public class VersionCheckUtils {
JSONObject differentPlugin; JSONObject differentPlugin;
String id; String id;
String version; String version;
try { if (differentPlugins != null) {
for (int i = 0; i < differentPlugins.size(); i++) { for (int i = 0; i < differentPlugins.size(); i++) {
String url = null; String url = null;
differentPlugin = differentPlugins.getJSONObject(i); differentPlugin = differentPlugins.getJSONObject(i);
@ -392,11 +395,10 @@ public class VersionCheckUtils {
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (url != null) {
downloadURL.put(id + "-" + version, url); downloadURL.put(id + "-" + version, url);
}
} }
} catch (Exception e) {
} }
return getPluginZipDownloadURL(downloadURL); return getPluginZipDownloadURL(downloadURL);
} }
@ -406,6 +408,7 @@ public class VersionCheckUtils {
CloseableHttpResponse httpResponse; CloseableHttpResponse httpResponse;
HttpGet httpGet = new HttpGet(); HttpGet httpGet = new HttpGet();
InputStream in = null; InputStream in = null;
HashMap<String,String> downloadURLs = new HashMap<>();
try { try {
for (String idAndVersion : urls.keySet()) { for (String idAndVersion : urls.keySet()) {
httpClient = HttpToolbox.getHttpClient(urls.get(idAndVersion)); httpClient = HttpToolbox.getHttpClient(urls.get(idAndVersion));
@ -415,7 +418,7 @@ public class VersionCheckUtils {
JSONObject urlJson = new JSONObject(IOUtils.inputStream2String(in)); JSONObject urlJson = new JSONObject(IOUtils.inputStream2String(in));
String downloadURL = urlJson.getString("result"); String downloadURL = urlJson.getString("result");
if (downloadURL != null) { if (downloadURL != null) {
urls.replace(idAndVersion, urlJson.getString("result")); downloadURLs.put(idAndVersion,downloadURL);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -423,6 +426,6 @@ public class VersionCheckUtils {
} finally { } finally {
CommonIOUtils.close(in); CommonIOUtils.close(in);
} }
return urls; return downloadURLs;
} }
} }

Loading…
Cancel
Save