Skip to content

Commit 0884233

Browse files
authored
include recommended PSU overlay patches in --recommendedPatches (#228)
1 parent 2d6a03b commit 0884233

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ List<AruPatch> getRecommendedPatches(AruProduct product, String version, String
154154
String releaseNumber = getReleaseNumber(product, version, userId, password);
155155
Document aruRecommendations = getRecommendedPatchesMetadata(product, releaseNumber, userId, password);
156156
List<AruPatch> patches = AruPatch.getPatches(aruRecommendations);
157+
String psuVersion = getPsuVersion(patches);
158+
if (!Utils.isEmptyString(psuVersion)) {
159+
patches.forEach(p -> logger.fine("Discarding recommended patch {1} {2}", p.patchId(), p.description()));
160+
logger.fine("Recommended patch list contains a PSU, getting recommendations for PSU version {0}",
161+
psuVersion);
162+
// get release number for PSU
163+
String psuReleaseNumber = getReleaseNumber(product, psuVersion, userId, password);
164+
// get recommended patches for PSU release (Overlay patches are only recommended on the PSU release)
165+
Document psuRecommendation = getRecommendedPatchesMetadata(product, psuReleaseNumber, userId, password);
166+
patches = AruPatch.getPatches(psuRecommendation);
167+
}
157168
patches.forEach(p -> logger.info("IMG-0068", product.description(), p.patchId(), p.description()));
158169
logger.exiting(patches);
159170
return patches;
@@ -165,6 +176,17 @@ List<AruPatch> getRecommendedPatches(AruProduct product, String version, String
165176
}
166177
}
167178

179+
private String getPsuVersion(List<AruPatch> patches) {
180+
for (AruPatch patch: patches) {
181+
if (patch.isPsu()) {
182+
// expected pattern "Oracle WebLogic Server 12.2.1.x.xxxxxx"
183+
String[] strings = patch.psuBundle().split(" ");
184+
return strings[strings.length - 1];
185+
}
186+
}
187+
return null;
188+
}
189+
168190
/**
169191
* Validate patches conflicts by passing a list of patches.
170192
*

imagetool/src/test/java/com/oracle/weblogic/imagetool/aru/AruUtilTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ Document getRecommendedPatchesMetadata(AruProduct product, String releaseNumber,
6767
String password) throws XPathExpressionException, AruException {
6868
Document result;
6969
try {
70-
if (releaseNumber.equals("336")) {
70+
// these release numbers are fake test data from the fake releases.xml found in test/resources
71+
if (releaseNumber.equals("336") || releaseNumber.equals("304")) {
7172
result = getResource("/recommended-patches.xml");
7273
} else {
7374
result = getResource("/no-patches.xml");

0 commit comments

Comments
 (0)