1
1
package com .oracle .weblogicx .imagebuilder .builder .util ;
2
2
3
+ import java .io .File ;
3
4
import java .io .IOException ;
4
5
import java .util .List ;
5
6
@@ -75,7 +76,7 @@ public static void getAllFMWReleases(String userId, String password) throws IOEx
75
76
* @param password password for support account
76
77
* @throws IOException when failed to access the aru api
77
78
*/
78
- public static void getLatestWLSPatches (String release , String userId , String password ) throws IOException {
79
+ public static void getLatestWLSPSU (String release , String userId , String password ) throws IOException {
79
80
getLatestPSU ("wls" , release , userId , password );
80
81
}
81
82
@@ -87,7 +88,7 @@ public static void getLatestWLSPatches(String release, String userId, String pas
87
88
* @param password password for support account
88
89
* @throws IOException when failed to access the aru api
89
90
*/
90
- public static void getLatestFMWPatches (String release , String userId , String password ) throws IOException {
91
+ public static void getLatestFMWPSU (String release , String userId , String password ) throws IOException {
91
92
getLatestPSU ("fmw" , release , userId , password );
92
93
}
93
94
@@ -210,7 +211,8 @@ private static void getLatestPSU(String category, String release, String userId
210
211
211
212
Document allPatches = HttpUtil .getXMLContent (expression , userId , password );
212
213
213
- savepatch (allPatches , userId , password );
214
+ //XPathUtil.prettyPrint(allPatches);
215
+ savePatch (allPatches , userId , password );
214
216
}
215
217
216
218
private static void getPatch (String category , String patchNumber , String userId , String password ) throws
@@ -229,33 +231,38 @@ private static void getPatch(String category, String patchNumber, String userId,
229
231
230
232
Document allPatches = HttpUtil .getXMLContent (url , userId , password );
231
233
232
- savepatch (allPatches , userId , password );
234
+ savePatch (allPatches , userId , password );
233
235
234
236
235
237
236
238
}
237
239
238
- private static void savepatch (Document allPatches , String userId , String password ) throws IOException {
240
+ private static void savePatch (Document allPatches , String userId , String password ) throws IOException {
239
241
try {
240
242
241
243
// TODO: needs to make sure there is one and some filtering if not sorting
242
244
243
245
String downLoadLink = XPathUtil .applyXPathReturnString (allPatches , "string"
244
246
+ "(/results/patch[1]/files/file/download_url/text())" );
245
247
246
- String doloadHost = XPathUtil .applyXPathReturnString (allPatches , "string"
248
+ String downLoadHost = XPathUtil .applyXPathReturnString (allPatches , "string"
247
249
+ "(/results/patch[1]/files/file/download_url/@host)" );
248
250
249
- String bugname = XPathUtil .applyXPathReturnString (allPatches , "string"
250
- + "(/results/patch[1]/name" );
251
+ String bugName = XPathUtil .applyXPathReturnString (allPatches , "/results/patch[1]/name" );
251
252
252
- // TODO find the download location
253
253
254
- String fileName = bugname + ".zip" ;
254
+ int index = downLoadLink . indexOf ( "patch_file=" ) ;
255
255
256
- HttpUtil .downloadFile (doloadHost +downLoadLink , fileName , userId , password );
256
+ if (index > 0 ) {
257
+ String fileName = CacheDownLoadUtil .getDownloadRoot () + File .separator + downLoadLink .substring
258
+ (index +"patch_file=" .length ());
257
259
258
- // TODO need method to update the cache data table ?
260
+ if (!CacheDownLoadUtil .existsInCache (bugName , fileName )) {
261
+ HttpUtil .downloadFile (downLoadHost +downLoadLink , fileName , userId , password );
262
+ }
263
+
264
+ CacheDownLoadUtil .updateTableOfContext (bugName , fileName );
265
+ }
259
266
260
267
} catch (XPathExpressionException xpe ) {
261
268
throw new IOException (xpe );
@@ -278,7 +285,7 @@ private static String getReleaseNumber(String category, String version, String u
278
285
}
279
286
280
287
public static void main (String args []) throws Exception {
281
- String release = ARUUtil .
getWLSReleaseNumber ( "121.2.1.3.0 ",
"[email protected] " ,
"iJCPiUah7jdmLk1E" );
288
+ ARUUtil .
getLatestWLSPSU ( "600000000073715 ",
"[email protected] " ,
"iJCPiUah7jdmLk1E" );
282
289
}
283
290
284
291
0 commit comments