Skip to content

Commit 85b54f7

Browse files
committed
refactor "opatch" into Constants and correct documentation of addPatch in quickstart
1 parent 6f870e0 commit 85b54f7

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/cache/AddPatchEntry.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ private CommandResponse validateAndAddToCache(String patchNumber, String passwor
109109
*/
110110
private CommandResponse addToCache(String patchNumber) {
111111
String key = AbstractFile.generateKey(patchNumber, version);
112+
113+
// Check if it is an Opatch patch
114+
String opatchNumber = Utils.getOpatchVersionFromZip(location.toAbsolutePath().toString());
115+
if (opatchNumber != null) {
116+
int lastSeparator = key.lastIndexOf(CacheStore.CACHE_KEY_SEPARATOR);
117+
key = key.substring(0,lastSeparator) + CacheStore.CACHE_KEY_SEPARATOR + Constants.OPATCH_PATCH_TYPE;
118+
}
112119
cacheStore.addToCache(key, location.toAbsolutePath().toString());
113120
String msg = String.format("Added Patch entry %s=%s for %s", key, location.toAbsolutePath(), type);
114121
logger.info(msg);

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/cache/DeleteEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public DeleteEntry(boolean isCLIMode) {
3131
public CommandResponse call() {
3232
if (!Utils.isEmptyString(key)) {
3333
if (Constants.CACHE_DIR_KEY.equals(key.toLowerCase())) {
34-
return new CommandResponse(-1, "Error: Cannot delete cache.dir entry. Use setCacheDir instead");
34+
return new CommandResponse(0, "Cannot delete key: " + key);
3535
} else if (Constants.DELETE_ALL_FOR_SURE.equalsIgnoreCase(key)) {
3636
Map<String, String> allEntries = cacheStore.getCacheItems();
3737
//allEntries.remove(CACHE_DIR_KEY);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,12 @@ void handleProxyUrls() throws IOException {
175175

176176
void addOPatch1394ToImage(Path tmpDir, String opatchBugNumber) throws Exception {
177177
// opatch patch now is in the format #####_opatch in the cache store
178-
//
178+
// So the version passing to the constructor of PatchFile is also "opatch".
179+
// since opatch releases is on it's own and there is not really a patch to opatch
180+
// and the version is embedded in the zip file version.txt
179181

180182
String filePath =
181-
new PatchFile(useCache, "opatch", "opatch", opatchBugNumber, userId, password).resolve(cacheStore);
183+
new PatchFile(useCache, Constants.OPATCH_PATCH_TYPE, Constants.OPATCH_PATCH_TYPE, opatchBugNumber, userId, password).resolve(cacheStore);
182184
Files.copy(Paths.get(filePath), Paths.get(tmpDir.toAbsolutePath().toString(), new File(filePath).getName()));
183185
filterStartTags.add("OPATCH_1394");
184186
if (this instanceof CreateImage) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private static Document getAllReleases(String category, String userId, String pa
356356

357357
if ("wls".equalsIgnoreCase(category)) {
358358
expression = "/results/release[starts-with(text(), 'Oracle WebLogic Server')]";
359-
} else if ("opatch".equalsIgnoreCase(category)) {
359+
} else if (Constants.OPATCH_PATCH_TYPE.equalsIgnoreCase(category)) {
360360
expression = "/results/release[starts-with(text(), 'OPatch')]";
361361
} else {
362362
expression = "/results/release[starts-with(text(), 'Fusion Middleware Upgrade')]";
@@ -417,13 +417,13 @@ private static String getPatch(String category, String version, String bugNumber
417417
IOException {
418418

419419
String releaseNumber = "";
420-
if (!category.equals("opatch")) {
420+
if (!category.equals(Constants.OPATCH_PATCH_TYPE)) {
421421
releaseNumber = getReleaseNumber(category, version, userId, password);
422422
}
423423
String url;
424424
if ("wls".equalsIgnoreCase(category)) {
425425
url = String.format(Constants.PATCH_SEARCH_URL, Constants.WLS_PROD_ID, bugNumber, releaseNumber);
426-
} else if ("opatch".equalsIgnoreCase(category)) {
426+
} else if (Constants.OPATCH_PATCH_TYPE.equalsIgnoreCase(category)) {
427427
url = String.format(Constants.OPATCH_BUG_URL, bugNumber);
428428
} else {
429429
url = String.format(Constants.PATCH_SEARCH_URL, Constants.FMW_PROD_ID, bugNumber, releaseNumber);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public final class Constants {
2424
static final String WLS_PROD_ID = "15991";
2525
static final String FMW_PROD_ID = "27638";
2626
static final String OPATCH_PROD_ID = "31944";
27+
public static final String OPATCH_PATCH_TYPE = "opatch";
2728
public static final String CACHE_DIR_KEY = "cache.dir";
2829
public static final String DEFAULT_WLS_VERSION = "12.2.1.3.0";
2930
public static final String DEFAULT_JDK_VERSION = "8u202";

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ public static String getOpatchVersionFromZip(String fileName) {
626626
}
627627
}
628628
} catch (IOException ioe) {
629-
ioe.printStackTrace();
629+
logger.warning("Cannot read opatch file " + fileName);
630+
logger.finest(ioe.getLocalizedMessage());
630631
}
631632
return null;
632633
}

site/quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ For each WebLogic patch, you will need to download it from Oracle Support and se
151151
27342434 for WebLogic version 12.2.1.3.0:
152152

153153
```bash
154-
imagetool cache addPatch --patchId 27342434 --version 12.2.1.3.0 --path /home/acmeuser/cache/p27342434_122130_Generic .zip -user [email protected] --passwordEnv MYPWD
154+
imagetool cache addPatch --patchId p27342434 --version 12.2.1.3.0 --path /home/acmeuser/cache/p27342434_122130_Generic .zip -user [email protected] --passwordEnv MYPWD
155155
```
156156

157157
You need to provide the credentials in the command line. It verifies the MD5 on the file system against the meta data
@@ -168,7 +168,7 @@ downloading the latest OPatch patch and setup the cache. For example, the lates
168168
.4.0.0. You can use this command to set up the cache after downloading from Oracle Support.
169169

170170
```bash
171-
imagetool cache addPatch --patchId 28186730 --version 13.9.4.0.0 --path /home/acmeuser/cache/p28186730_139400_Generic.zip
171+
imagetool cache addPatch --patchId p28186730 --version 13.9.4.0.0 --path /home/acmeuser/cache/p28186730_139400_Generic.zip
172172
```
173173

174174
## Patching an existing image

0 commit comments

Comments
 (0)