Skip to content

Commit bb75cfa

Browse files
committed
Add method to find available manifest versions for upgrade
1 parent 9795fd0 commit bb75cfa

File tree

4 files changed

+118
-7
lines changed

4 files changed

+118
-7
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.wildfly.installationmanager;
2+
3+
import java.util.List;
4+
5+
/**
6+
* Provides list of available manifest versions for given channel.
7+
*/
8+
public class AvailableManifestVersions {
9+
10+
private final String channelName;
11+
private final String location;
12+
private final ManifestVersionPair currentVersion;
13+
private final List<ManifestVersionPair> availableVersions;
14+
15+
public AvailableManifestVersions(String channelName, String location, ManifestVersionPair currentVersion, List<ManifestVersionPair> availableVersions) {
16+
this.channelName = channelName;
17+
this.location = location;
18+
this.currentVersion = currentVersion;
19+
this.availableVersions = availableVersions;
20+
}
21+
22+
public String getChannelName() {
23+
return channelName;
24+
}
25+
26+
public String getLocation() {
27+
return location;
28+
}
29+
30+
public ManifestVersionPair getCurrentVersion() {
31+
return currentVersion;
32+
}
33+
34+
public List<ManifestVersionPair> getAvailableVersions() {
35+
return availableVersions;
36+
}
37+
}

src/main/java/org/wildfly/installationmanager/ManifestVersionChange.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public class ManifestVersionChange {
77

88
private final String channelName;
99
private final String location;
10-
private final String currentVersion;
11-
private final String newVersion;
10+
private final ManifestVersionPair currentVersion;
11+
private final ManifestVersionPair newVersion;
1212
private final boolean isDowngrade;
1313

1414
/**
@@ -20,7 +20,7 @@ public class ManifestVersionChange {
2020
* @param newVersion the new manifest version to be updated to
2121
* @param isDowngrade is this version change considered a downgrade?
2222
*/
23-
public ManifestVersionChange(String channelName, String location, String currentVersion, String newVersion, boolean isDowngrade) {
23+
public ManifestVersionChange(String channelName, String location, ManifestVersionPair currentVersion, ManifestVersionPair newVersion, boolean isDowngrade) {
2424
this.channelName = channelName;
2525
this.location = location;
2626
this.currentVersion = currentVersion;
@@ -45,14 +45,14 @@ public String getLocation() {
4545
/**
4646
* @return current manifest version
4747
*/
48-
public String getCurrentVersion() {
48+
public ManifestVersionPair getCurrentVersion() {
4949
return currentVersion;
5050
}
5151

5252
/**
5353
* @return the new manifest version to be updated to
5454
*/
55-
public String getNewVersion() {
55+
public ManifestVersionPair getNewVersion() {
5656
return newVersion;
5757
}
5858

@@ -62,4 +62,5 @@ public String getNewVersion() {
6262
public boolean isDowngrade() {
6363
return isDowngrade;
6464
}
65+
6566
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package org.wildfly.installationmanager;
2+
3+
import java.util.Objects;
4+
5+
/**
6+
* Wraps a pair of manifest physical/logical version strings.
7+
*/
8+
public class ManifestVersionPair {
9+
private final String physicalVersion;
10+
private final String logicalVersion;
11+
12+
/**
13+
* Pair of physical / logical version strings.
14+
*
15+
* @param physicalVersion version string, either a maven artifact version for Maven-based channels,
16+
* or a URL for URL-based channels
17+
* @param logicalVersion descriptive version string intended for human understanding, optional
18+
*/
19+
public ManifestVersionPair(String physicalVersion, String logicalVersion) {
20+
this.physicalVersion = physicalVersion;
21+
this.logicalVersion = logicalVersion;
22+
}
23+
24+
/**
25+
* @return descriptive version string intended for human understanding, optional
26+
*/
27+
public String getLogicalVersion() {
28+
return logicalVersion;
29+
}
30+
31+
/**
32+
* @return physicalVersion version string, either a maven artifact version for Maven-based channels,
33+
* or a URL for URL-based channels
34+
*/
35+
public String getPhysicalVersion() {
36+
return physicalVersion;
37+
}
38+
39+
@Override
40+
public String toString() {
41+
return "ManifestVersionPair{" +
42+
"physicalVersion='" + physicalVersion + '\'' +
43+
", logicalVersion='" + logicalVersion + '\'' +
44+
'}';
45+
}
46+
47+
@Override
48+
public boolean equals(Object o) {
49+
if (o == null || getClass() != o.getClass()) return false;
50+
51+
ManifestVersionPair that = (ManifestVersionPair) o;
52+
return Objects.equals(physicalVersion, that.physicalVersion) && Objects.equals(logicalVersion, that.logicalVersion);
53+
}
54+
55+
@Override
56+
public int hashCode() {
57+
int result = Objects.hashCode(physicalVersion);
58+
result = 31 * result + Objects.hashCode(logicalVersion);
59+
return result;
60+
}
61+
}

src/main/java/org/wildfly/installationmanager/spi/InstallationManager.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.wildfly.installationmanager.spi;
2020

2121
import org.wildfly.installationmanager.ArtifactChange;
22+
import org.wildfly.installationmanager.AvailableManifestVersions;
2223
import org.wildfly.installationmanager.CandidateType;
2324
import org.wildfly.installationmanager.FileConflict;
2425
import org.wildfly.installationmanager.InstallationChanges;
@@ -127,7 +128,7 @@ public interface InstallationManager {
127128
*
128129
* @param repositories List of repositories to be used to find the available updates. If it is null or an empty list,
129130
* the default repositories will be used instead.
130-
* @return {@link InstallationUpdates} collections of artifact and channels that are to be updated.
131+
* @return {@link InstallationUpdates} collections of artifact and Wildfly Channel manifests that can be updated.
131132
* @throws Exception In case of an error.
132133
*/
133134
InstallationUpdates findInstallationUpdates(List<Repository> repositories) throws Exception;
@@ -138,11 +139,22 @@ public interface InstallationManager {
138139
* @param repositories List of repositories to be used to find the available updates. If it is null or an empty list,
139140
* the default repositories will be used instead.
140141
* @param manifestVersions Manifest versions to update to. All subscribed channels have to be specified.
141-
* @return {@link InstallationUpdates} collections of artifact and channels that are to be updated.
142+
* @return {@link InstallationUpdates} collections of artifact and Wildfly Channel manifests that can be updated.
142143
* @throws Exception In case of an error.
143144
*/
144145
InstallationUpdates findInstallationUpdates(List<Repository> repositories, List<ManifestVersion> manifestVersions) throws Exception;
145146

147+
/**
148+
* Lists possible upgrades for subscribed manifests. The results may not include manifests for which no upgrades
149+
* are available. Only Maven-based manifests are returned, no upgrades are be listed for URL-based manifests.
150+
*
151+
* @param repositories List of repositories to be used to find the available updates. If it is null or an empty list,
152+
* the default repositories will be used instead.
153+
* @param includeDowngrades If true, manifest versions lower than currently used manifest version will be listed as well.
154+
* @return list of AvailableManifestVersions objects containing manifest info and list of available manifest versions.
155+
*/
156+
List<AvailableManifestVersions> findAvailableManifestVersions(List<Repository> repositories, boolean includeDowngrades) throws Exception;
157+
146158
/**
147159
* Lists channels the server installation is subscribed to.
148160
* If the servers is not subscribed to any channels, empty list is returned.

0 commit comments

Comments
 (0)