From 70d57c71e51758fe71d05cf142fb8cf6624955de Mon Sep 17 00:00:00 2001 From: "derek.sharpe" Date: Tue, 3 Dec 2024 16:53:22 +0000 Subject: [PATCH] DB19 installer is not required for OHS 14.1.2 installs --- .../imagetool/aru/InstalledPatch.java | 41 +++++++++++-------- .../imagetool/installer/FmwInstallerType.java | 19 +++++++-- .../installer/MiddlewareInstall.java | 14 +++---- .../imagetool/installer/InstallerTest.java | 12 ++++-- 4 files changed, 55 insertions(+), 31 deletions(-) diff --git a/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/InstalledPatch.java b/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/InstalledPatch.java index ccd194e5c..139eee73a 100644 --- a/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/InstalledPatch.java +++ b/imagetool/src/main/java/com/oracle/weblogic/imagetool/aru/InstalledPatch.java @@ -19,6 +19,13 @@ public class InstalledPatch { private String uniquePatchNumber; private String patchDescription; + // Patterns for matching PSU versions in patch descriptions + private static final Pattern PSU_VERSION_PATTERN = Pattern.compile( + "WLS PATCH SET UPDATE (?:" + + "(\\d+\\.\\d+\\.\\d+\\.\\d+\\.)\\d+\\(ID:(\\d+)\\.\\d+\\)|" // Pattern for format: x.x.x.x.0(ID:123456.0) + + "(\\d+\\.\\d+\\.\\d+\\.\\d+\\.[1-9]\\d+)" // Pattern for format: x.x.x.x.nn + + ")"); + /** * Parse the output from the image probe list of Oracle patches. * @@ -54,28 +61,28 @@ public static List getPatchList(String oraclePatches) { * @return the version of the PSU, or null if no PSU is found. */ public static String getPsuVersion(List installedPatches) { - String result = null; - // search inventory for PSU and extract PSU version, if available - Pattern patternOne = Pattern.compile( - "WLS PATCH SET UPDATE (\\d+\\.\\d+\\.\\d+\\.\\d+\\.)\\d+\\(ID:(\\d+)\\.\\d+\\)"); - Pattern patternTwo = Pattern.compile( - "WLS PATCH SET UPDATE (\\d+\\.\\d+\\.\\d+\\.\\d+\\.[1-9]\\d+)"); + if (installedPatches == null || installedPatches.isEmpty()) { + return null; + } for (InstalledPatch patch : installedPatches) { String description = patch.patchDescription(); - Matcher matchPatternOne = patternOne.matcher(description); - Matcher matchPatternTwo = patternTwo.matcher(description); - if (matchPatternOne.find()) { - result = matchPatternOne.group(1) + matchPatternOne.group(2); - logger.fine("Found PSU in inventory {0}, in {1}", result, description); - break; - } else if (matchPatternTwo.find()) { - result = matchPatternTwo.group(1); - logger.fine("Found PSU in inventory {0}, in {1}", result, description); - break; + Matcher matcher = PSU_VERSION_PATTERN.matcher(description); + + if (matcher.find()) { + String psuVersion; + if (matcher.group(1) != null) { + // Handle format: x.x.x.x.0(ID:123456.0) + psuVersion = matcher.group(1) + matcher.group(2); + } else { + // Handle format: x.x.x.x.nn + psuVersion = matcher.group(3); + } + logger.fine("Found PSU in inventory {0}, in {1}", psuVersion, description); + return psuVersion; } } - return result; + return null; } public String bugNumber() { diff --git a/imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/FmwInstallerType.java b/imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/FmwInstallerType.java index e83da9452..044f60be2 100644 --- a/imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/FmwInstallerType.java +++ b/imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/FmwInstallerType.java @@ -3,6 +3,7 @@ package com.oracle.weblogic.imagetool.installer; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -82,7 +83,16 @@ public enum FmwInstallerType { InstallerType.FMW, InstallerType.WCS), OHS(Utils.toSet(AruProduct.OHS, AruProduct.OAM_WG, AruProduct.WLS, AruProduct.JDBC, AruProduct.FMWPLAT, AruProduct.OSS, AruProduct.FIT, AruProduct.JRF, AruProduct.FMW_GLCM), - InstallerType.OHS, InstallerType.DB19), + InstallerType.OHS) { + @Override + public List installerList(String version) { + List ohsInstallers = new ArrayList<>(Arrays.asList(OHS.installers)); + if (version.equals("12.2.1.4.0")) { + ohsInstallers.add(InstallerType.DB19); + } + return ohsInstallers; + } + }, ODI(Collections.singleton(AruProduct.ODI), InstallerType.ODI) ; @@ -95,12 +105,13 @@ public enum FmwInstallerType { this.products = products; } - public List installerList() { + @SuppressWarnings("unused") // version parameter is needed in the OHS override function + public List installerList(String version) { return Arrays.asList(installers); } - public String installerListString() { - return Arrays.stream(installers).map(Object::toString).collect(Collectors.joining(", ")); + public String installerListString(String version) { + return installerList(version).stream().map(Object::toString).collect(Collectors.joining(", ")); } public Set products() { diff --git a/imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/MiddlewareInstall.java b/imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/MiddlewareInstall.java index 2c0ef20fa..9d00dea24 100644 --- a/imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/MiddlewareInstall.java +++ b/imagetool/src/main/java/com/oracle/weblogic/imagetool/installer/MiddlewareInstall.java @@ -34,10 +34,10 @@ public class MiddlewareInstall { */ public MiddlewareInstall(FmwInstallerType type, String version, List responseFiles, Architecture target) throws FileNotFoundException { - logger.info("IMG-0039", type.installerListString(), version); + logger.info("IMG-0039", type.installerListString(version), version); fmwInstallerType = type; - for (InstallerType installer : type.installerList()) { + for (InstallerType installer : type.installerList(version)) { MiddlewareInstallPackage pkg = new MiddlewareInstallPackage(); pkg.type = installer; pkg.installer = new CachedFile(installer, version, target); @@ -47,7 +47,7 @@ public MiddlewareInstall(FmwInstallerType type, String version, List respo } addInstaller(pkg); } - setResponseFiles(responseFiles); + setResponseFiles(responseFiles, version); } private static String getJarNameFromInstaller(Path installerFile) throws IOException { @@ -96,11 +96,11 @@ public List getInstallers() { return installerFiles; } - private boolean addInstaller(MiddlewareInstallPackage installPackage) { - return installerFiles.add(installPackage); + private void addInstaller(MiddlewareInstallPackage installPackage) { + installerFiles.add(installPackage); } - private void setResponseFiles(List responseFiles) throws FileNotFoundException { + private void setResponseFiles(List responseFiles, String version) throws FileNotFoundException { if (responseFiles == null || responseFiles.isEmpty()) { return; } @@ -110,7 +110,7 @@ private void setResponseFiles(List responseFiles) throws FileNotFoundExcep if (responseFiles.size() != installerFiles.size()) { throw new IllegalArgumentException( Utils.getMessage("IMG-0040", - fmwInstallerType.installerListString(), + fmwInstallerType.installerListString(version), responseFiles.size(), installerFiles.size())); } diff --git a/imagetool/src/test/java/com/oracle/weblogic/imagetool/installer/InstallerTest.java b/imagetool/src/test/java/com/oracle/weblogic/imagetool/installer/InstallerTest.java index c12dcf03c..f67cdcff7 100644 --- a/imagetool/src/test/java/com/oracle/weblogic/imagetool/installer/InstallerTest.java +++ b/imagetool/src/test/java/com/oracle/weblogic/imagetool/installer/InstallerTest.java @@ -11,23 +11,29 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; @Tag("unit") class InstallerTest { @Test void fmwInstallerTypeStringTest() { - assertEquals("fmw, soa, osb", FmwInstallerType.SOA_OSB.installerListString(), + assertEquals("fmw, soa, osb", FmwInstallerType.SOA_OSB.installerListString("12.2.1.4.0"), "string list of installer types for SOA_OSB is wrong"); } @Test void fmwInstallerTypeListTest() { assertEquals(Arrays.asList(InstallerType.FMW, InstallerType.OSB), - FmwInstallerType.OSB.installerList(), "installer list for OSB is wrong"); + FmwInstallerType.OSB.installerList("12.2.1.4.0"), "installer list for OSB is wrong"); assertEquals(Arrays.asList(InstallerType.FMW, InstallerType.SOA, InstallerType.OSB), - FmwInstallerType.SOA_OSB.installerList(), "installer list for OSB is wrong"); + FmwInstallerType.SOA_OSB.installerList("12.2.1.4.0"), "installer list for OSB is wrong"); + + assertTrue(FmwInstallerType.OHS.installerList("12.2.1.4.0").contains(InstallerType.DB19)); + assertFalse(FmwInstallerType.OHS.installerList("14.1.2.0.0").contains(InstallerType.DB19), + "Only OHS 12.2.1.4 requires the DB19 installer (patch)"); } @Test