|
|
|
@ -59,7 +59,6 @@ import java.util.*;
|
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
|
|
|
|
|
|
import static com.fr.design.dialog.FineJOptionPane.OPTION_OK_CANCEL; |
|
|
|
|
import static java.nio.charset.StandardCharsets.*; |
|
|
|
|
import static javax.swing.JOptionPane.QUESTION_MESSAGE; |
|
|
|
|
|
|
|
|
@ -87,7 +86,6 @@ public class UpdateMainDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
private static final String HYPHEN = "-"; |
|
|
|
|
|
|
|
|
|
private final SimpleDateFormat CHANGELOG_FORMAT = new SimpleDateFormat("M/d/y, h:m:s a", Locale.ENGLISH); |
|
|
|
|
private final SimpleDateFormat UPDATELOG_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
private final SimpleDateFormat UPDATE_INFO_TABLE_FORMAT = new SimpleDateFormat("yyyy.MM.dd"); |
|
|
|
|
|
|
|
|
@ -432,7 +430,7 @@ public class UpdateMainDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
return array; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage()); |
|
|
|
|
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
|
|
|
|
} |
|
|
|
|
return JSONArray.create(); |
|
|
|
|
} |
|
|
|
@ -449,7 +447,7 @@ public class UpdateMainDialog extends UIDialog {
|
|
|
|
|
updateCachedInfoFile(jsonArray); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
getUpdateInfoSuccess = true; |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage()); |
|
|
|
|
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -463,7 +461,7 @@ public class UpdateMainDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//从文件中读取缓存的更新信息
|
|
|
|
|
private void getCachedUpdateInfo(String keyword) throws Exception { |
|
|
|
|
private void getCachedUpdateInfo(String keyword) { |
|
|
|
|
String cacheInfoPath = getUpdateCacheInfo(); |
|
|
|
|
File cacheFile = new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), "resources", "offlineres", cacheInfoPath)); |
|
|
|
|
if (!ComparatorUtils.equals(lastUpdateCacheState, "success")) { |
|
|
|
@ -476,22 +474,26 @@ public class UpdateMainDialog extends UIDialog {
|
|
|
|
|
String readStr, updateTimeStr; |
|
|
|
|
while ((readStr = br.readLine()) != null) { |
|
|
|
|
String[] updateInfo = readStr.split("\\t"); |
|
|
|
|
if (updateInfo.length == 2) { |
|
|
|
|
updateTimeStr = updateInfo[0]; |
|
|
|
|
Date updateTime = CHANGELOG_FORMAT.parse(updateTimeStr); |
|
|
|
|
if (updateInfo.length == 3) { |
|
|
|
|
updateTimeStr = updateInfo[UpdateInfoTable.UPDATE_DATE_INDEX]; |
|
|
|
|
Date updateTime = UPDATELOG_FORMAT.parse(updateTimeStr); |
|
|
|
|
|
|
|
|
|
//形如 Build#release-2018.07.31.03.03.52.80
|
|
|
|
|
String currentNO = GeneralUtils.readBuildNO(); |
|
|
|
|
Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1)); |
|
|
|
|
if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) { |
|
|
|
|
if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateInfo[1], keyword)) { |
|
|
|
|
keyword.replace('.','-'); |
|
|
|
|
if (!containsKeyword(UPDATELOG_FORMAT.format(updateTime), keyword) && !containsKeyword(updateInfo[UpdateInfoTable.UPDATE_TITLE_INDEX], keyword)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (isValidLogInfo(updateInfo[1]) && curJarDate != null) { |
|
|
|
|
updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateInfo[1], updateTime.after(curJarDate)}); |
|
|
|
|
if (isValidLogInfo(updateInfo[UpdateInfoTable.UPDATE_TITLE_INDEX]) && curJarDate != null) { |
|
|
|
|
updateInfoList.add(new Object[]{UPDATELOG_FORMAT.format(updateTime), updateInfo[UpdateInfoTable.UPDATE_VERSION_INDEX], updateInfo[UpdateInfoTable.UPDATE_TITLE_INDEX], updateTime.after(curJarDate)}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -520,7 +522,7 @@ public class UpdateMainDialog extends UIDialog {
|
|
|
|
|
try (BufferedWriter bufferWriter = new BufferedWriter(writerStream)) { |
|
|
|
|
for (int i = 0; i < jsonArray.length(); i++) { |
|
|
|
|
JSONObject jo = (JSONObject) jsonArray.get(i); |
|
|
|
|
bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title")); |
|
|
|
|
bufferWriter.write((String) jo.get("updateTime") + '\t' + jo.get("version") + '\t' + jo.get("jiraId") + " " + jo.get("info")); |
|
|
|
|
bufferWriter.newLine(); |
|
|
|
|
bufferWriter.flush(); |
|
|
|
|
} |
|
|
|
@ -545,13 +547,14 @@ public class UpdateMainDialog extends UIDialog {
|
|
|
|
|
if (curJarDate == null) { |
|
|
|
|
curJarDate = updateTime; |
|
|
|
|
} |
|
|
|
|
if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) { |
|
|
|
|
if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateTitle, keyword)) { |
|
|
|
|
if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY) && keyword != null) { |
|
|
|
|
keyword.replace('.', '-'); |
|
|
|
|
if (!containsKeyword(UPDATELOG_FORMAT.format(updateTime), keyword) && !containsKeyword(updateTitle, keyword)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (isValidLogInfo(updateTitle)) { |
|
|
|
|
updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateVersionStr, updateTitle, updateTime.after(curJarDate)}); |
|
|
|
|
updateInfoList.add(new Object[]{updateTimeStr, updateVersionStr, updateTitle, updateTime.after(curJarDate)}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return new ArrayList<>(updateInfoList); |
|
|
|
|