|
|
|
@ -1,10 +1,9 @@
|
|
|
|
|
package com.fr.design; |
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.decision.update.data.UpdateConstants; |
|
|
|
|
import com.fr.decision.update.exception.UpdateException; |
|
|
|
|
import com.fr.decision.update.info.UpdateCallBack; |
|
|
|
|
import com.fr.decision.update.info.UpdateProcessBean; |
|
|
|
|
import com.fr.decision.update.util.UpdateFileUtils; |
|
|
|
|
import com.fr.design.env.DesignerWorkspaceInfo; |
|
|
|
|
import com.fr.design.env.DesignerWorkspaceType; |
|
|
|
|
import com.fr.design.env.RemoteWorkspace; |
|
|
|
@ -83,9 +82,9 @@ public class VersionCheckUtils {
|
|
|
|
|
return checkLocalAndRemoteJartime(selectedEnv) && checkLocalAndRemotePlugin().size() == 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void showVersionCheckDialog(String envName){ |
|
|
|
|
if(!VersionCheckUtils.versionCheck(envName)){ |
|
|
|
|
VersionCheckMessageDialog versionCheckMessageDialog = new VersionCheckMessageDialog(DesignerContext.getDesignerFrame(),Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"),envName); |
|
|
|
|
public static void showVersionCheckDialog(String envName) { |
|
|
|
|
if (!VersionCheckUtils.versionCheck(envName)) { |
|
|
|
|
VersionCheckMessageDialog versionCheckMessageDialog = new VersionCheckMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), envName); |
|
|
|
|
versionCheckMessageDialog.setVisible(true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -96,7 +95,7 @@ public class VersionCheckUtils {
|
|
|
|
|
return checkLocalAndRemoteJartime(selectedEnv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean checkLocalAndRemoteJartime(DesignerWorkspaceInfo selectedEnv){ |
|
|
|
|
public static boolean checkLocalAndRemoteJartime(DesignerWorkspaceInfo selectedEnv) { |
|
|
|
|
//是否需要做服务校验
|
|
|
|
|
if (needCheckBranch(selectedEnv)) { |
|
|
|
|
String localBranch; |
|
|
|
@ -334,54 +333,20 @@ public class VersionCheckUtils {
|
|
|
|
|
private static void downloadPlugins(Map<String, String> urls, UpdateCallBack callBack) { |
|
|
|
|
CommonIOUtils.deleteFile(new File(SYNCLIB)); |
|
|
|
|
UpdateProcessBean bean = new UpdateProcessBean(); |
|
|
|
|
FileOutputStream fos = null; |
|
|
|
|
CloseableHttpClient httpClient; |
|
|
|
|
CloseableHttpResponse httpResponse; |
|
|
|
|
HttpGet httpGet = new HttpGet(); |
|
|
|
|
InputStream in = null; |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
for (String idAndVersion : urls.keySet()) { |
|
|
|
|
try { |
|
|
|
|
httpGet.setURI(URI.create(urls.get(idAndVersion))); |
|
|
|
|
httpClient = HttpToolbox.getHttpClient(urls.get(idAndVersion)); |
|
|
|
|
String target = SYNCPLUGINLIB + idAndVersion + ZIP; |
|
|
|
|
httpResponse = httpClient.execute(httpGet); |
|
|
|
|
if (httpResponse.getStatusLine().getStatusCode() != 200) { |
|
|
|
|
FineLoggerFactory.getLogger().error("download plugin error :" + urls.get(idAndVersion)); |
|
|
|
|
String url = urls.get(idAndVersion); |
|
|
|
|
if (null == url) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
long totalSize = httpResponse.getEntity().getContentLength(); |
|
|
|
|
in = httpResponse.getEntity().getContent(); |
|
|
|
|
//保存文件
|
|
|
|
|
File saveDir = new File(target); |
|
|
|
|
StableUtils.makesureFileExist(saveDir); |
|
|
|
|
|
|
|
|
|
bean.setDownloadedFiles(bean.getDownloadedFiles() + 1); |
|
|
|
|
bean.setName(idAndVersion); |
|
|
|
|
bean.setTotalLength((int) totalSize); |
|
|
|
|
bean.setDownloadLength(0); |
|
|
|
|
callBack.updateProgress(bean); |
|
|
|
|
fos = new FileOutputStream(saveDir); |
|
|
|
|
int bytesRead; |
|
|
|
|
int totalBytesRead = 0; |
|
|
|
|
byte[] getData = new byte[UpdateConstants.BYTE]; |
|
|
|
|
while ((bytesRead = in.read(getData)) != -1) { |
|
|
|
|
fos.write(getData, 0, bytesRead); |
|
|
|
|
getData = new byte[UpdateConstants.BYTE]; |
|
|
|
|
totalBytesRead += bytesRead; |
|
|
|
|
bean.setDownloadLength(totalBytesRead); |
|
|
|
|
callBack.updateProgress(bean); |
|
|
|
|
} |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
String target = SYNCPLUGINLIB + idAndVersion + ZIP; |
|
|
|
|
UpdateFileUtils.downloadFile(url, target, callBack, bean,idAndVersion); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} finally { |
|
|
|
|
CommonIOUtils.close(fos); |
|
|
|
|
CommonIOUtils.close(in); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Map<String, String> getPluginsDownloadURL(JSONArray differentPlugins, Set<String> uninstallFailed) { |
|
|
|
|
Map<String, String> downloadURL = new HashMap<>(); |
|
|
|
@ -415,7 +380,7 @@ public class VersionCheckUtils {
|
|
|
|
|
CloseableHttpResponse httpResponse; |
|
|
|
|
HttpGet httpGet = new HttpGet(); |
|
|
|
|
InputStream in = null; |
|
|
|
|
HashMap<String,String> downloadURLs = new HashMap<>(); |
|
|
|
|
HashMap<String, String> downloadURLs = new HashMap<>(); |
|
|
|
|
try { |
|
|
|
|
for (String idAndVersion : urls.keySet()) { |
|
|
|
|
httpClient = HttpToolbox.getHttpClient(urls.get(idAndVersion)); |
|
|
|
@ -425,7 +390,7 @@ public class VersionCheckUtils {
|
|
|
|
|
JSONObject urlJson = new JSONObject(IOUtils.inputStream2String(in)); |
|
|
|
|
String downloadURL = urlJson.getString("result"); |
|
|
|
|
if (downloadURL != null) { |
|
|
|
|
downloadURLs.put(idAndVersion,downloadURL); |
|
|
|
|
downloadURLs.put(idAndVersion, downloadURL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|