Skip to content

Commit ca6c200

Browse files
authored
update all products with latest PSU or recommended patches, not just WLS (#290)
1 parent 66e56f6 commit ca6c200

File tree

8 files changed

+116
-47
lines changed

8 files changed

+116
-47
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
1212
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
13+
import com.oracle.weblogic.imagetool.util.Utils;
1314

1415
public class InstalledPatch {
1516
private static final LoggingFacade logger = LoggingFactory.getLogger(InstalledPatch.class);
@@ -25,10 +26,14 @@ public class InstalledPatch {
2526
* @return a simple list of InstalledPatch
2627
*/
2728
public static List<InstalledPatch> getPatchList(String oraclePatches) {
29+
logger.entering(oraclePatches);
2830
List<InstalledPatch> result = new ArrayList<>();
31+
if (Utils.isEmptyString(oraclePatches)) {
32+
return result;
33+
}
2934
String[] tokens = oraclePatches.split(";");
3035
if (tokens.length % 3 != 0) {
31-
logger.severe("Too many tokens in oracle patches " + tokens.length);
36+
logger.severe("IMG-0095", tokens.length);
3237
}
3338
for (int i = 0; i < tokens.length; i++) {
3439
InstalledPatch found = new InstalledPatch();
@@ -42,6 +47,7 @@ public static List<InstalledPatch> getPatchList(String oraclePatches) {
4247
result.add(found);
4348
}
4449

50+
logger.exiting(result.size());
4551
return result;
4652
}
4753

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ public CommandResponse call() throws Exception {
141141
return new CommandResponse(-1, "IMG-0055");
142142
}
143143

144-
FmwInstallerType installerType = FmwInstallerType.fromValue(
145-
baseImageProperties.getProperty("wlsType", "WLS"));
144+
FmwInstallerType installerType = FmwInstallerType.fromProductList(
145+
baseImageProperties.getProperty("oracleInstalledProducts"));
146+
logger.info("IMG-0094", installerType);
146147
// resolve required patches
147148
handlePatchFiles(installerType, installedPatches);
148149

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

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
import java.util.Arrays;
77
import java.util.Collections;
88
import java.util.List;
9+
import java.util.Set;
910
import java.util.stream.Collectors;
11+
import java.util.stream.Stream;
1012

1113
import com.oracle.weblogic.imagetool.aru.AruProduct;
14+
import com.oracle.weblogic.imagetool.logging.LoggingFacade;
15+
import com.oracle.weblogic.imagetool.logging.LoggingFactory;
1216
import com.oracle.weblogic.imagetool.util.Utils;
1317

1418
/**
@@ -20,63 +24,63 @@ public enum FmwInstallerType {
2024
// data from https://updates.oracle.com/Orion/Services/metadata?table=aru_products
2125

2226
// Oracle WebLogic Server
23-
WLS(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.FMWPLAT),
27+
WLS(Utils.toSet(AruProduct.WLS, AruProduct.COH, AruProduct.FMWPLAT),
2428
InstallerType.WLS),
25-
WLSSLIM(Utils.list(WLS.products),
29+
WLSSLIM(Utils.toSet(WLS.products),
2630
InstallerType.WLSSLIM),
27-
WLSDEV(Utils.list(WLS.products),
31+
WLSDEV(Utils.toSet(WLS.products),
2832
InstallerType.WLSDEV),
2933

3034
// Oracle WebLogic Server Infrastructure (JRF)
31-
FMW(Utils.list(WLS.products, AruProduct.JRF, AruProduct.JDEV),
35+
FMW(Utils.toSet(WLS.products, AruProduct.JRF, AruProduct.JDEV),
3236
InstallerType.FMW),
3337
// Oracle Service Bus
34-
OSB(Utils.list(FMW.products, AruProduct.OSB),
38+
OSB(Utils.toSet(FMW.products, AruProduct.OSB),
3539
InstallerType.FMW, InstallerType.OSB),
3640
// Oracle SOA Suite
37-
SOA(Utils.list(FMW.products, AruProduct.SOA),
41+
SOA(Utils.toSet(FMW.products, AruProduct.SOA),
3842
InstallerType.FMW, InstallerType.SOA),
3943
// Oracle SOA Suite (with Service Bus)
40-
SOA_OSB(Utils.list(FMW.products, AruProduct.SOA, AruProduct.OSB),
44+
SOA_OSB(Utils.toSet(FMW.products, AruProduct.SOA, AruProduct.OSB),
4145
InstallerType.FMW, InstallerType.SOA, InstallerType.OSB),
4246
// Oracle SOA Suite (with Service Bus and B2B)
43-
SOA_OSB_B2B(Utils.list(FMW.products, AruProduct.SOA, AruProduct.OSB),
47+
SOA_OSB_B2B(Utils.toSet(FMW.products, AruProduct.SOA, AruProduct.OSB),
4448
InstallerType.FMW, InstallerType.SOA, InstallerType.OSB, InstallerType.B2B),
4549
// Oracle Managed File Transfer
46-
MFT(Utils.list(FMW.products, AruProduct.MFT),
50+
MFT(Utils.toSet(FMW.products, AruProduct.MFT),
4751
InstallerType.FMW, InstallerType.MFT),
4852
// Oracle Identity Manager
49-
IDM(Utils.list(FMW.products, AruProduct.IDM),
53+
IDM(Utils.toSet(FMW.products, AruProduct.IDM),
5054
InstallerType.FMW, InstallerType.IDM),
5155
// Oracle Identity Manager
52-
IDM_WLS(Collections.singletonList(AruProduct.IDM),
56+
IDM_WLS(Collections.singleton(AruProduct.IDM),
5357
InstallerType.IDM),
5458
// Oracle Access Manager
55-
OAM(Utils.list(FMW.products, AruProduct.OAM),
59+
OAM(Utils.toSet(FMW.products, AruProduct.OAM),
5660
InstallerType.FMW, InstallerType.OAM),
5761
// Oracle Identity Governance
58-
OIG(Utils.list(FMW.products, AruProduct.SOA, AruProduct.OSB, AruProduct.IDM),
62+
OIG(Utils.toSet(FMW.products, AruProduct.SOA, AruProduct.OSB, AruProduct.IDM),
5963
InstallerType.FMW, InstallerType.SOA, InstallerType.OSB, InstallerType.IDM),
6064
// Oracle Unified Directory
61-
OUD(Collections.singletonList(AruProduct.OUD),
65+
OUD(Collections.singleton(AruProduct.OUD),
6266
InstallerType.OUD),
6367
// Oracle Unified Directory
64-
OUD_WLS(Utils.list(FMW.products, AruProduct.OUD),
68+
OUD_WLS(Utils.toSet(FMW.products, AruProduct.OUD),
6569
InstallerType.FMW, InstallerType.OUD),
6670
// Oracle WebCenter Content
67-
WCC(Utils.list(FMW.products, AruProduct.WCC),
71+
WCC(Utils.toSet(FMW.products, AruProduct.WCC),
6872
InstallerType.FMW, InstallerType.WCC),
6973
// Oracle WebCenter Portal
70-
WCP(Utils.list(FMW.products, AruProduct.WCP),
74+
WCP(Utils.toSet(FMW.products, AruProduct.WCP),
7175
InstallerType.FMW, InstallerType.WCP),
7276
// Oracle WebCenter Sites
73-
WCS(Utils.list(FMW.products, AruProduct.WCS),
77+
WCS(Utils.toSet(FMW.products, AruProduct.WCS),
7478
InstallerType.FMW, InstallerType.WCS)
7579
;
7680

7781
private final InstallerType[] installers;
78-
private final List<AruProduct> products;
79-
FmwInstallerType(List<AruProduct> products, InstallerType... installers) {
82+
private final Set<AruProduct> products;
83+
FmwInstallerType(Set<AruProduct> products, InstallerType... installers) {
8084
this.installers = installers;
8185
this.products = products;
8286
}
@@ -89,7 +93,7 @@ public String installerListString() {
8993
return Arrays.stream(installers).map(Object::toString).collect(Collectors.joining(", "));
9094
}
9195

92-
public List<AruProduct> products() {
96+
public Set<AruProduct> products() {
9397
return products;
9498
}
9599

@@ -109,11 +113,47 @@ public static FmwInstallerType fromValue(String value) {
109113

110114
private static final List<FmwInstallerType> weblogicServerTypes = Arrays.asList(WLS, WLSDEV, WLSSLIM);
111115

116+
private static final LoggingFacade logger = LoggingFactory.getLogger(FmwInstallerType.class);
117+
112118
/**
113119
* Return a list of all WebLogic Server types (not JRF types).
114120
* @return list of WLS enum types.
115121
*/
116122
public static boolean isBaseWeblogicServer(FmwInstallerType value) {
117123
return weblogicServerTypes.contains(value);
118124
}
125+
126+
/**
127+
* Derive the FmwInstallerType from a list of product families.
128+
* These product families are found in inventory/registry.xml.
129+
* @param products a comma-separated list of product families
130+
* @return the best match for the list of product families
131+
*/
132+
public static FmwInstallerType fromProductList(String products) {
133+
logger.entering(products);
134+
// create a set from the comma-separated list
135+
Set<AruProduct> productSet = Stream.of(products.split(","))
136+
.filter(e -> !"TOPLINK".equals(e)) // skip TOPLINK product (WLS always contains TOPLINK)
137+
.filter(e -> !"BPM".equals(e)) // skip BPM product (SOA always contains BPM)
138+
.map(e -> "INFRA".equals(e) ? "JRF" : e) // map -> replaces any occurrence of INFRA with JRF
139+
.map(AruProduct::valueOf) // convert String to AruProduct enum
140+
.collect(Collectors.toSet());
141+
142+
logger.finer("Derived product set {0} from {1}", productSet, products);
143+
144+
for (FmwInstallerType type : values()) {
145+
// Use the product set to compare products, but remove products that CIE does not include in registry.xml
146+
Set<AruProduct> aruProducts = type.products().stream()
147+
.filter(e -> !AruProduct.FMWPLAT.equals(e)) // never shows up on installed product family
148+
.filter(e -> !AruProduct.JDEV.equals(e)) // never shows up on installed product family
149+
.collect(Collectors.toSet());
150+
151+
if (aruProducts.equals(productSet)) {
152+
logger.exiting(type);
153+
return type;
154+
}
155+
}
156+
logger.exiting(WLS);
157+
return WLS;
158+
}
119159
}

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/Utils.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@
2121
import java.nio.file.StandardCopyOption;
2222
import java.nio.file.attribute.PosixFilePermissions;
2323
import java.text.MessageFormat;
24-
import java.util.ArrayList;
24+
import java.util.Arrays;
2525
import java.util.Base64;
2626
import java.util.Collection;
2727
import java.util.Collections;
2828
import java.util.Comparator;
2929
import java.util.Enumeration;
30+
import java.util.HashSet;
3031
import java.util.List;
3132
import java.util.Objects;
3233
import java.util.Properties;
3334
import java.util.ResourceBundle;
35+
import java.util.Set;
3436
import java.util.regex.Matcher;
3537
import java.util.regex.Pattern;
3638
import java.util.stream.Collectors;
@@ -51,7 +53,7 @@ public class Utils {
5153
private static final LoggingFacade logger = LoggingFactory.getLogger(Utils.class);
5254

5355
@NonNls
54-
private static ResourceBundle bundle = ResourceBundle.getBundle("ImageTool");
56+
private static final ResourceBundle bundle = ResourceBundle.getBundle("ImageTool");
5557

5658
private Utils() {
5759
// hide constructor, usage of this class is only static utilities
@@ -306,8 +308,7 @@ public static void deleteFilesRecursively(String pathDir) throws IOException {
306308
}
307309

308310
if (Files.exists(tmpDir)) {
309-
logger.warning("Unable to cleanup temp directory, it is safe to remove this directory manually "
310-
+ tmpDir.toString());
311+
logger.warning("IMG-0038", tmpDir);
311312
}
312313
}
313314
}
@@ -751,16 +752,27 @@ public static void removeIntermediateDockerImages(String builder, String buildId
751752
}
752753

753754
/**
754-
* Create a new list from an existing collection and adding additional elements, if desired.
755+
* Create a new set from an existing collection and adding additional elements, if desired.
755756
* @param start a set of elements to start from
756757
* @param elements zero to many additional elements to add to the new list
757-
* @param <T> the class of the elements to add
758-
* @return a new list of element T
758+
* @param <T> the class of the elements in the Set
759+
* @return a new set of the specified T
759760
*/
760761
@SafeVarargs
761-
public static <T> List<T> list(Collection<? extends T> start, T... elements) {
762-
List<T> result = new ArrayList<>(start);
762+
public static <T> Set<T> toSet(Collection<? extends T> start, T... elements) {
763+
Set<T> result = new HashSet<>(start);
763764
Collections.addAll(result, elements);
764765
return result;
765766
}
767+
768+
/**
769+
* Create a new Set from a list of elements.
770+
* @param array elements to be added to the Set
771+
* @param <T> the class of the elements in the Set
772+
* @return a set of the specified T
773+
*/
774+
@SafeVarargs
775+
public static <T> Set<T> toSet(T... array) {
776+
return toSet(Arrays.asList(array));
777+
}
766778
}

imagetool/src/main/resources/ImageTool.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ IMG-0034=Patch ID {0} has multiple versions, please retry the command using one
3636
IMG-0035=additionalBuildFile could not be copied: {0}
3737
IMG-0036=Unable to find installer inventory file: {0}
3838
IMG-0037=Failed to find patch {0} for version {1}
39-
IMG-0038=NO LONGER USED
39+
IMG-0038=Unable to cleanup temp directory, it is safe to remove this directory manually: {0}
4040
IMG-0039=Using middleware installers ([[green: {0}]]) version [[cyan: {1}]]
4141
IMG-0040=When providing custom response files, a response file must be provided for each of the installers {0}. Found {1}, expected {2}.
4242
IMG-0041=Using provided installer response file: {0} for {1} install
@@ -92,3 +92,5 @@ IMG-0090=Rebasing WDT models. A domain was not found in the source image at {0}
9292
IMG-0091=Reading settings from the source image {0}
9393
IMG-0092=ORACLE_HOME already exists in {0} (--fromImage), skipping middleware installs
9494
IMG-0093=Patching skipped. Using CREATE to patch --fromImage with an existing ORACLE_HOME is not supported. To create a patched image, use CREATE with a linux base image and apply the WebLogic install and patches at the same time.
95+
IMG-0094=Source image installer type: ([[green: {0}]])
96+
IMG-0095=Unable to parse response for Oracle patches in fromImage: {0}

imagetool/src/main/resources/probe-env/inspect-image-long.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ fi
4040

4141
if [ -n "$ORACLE_HOME" ]; then
4242
echo oracleHome="$ORACLE_HOME"
43-
WLS_TYPE=$(cat "$ORACLE_HOME"/inventory/registry.xml 2> /dev/null | grep -q 'WebLogic Server for FMW' && printf "fmw")
44-
if [ -n "$WLS_TYPE" ]; then
45-
echo wlsType="$WLS_TYPE"
46-
fi
43+
4744
if [ -n "$JAVA_HOME" ]; then
4845
echo wlsVersion="$("$JAVA_HOME"/bin/java -cp "$ORACLE_HOME"/wlserver/server/lib/weblogic.jar weblogic.version 2> /dev/null | grep -oE -m 1 '([[:digit:]\.]+)' | head -1)"
4946
fi

imagetool/src/main/resources/probe-env/inspect-image.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ fi
4040

4141
if [ -n "$ORACLE_HOME" ]; then
4242
echo oracleHome="$ORACLE_HOME"
43-
WLS_TYPE=$(cat "$ORACLE_HOME"/inventory/registry.xml 2> /dev/null | grep -q 'WebLogic Server for FMW' && printf "fmw")
44-
if [ -n "$WLS_TYPE" ]; then
45-
echo wlsType="$WLS_TYPE"
46-
fi
43+
4744
if [ -n "$JAVA_HOME" ]; then
4845
echo wlsVersion="$("$JAVA_HOME"/bin/java -cp "$ORACLE_HOME"/wlserver/server/lib/weblogic.jar weblogic.version 2> /dev/null | grep -oE -m 1 '([[:digit:]\.]+)' | head -1)"
4946
fi

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.Arrays;
77

88
import com.oracle.weblogic.imagetool.aru.AruProduct;
9+
import com.oracle.weblogic.imagetool.util.Utils;
910
import org.junit.jupiter.api.Tag;
1011
import org.junit.jupiter.api.Test;
1112

@@ -30,12 +31,18 @@ void fmwInstallerTypeListTest() {
3031

3132
@Test
3233
void fmwInstallerProductIds() {
33-
assertEquals(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.FMWPLAT), FmwInstallerType.WLS.products(),
34+
AruProduct[] list1 = {AruProduct.WLS, AruProduct.COH, AruProduct.FMWPLAT};
35+
assertEquals(Utils.toSet(list1), FmwInstallerType.WLS.products(),
3436
"WLS product list is incorrect or out of order");
35-
assertEquals(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.FMWPLAT, AruProduct.JRF, AruProduct.JDEV),
36-
FmwInstallerType.FMW.products(), "FMW product list is incorrect or out of order");
37-
assertEquals(Arrays.asList(AruProduct.WLS, AruProduct.COH, AruProduct.FMWPLAT, AruProduct.JRF, AruProduct.JDEV,
38-
AruProduct.SOA), FmwInstallerType.SOA.products(), "SOA product list is incorrect or out of order");
37+
38+
AruProduct[] list2 = {AruProduct.WLS, AruProduct.COH, AruProduct.FMWPLAT, AruProduct.JRF, AruProduct.JDEV};
39+
assertEquals(Utils.toSet(list2), FmwInstallerType.FMW.products(),
40+
"FMW product list is incorrect or out of order");
41+
42+
AruProduct[] list3 = {AruProduct.WLS, AruProduct.COH, AruProduct.FMWPLAT, AruProduct.JRF, AruProduct.JDEV,
43+
AruProduct.SOA};
44+
assertEquals(Utils.toSet(list3), FmwInstallerType.SOA.products(),
45+
"SOA product list is incorrect or out of order");
3946
}
4047

4148
@Test
@@ -45,5 +52,12 @@ void fmwInstallerFromValue() {
4552
assertEquals(FmwInstallerType.FMW, FmwInstallerType.fromValue("fmw"),
4653
"fromValue fmw failed for FmwInstallerType");
4754
}
55+
56+
@Test
57+
void fromProductList() {
58+
assertEquals(FmwInstallerType.WLS, FmwInstallerType.fromProductList("WLS,COH,TOPLINK"));
59+
assertEquals(FmwInstallerType.FMW, FmwInstallerType.fromProductList("INFRA,WLS,COH,TOPLINK"));
60+
assertEquals(FmwInstallerType.SOA_OSB, FmwInstallerType.fromProductList("INFRA,WLS,COH,TOPLINK,BPM,SOA,OSB"));
61+
}
4862
}
4963

0 commit comments

Comments
 (0)