mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
major version in update channel and update strategy
This commit is contained in:
@@ -29,6 +29,7 @@ public class UpdateChannel {
|
||||
private final String myId;
|
||||
private final String myName;
|
||||
private final ChannelStatus myStatus;
|
||||
private final int myMajorVersion;
|
||||
private final String myHomePageUrl;
|
||||
private final String myFeedbackUrl;
|
||||
private final List<BuildInfo> myBuilds;
|
||||
@@ -37,6 +38,10 @@ public class UpdateChannel {
|
||||
myId = node.getAttributeValue("id");
|
||||
myName = node.getAttributeValue("name");
|
||||
myStatus = ChannelStatus.fromCode(node.getAttributeValue("status"));
|
||||
|
||||
String majorVersion = node.getAttributeValue("majorVersion");
|
||||
myMajorVersion = majorVersion != null ? Integer.parseInt(majorVersion) : -1;
|
||||
|
||||
myHomePageUrl = node.getAttributeValue("url");
|
||||
myFeedbackUrl = node.getAttributeValue("feedback");
|
||||
|
||||
@@ -58,6 +63,10 @@ public class UpdateChannel {
|
||||
return build;
|
||||
}
|
||||
|
||||
public int getMajorVersion() {
|
||||
return myMajorVersion;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
+4
-2
@@ -263,7 +263,9 @@ public final class UpdateChecker {
|
||||
|
||||
@NotNull
|
||||
public static CheckForUpdateResult doCheckForUpdates() {
|
||||
BuildNumber ourBuild = ApplicationInfo.getInstance().getBuild();
|
||||
ApplicationInfo appInfo = ApplicationInfo.getInstance();
|
||||
BuildNumber currentBuild = appInfo.getBuild();
|
||||
int majorVersion = Integer.parseInt(appInfo.getMajorVersion());
|
||||
final UpdatesXmlLoader loader = new UpdatesXmlLoader(getUpdateUrl(), getInstallationUID(), null);
|
||||
final UpdateSettings settings = UpdateSettings.getInstance();
|
||||
final UpdatesInfo info;
|
||||
@@ -277,7 +279,7 @@ public final class UpdateChecker {
|
||||
return new CheckForUpdateResult(UpdateStrategy.State.CONNECTION_ERROR, e);
|
||||
}
|
||||
|
||||
UpdateStrategy strategy = new UpdateStrategy(ourBuild, info, settings);
|
||||
UpdateStrategy strategy = new UpdateStrategy(majorVersion, currentBuild, info, settings);
|
||||
return strategy.checkForUpdates();
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -31,16 +31,19 @@ public class UpdateStrategy {
|
||||
public static enum State {LOADED, CONNECTION_ERROR, NOTHING_LOADED}
|
||||
|
||||
private UserUpdateSettings updateSettings;
|
||||
private int myMajorVersion;
|
||||
private BuildNumber ourBuild;
|
||||
|
||||
private ChannelStatus myChannelStatus;
|
||||
private UpdatesInfo updatesInfo;
|
||||
|
||||
|
||||
public UpdateStrategy(@NotNull BuildNumber ourBuild, @NotNull UpdatesInfo updatesInfo, @NotNull UserUpdateSettings updateSettings) {
|
||||
public UpdateStrategy(int majorVersion, @NotNull BuildNumber currentBuild, @NotNull UpdatesInfo updatesInfo,
|
||||
@NotNull UserUpdateSettings updateSettings) {
|
||||
myMajorVersion = majorVersion;
|
||||
this.updatesInfo = updatesInfo;
|
||||
this.updateSettings = updateSettings;
|
||||
this.ourBuild = ourBuild;
|
||||
this.ourBuild = currentBuild;
|
||||
myChannelStatus = updateSettings.getSelectedChannelStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class UpdateStrategyTest extends TestCase {
|
||||
public void testWithUndefinedSelection() {
|
||||
final TestUpdateSettings settings = new TestUpdateSettings();
|
||||
//first time load
|
||||
UpdateStrategy strategy = new UpdateStrategy(BuildNumber.fromString("IU-98.520"), UpdatesInfoXppParserTest.InfoReader.read("idea-same.xml"), settings);
|
||||
UpdateStrategy strategy = new UpdateStrategy(9, BuildNumber.fromString("IU-98.520"), UpdatesInfoXppParserTest.InfoReader.read("idea-same.xml"), settings);
|
||||
|
||||
final CheckForUpdateResult result1 = strategy.checkForUpdates();
|
||||
Assert.assertEquals(UpdateStrategy.State.LOADED, result1.getState());
|
||||
@@ -54,7 +54,7 @@ public class UpdateStrategyTest extends TestCase {
|
||||
//assume user has version 9 eap - and used eap channel - we want to introduce new eap
|
||||
final TestUpdateSettings settings = new TestUpdateSettings(ChannelStatus.EAP, true, null);
|
||||
//first time load
|
||||
UpdateStrategy strategy = new UpdateStrategy(BuildNumber.fromString("IU-95.429"), UpdatesInfoXppParserTest.InfoReader.read("idea-new9eap.xml"), settings);
|
||||
UpdateStrategy strategy = new UpdateStrategy(9, BuildNumber.fromString("IU-95.429"), UpdatesInfoXppParserTest.InfoReader.read("idea-new9eap.xml"), settings);
|
||||
|
||||
final CheckForUpdateResult result = strategy.checkForUpdates();
|
||||
Assert.assertEquals(UpdateStrategy.State.LOADED, result.getState());
|
||||
@@ -68,7 +68,7 @@ public class UpdateStrategyTest extends TestCase {
|
||||
// and new channel appears - eap of version 10 is there
|
||||
final TestUpdateSettings settings = new TestUpdateSettings(ChannelStatus.EAP, true, null);
|
||||
//first time load
|
||||
UpdateStrategy strategy = new UpdateStrategy(BuildNumber.fromString("IU-95.627"), UpdatesInfoXppParserTest.InfoReader.read("idea-newChannel.xml"), settings);
|
||||
UpdateStrategy strategy = new UpdateStrategy(9, BuildNumber.fromString("IU-95.627"), UpdatesInfoXppParserTest.InfoReader.read("idea-newChannel.xml"), settings);
|
||||
|
||||
|
||||
final CheckForUpdateResult result = strategy.checkForUpdates();
|
||||
@@ -89,7 +89,7 @@ public class UpdateStrategyTest extends TestCase {
|
||||
//we need to show only one dialog
|
||||
final TestUpdateSettings settings = new TestUpdateSettings(ChannelStatus.EAP, true, null);
|
||||
//first time load
|
||||
UpdateStrategy strategy = new UpdateStrategy(BuildNumber.fromString("IU-95.429"), UpdatesInfoXppParserTest.InfoReader.read("idea-newChannel.xml"), settings);
|
||||
UpdateStrategy strategy = new UpdateStrategy(9, BuildNumber.fromString("IU-95.429"), UpdatesInfoXppParserTest.InfoReader.read("idea-newChannel.xml"), settings);
|
||||
|
||||
final CheckForUpdateResult result = strategy.checkForUpdates();
|
||||
Assert.assertEquals(UpdateStrategy.State.LOADED, result.getState());
|
||||
|
||||
Reference in New Issue
Block a user