Skip to content

Commit 6603fa9

Browse files
authored
Allow recommendedPatches for all install types (#192)
* fix latestPSU and recommended patches to include all products
1 parent 7bad1b1 commit 6603fa9

File tree

14 files changed

+328
-202
lines changed

14 files changed

+328
-202
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cachestore/PatchFile.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ synchronized void initPatchInfo() throws IOException, XPathExpressionException {
151151
}
152152

153153
if (checkPsuVersion()) {
154-
String patchXpath = String.format("string(/results/patch/release[@name='%s'])", patchSetVersion);
154+
String patchXpath = String.format(
155+
"string(/results/patch[./platform[@id='2000' or @id='226']]/release[@name='%s'])", patchSetVersion);
155156
String patch = XPathUtil.applyXPathReturnString(aruInfo, patchXpath);
156157
// if the patch has a PSU version in ARU, set the patch version to PSU version (download PSU version)
157158
if (!Utils.isEmptyString(patch)) {
@@ -176,8 +177,10 @@ synchronized void initPatchInfo() throws IOException, XPathExpressionException {
176177
*/
177178
private void getReleaseInfoFromAru() throws IOException, XPathExpressionException {
178179
// get release number and release name from ARU data
179-
String releasePath = String.format("/results/patch/release[@name='%s']/@id", getVersion());
180-
String releaseNamePath = String.format("/results/patch/release[@name='%s']/text()", getVersion());
180+
String releasePath = String.format(
181+
"/results/patch[./platform[@id='2000' or @id='226']]/release[@name='%s']/@id", getVersion());
182+
String releaseNamePath = String.format(
183+
"/results/patch[./platform[@id='2000' or @id='226']]/release[@name='%s']/text()", getVersion());
181184

182185
logger.finest("Searching for release number with xpath: {0}", releasePath);
183186
releaseNumber = XPathUtil.applyXPathReturnString(aruInfo, releasePath);
@@ -227,7 +230,8 @@ public String getReleaseNumber() throws IOException, XPathExpressionException {
227230
*/
228231
boolean verifyPatchVersion() throws MultiplePatchVersionsException, XPathExpressionException {
229232
List<String> versionsForPatch =
230-
XPathUtil.applyXPathReturnList(getAruInfo(), "/results/patch/release/@name");
233+
XPathUtil.applyXPathReturnList(getAruInfo(),
234+
"/results/patch[./platform[@id='2000' or @id='226']]/release/@name");
231235
logger.fine("versions for patch {0} are {1}", getBugNumber(), versionsForPatch);
232236

233237
if (!versionsForPatch.contains(getVersion())) {
@@ -266,7 +270,8 @@ private String downloadPatch(CacheStore cacheStore) throws IOException, XPathExp
266270
}
267271

268272
// select the patch based on the version requested, or default to the installer version, see getVersion()
269-
String patchXpath = String.format("string(/results/patch[release[@name='%s']]", getVersion());
273+
String patchXpath = String.format(
274+
"string(/results/patch[./platform[@id='2000' or @id='226']][release[@name='%s']]", getVersion());
270275

271276
String downloadUrlXpath = patchXpath + "/files/file/download_url";
272277
String downLoadLink = XPathUtil.applyXPathReturnString(getAruInfo(),downloadUrlXpath + "/text())");

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ boolean shouldUpdateOpatch() {
221221
*
222222
* @throws Exception in case of error
223223
*/
224-
void handlePatchFiles() throws Exception {
225-
handlePatchFiles(null, null);
224+
void handlePatchFiles(FmwInstallerType installerType) throws Exception {
225+
handlePatchFiles(installerType, null, null);
226226
}
227227

228228
/**
@@ -232,7 +232,8 @@ void handlePatchFiles() throws Exception {
232232
* @param previousInventory existing inventory found in the "from" image
233233
* @throws Exception in case of error
234234
*/
235-
void handlePatchFiles(String previousInventory, String psuVersion) throws Exception {
235+
void handlePatchFiles(FmwInstallerType installerType, String previousInventory, String psuVersion)
236+
throws Exception {
236237
logger.entering(psuVersion);
237238
if (!applyingPatches()) {
238239
return;
@@ -249,7 +250,7 @@ void handlePatchFiles(String previousInventory, String psuVersion) throws Except
249250
if (recommendedPatches) {
250251
// Get the latest PSU and its recommended patches
251252
List<String> patchList =
252-
AruUtil.getLatestPsuRecommendedPatches(FmwInstallerType.WLS, getInstallerVersion(), userId, password);
253+
AruUtil.getRecommendedPatches(installerType, getInstallerVersion(), userId, password);
253254

254255
if (patchList.isEmpty()) {
255256
recommendedPatches = false;
@@ -262,14 +263,16 @@ void handlePatchFiles(String previousInventory, String psuVersion) throws Except
262263
}
263264
} else if (latestPSU) {
264265
// PSUs for WLS and JRF installers are considered WLS patches
265-
String patchId = AruUtil.getLatestPsuNumber(FmwInstallerType.WLS, getInstallerVersion(), userId, password);
266+
List<String> patchIds = AruUtil.getLatestPsuNumber(installerType, getInstallerVersion(), userId, password);
266267

267-
if (Utils.isEmptyString(patchId)) {
268+
if (patchIds.isEmpty()) {
268269
latestPSU = false;
269270
logger.fine("Latest PSU NOT FOUND, ignoring latestPSU flag");
270271
} else {
271-
logger.fine("Found latest PSU {0}", patchId);
272-
patchFiles.add(new PatchFile(patchId, getInstallerVersion(), null, userId, password));
272+
logger.fine("Found latest PSU {0}", patchIds);
273+
for (String patchId : patchIds) {
274+
patchFiles.add(new PatchFile(patchId, getInstallerVersion(), null, userId, password));
275+
}
273276
}
274277
}
275278

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CreateImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public CommandResponse call() throws Exception {
7171
wdtOptions.handleWdtArgs(dockerfileOptions, cmdBuilder, tmpDir);
7272

7373
// resolve required patches
74-
handlePatchFiles();
74+
handlePatchFiles(installerType);
7575

7676
// If patching, patch OPatch first
7777
if (applyingPatches() && shouldUpdateOpatch()) {

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/RebaseImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public CommandResponse call() throws Exception {
133133
dockerfileOptions.setMiddlewareInstall(install);
134134

135135
// resolve required patches
136-
handlePatchFiles();
136+
handlePatchFiles(installerType);
137137

138138
// If patching, patch OPatch first
139139
if (applyingPatches() && shouldUpdateOpatch()) {

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/UpdateImage.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
1717
import com.oracle.weblogic.imagetool.cachestore.OPatchFile;
18+
import com.oracle.weblogic.imagetool.installer.FmwInstallerType;
1819
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
1920
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
2021
import com.oracle.weblogic.imagetool.util.Constants;
@@ -145,8 +146,10 @@ public CommandResponse call() throws Exception {
145146
return new CommandResponse(-1, "IMG-0055");
146147
}
147148

149+
FmwInstallerType installerType = FmwInstallerType.fromValue(
150+
baseImageProperties.getProperty("WLS_TYPE", "WLS"));
148151
// resolve required patches
149-
handlePatchFiles(lsinventoryText, psuVersion);
152+
handlePatchFiles(installerType, lsinventoryText, psuVersion);
150153

151154
// create dockerfile
152155
String dockerfile = Utils.writeDockerfile(tmpDir + File.separator + "Dockerfile",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package com.oracle.weblogic.imagetool.installer;
5+
6+
/**
7+
* ARU product codes for patching.
8+
*/
9+
public enum AruProduct {
10+
WLS("15991", "Oracle WebLogic Server"),
11+
COH("13964", "Oracle Coherence"),
12+
OSB("16011", "Oracle Service Bus"),
13+
SOA("12745", "Oracle SOA Suite"),
14+
IDM("18391", "Oracle Identity Manager"),
15+
OAM("18388", "Oracle Access Manager"),
16+
OUD("19748", "Oracle Unified Directory"),
17+
WCC("13946", "Oracle WebCenter Content"),
18+
WCP("15224", "Oracle WebCenter Portal"),
19+
WCS("20995", "Oracle WebCenter Sites")
20+
//FIT("33256", "Fusion Internal Tools") No longer used after July 2020 PSU
21+
;
22+
23+
private String productId;
24+
private String description;
25+
AruProduct(String productId, String description) {
26+
this.productId = productId;
27+
this.description = description;
28+
}
29+
30+
public String productId() {
31+
return productId;
32+
}
33+
34+
public String description() {
35+
return description;
36+
}
37+
}

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

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,98 @@
44
package com.oracle.weblogic.imagetool.installer;
55

66
import java.util.Arrays;
7+
import java.util.Collections;
78
import java.util.List;
9+
import java.util.stream.Collectors;
10+
11+
import com.oracle.weblogic.imagetool.util.Utils;
812

913
/**
1014
* Supported Fusion Middleware installer sets.
15+
* Each installer set contains a list of ARU Products for resolving the product name and ARU ID,
16+
* as well as a list of installers needed to create the Oracle Home for that product.
1117
*/
1218
public enum FmwInstallerType {
13-
WLSSLIM(InstallerType.WLSSLIM),
14-
WLSDEV(InstallerType.WLSDEV),
15-
WLS(InstallerType.WLS), //WebLogic Server
16-
FMW(InstallerType.FMW), //WebLogic Server Infrastructure (JRF)
17-
OSB(InstallerType.FMW, InstallerType.OSB), //Service Bus
18-
SOA(InstallerType.FMW, InstallerType.SOA), //SOA Suite
19-
SOA_OSB(InstallerType.FMW, InstallerType.SOA, InstallerType.OSB),
20-
IDM(InstallerType.FMW, InstallerType.IDM),
21-
IDM_WLS(InstallerType.IDM),
22-
OAM(InstallerType.FMW, InstallerType.OAM), //Identity and Access Manager
23-
OIG(InstallerType.FMW, InstallerType.SOA, InstallerType.OSB, InstallerType.IDM),
24-
OUD(InstallerType.OUD), //Oracle Unified Directory
25-
OUD_WLS(InstallerType.FMW, InstallerType.OUD), //Oracle Unified Directory
26-
WCC(InstallerType.FMW, InstallerType.WCC), //Web Center Content
27-
WCP(InstallerType.FMW, InstallerType.WCP), //Web Center Portal
28-
WCS(InstallerType.FMW, InstallerType.WCS) //Web Center Sites
19+
// data from https://updates.oracle.com/Orion/Services/metadata?table=aru_products
20+
21+
// Oracle WebLogic Server
22+
WLSSLIM(Arrays.asList(AruProduct.WLS, AruProduct.COH),
23+
InstallerType.WLSSLIM),
24+
WLSDEV(Arrays.asList(AruProduct.WLS, AruProduct.COH),
25+
InstallerType.WLSDEV),
26+
WLS(Arrays.asList(AruProduct.WLS, AruProduct.COH),
27+
InstallerType.WLS),
28+
// Oracle WebLogic Server Infrastructure (JRF)
29+
FMW(Arrays.asList(AruProduct.WLS, AruProduct.COH),
30+
InstallerType.FMW),
31+
// Oracle Service Bus
32+
OSB(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.OSB),
33+
InstallerType.FMW, InstallerType.OSB),
34+
// Oracle SOA Suite
35+
SOA(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.SOA),
36+
InstallerType.FMW, InstallerType.SOA),
37+
// Oracle SOA Suite (with Service Bus)
38+
SOA_OSB(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.SOA, AruProduct.OSB),
39+
InstallerType.FMW, InstallerType.SOA, InstallerType.OSB),
40+
// Oracle Identity Manager
41+
IDM(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.IDM),
42+
InstallerType.FMW, InstallerType.IDM),
43+
// Oracle Identity Manager
44+
IDM_WLS(Collections.singletonList(AruProduct.IDM),
45+
InstallerType.IDM),
46+
// Oracle Access Manager
47+
OAM(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.OAM),
48+
InstallerType.FMW, InstallerType.OAM),
49+
// Oracle Identity Governance
50+
OIG(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.SOA, AruProduct.OSB, AruProduct.IDM),
51+
InstallerType.FMW, InstallerType.SOA, InstallerType.OSB, InstallerType.IDM),
52+
// Oracle Unified Directory
53+
OUD(Collections.singletonList(AruProduct.OUD),
54+
InstallerType.OUD),
55+
// Oracle Unified Directory
56+
OUD_WLS(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.OUD),
57+
InstallerType.FMW, InstallerType.OUD),
58+
// Oracle WebCenter Content
59+
WCC(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.WCC),
60+
InstallerType.FMW, InstallerType.WCC),
61+
// Oracle WebCenter Portal
62+
WCP(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.WCP),
63+
InstallerType.FMW, InstallerType.WCP),
64+
// Oracle WebCenter Sites
65+
WCS(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.WCS),
66+
InstallerType.FMW, InstallerType.WCS)
2967
;
3068

3169
private InstallerType[] installers;
32-
FmwInstallerType(InstallerType... installers) {
70+
private List<AruProduct> products;
71+
FmwInstallerType(List<AruProduct> products, InstallerType... installers) {
3372
this.installers = installers;
73+
this.products = products;
3474
}
3575

36-
public List<InstallerType> getInstallerList() {
76+
public List<InstallerType> installerList() {
3777
return Arrays.asList(installers);
3878
}
79+
80+
public String installerListString() {
81+
return Arrays.stream(installers).map(Object::toString).collect(Collectors.joining(", "));
82+
}
83+
84+
public List<AruProduct> products() {
85+
return products;
86+
}
87+
88+
/**
89+
* Create the FMW installer type Enum from the String value.
90+
* @param value the installer type string, ignoring case.
91+
* @return the enum installer type.
92+
*/
93+
public static FmwInstallerType fromValue(String value) {
94+
for (FmwInstallerType type : values()) {
95+
if (type.name().equalsIgnoreCase(value)) {
96+
return type;
97+
}
98+
}
99+
throw new IllegalArgumentException(Utils.getMessage("IMG-0080", value));
100+
}
39101
}

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,4 @@ public enum InstallerType {
3939
public String toString() {
4040
return value;
4141
}
42-
43-
/**
44-
* Create the installer type Enum from the String value.
45-
* @param value the installer type string, ignoring case.
46-
* @return the enum installer type.
47-
*/
48-
public static InstallerType fromValue(String value) {
49-
for (InstallerType eachType : InstallerType.values()) {
50-
if (eachType.value.equalsIgnoreCase(value)) {
51-
return eachType;
52-
}
53-
}
54-
throw new IllegalArgumentException("argument " + value + " does not match any InstallerType");
55-
}
5642
}

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.util.ArrayList;
1111
import java.util.Enumeration;
1212
import java.util.List;
13-
import java.util.stream.Collectors;
1413
import java.util.zip.ZipEntry;
1514
import java.util.zip.ZipFile;
1615
import javax.xml.xpath.XPathExpressionException;
@@ -26,7 +25,7 @@ public class MiddlewareInstall {
2625
private static final LoggingFacade logger = LoggingFactory.getLogger(MiddlewareInstall.class);
2726

2827
private List<MiddlewareInstallPackage> installerFiles = new ArrayList<>();
29-
private final String installerListString;
28+
private FmwInstallerType fmwInstallerType;
3029

3130
/**
3231
* Get the install metadata for a given middleware install type.
@@ -35,12 +34,10 @@ public class MiddlewareInstall {
3534
public MiddlewareInstall(FmwInstallerType type, String version, List<Path> responseFiles)
3635
throws FileNotFoundException {
3736

38-
List<InstallerType> list = type.getInstallerList();
37+
logger.info("IMG-0039", type.installerListString(), version);
38+
fmwInstallerType = type;
3939

40-
installerListString = list.stream().map(Object::toString).collect(Collectors.joining(", "));
41-
logger.info("IMG-0039", installerListString, version);
42-
43-
for (InstallerType installer : list) {
40+
for (InstallerType installer : type.installerList()) {
4441
MiddlewareInstallPackage pkg = new MiddlewareInstallPackage();
4542
pkg.type = installer;
4643
pkg.installer = new CachedFile(installer, version);
@@ -112,7 +109,7 @@ private void setResponseFiles(List<Path> responseFiles) throws FileNotFoundExcep
112109
if (responseFiles.size() != installerFiles.size()) {
113110
throw new IllegalArgumentException(
114111
Utils.getMessage("IMG-0040",
115-
installerListString,
112+
fmwInstallerType.installerListString(),
116113
responseFiles.size(),
117114
installerFiles.size()));
118115
}

0 commit comments

Comments
 (0)