6
6
import java .util .Arrays ;
7
7
import java .util .Collections ;
8
8
import java .util .List ;
9
+ import java .util .Set ;
9
10
import java .util .stream .Collectors ;
11
+ import java .util .stream .Stream ;
10
12
11
13
import com .oracle .weblogic .imagetool .aru .AruProduct ;
14
+ import com .oracle .weblogic .imagetool .logging .LoggingFacade ;
15
+ import com .oracle .weblogic .imagetool .logging .LoggingFactory ;
12
16
import com .oracle .weblogic .imagetool .util .Utils ;
13
17
14
18
/**
@@ -20,63 +24,63 @@ public enum FmwInstallerType {
20
24
// data from https://updates.oracle.com/Orion/Services/metadata?table=aru_products
21
25
22
26
// Oracle WebLogic Server
23
- WLS (Arrays . asList (AruProduct .WLS , AruProduct .COH , AruProduct .FMWPLAT ),
27
+ WLS (Utils . toSet (AruProduct .WLS , AruProduct .COH , AruProduct .FMWPLAT ),
24
28
InstallerType .WLS ),
25
- WLSSLIM (Utils .list (WLS .products ),
29
+ WLSSLIM (Utils .toSet (WLS .products ),
26
30
InstallerType .WLSSLIM ),
27
- WLSDEV (Utils .list (WLS .products ),
31
+ WLSDEV (Utils .toSet (WLS .products ),
28
32
InstallerType .WLSDEV ),
29
33
30
34
// 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 ),
32
36
InstallerType .FMW ),
33
37
// Oracle Service Bus
34
- OSB (Utils .list (FMW .products , AruProduct .OSB ),
38
+ OSB (Utils .toSet (FMW .products , AruProduct .OSB ),
35
39
InstallerType .FMW , InstallerType .OSB ),
36
40
// Oracle SOA Suite
37
- SOA (Utils .list (FMW .products , AruProduct .SOA ),
41
+ SOA (Utils .toSet (FMW .products , AruProduct .SOA ),
38
42
InstallerType .FMW , InstallerType .SOA ),
39
43
// 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 ),
41
45
InstallerType .FMW , InstallerType .SOA , InstallerType .OSB ),
42
46
// 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 ),
44
48
InstallerType .FMW , InstallerType .SOA , InstallerType .OSB , InstallerType .B2B ),
45
49
// Oracle Managed File Transfer
46
- MFT (Utils .list (FMW .products , AruProduct .MFT ),
50
+ MFT (Utils .toSet (FMW .products , AruProduct .MFT ),
47
51
InstallerType .FMW , InstallerType .MFT ),
48
52
// Oracle Identity Manager
49
- IDM (Utils .list (FMW .products , AruProduct .IDM ),
53
+ IDM (Utils .toSet (FMW .products , AruProduct .IDM ),
50
54
InstallerType .FMW , InstallerType .IDM ),
51
55
// Oracle Identity Manager
52
- IDM_WLS (Collections .singletonList (AruProduct .IDM ),
56
+ IDM_WLS (Collections .singleton (AruProduct .IDM ),
53
57
InstallerType .IDM ),
54
58
// Oracle Access Manager
55
- OAM (Utils .list (FMW .products , AruProduct .OAM ),
59
+ OAM (Utils .toSet (FMW .products , AruProduct .OAM ),
56
60
InstallerType .FMW , InstallerType .OAM ),
57
61
// 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 ),
59
63
InstallerType .FMW , InstallerType .SOA , InstallerType .OSB , InstallerType .IDM ),
60
64
// Oracle Unified Directory
61
- OUD (Collections .singletonList (AruProduct .OUD ),
65
+ OUD (Collections .singleton (AruProduct .OUD ),
62
66
InstallerType .OUD ),
63
67
// Oracle Unified Directory
64
- OUD_WLS (Utils .list (FMW .products , AruProduct .OUD ),
68
+ OUD_WLS (Utils .toSet (FMW .products , AruProduct .OUD ),
65
69
InstallerType .FMW , InstallerType .OUD ),
66
70
// Oracle WebCenter Content
67
- WCC (Utils .list (FMW .products , AruProduct .WCC ),
71
+ WCC (Utils .toSet (FMW .products , AruProduct .WCC ),
68
72
InstallerType .FMW , InstallerType .WCC ),
69
73
// Oracle WebCenter Portal
70
- WCP (Utils .list (FMW .products , AruProduct .WCP ),
74
+ WCP (Utils .toSet (FMW .products , AruProduct .WCP ),
71
75
InstallerType .FMW , InstallerType .WCP ),
72
76
// Oracle WebCenter Sites
73
- WCS (Utils .list (FMW .products , AruProduct .WCS ),
77
+ WCS (Utils .toSet (FMW .products , AruProduct .WCS ),
74
78
InstallerType .FMW , InstallerType .WCS )
75
79
;
76
80
77
81
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 ) {
80
84
this .installers = installers ;
81
85
this .products = products ;
82
86
}
@@ -89,7 +93,7 @@ public String installerListString() {
89
93
return Arrays .stream (installers ).map (Object ::toString ).collect (Collectors .joining (", " ));
90
94
}
91
95
92
- public List <AruProduct > products () {
96
+ public Set <AruProduct > products () {
93
97
return products ;
94
98
}
95
99
@@ -109,11 +113,47 @@ public static FmwInstallerType fromValue(String value) {
109
113
110
114
private static final List <FmwInstallerType > weblogicServerTypes = Arrays .asList (WLS , WLSDEV , WLSSLIM );
111
115
116
+ private static final LoggingFacade logger = LoggingFactory .getLogger (FmwInstallerType .class );
117
+
112
118
/**
113
119
* Return a list of all WebLogic Server types (not JRF types).
114
120
* @return list of WLS enum types.
115
121
*/
116
122
public static boolean isBaseWeblogicServer (FmwInstallerType value ) {
117
123
return weblogicServerTypes .contains (value );
118
124
}
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
+ }
119
159
}
0 commit comments