2
2
3
3
import java .io .File ;
4
4
import java .io .IOException ;
5
+ import java .util .ArrayList ;
5
6
import java .util .List ;
6
7
7
8
import javax .xml .parsers .DocumentBuilder ;
@@ -80,10 +81,11 @@ public static void getAllFMWReleases(String userId, String password) throws IOEx
80
81
* @param userId userid for support account
81
82
* @param password password for support account
82
83
* @throws IOException when failed to access the aru api
84
+ * @return String bug number
83
85
*/
84
- public static void getLatestWLSPSU (String version , String userId , String password ) throws IOException {
86
+ public static String getLatestWLSPSU (String version , String userId , String password ) throws IOException {
85
87
String releaseNumber = getReleaseNumber ("wls" , version , userId , password );
86
- getLatestPSU ("wls" , releaseNumber , userId , password );
88
+ return getLatestPSU ("wls" , releaseNumber , userId , password );
87
89
}
88
90
89
91
/**
@@ -93,10 +95,11 @@ public static void getLatestWLSPSU(String version, String userId, String passwor
93
95
* @param userId userid for support account
94
96
* @param password password for support account
95
97
* @throws IOException when failed to access the aru api
98
+ * @return String bug number
96
99
*/
97
- public static void getLatestFMWPSU (String version , String userId , String password ) throws IOException {
100
+ public static String getLatestFMWPSU (String version , String userId , String password ) throws IOException {
98
101
String releaseNumber = getReleaseNumber ("wls" , version , userId , password );
99
- getLatestPSU ("fmw" , releaseNumber , userId , password );
102
+ return getLatestPSU ("fmw" , releaseNumber , userId , password );
100
103
}
101
104
102
105
/**
@@ -107,10 +110,16 @@ public static void getLatestFMWPSU(String version, String userId, String passwo
107
110
* @param password password for support account
108
111
* @throws IOException when failed to access the aru api
109
112
*/
110
- public static void getWLSPatches (List <String > patches , String userId , String password ) throws
113
+ public static List < String > getWLSPatches (List <String > patches , String userId , String password ) throws
111
114
IOException {
112
- for (String patch : patches )
113
- getPatch ("wls" , patch , userId , password );
115
+ List <String > results = new ArrayList <>();
116
+ for (String patch : patches ) {
117
+ String rs = getPatch ("wls" , patch , userId , password );
118
+ if (rs != null ) {
119
+ results .add (rs );
120
+ }
121
+ }
122
+ return results ;
114
123
}
115
124
116
125
/**
@@ -121,10 +130,17 @@ public static void getWLSPatches(List<String> patches, String userId, String pa
121
130
* @param password password for support account
122
131
* @throws IOException when failed to access the aru api
123
132
*/
124
- public static void getFMWPatches (String category , List <String > patches , String userId , String password ) throws
133
+ public static List <String > getFMWPatches (String category , List <String > patches , String userId , String password )
134
+ throws
125
135
IOException {
126
- for (String patch : patches )
127
- getPatch ("fmw" , patch , userId , password );
136
+ List <String > results = new ArrayList <>();
137
+ for (String patch : patches ) {
138
+ String rs = getPatch ("fmw" , patch , userId , password );
139
+ if (rs != null ) {
140
+ results .add (rs );
141
+ }
142
+ }
143
+ return results ;
128
144
}
129
145
130
146
/**
@@ -205,7 +221,8 @@ private static Document getAllReleases(String category, String userId, String p
205
221
206
222
}
207
223
208
- private static void getLatestPSU (String category , String release , String userId , String password ) throws IOException {
224
+ private static String getLatestPSU (String category , String release , String userId , String password ) throws
225
+ IOException {
209
226
210
227
String expression ;
211
228
if ("wls" .equalsIgnoreCase (category ))
@@ -217,7 +234,7 @@ private static void getLatestPSU(String category, String release, String userId
217
234
savePatch (allPatches , userId , password );
218
235
}
219
236
220
- private static void getPatch (String category , String patchNumber , String userId , String password ) throws
237
+ private static String getPatch (String category , String patchNumber , String userId , String password ) throws
221
238
IOException {
222
239
223
240
// HTTP_STATUS=$(curl -v -w "%{http_code}" -b cookies.txt -L --header 'Authorization: Basic ${basicauth}' "https://updates.oracle.com/Orion/Services/search?product=15991&release=$releaseid&include_prereqs=true" -o latestpsu.xml)
@@ -230,10 +247,10 @@ private static void getPatch(String category, String patchNumber, String userId,
230
247
231
248
Document allPatches = HttpUtil .getXMLContent (url , userId , password );
232
249
233
- savePatch (allPatches , userId , password );
250
+ return savePatch (allPatches , userId , password );
234
251
}
235
252
236
- private static void savePatch (Document allPatches , String userId , String password ) throws IOException {
253
+ private static String savePatch (Document allPatches , String userId , String password ) throws IOException {
237
254
try {
238
255
239
256
// TODO: needs to make sure there is one and some filtering if not sorting
@@ -260,12 +277,14 @@ private static void savePatch(Document allPatches, String userId, String passwor
260
277
} else {
261
278
System .out .println (String .format ("patch %s already downloaded for bug %s" , fileName , bugName ));
262
279
}
280
+ return bugName ;
263
281
}
264
282
265
283
} catch (XPathExpressionException xpe ) {
266
284
throw new IOException (xpe );
267
285
}
268
286
287
+ return null ;
269
288
}
270
289
271
290
private static String getReleaseNumber (String category , String version , String userId , String password ) throws
@@ -297,10 +316,7 @@ public static boolean checkCredentials(String userId, String password) {
297
316
}
298
317
299
318
public static void main (String args []) throws Exception {
300
- // System.out.println("Credentials isValid: " + ARUUtil.checkCredentials("[email protected] ", "iJCPiUah7jdmLk1E"));
301
- // System.out.println("Credentials isValid: " + ARUUtil.checkCredentials("[email protected] ", "invalid"));
302
- ARUUtil .
getLatestWLSPSU (
"12.2.1.3.0" ,
"[email protected] " ,
"omSAI@123" );
303
- //ARUUtil.getLatestWLSPSU("12.2.1.3.0","[email protected] ", "iJCPiUah7jdmLk1E");
319
+ ARUUtil .
getLatestWLSPSU (
"12.2.1.3.0" ,
"[email protected] " ,
"iJCPiUah7jdmLk1E" );
304
320
}
305
321
306
322
0 commit comments