Skip to content

Commit 645d8d3

Browse files
correcting wallet handling across multiple archives to process the wallets in the right order (#1411)
* correcting wallet handling across multiple archives to process the wallets in the right order * enhancing error handling
1 parent 82cdf34 commit 645d8d3

File tree

4 files changed

+70
-15
lines changed

4 files changed

+70
-15
lines changed

core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
import java.net.URL;
1414
import java.nio.file.Files;
1515
import java.security.NoSuchAlgorithmException;
16+
import java.util.ArrayList;
17+
import java.util.HashSet;
1618
import java.util.List;
1719
import java.util.ListIterator;
1820
import java.util.Map;
21+
import java.util.Set;
1922
import java.util.jar.JarFile;
2023
import java.util.jar.Manifest;
2124
import java.util.zip.ZipEntry;
@@ -3698,6 +3701,48 @@ public int removeFileStoreDirectory(String fileStoreName, boolean silent)
36983701
// database wallet methods //
36993702
///////////////////////////////////////////////////////////////////////////////////////////////
37003703

3704+
/**
3705+
* Get the list of database wallet names from the archive.
3706+
*
3707+
* @return the list of wallet names
3708+
* @throws WLSDeployArchiveIOException if an IOException occurred while reading the archive
3709+
*/
3710+
public List<String> getDatabaseWalletNames() throws WLSDeployArchiveIOException {
3711+
final String METHOD = "getDatabaseWalletNames";
3712+
LOGGER.entering(CLASS, METHOD);
3713+
3714+
// This is ugly because of the deprecated atpwallet location.
3715+
Set<String> results = new HashSet<>();
3716+
List<String> zipEntries = getZipFile().listZipEntries();
3717+
int prefixLength = ARCHIVE_DB_WALLETS_DIR.length() + 1;
3718+
for (String zipEntry : zipEntries) {
3719+
if (zipEntry.startsWith(OLD_ARCHIVE_ATP_WALLET_PATH)) {
3720+
LOGGER.finer("Adding deprecated atpwallet as {0}",DEFAULT_RCU_WALLET_NAME);
3721+
results.add(DEFAULT_RCU_WALLET_NAME);
3722+
} else if (zipEntry.startsWith(ARCHIVE_DB_WALLETS_DIR)) {
3723+
// skip over the wlsdeploy/dbWallets/ entry
3724+
if (zipEntry.length() <= prefixLength) {
3725+
continue;
3726+
}
3727+
3728+
int walletNameDirectorySeparatorIndex = zipEntry.indexOf(ZIP_SEP, prefixLength);
3729+
if (walletNameDirectorySeparatorIndex == -1) {
3730+
WLSDeployArchiveIOException ex = new WLSDeployArchiveIOException("WLSDPLY-01460",
3731+
getArchiveFileName(), zipEntry);
3732+
LOGGER.throwing(CLASS, METHOD, ex);
3733+
throw ex;
3734+
}
3735+
String walletName = zipEntry.substring(prefixLength, walletNameDirectorySeparatorIndex);
3736+
3737+
LOGGER.finer("Adding wallet {0}", walletName);
3738+
results.add(walletName);
3739+
}
3740+
}
3741+
3742+
LOGGER.exiting(CLASS, METHOD, results);
3743+
return new ArrayList<>(results);
3744+
}
3745+
37013746
/**
37023747
* Add a database wallet to the archive.
37033748
*

core/src/main/python/wlsdeploy/tool/util/archive_helper.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,17 @@ def extract_database_wallet(self, wallet_name=WLSDeployArchive.DEFAULT_RCU_WALLE
384384
:raises: BundleAwareException of the appropriate type: if an error occurs
385385
"""
386386
_method_name = 'extract_database_wallet'
387-
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)
387+
self.__logger.entering(wallet_name, class_name=self.__class_name, method_name=_method_name)
388388

389389
resulting_wallet_path = None
390-
for archive_file in self.__archive_files[::-1]:
390+
for archive_file in self.__archive_files:
391391
wallet_path = archive_file.extractDatabaseWallet(self.__domain_home, wallet_name)
392392
# Allow iteration to continue through all archive files but
393393
# make sure to store off the path for a wallet that was extracted.
394394
#
395+
self.__logger.finer('extract wallet {0} from archive file {1} returned wallet path {2}',
396+
wallet_name, archive_file.getArchiveFileName(), wallet_path,
397+
class_name=self.__class_name, method_name=_method_name)
395398
if wallet_path is not None:
396399
# If multiple archives contain the same named wallet, they
397400
# will all have the same path.
@@ -402,19 +405,25 @@ def extract_database_wallet(self, wallet_name=WLSDeployArchive.DEFAULT_RCU_WALLE
402405
return resulting_wallet_path
403406

404407
def extract_all_database_wallets(self):
408+
_method_name = 'extract_all_database_wallets'
409+
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)
410+
411+
# extract_database_wallet() loops through the archive files so just collect
412+
# the list of wallet names from the archive files and then loop through that list.
405413

414+
wallet_names = sets.Set()
406415
for archive_file in self.__archive_files:
407-
archive_entries = archive_file.getArchiveEntries()
408-
wallet_names = sets.Set()
409-
for entry in archive_entries:
410-
if entry.startswith(WLSDeployArchive.ARCHIVE_DB_WALLETS_DIR):
411-
if os.path.isdir(entry):
412-
wallet_names.add(os.path.basename(entry))
413-
else:
414-
name = os.path.basename(os.path.dirname(entry))
415-
wallet_names.add(name)
416-
for wallet_name in wallet_names:
417-
self.extract_database_wallet(wallet_name)
416+
self.__logger.finer('processing archive_file {0}', archive_file.getArchiveFileName(),
417+
class_name=self.__class_name, method_name=_method_name)
418+
archive_wallet_names = archive_file.getDatabaseWalletNames()
419+
wallet_names.update(archive_wallet_names)
420+
421+
for wallet_name in wallet_names:
422+
self.__logger.finer('extracting database wallet {0}', wallet_name,
423+
class_name=self.__class_name, method_name=_method_name)
424+
self.extract_database_wallet(wallet_name)
425+
426+
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)
418427

419428
def extract_opss_wallet(self):
420429
"""
@@ -426,7 +435,7 @@ def extract_opss_wallet(self):
426435
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)
427436

428437
resulting_wallet_path = None
429-
for archive_file in self.__archive_files[::-1]:
438+
for archive_file in self.__archive_files:
430439
wallet_path = archive_file.extractOPSSWallet(self.__domain_home)
431440
# Allow iteration to continue through all archive files but
432441
# make sure to store off the path for a wallet that was extracted.

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ WLSDPLY-01456=Failed to remove File Store {0} from archive file {1} because the
234234
WLSDPLY-01457=Failed to remove database wallet {0} from archive file {1} because the archive file did not contain {2}.
235235
WLSDPLY-01458=Failed to remove OPSS wallet from archive file {0} because the archive file did not contain {1}.
236236
WLSDPLY-01459=Failed to add RCU Wallet to archive because the archive file {0} already contains an RCU wallet with {1} entries.
237-
237+
WLSDPLY-01460=Failed to get the database wallet names from archive file {0} because the archive contains an invalid database wallet entry at {1}
238238

239239
# oracle.weblogic.deploy.util.WLSDeployZipFile.java
240240
WLSDPLY-01500=The zip file {0} has the saved entry {1}

documentation/3.0/content/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ None
2222
#### Bug Fixes
2323
- #1405: Corrected some issues with the Windows shell scripts where they were not properly handling paths with spaces.
2424
- #1409: Corrected a bug where a wallet deprecation message was still being logged as a warning.
25+
- #1411: Corrected a bug where wallet extraction handling with multiple archive files was happening in the wrong order.
2526

2627
#### Known Issues
2728
1. When running `discoverDomain` with the `-remote` flag, there are several MBeans that are not being properly handled that

0 commit comments

Comments
 (0)