66import java .util .Arrays ;
77import java .util .Collections ;
88import java .util .List ;
9+ import java .util .Set ;
910import java .util .stream .Collectors ;
11+ import java .util .stream .Stream ;
1012
1113import com .oracle .weblogic .imagetool .aru .AruProduct ;
14+ import com .oracle .weblogic .imagetool .logging .LoggingFacade ;
15+ import com .oracle .weblogic .imagetool .logging .LoggingFactory ;
1216import 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}
0 commit comments