10
10
import java .nio .file .Paths ;
11
11
import java .util .Map ;
12
12
13
+ import com .oracle .weblogic .imagetool .installer .InstallerType ;
13
14
import com .oracle .weblogic .imagetool .logging .LoggingFacade ;
14
15
import com .oracle .weblogic .imagetool .logging .LoggingFactory ;
15
16
import com .oracle .weblogic .imagetool .util .Utils ;
@@ -65,6 +66,11 @@ public class UserSettings {
65
66
*/
66
67
private final Integer aruRetryInterval ;
67
68
69
+ /**
70
+ * The time between each ARU REST call in milliseconds.
71
+ */
72
+ private final Map <String , Object > installers ;
73
+
68
74
/**
69
75
* Default construct with all default values for settings.
70
76
*/
@@ -77,6 +83,7 @@ public UserSettings() {
77
83
78
84
aruRetryMax = null ;
79
85
aruRetryInterval = null ;
86
+ installers = null ;
80
87
}
81
88
82
89
/**
@@ -94,6 +101,8 @@ public UserSettings(Map<String, Object> settings) {
94
101
95
102
aruRetryMax = getValue ("aruRetryMax" , Integer .class , settings );
96
103
aruRetryInterval = getValue ("aruRetryInterval" , Integer .class , settings );
104
+
105
+ installers = getValue ("installers" , Map .class , settings );
97
106
}
98
107
99
108
/**
@@ -130,18 +139,22 @@ public static UserSettings load(InputStream settings) {
130
139
}
131
140
132
141
private <T > T getValue (String settingName , Class <T > type , Map <String , Object > settings ) {
142
+ if (settings == null ) {
143
+ return null ;
144
+ }
145
+
133
146
Object value = settings .get (settingName );
134
147
if (value == null ) {
135
148
return null ;
136
149
}
137
150
138
151
if (type .isInstance (value )) {
139
152
return type .cast (value );
140
- } else {
141
- logger .severe ("Setting for {0} could not be loaded. Expected {1}, but found {2}. Invalid value: {3}" ,
142
- settingName , type , value .getClass (), value .toString ());
143
- return null ;
144
153
}
154
+
155
+ logger .severe ("Setting for {0} could not be loaded. Expected {1}, but found {2}. Invalid value: {3}" ,
156
+ settingName , type , value .getClass (), value .toString ());
157
+ return null ;
145
158
}
146
159
147
160
/**
@@ -222,6 +235,22 @@ public int getAruRetryInterval() {
222
235
return aruRetryInterval ;
223
236
}
224
237
238
+ /**
239
+ * The settings asscociated with the installers to be used.
240
+ * @return a map of settings for installers
241
+ */
242
+ public Map <String ,Object > getInstallers () {
243
+ return installers ;
244
+ }
245
+
246
+ public String getDefaultInstallerVersion (InstallerType installerType ) {
247
+ if (installers == null ) {
248
+ return null ;
249
+ }
250
+ Map <String , Object > installerSettings = getValue (installerType .toString (), Map .class , installers );
251
+ return getValue ("defaultVersion" , String .class , installerSettings );
252
+ }
253
+
225
254
/**
226
255
* UserSettings as a YAML string.
227
256
* @return UserSettings as a YAML string.
0 commit comments