Skip to content

Extract files from user custom folder in archive #969

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
Aug 20, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public class WLSDeployArchive {
*/
public static final String ARCHIVE_CPLIB_TARGET_DIR = WLSDPLY_ARCHIVE_BINARY_DIR + "/classpathLibraries";

/**
* Top-level archive subdirectory where the classpath JARs/directories are stored and the
* subdirectory to which they will be extracted.
*/
public static final String ARCHIVE_CUSTOM_TARGET_DIR = WLSDPLY_ARCHIVE_BINARY_DIR + "/custom";
/**
* Top-level archive subdirectory where the $DOMAIN_HOME/bin scripts are stored.
*/
Expand Down Expand Up @@ -907,6 +912,40 @@ public void extractClasspathLibraries(File domainHome) throws WLSDeployArchiveIO
LOGGER.exiting(CLASS, METHOD);
}

/**
* Get the list of user custom file names in the archive.
*
* @return the list of $DOMAIN_HOME/wlsdeploy/custom library names
* @throws WLSDeployArchiveIOException if an error occurs reading the archive
*/
public List<String> listCustomFiles() throws WLSDeployArchiveIOException {
final String METHOD = "listCustomFiles";

LOGGER.entering(CLASS, METHOD);
List<String> result = getZipFile().listZipEntries(ARCHIVE_CUSTOM_TARGET_DIR + ZIP_SEP);
// Remove the top-level directory entry from the list...
result.remove(ARCHIVE_CUSTOM_TARGET_DIR + ZIP_SEP);
LOGGER.exiting(CLASS, METHOD, result);
return result;
}

/**
* Extract the user custom files in the archive to the specified domain home directory.
*
* @param domainHome the domain home directory
* @throws WLSDeployArchiveIOException in an error occurs reading the archive or writing the files.
* @throws IllegalArgumentException if the domain home directory is not a valid, existing directory
*/
public void extractCustomFiles(File domainHome) throws WLSDeployArchiveIOException {
final String METHOD = "extractCustomFiles";

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

extractDirectoryFromZip(ARCHIVE_CUSTOM_TARGET_DIR, domainHome);
LOGGER.exiting(CLASS, METHOD);
}

/**
* Adds an application's deployment plan file to the archive.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ def __create_domain(self):

self.library_helper.install_domain_libraries()
self.library_helper.extract_classpath_libraries()

self.library_helper.install_domain_scripts()
self.wlsroles_helper.process_roles()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def update(self):

self.library_helper.install_domain_libraries()
self.library_helper.extract_classpath_libraries()
self.library_helper.extract_custom_files()
self.library_helper.install_domain_scripts()

def update_machines_clusters_and_servers(self, delete_now=True):
Expand Down
27 changes: 27 additions & 0 deletions core/src/main/python/wlsdeploy/tool/util/archive_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,33 @@ def extract_classpath_libraries(self):
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=count)
return count

def extract_custom_archive(self):
"""
Extract all of the custom files in the archive to the $DOMAIN_HOME/wlsdeploy/custom
directory.
:return: the number of files extracted
:raises: BundleAwareException of the appropriate type: if an error occurs
"""
_method_name = 'extract_custom_archive'
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)

count = 0
for archive_file in self.__archive_files:
try:
cp_libs = archive_file.listCustomFiles()
if cp_libs.size() > 0:
archive_file.extractCustomFiles(self.__domain_home)
count += cp_libs.size()
except (WLSDeployArchiveIOException, IllegalArgumentException), e:
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19310',
self.__archive_files_text, self.__domain_home.getAbsolutePath(),
e.getLocalizedMessage(), error=e)
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
raise ex

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

def extract_domain_bin_script(self, script_path):
"""
Extract the specified domain bin script to the $DOMAIN_HOME/bin directory.
Expand Down
21 changes: 21 additions & 0 deletions core/src/main/python/wlsdeploy/tool/util/library_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@ def extract_classpath_libraries(self):
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
return

def extract_custom_files(self):
"""
Extract any custom files in the archive to the domain home.
:raises: BundleAwareException of the specified type: if an error occurs
"""
_method_name = 'extract_custom_files'

self.logger.entering(self.domain_home, class_name=self.__class_name, method_name=_method_name)
if self.archive_helper is None:
self.logger.info('WLSDPLY-12565', class_name=self.__class_name, method_name=_method_name)
else:
num_cp_libs = self.archive_helper.extract_custom_archive()
if num_cp_libs > 0:
self.logger.info('WLSDPLY-12566', num_cp_libs, self.domain_home,
class_name=self.__class_name, method_name=_method_name)
else:
self.logger.info('WLSDPLY-12567', self.model_context.get_archive_file_name(),
class_name=self.__class_name, method_name=_method_name)
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
return

def install_domain_scripts(self):
"""
Extract the scripts from domain bin listed in the model, if any, to the <DOMAIN_HOME>/bin directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,9 @@ WLSDPLY-12563=Unable to retrieve database connection info, please make sure the
RCUDbInfo.tns.alias exists in the tnsnames.ora file in the ATP wallet.
WLSDPLY-12564=Unable to retrieve database connection string, please make sure it is specified in \
RCUDbInfo.rcu_db_conn_string field or in command line argument '-rcu_database'.

WLSDPLY-12565=The archive file was not provided so there are no custom files to extract
WLSDPLY-12566=Installing {0} user custom files to domain home {1}
WLSDPLY-12567=The archive file {0} contains no user custom files to install

# domain_typedef.py
WLSDPLY-12300={0} got the domain type {1} but the domain type definition file {2} was not valid: {3}
Expand Down Expand Up @@ -1489,6 +1491,7 @@ WLSDPLY-19306=Unable to extract domain library {0} from archive file {1}: {2}
WLSDPLY-19307=Unable to extract classpath libraries from archive file {0} to domain directory {1}: {2}
WLSDPLY-19308=Failed to extract script to domain bin {0} because it does not exist in archive file {1}
WLSDPLY-19309=Unable to extract from domain bin {0} from archive file {1}: {2}
WLSDPLY-19310=Unable to extract user custom files from archive file {0} to domain directory {1}: {2}

# wlsdeploy/tool/util/topology_helper.py
WLSDPLY-19400=Creating placeholder for server template {0}
Expand Down