Skip to content

Commit 3bdee7d

Browse files
committed
Merge branch 'debt-cleanup' into 'main'
DB19 installer is not required for OHS 14.1.2 installs See merge request weblogic-cloud/weblogic-image-tool!493
2 parents 12524d3 + 70d57c7 commit 3bdee7d

File tree

4 files changed

+55
-31
lines changed

4 files changed

+55
-31
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/InstalledPatch.java

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ public class InstalledPatch {
1919
private String uniquePatchNumber;
2020
private String patchDescription;
2121

22+
// Patterns for matching PSU versions in patch descriptions
23+
private static final Pattern PSU_VERSION_PATTERN = Pattern.compile(
24+
"WLS PATCH SET UPDATE (?:"
25+
+ "(\\d+\\.\\d+\\.\\d+\\.\\d+\\.)\\d+\\(ID:(\\d+)\\.\\d+\\)|" // Pattern for format: x.x.x.x.0(ID:123456.0)
26+
+ "(\\d+\\.\\d+\\.\\d+\\.\\d+\\.[1-9]\\d+)" // Pattern for format: x.x.x.x.nn
27+
+ ")");
28+
2229
/**
2330
* Parse the output from the image probe list of Oracle patches.
2431
*
@@ -54,28 +61,28 @@ public static List<InstalledPatch> getPatchList(String oraclePatches) {
5461
* @return the version of the PSU, or null if no PSU is found.
5562
*/
5663
public static String getPsuVersion(List<InstalledPatch> installedPatches) {
57-
String result = null;
58-
// search inventory for PSU and extract PSU version, if available
59-
Pattern patternOne = Pattern.compile(
60-
"WLS PATCH SET UPDATE (\\d+\\.\\d+\\.\\d+\\.\\d+\\.)\\d+\\(ID:(\\d+)\\.\\d+\\)");
61-
Pattern patternTwo = Pattern.compile(
62-
"WLS PATCH SET UPDATE (\\d+\\.\\d+\\.\\d+\\.\\d+\\.[1-9]\\d+)");
64+
if (installedPatches == null || installedPatches.isEmpty()) {
65+
return null;
66+
}
6367

6468
for (InstalledPatch patch : installedPatches) {
6569
String description = patch.patchDescription();
66-
Matcher matchPatternOne = patternOne.matcher(description);
67-
Matcher matchPatternTwo = patternTwo.matcher(description);
68-
if (matchPatternOne.find()) {
69-
result = matchPatternOne.group(1) + matchPatternOne.group(2);
70-
logger.fine("Found PSU in inventory {0}, in {1}", result, description);
71-
break;
72-
} else if (matchPatternTwo.find()) {
73-
result = matchPatternTwo.group(1);
74-
logger.fine("Found PSU in inventory {0}, in {1}", result, description);
75-
break;
70+
Matcher matcher = PSU_VERSION_PATTERN.matcher(description);
71+
72+
if (matcher.find()) {
73+
String psuVersion;
74+
if (matcher.group(1) != null) {
75+
// Handle format: x.x.x.x.0(ID:123456.0)
76+
psuVersion = matcher.group(1) + matcher.group(2);
77+
} else {
78+
// Handle format: x.x.x.x.nn
79+
psuVersion = matcher.group(3);
80+
}
81+
logger.fine("Found PSU in inventory {0}, in {1}", psuVersion, description);
82+
return psuVersion;
7683
}
7784
}
78-
return result;
85+
return null;
7986
}
8087

8188
public String bugNumber() {

imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/FmwInstallerType.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
package com.oracle.weblogic.imagetool.installer;
55

6+
import java.util.ArrayList;
67
import java.util.Arrays;
78
import java.util.Collections;
89
import java.util.List;
@@ -82,7 +83,16 @@ public enum FmwInstallerType {
8283
InstallerType.FMW, InstallerType.WCS),
8384
OHS(Utils.toSet(AruProduct.OHS, AruProduct.OAM_WG, AruProduct.WLS, AruProduct.JDBC, AruProduct.FMWPLAT,
8485
AruProduct.OSS, AruProduct.FIT, AruProduct.JRF, AruProduct.FMW_GLCM),
85-
InstallerType.OHS, InstallerType.DB19),
86+
InstallerType.OHS) {
87+
@Override
88+
public List<InstallerType> installerList(String version) {
89+
List<InstallerType> ohsInstallers = new ArrayList<>(Arrays.asList(OHS.installers));
90+
if (version.equals("12.2.1.4.0")) {
91+
ohsInstallers.add(InstallerType.DB19);
92+
}
93+
return ohsInstallers;
94+
}
95+
},
8696
ODI(Collections.singleton(AruProduct.ODI),
8797
InstallerType.ODI)
8898
;
@@ -95,12 +105,13 @@ public enum FmwInstallerType {
95105
this.products = products;
96106
}
97107

98-
public List<InstallerType> installerList() {
108+
@SuppressWarnings("unused") // version parameter is needed in the OHS override function
109+
public List<InstallerType> installerList(String version) {
99110
return Arrays.asList(installers);
100111
}
101112

102-
public String installerListString() {
103-
return Arrays.stream(installers).map(Object::toString).collect(Collectors.joining(", "));
113+
public String installerListString(String version) {
114+
return installerList(version).stream().map(Object::toString).collect(Collectors.joining(", "));
104115
}
105116

106117
public Set<AruProduct> products() {

imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/MiddlewareInstall.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public class MiddlewareInstall {
3434
*/
3535
public MiddlewareInstall(FmwInstallerType type, String version, List<Path> responseFiles,
3636
Architecture target) throws FileNotFoundException {
37-
logger.info("IMG-0039", type.installerListString(), version);
37+
logger.info("IMG-0039", type.installerListString(version), version);
3838
fmwInstallerType = type;
3939

40-
for (InstallerType installer : type.installerList()) {
40+
for (InstallerType installer : type.installerList(version)) {
4141
MiddlewareInstallPackage pkg = new MiddlewareInstallPackage();
4242
pkg.type = installer;
4343
pkg.installer = new CachedFile(installer, version, target);
@@ -47,7 +47,7 @@ public MiddlewareInstall(FmwInstallerType type, String version, List<Path> respo
4747
}
4848
addInstaller(pkg);
4949
}
50-
setResponseFiles(responseFiles);
50+
setResponseFiles(responseFiles, version);
5151
}
5252

5353
private static String getJarNameFromInstaller(Path installerFile) throws IOException {
@@ -96,11 +96,11 @@ public List<MiddlewareInstallPackage> getInstallers() {
9696
return installerFiles;
9797
}
9898

99-
private boolean addInstaller(MiddlewareInstallPackage installPackage) {
100-
return installerFiles.add(installPackage);
99+
private void addInstaller(MiddlewareInstallPackage installPackage) {
100+
installerFiles.add(installPackage);
101101
}
102102

103-
private void setResponseFiles(List<Path> responseFiles) throws FileNotFoundException {
103+
private void setResponseFiles(List<Path> responseFiles, String version) throws FileNotFoundException {
104104
if (responseFiles == null || responseFiles.isEmpty()) {
105105
return;
106106
}
@@ -110,7 +110,7 @@ private void setResponseFiles(List<Path> responseFiles) throws FileNotFoundExcep
110110
if (responseFiles.size() != installerFiles.size()) {
111111
throw new IllegalArgumentException(
112112
Utils.getMessage("IMG-0040",
113-
fmwInstallerType.installerListString(),
113+
fmwInstallerType.installerListString(version),
114114
responseFiles.size(),
115115
installerFiles.size()));
116116
}

imagetool/src/test/java/com/oracle/weblogic/imagetool/installer/InstallerTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,29 @@
1111
import org.junit.jupiter.api.Test;
1212

1313
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertFalse;
1415
import static org.junit.jupiter.api.Assertions.assertNull;
16+
import static org.junit.jupiter.api.Assertions.assertTrue;
1517

1618
@Tag("unit")
1719
class InstallerTest {
1820
@Test
1921
void fmwInstallerTypeStringTest() {
20-
assertEquals("fmw, soa, osb", FmwInstallerType.SOA_OSB.installerListString(),
22+
assertEquals("fmw, soa, osb", FmwInstallerType.SOA_OSB.installerListString("12.2.1.4.0"),
2123
"string list of installer types for SOA_OSB is wrong");
2224
}
2325

2426
@Test
2527
void fmwInstallerTypeListTest() {
2628
assertEquals(Arrays.asList(InstallerType.FMW, InstallerType.OSB),
27-
FmwInstallerType.OSB.installerList(), "installer list for OSB is wrong");
29+
FmwInstallerType.OSB.installerList("12.2.1.4.0"), "installer list for OSB is wrong");
2830

2931
assertEquals(Arrays.asList(InstallerType.FMW, InstallerType.SOA, InstallerType.OSB),
30-
FmwInstallerType.SOA_OSB.installerList(), "installer list for OSB is wrong");
32+
FmwInstallerType.SOA_OSB.installerList("12.2.1.4.0"), "installer list for OSB is wrong");
33+
34+
assertTrue(FmwInstallerType.OHS.installerList("12.2.1.4.0").contains(InstallerType.DB19));
35+
assertFalse(FmwInstallerType.OHS.installerList("14.1.2.0.0").contains(InstallerType.DB19),
36+
"Only OHS 12.2.1.4 requires the DB19 installer (patch)");
3137
}
3238

3339
@Test

0 commit comments

Comments
 (0)