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
@@ -70,25 +71,27 @@ public static void getAllFMWReleases(String userId, String password) throws IOEx
70
71
/**
71
72
* Download the latest WLS patches(PSU) for the release
72
73
*
73
- * @param release release number
74
+ * @param version release number
74
75
* @param userId userid for support account
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
- getLatestPSU ("wls" , release , userId , password );
79
+ public static void getLatestWLSPSU (String version , String userId , String password ) throws IOException {
80
+ String releaseNumber = getReleaseNumber ("wls" , version , userId , password );
81
+ getLatestPSU ("wls" , releaseNumber , userId , password );
80
82
}
81
83
82
84
/**
83
85
* Download the latest FMW patches(PSU) for the release
84
86
*
85
- * @param release release number
87
+ * @param version version number 12.2.1.3.0
86
88
* @param userId userid for support account
87
89
* @param password password for support account
88
90
* @throws IOException when failed to access the aru api
89
91
*/
90
- public static void getLatestFMWPatches (String release , String userId , String password ) throws IOException {
91
- getLatestPSU ("fmw" , release , userId , password );
92
+ public static void getLatestFMWPSU (String version , String userId , String password ) throws IOException {
93
+ String releaseNumber = getReleaseNumber ("wls" , version , userId , password );
94
+ getLatestPSU ("fmw" , releaseNumber , userId , password );
92
95
}
93
96
94
97
/**
@@ -187,7 +190,7 @@ private static Document getAllReleases(String category, String userId, String p
187
190
}
188
191
189
192
doc .appendChild (element );
190
- XPathUtil .prettyPrint (doc );
193
+ // XPathUtil.prettyPrint(doc);
191
194
192
195
return doc ;
193
196
@@ -210,7 +213,8 @@ private static void getLatestPSU(String category, String release, String userId
210
213
211
214
Document allPatches = HttpUtil .getXMLContent (expression , userId , password );
212
215
213
- savepatch (allPatches , userId , password );
216
+ //XPathUtil.prettyPrint(allPatches);
217
+ savePatch (allPatches , userId , password );
214
218
}
215
219
216
220
private static void getPatch (String category , String patchNumber , String userId , String password ) throws
@@ -229,33 +233,38 @@ private static void getPatch(String category, String patchNumber, String userId,
229
233
230
234
Document allPatches = HttpUtil .getXMLContent (url , userId , password );
231
235
232
- savepatch (allPatches , userId , password );
236
+ savePatch (allPatches , userId , password );
233
237
234
238
235
239
236
240
}
237
241
238
- private static void savepatch (Document allPatches , String userId , String password ) throws IOException {
242
+ private static void savePatch (Document allPatches , String userId , String password ) throws IOException {
239
243
try {
240
244
241
245
// TODO: needs to make sure there is one and some filtering if not sorting
242
246
243
247
String downLoadLink = XPathUtil .applyXPathReturnString (allPatches , "string"
244
248
+ "(/results/patch[1]/files/file/download_url/text())" );
245
249
246
- String doloadHost = XPathUtil .applyXPathReturnString (allPatches , "string"
250
+ String downLoadHost = XPathUtil .applyXPathReturnString (allPatches , "string"
247
251
+ "(/results/patch[1]/files/file/download_url/@host)" );
248
252
249
- String bugname = XPathUtil .applyXPathReturnString (allPatches , "string"
250
- + "(/results/patch[1]/name" );
253
+ String bugName = XPathUtil .applyXPathReturnString (allPatches , "/results/patch[1]/name" );
251
254
252
- // TODO find the download location
253
255
254
- String fileName = bugname + ".zip" ;
256
+ int index = downLoadLink . indexOf ( "patch_file=" ) ;
255
257
256
- HttpUtil .downloadFile (doloadHost +downLoadLink , fileName , userId , password );
258
+ if (index > 0 ) {
259
+ String fileName = CacheDownLoadUtil .getDownloadRoot () + File .separator + downLoadLink .substring
260
+ (index +"patch_file=" .length ());
257
261
258
- // TODO need method to update the cache data table ?
262
+ if (!CacheDownLoadUtil .existsInCache (bugName , fileName )) {
263
+ HttpUtil .downloadFile (downLoadHost +downLoadLink , fileName , userId , password );
264
+ }
265
+
266
+ CacheDownLoadUtil .updateTableOfContext (bugName , fileName );
267
+ }
259
268
260
269
} catch (XPathExpressionException xpe ) {
261
270
throw new IOException (xpe );
@@ -278,7 +287,7 @@ private static String getReleaseNumber(String category, String version, String u
278
287
}
279
288
280
289
public static void main (String args []) throws Exception {
281
- String release = ARUUtil .
getWLSReleaseNumber ( "121 .2.1.3.0",
"[email protected] " ,
"iJCPiUah7jdmLk1E" );
290
+ ARUUtil .
getLatestWLSPSU ( "12 .2.1.3.0",
"[email protected] " ,
"iJCPiUah7jdmLk1E" );
282
291
}
283
292
284
293
0 commit comments