Skip to content

addressing WDT-709, WDT-710, and a ServerTemplate issue introduced by PR #1345 #1348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 81 additions & 22 deletions core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ public class WLSDeployArchive {
// Deprecated top-level archive subdirectory where the opss wallet is stored.
public static final String OLD_ARCHIVE_OPSS_WALLET_PATH = "opsswallet";

/**
* The archive subdirectory name where all database wallets are stored.
*/
public static final String DB_WALLETS_DIR_NAME = "dbWallets";

/**
* The archive subdirectory name used by default for the database wallet for the RCU database.
*/
public static final String DEFAULT_RCU_WALLET_NAME = "rcu";

/**
* Top-level archive subdirectory where all database wallets are stored in subdirectories.
*/
public static final String ARCHIVE_DB_WALLETS_DIR =
String.format("%s/%s/", WLSDPLY_ARCHIVE_BINARY_DIR, DB_WALLETS_DIR_NAME);

/**
* Default, top-level archive subdirectory where the database wallet for the RCU database is stored.
*/
public static final String DEFAULT_RCU_WALLET_PATH = ARCHIVE_DB_WALLETS_DIR + DEFAULT_RCU_WALLET_NAME;

/**
* Top-level archive subdirectory where the atp wallet is stored.
*/
Expand Down Expand Up @@ -514,6 +535,14 @@ public String addApplication(String appPath) throws WLSDeployArchiveIOException
return newName;
}

/**
* Replace an existing application in the archive file.
*
* @param appPath the path within the archive of the app to remove
* @param tempFile the file system location of the new app to replace the existing one
* @return the archive path of the new application
* @throws WLSDeployArchiveIOException if an IOException occurred while reading or writing changes
*/
public String replaceApplication(String appPath, String tempFile) throws WLSDeployArchiveIOException {
final String METHOD = "replaceApplication";
LOGGER.entering(CLASS, METHOD, appPath);
Expand Down Expand Up @@ -567,33 +596,29 @@ public List<String> listApplications() throws WLSDeployArchiveIOException {
}

/**
* Extract the ATP wallet in the archive.
* Extract the named database wallet.
*
* @param domainHome the domain home directory
* @param walletName the name of the database wallet to extract (e.g., rcu)
* @return the full path to the directory containing the extracted wallet files or null, if no wallet was found.
* @throws WLSDeployArchiveIOException if an error occurs while reading or extracting the archive files.
*/
public String extractATPWallet(File domainHome) throws WLSDeployArchiveIOException {
final String METHOD = "extractATPWallet";
public String extractDatabaseWallet(File domainHome, String walletName) throws WLSDeployArchiveIOException {
final String METHOD = "extractDatabaseWallet";

LOGGER.entering(CLASS, METHOD, domainHome);
validateExistingDirectory(domainHome, "domainHome", getArchiveFileName(), METHOD);
LOGGER.entering(CLASS, METHOD, domainHome, walletName);

// Look in the updated location first
String extractPath = null;
List<String> zipEntries = getZipFile().listZipEntries(ARCHIVE_ATP_WALLET_PATH + ZIP_SEP);
zipEntries.remove(ARCHIVE_ATP_WALLET_PATH + ZIP_SEP);
if (!zipEntries.isEmpty()) {
extractPath = ARCHIVE_ATP_WALLET_PATH + ZIP_SEP;
extractWallet(domainHome, extractPath, zipEntries, null);
extractPath = new File(domainHome, extractPath).getAbsolutePath();
if (DEFAULT_RCU_WALLET_NAME.equals(walletName)) {
// handle archive files with deprecated path, as needed
extractPath = extractRCUWallet(domainHome);
} else {
// Look in the deprecated location.
zipEntries = getZipFile().listZipEntries(OLD_ARCHIVE_ATP_WALLET_PATH + ZIP_SEP);
zipEntries.remove(OLD_ARCHIVE_ATP_WALLET_PATH + ZIP_SEP);
validateExistingDirectory(domainHome, "domainHome", getArchiveFileName(), METHOD);
List<String> zipEntries = getZipFile().listZipEntries(ARCHIVE_DB_WALLETS_DIR + walletName + ZIP_SEP);
zipEntries.remove(ARCHIVE_DB_WALLETS_DIR + walletName + ZIP_SEP);
if (!zipEntries.isEmpty()) {
extractPath = ARCHIVE_ATP_WALLET_PATH + ZIP_SEP;
extractWallet(domainHome, extractPath, zipEntries, "WLSDPLY-01427");
extractPath = ARCHIVE_DB_WALLETS_DIR + walletName + ZIP_SEP;
extractWallet(domainHome, extractPath, zipEntries, null, null, null);
extractPath = new File(domainHome, extractPath).getAbsolutePath();
}
}
Expand Down Expand Up @@ -621,15 +646,15 @@ public String extractOPSSWallet(File domainHome) throws WLSDeployArchiveIOExcept
zipEntries.remove(ARCHIVE_OPSS_WALLET_PATH + ZIP_SEP);
if (!zipEntries.isEmpty()) {
extractPath = ARCHIVE_OPSS_WALLET_PATH + ZIP_SEP;
extractWallet(domainHome, extractPath, zipEntries, null);
extractWallet(domainHome, extractPath, zipEntries, null, null, null);
extractPath = new File(domainHome, extractPath).getAbsolutePath();
} else {
// Look in the deprecated location.
zipEntries = getZipFile().listZipEntries(OLD_ARCHIVE_OPSS_WALLET_PATH + ZIP_SEP);
zipEntries.remove(OLD_ARCHIVE_OPSS_WALLET_PATH + ZIP_SEP);
if (!zipEntries.isEmpty()) {
extractPath = OLD_ARCHIVE_OPSS_WALLET_PATH + ZIP_SEP;
extractWallet(domainHome, extractPath, zipEntries, "WLSDPLY-01433");
extractWallet(domainHome, extractPath, zipEntries, "WLSDPLY-01433",null, null);
extractPath = new File(domainHome, extractPath).getAbsolutePath();
}
}
Expand Down Expand Up @@ -1556,8 +1581,8 @@ protected String addUrlToZip(String zipPathPrefix, URL url, String extension, bo
return newName;
}

protected void extractWallet(File domainHome, String extractPath, List<String> zipEntries, String deprecationKey)
throws WLSDeployArchiveIOException {
protected void extractWallet(File domainHome, String extractPath, List<String> zipEntries, String deprecationKey,
String fromDir, String toDir) throws WLSDeployArchiveIOException {
final String METHOD = "extractWallet";
LOGGER.entering(CLASS, METHOD, domainHome, extractPath, zipEntries, deprecationKey);

Expand Down Expand Up @@ -1586,7 +1611,11 @@ protected void extractWallet(File domainHome, String extractPath, List<String> z
extractToLocation = new File(domainHome, WLSDPLY_ARCHIVE_BINARY_DIR);
LOGGER.warning(deprecationKey, getArchiveFileName(), zipEntry, extractPath);
}
extractFileFromZip(zipEntry, extractToLocation);
if (StringUtils.isEmpty(fromDir) && StringUtils.isEmpty(toDir)) {
extractFileFromZip(zipEntry, extractToLocation);
} else {
extractFileFromZip(zipEntry, fromDir, toDir, extractToLocation);
}
}
}
}
Expand Down Expand Up @@ -1765,6 +1794,36 @@ protected void extractFileFromZip(String itemToExtract, String fromDir, String t
LOGGER.exiting(CLASS, METHOD);
}

protected String extractRCUWallet(File domainHome) throws WLSDeployArchiveIOException {
final String METHOD = "extractRCUWallet";

LOGGER.entering(CLASS, METHOD, domainHome);
validateExistingDirectory(domainHome, "domainHome", getArchiveFileName(), METHOD);

// Look in the updated location first
String extractPath = null;
List<String> zipEntries = getZipFile().listZipEntries(DEFAULT_RCU_WALLET_PATH + ZIP_SEP);
zipEntries.remove(DEFAULT_RCU_WALLET_PATH + ZIP_SEP);
if (!zipEntries.isEmpty()) {
extractPath = DEFAULT_RCU_WALLET_PATH + ZIP_SEP;
extractWallet(domainHome, extractPath, zipEntries, null, null, null);
extractPath = new File(domainHome, extractPath).getAbsolutePath();
} else {
// Look in the deprecated location.
zipEntries = getZipFile().listZipEntries(OLD_ARCHIVE_ATP_WALLET_PATH + ZIP_SEP);
zipEntries.remove(OLD_ARCHIVE_ATP_WALLET_PATH + ZIP_SEP);
if (!zipEntries.isEmpty()) {
extractPath = DEFAULT_RCU_WALLET_PATH + ZIP_SEP;
extractWallet(domainHome, extractPath, zipEntries, "WLSDPLY-01427",
OLD_ARCHIVE_ATP_WALLET_PATH, DB_WALLETS_DIR_NAME + ZIP_SEP + DEFAULT_RCU_WALLET_NAME);
extractPath = new File(domainHome, extractPath).getAbsolutePath();
}
}

LOGGER.exiting(CLASS, METHOD, extractPath);
return extractPath;
}

///////////////////////////////////////////////////////////////////////////
// Private Helper methods used by the protected methods above... //
///////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/python/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def _validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin
# 2. If it is plain old regular oracle db, do nothing
# 3. If it deos not have tns_admin in the model, then the wallet must be in the archive
if not has_tns_admin:
wallet_path = archive_helper.extract_atp_wallet()
wallet_path = archive_helper.extract_database_wallet()
if wallet_path:
# update the model to add the tns_admin
model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
Expand Down Expand Up @@ -323,7 +323,7 @@ def main(model_context):
# check if there is an atpwallet and extract in the domain dir
# it is to support non JRF domain but user wants to use ATP database
if has_atp and archive_helper:
archive_helper.extract_atp_wallet()
archive_helper.extract_database_wallet()

creator = DomainCreator(model_dictionary, model_context, aliases)
creator.create()
Expand Down
37 changes: 25 additions & 12 deletions core/src/main/python/wlsdeploy/tool/util/archive_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,23 +349,30 @@ def get_archive_entries(self):
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=all_entries)
return all_entries

def extract_atp_wallet(self):
def extract_database_wallet(self, wallet_name=WLSDeployArchive.DEFAULT_RCU_WALLET_NAME):
"""
Extract the and unzip the ATP wallet, if present, and return the path to the wallet directory.
Extract the and unzip the named database wallet, if present, and return the path to
the wallet directory.
:return: the path to the extracted wallet, or None if no wallet was found
:raises: BundleAwareException of the appropriate type: if an error occurs
"""
_method_name = 'extract_atp_wallet'
_method_name = 'extract_database_wallet'
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)

wallet_path = None
resulting_wallet_path = None
for archive_file in self.__archive_files[::-1]:
wallet_path = archive_file.extractATPWallet(self.__domain_home)
wallet_path = archive_file.extractDatabaseWallet(self.__domain_home, wallet_name)
# Allow iteration to continue through all archive files but
# make sure to store off the path for a wallet that was extracted.
#
if wallet_path is not None:
break
# If multiple archives contain the same named wallet, they
# will all have the same path.
#
resulting_wallet_path = wallet_path

self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=wallet_path)
return wallet_path
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=resulting_wallet_path)
return resulting_wallet_path

def extract_opss_wallet(self):
"""
Expand All @@ -376,14 +383,20 @@ def extract_opss_wallet(self):
_method_name = 'extract_opss_wallet'
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)

wallet_path = None
resulting_wallet_path = None
for archive_file in self.__archive_files[::-1]:
wallet_path = archive_file.extractOPSSWallet(self.__domain_home)
# Allow iteration to continue through all archive files but
# make sure to store off the path for a wallet that was extracted.
#
if wallet_path is not None:
break
# If multiple archives contain the same named wallet, they
# will all have the same path.
#
resulting_wallet_path = wallet_path

self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=wallet_path)
return wallet_path
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=resulting_wallet_path)
return resulting_wallet_path

def get_manifest(self, source_path):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@
],
"CleanupOrphanedSessionsEnabled": [ {"version": "[12.2.1.4,)", "wlst_mode": "both", "wlst_name": "CleanupOrphanedSessionsEnabled", "wlst_path": "WP001", "default_value": "false", "wlst_type": "boolean" } ],
"ClientCertProxyEnabled": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "ClientCertProxyEnabled", "wlst_path": "WP001", "default_value": "false", "wlst_type": "boolean" } ],
"Cluster": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "Cluster", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "get_method": "LSA", "set_method": "${MBEAN.set_server_cluster_mbean:MBEAN.set_cluster_mbean}", "set_mbean_type": "${:weblogic.management.configuration.ClusterMBean}" } ],
"Cluster": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "Cluster", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "get_method": "LSA", "set_method": "${:MBEAN.set_cluster_mbean}", "set_mbean_type": "${:weblogic.management.configuration.ClusterMBean}" } ],
"ClusterWeight": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "ClusterWeight", "wlst_path": "WP001", "default_value": 100, "wlst_type": "integer" } ],
"CoherenceClusterSystemResource": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "CoherenceClusterSystemResource", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "get_method": "LSA", "set_method": "${:MBEAN.set_coherence_cluster_mbean}", "set_mbean_type": "${:weblogic.management.configuration.CoherenceClusterSystemResourceMBean}" } ],
"CompleteCOMMessageTimeout": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "CompleteCOMMessageTimeout", "wlst_path": "WP001", "default_value": -1, "wlst_type": "integer" } ],
Expand Down
Loading