Skip to content

Commit 156d744

Browse files
authored
change ARU URL for PSU resolution (#104)
1 parent e3ff472 commit 156d744

File tree

9 files changed

+56
-45
lines changed

9 files changed

+56
-45
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/model/AbstractFile.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public AbstractFile(String id, String version, CachePolicy cachePolicy, String u
4242

4343
public String generateKey(String id, String version) {
4444

45+
logger.entering(id, version);
4546
// Note: this will be invoked by InstallerFile or PatchFile
4647
// for patches there are specific format, currently installers are
4748
// wls, fmw, jdk.
@@ -56,7 +57,7 @@ public String generateKey(String id, String version) {
5657
}
5758
}
5859

59-
logger.finest("AbstractFile generating key returns " + mykey);
60+
logger.exiting(mykey);
6061
return mykey;
6162
}
6263

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/UpdateImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public CommandResponse call() throws Exception {
118118
byte[] lsinventoryContent = Base64.getDecoder().decode(b64lsout);
119119
lsinventoryText = new String(lsinventoryContent);
120120

121-
logger.finest("ls inventory = " + lsinventoryText);
121+
logger.finer("ls inventory = " + lsinventoryText);
122122

123123
// Any better way to do this ?
124124

imagetool/src/main/java/com/oracle/weblogic/imagetool/impl/InstallerFile.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ public InstallerFile(CachePolicy cachePolicy, InstallerType type, String version
3232
@Override
3333
public String resolve(CacheStore cacheStore) throws Exception {
3434
// check entry exists in cache
35-
logger.finest("InstallerFile resolve " + getKey());
36-
String filePath = cacheStore.getValueFromCache(getKey());
35+
String key = getKey();
36+
logger.entering(key);
37+
String filePath = cacheStore.getValueFromCache(key);
3738
if (!isFileOnDisk(filePath)) {
38-
throw new Exception("Please download the installer manually and put it in the cache " + getKey());
39+
throw new Exception("Please download the installer manually and put it in the cache " + key);
3940
}
40-
logger.finest("InstallerFile resolve " + filePath);
41+
logger.exiting(filePath);
4142

4243
return filePath;
4344
}

imagetool/src/main/java/com/oracle/weblogic/imagetool/impl/PatchFile.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public PatchFile(CachePolicy cachePolicy, String category, String version, Strin
4343
public String resolve(CacheStore cacheStore) throws Exception {
4444
//patchId is null in case of latestPSU
4545

46-
logger.entering();
46+
logger.entering(patchId);
4747
String filePath = cacheStore.getValueFromCache(getKey());
4848
boolean fileExists = isFileOnDisk(filePath);
4949

@@ -53,13 +53,15 @@ public String resolve(CacheStore cacheStore) throws Exception {
5353
logger.fine("Could not find patch in cache category={0} version={1} patchId={2}",
5454
category, version, patchId);
5555

56-
if (userId == null || password == null)
56+
if (userId == null || password == null) {
5757
throw new Exception(String.format(
58-
"Patch %s is not in the cache store and you have not provide Oracle Support "
59-
+ "credentials in the command line. Please provide --user with one of the password "
60-
+ "option or "
61-
+ "populate the cache store manually",
62-
patchId));
58+
"Patch %s is not in the cache store and you have not provide Oracle Support "
59+
+ "credentials in the command line. Please provide --user with one of the password "
60+
+ "option or "
61+
+ "populate the cache store manually",
62+
patchId));
63+
}
64+
logger.info("IMG-0018", patchId);
6365
filePath = downloadPatch(cacheStore);
6466
}
6567

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/ARUUtil.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static String getLatestPSUNumber(WLSInstallerType category, String versio
4343
logger.entering(category, version, userId);
4444
try {
4545
String releaseNumber = getReleaseNumber(category, version, userId, password);
46-
SearchResult searchResult = getAllPSU(category, releaseNumber, userId, password);
46+
SearchResult searchResult = getRecommendedPsuMetadata(category, releaseNumber, userId, password);
4747
if (searchResult.isSuccess()) {
4848
Document results = searchResult.getResults();
4949
String result = XPathUtil.applyXPathReturnString(results, "/results/patch[1]/name");
@@ -143,14 +143,14 @@ public static ValidationResult validatePatches(String inventoryContent, List<Str
143143
for (String patch : patches) {
144144

145145
if (patch == null) {
146-
logger.finest("Skipping null patch");
146+
logger.finer("Skipping null patch");
147147
continue;
148148
}
149149
checkForMultiplePatches(patch, userId, password);
150-
logger.info("Passed patch multiple versions test");
150+
logger.fine("IMG-0021");
151151

152152
String bugReleaseNumber = ARUUtil.getPatchInfo(patch, userId, password);
153-
logger.info(String.format("Patch %s release %s found ", patch, bugReleaseNumber));
153+
logger.info("IMG-0022", patch, bugReleaseNumber);
154154
int ind = patch.indexOf('_');
155155
String baseBugNumber = patch;
156156
if (ind > 0) {
@@ -265,18 +265,18 @@ private static Document getAllReleases(WLSInstallerType category, String userId,
265265
}
266266
}
267267

268-
private static SearchResult getAllPSU(WLSInstallerType category, String release, String userId, String password)
269-
throws IOException {
270-
271-
String url;
272-
273-
if (WLSInstallerType.WLS == category)
274-
url = String.format(Constants.LATEST_PSU_URL, Constants.WLS_PROD_ID, release);
275-
else
276-
url = String.format(Constants.LATEST_PSU_URL, Constants.FMW_PROD_ID, release);
268+
private static SearchResult getRecommendedPsuMetadata(WLSInstallerType category, String release, String userId,
269+
String password) throws IOException {
277270

278-
return getSearchResult(HttpUtil.getXMLContent(url, userId, password));
271+
logger.entering();
272+
String productId = WLSInstallerType.WLS == category ? Constants.WLS_PROD_ID : Constants.FMW_PROD_ID;
273+
String url = String.format(Constants.RECOMMENDED_PATCHES_URL, productId, release)
274+
+ Constants.ONLY_GET_RECOMMENDED_PSU;
275+
logger.finer("getting PSU info from {0}", url);
279276

277+
SearchResult result = getSearchResult(HttpUtil.getXMLContent(url, userId, password));
278+
logger.exiting();
279+
return result;
280280
}
281281

282282
private static String getPatch(String bugNumber, String userId, String password, String destDir)
@@ -404,7 +404,7 @@ private static String savePatch(Document allPatches, String userId, String passw
404404
private static String getPatchInfo(String bugNumber, String userId, String password)
405405
throws
406406
IOException {
407-
logger.finest("Entering getPatchInfo " + bugNumber);
407+
logger.entering(bugNumber);
408408

409409
try {
410410
int ind = bugNumber.indexOf('_');
@@ -425,7 +425,7 @@ private static String getPatchInfo(String bugNumber, String userId, String passw
425425

426426
logger.finest("applying xpath: " + xpath);
427427
String releaseNumber = XPathUtil.applyXPathReturnString(allPatches, xpath);
428-
logger.finest(String.format("Exiting getPatchInfo %s = %s ", bugNumber, releaseNumber));
428+
logger.exiting(releaseNumber);
429429
if (releaseNumber == null || "".equals(releaseNumber)) {
430430
String error = String.format("Patch id %s not found", bugNumber);
431431
logger.severe(error);
@@ -457,7 +457,7 @@ private static String getReleaseNumber(WLSInstallerType category, String version
457457
String key = category + CacheStore.CACHE_KEY_SEPARATOR + version;
458458
String retVal = releaseNumbersMap.getOrDefault(key, null);
459459
if (Utils.isEmptyString(retVal)) {
460-
logger.info("IMG-0011");
460+
logger.fine("Retrieving product release numbers from Oracle...");
461461
Document allReleases = getAllReleases(category, userId, password);
462462

463463
String expression = String.format("string(/results/release[@name = '%s']/@id)", version);

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public final class Constants {
1414
static final String REL_URL = "https://updates.oracle.com/Orion/Services/metadata?table=aru_releases";
1515
static final String LATEST_PSU_URL =
1616
"https://updates.oracle.com/Orion/Services/search?product=%s&release=%s";
17+
static final String RECOMMENDED_PATCHES_URL = "https://updates.oracle.com//Orion/Services/search?patch_type=all&life_cycle=Recommended&product=%s&release=%s";
18+
static final String ONLY_GET_RECOMMENDED_PSU = "&description=WLS%20PATCH%20SET%20UPDATE";
1719
static final String ARU_LANG_URL = "https://updates.oracle.com/Orion/Services/metadata?table=aru_languages";
1820
static final String PATCH_SEARCH_URL = "https://updates.oracle"
1921
+ ".com/Orion/Services/search?product=%s&bug=%s&release=%s";

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/HttpUtil.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class HttpUtil {
4242
private static final LoggingFacade logger = LoggingFactory.getLogger(HttpUtil.class);
4343

4444
private static Document parseXmlString(String xmlString) throws ClientProtocolException {
45-
logger.entering(xmlString);
45+
logger.entering();
4646

4747
try {
4848
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -107,10 +107,11 @@ private static HttpClient getOraClient(String userId, String password) {
107107
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(
108108
userId, password));
109109
}
110+
HttpClient result = HttpClientBuilder.create().setDefaultRequestConfig(config.build())
111+
.setDefaultCookieStore(cookieStore).useSystemProperties()
112+
.setDefaultCredentialsProvider(credentialsProvider).build();
110113
logger.exiting();
111-
return HttpClientBuilder.create().setDefaultRequestConfig(config.build())
112-
.setDefaultCookieStore(cookieStore).useSystemProperties()
113-
.setDefaultCredentialsProvider(credentialsProvider).build();
114+
return result;
114115
}
115116

116117
/**
@@ -133,7 +134,7 @@ public static void downloadFile(String url, String fileName, String username, St
133134
} catch (Exception ex) {
134135
String message = String.format("Failed to download and save file %s from %s: %s", fileName, url,
135136
ex.getLocalizedMessage());
136-
logger.info(message);
137+
logger.severe(message);
137138
throw new IOException(message, ex);
138139
}
139140
logger.exiting(fileName);

imagetool/src/main/java/com/oracle/weblogic/imagetool/util/Utils.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ public static void runDockerCommand(List<String> cmdBuilder, Path dockerLog)
203203
}
204204

205205
ProcessBuilder processBuilder = new ProcessBuilder(cmdBuilder);
206-
logger.finest("Starting docker process...");
206+
logger.finer("Starting docker process...");
207207
final Process process = processBuilder.start();
208-
logger.finest("Docker process started");
208+
logger.finer("Docker process started");
209209
writeFromInputToOutputStreams(process.getInputStream(), outputStreams.toArray(new OutputStream[0]));
210-
logger.finest("Waiting for Docker to finish");
210+
logger.finer("Waiting for Docker to finish");
211211
if (process.waitFor() != 0) {
212212
processError(process);
213213
}
@@ -488,7 +488,7 @@ public static List<String> getDockerRunCmd(String hostDirToMount, String dockerI
488488
byte[] fileBytes = Files.readAllBytes(Paths.get(hostDirToMount + File.separator + scriptToRun));
489489
String encodedFile = Base64.getEncoder().encodeToString(fileBytes);
490490
String oneCommand = String.format("echo %s | base64 -d | /bin/bash", encodedFile);
491-
logger.finest("ONE COMMAND [" + oneCommand + "]");
491+
logger.finer("ONE COMMAND [" + oneCommand + "]");
492492
final List<String> retVal = Stream.of(
493493
"docker", "run",
494494
dockerImage, "/bin/bash", "-c", oneCommand).collect(Collectors.toList());
@@ -644,7 +644,7 @@ public static String getOpatchVersionFromZip(String fileName) {
644644
}
645645
} catch (IOException ioe) {
646646
logger.warning("Cannot read opatch file " + fileName);
647-
logger.finest(ioe.getLocalizedMessage());
647+
logger.finer(ioe.getLocalizedMessage());
648648
}
649649
return null;
650650
}
@@ -666,11 +666,10 @@ public static boolean validatePatchIds(List<String> patches, boolean rigid) {
666666
}
667667
if (patches != null && !patches.isEmpty()) {
668668
for (String patchId : patches) {
669-
logger.finest("pattern match id " + patchId);
669+
logger.finer("pattern match id " + patchId);
670670
Matcher matcher = patchIdPattern.matcher(patchId);
671671
if (!matcher.matches()) {
672672
String errorFormat;
673-
String error;
674673
if (rigid) {
675674
errorFormat = "12345678_12.2.1.3.0";
676675
} else {
@@ -702,7 +701,7 @@ public static void setOracleHome(String installerResponse, DockerfileOptions opt
702701
Path installerResponseFile = Paths.get(installerResponse);
703702
Pattern pattern = Pattern.compile("^\\s*ORACLE_HOME=(.*)?");
704703
Matcher matcher = pattern.matcher("");
705-
logger.finest("Reading installer response file: {0}", installerResponseFile.getFileName());
704+
logger.finer("Reading installer response file: {0}", installerResponseFile.getFileName());
706705

707706
try {
708707
BufferedReader reader = new BufferedReader(new FileReader(installerResponseFile.toFile()));

imagetool/src/main/resources/ImageTool.properties

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ IMG-0002=User specified fromImage {0}
44
IMG-0003=Temporary directory used for docker build context: {0}
55
IMG-0004=Invalid patch id {0}. The patch id must be in the format of {1}. Where the first part is the 8 digit patch ID, and the second half, after the underscore, is the release version for the patch. The release version needs to be specified with 5 places such as 12.2.1.3.0 or 12.2.1.3.190416. Release version is required when adding a patch to the cache or when multiple versions of the same patch number exist for different versions.
66
IMG-0005=Installer response file: {0}
7-
IMG-0006=patch conflict check successful
7+
IMG-0006=No patch conflicts detected
88
IMG-0007=WDT Download link = {0}
99
IMG-0008=OPatch patch number {0} cached file {1} version {2}
1010
IMG-0009=skipping patch conflict check, no support credentials provided
1111
IMG-0010=Oracle Home will be set to {0}
12-
IMG-0011=Retrieving latest release information from Oracle
12+
IMG-0011=XXXX NOT USED
1313
IMG-0012=Validating patches
1414
IMG-0013=Error parsing additional build commands file {0}
1515
IMG-0014=Additional build command section, {0}, was not one of the valid sections: {1}
1616
IMG-0015=Additional build commands, adding {0} lines to section [{1}]
1717
IMG-0016=Image Tool build ID: {0}
1818
IMG-0017=Using {0} patch {1} from cache: {2}
19+
IMG-0018=Downloading patch {0}...
20+
IMG-0019=Finding patch number for latest PSU...
21+
IMG-0020=Latest PSU patch number is {0}
22+
IMG-0021=Passed patch multiple versions test
23+
IMG-0022=Patch {0} found for release {1}

0 commit comments

Comments
 (0)