@@ -105,7 +105,8 @@ public static String getLatestPSUFor(String category, String version, String use
105
105
* @return Document listing of all patches (full details)
106
106
* @throws IOException when failed
107
107
*/
108
- public static Document getAllPSUFor (String category , String version , String userId , String password ) throws IOException {
108
+ public static SearchResult getAllPSUFor (String category , String version , String userId , String password ) throws
109
+ IOException {
109
110
String releaseNumber = getReleaseNumber (category , version , userId , password );
110
111
return getAllPSU (category , releaseNumber , userId , password );
111
112
}
@@ -221,7 +222,7 @@ public static ValidationResult validatePatches(List<String> patches, String cate
221
222
* @return dom document detail about the patch
222
223
* @throws IOException when something goes wrong
223
224
*/
224
- public static Document getPatchDetail (String category , String version , String bugNumber , String userId , String
225
+ public static SearchResult getPatchDetail (String category , String version , String bugNumber , String userId , String
225
226
password )
226
227
throws
227
228
IOException {
@@ -233,7 +234,26 @@ public static Document getPatchDetail(String category, String version, String bu
233
234
else
234
235
url = String .format (PATCH_SEARCH_URL , FMW_PROD_ID , bugNumber , releaseNumber );
235
236
236
- return HttpUtil .getXMLContent (url , userId , password );
237
+ return getSearchResult (HttpUtil .getXMLContent (url , userId , password ));
238
+ }
239
+
240
+ private static SearchResult getSearchResult (Document result ) throws IOException {
241
+ SearchResult returnResult = new SearchResult ();
242
+ returnResult .setSuccess (true );
243
+
244
+ try {
245
+ NodeList nodeList = XPathUtil .applyXPathReturnNodeList (result , "/results/error" );
246
+ if (nodeList .getLength () > 0 ) {
247
+ returnResult .setSuccess (false );
248
+ returnResult .setErrorMessage (XPathUtil .applyXPathReturnString (result , "/results/error/message" ));
249
+ } else {
250
+ returnResult .setResults (result );
251
+ }
252
+ } catch (XPathExpressionException xpe ) {
253
+ throw new IOException (xpe );
254
+ }
255
+
256
+ return returnResult ;
237
257
238
258
}
239
259
@@ -280,26 +300,27 @@ private static Document getAllReleases(String category, String userId, String p
280
300
private static String getLatestPSU (String category , String release , String userId , String password ) throws
281
301
IOException {
282
302
283
- String expression ;
303
+ String url ;
284
304
if ("wls" .equalsIgnoreCase (category ))
285
- expression = String .format (LATEST_PSU_URL , WLS_PROD_ID , release );
305
+ url = String .format (LATEST_PSU_URL , WLS_PROD_ID , release );
286
306
else
287
- expression = String .format (LATEST_PSU_URL , FMW_PROD_ID , release );
307
+ url = String .format (LATEST_PSU_URL , FMW_PROD_ID , release );
288
308
289
- Document allPatches = HttpUtil .getXMLContent (expression , userId , password );
309
+ Document allPatches = HttpUtil .getXMLContent (url , userId , password );
290
310
return savePatch (allPatches , userId , password );
291
311
}
292
312
293
- private static Document getAllPSU (String category , String release , String userId , String password ) throws
313
+ private static SearchResult getAllPSU (String category , String release , String userId , String password ) throws
294
314
IOException {
295
315
296
- String expression ;
316
+ String url ;
297
317
if ("wls" .equalsIgnoreCase (category ))
298
- expression = String .format (LATEST_PSU_URL , WLS_PROD_ID , release );
318
+ url = String .format (LATEST_PSU_URL , WLS_PROD_ID , release );
299
319
else
300
- expression = String .format (LATEST_PSU_URL , FMW_PROD_ID , release );
320
+ url = String .format (LATEST_PSU_URL , FMW_PROD_ID , release );
321
+
322
+ return getSearchResult (HttpUtil .getXMLContent (url , userId , password ));
301
323
302
- return HttpUtil .getXMLContent (expression , userId , password );
303
324
}
304
325
305
326
private static String getPatch (String category , String version , String bugNumber , String userId , String password )
@@ -386,7 +407,6 @@ public static boolean checkCredentials(String username, String password) {
386
407
}
387
408
return true ;
388
409
}
389
-
390
-
410
+
391
411
}
392
412
0 commit comments