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

Loading…
Cancel
Save