Skip to content

Commit 3d55a23

Browse files
merged changes from origin
Former-commit-id: e140c36d4a9b0c052bcfcc7f83c221e370907089
2 parents 74d4eb2 + a769681 commit 3d55a23

File tree

1 file changed

+34
-18
lines changed
  • src/main/java/com/oracle/weblogicx/imagebuilder/builder/util

1 file changed

+34
-18
lines changed

src/main/java/com/oracle/weblogicx/imagebuilder/builder/util/ARUUtil.java

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.File;
44
import java.io.IOException;
5+
import java.util.ArrayList;
56
import java.util.List;
67

78
import javax.xml.parsers.DocumentBuilder;
@@ -80,10 +81,11 @@ public static void getAllFMWReleases(String userId, String password) throws IOEx
8081
* @param userId userid for support account
8182
* @param password password for support account
8283
* @throws IOException when failed to access the aru api
84+
* @return String bug number
8385
*/
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 {
8587
String releaseNumber = getReleaseNumber("wls", version, userId, password);
86-
getLatestPSU("wls", releaseNumber, userId, password);
88+
return getLatestPSU("wls", releaseNumber, userId, password);
8789
}
8890

8991
/**
@@ -93,10 +95,11 @@ public static void getLatestWLSPSU(String version, String userId, String passwor
9395
* @param userId userid for support account
9496
* @param password password for support account
9597
* @throws IOException when failed to access the aru api
98+
* @return String bug number
9699
*/
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 {
98101
String releaseNumber = getReleaseNumber("wls", version, userId, password);
99-
getLatestPSU("fmw", releaseNumber, userId, password);
102+
return getLatestPSU("fmw", releaseNumber, userId, password);
100103
}
101104

102105
/**
@@ -107,10 +110,16 @@ public static void getLatestFMWPSU(String version, String userId, String passwo
107110
* @param password password for support account
108111
* @throws IOException when failed to access the aru api
109112
*/
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
111114
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;
114123
}
115124

116125
/**
@@ -121,10 +130,17 @@ public static void getWLSPatches(List<String> patches, String userId, String pa
121130
* @param password password for support account
122131
* @throws IOException when failed to access the aru api
123132
*/
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
125135
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;
128144
}
129145

130146
/**
@@ -205,7 +221,8 @@ private static Document getAllReleases(String category, String userId, String p
205221

206222
}
207223

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 {
209226

210227
String expression;
211228
if ("wls".equalsIgnoreCase(category))
@@ -217,7 +234,7 @@ private static void getLatestPSU(String category, String release, String userId
217234
savePatch(allPatches, userId, password);
218235
}
219236

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
221238
IOException {
222239

223240
// 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,
230247

231248
Document allPatches = HttpUtil.getXMLContent(url, userId, password);
232249

233-
savePatch(allPatches, userId, password);
250+
return savePatch(allPatches, userId, password);
234251
}
235252

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 {
237254
try {
238255

239256
// 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
260277
} else {
261278
System.out.println(String.format("patch %s already downloaded for bug %s", fileName, bugName));
262279
}
280+
return bugName;
263281
}
264282

265283
} catch (XPathExpressionException xpe) {
266284
throw new IOException(xpe);
267285
}
268286

287+
return null;
269288
}
270289

271290
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) {
297316
}
298317

299318
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");
304320
}
305321

306322

0 commit comments

Comments
 (0)