Skip to content

Commit 18d05d9

Browse files
Extract files from user custom folder in archive (#969)
1 parent 4af893e commit 18d05d9

File tree

6 files changed

+93
-1
lines changed

6 files changed

+93
-1
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ public class WLSDeployArchive {
7575
*/
7676
public static final String ARCHIVE_CPLIB_TARGET_DIR = WLSDPLY_ARCHIVE_BINARY_DIR + "/classpathLibraries";
7777

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

915+
/**
916+
* Get the list of user custom file names in the archive.
917+
*
918+
* @return the list of $DOMAIN_HOME/wlsdeploy/custom library names
919+
* @throws WLSDeployArchiveIOException if an error occurs reading the archive
920+
*/
921+
public List<String> listCustomFiles() throws WLSDeployArchiveIOException {
922+
final String METHOD = "listCustomFiles";
923+
924+
LOGGER.entering(CLASS, METHOD);
925+
List<String> result = getZipFile().listZipEntries(ARCHIVE_CUSTOM_TARGET_DIR + ZIP_SEP);
926+
// Remove the top-level directory entry from the list...
927+
result.remove(ARCHIVE_CUSTOM_TARGET_DIR + ZIP_SEP);
928+
LOGGER.exiting(CLASS, METHOD, result);
929+
return result;
930+
}
931+
932+
/**
933+
* Extract the user custom files in the archive to the specified domain home directory.
934+
*
935+
* @param domainHome the domain home directory
936+
* @throws WLSDeployArchiveIOException in an error occurs reading the archive or writing the files.
937+
* @throws IllegalArgumentException if the domain home directory is not a valid, existing directory
938+
*/
939+
public void extractCustomFiles(File domainHome) throws WLSDeployArchiveIOException {
940+
final String METHOD = "extractCustomFiles";
941+
942+
LOGGER.entering(CLASS, METHOD, domainHome);
943+
validateExistingDirectory(domainHome, "domainHome", getArchiveFileName(), METHOD);
944+
945+
extractDirectoryFromZip(ARCHIVE_CUSTOM_TARGET_DIR, domainHome);
946+
LOGGER.exiting(CLASS, METHOD);
947+
}
948+
910949
/**
911950
* Adds an application's deployment plan file to the archive.
912951
*

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ def __create_domain(self):
378378

379379
self.library_helper.install_domain_libraries()
380380
self.library_helper.extract_classpath_libraries()
381+
381382
self.library_helper.install_domain_scripts()
382383
self.wlsroles_helper.process_roles()
383384

core/src/main/python/wlsdeploy/tool/deploy/topology_updater.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def update(self):
112112

113113
self.library_helper.install_domain_libraries()
114114
self.library_helper.extract_classpath_libraries()
115+
self.library_helper.extract_custom_files()
115116
self.library_helper.install_domain_scripts()
116117

117118
def update_machines_clusters_and_servers(self, delete_now=True):

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,33 @@ def extract_classpath_libraries(self):
306306
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=count)
307307
return count
308308

309+
def extract_custom_archive(self):
310+
"""
311+
Extract all of the custom files in the archive to the $DOMAIN_HOME/wlsdeploy/custom
312+
directory.
313+
:return: the number of files extracted
314+
:raises: BundleAwareException of the appropriate type: if an error occurs
315+
"""
316+
_method_name = 'extract_custom_archive'
317+
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)
318+
319+
count = 0
320+
for archive_file in self.__archive_files:
321+
try:
322+
cp_libs = archive_file.listCustomFiles()
323+
if cp_libs.size() > 0:
324+
archive_file.extractCustomFiles(self.__domain_home)
325+
count += cp_libs.size()
326+
except (WLSDeployArchiveIOException, IllegalArgumentException), e:
327+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19310',
328+
self.__archive_files_text, self.__domain_home.getAbsolutePath(),
329+
e.getLocalizedMessage(), error=e)
330+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
331+
raise ex
332+
333+
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=count)
334+
return count
335+
309336
def extract_domain_bin_script(self, script_path):
310337
"""
311338
Extract the specified domain bin script to the $DOMAIN_HOME/bin directory.

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,27 @@ def extract_classpath_libraries(self):
8686
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
8787
return
8888

89+
def extract_custom_files(self):
90+
"""
91+
Extract any custom files in the archive to the domain home.
92+
:raises: BundleAwareException of the specified type: if an error occurs
93+
"""
94+
_method_name = 'extract_custom_files'
95+
96+
self.logger.entering(self.domain_home, class_name=self.__class_name, method_name=_method_name)
97+
if self.archive_helper is None:
98+
self.logger.info('WLSDPLY-12565', class_name=self.__class_name, method_name=_method_name)
99+
else:
100+
num_cp_libs = self.archive_helper.extract_custom_archive()
101+
if num_cp_libs > 0:
102+
self.logger.info('WLSDPLY-12566', num_cp_libs, self.domain_home,
103+
class_name=self.__class_name, method_name=_method_name)
104+
else:
105+
self.logger.info('WLSDPLY-12567', self.model_context.get_archive_file_name(),
106+
class_name=self.__class_name, method_name=_method_name)
107+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
108+
return
109+
89110
def install_domain_scripts(self):
90111
"""
91112
Extract the scripts from domain bin listed in the model, if any, to the <DOMAIN_HOME>/bin directory.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,9 @@ WLSDPLY-12563=Unable to retrieve database connection info, please make sure the
13221322
RCUDbInfo.tns.alias exists in the tnsnames.ora file in the ATP wallet.
13231323
WLSDPLY-12564=Unable to retrieve database connection string, please make sure it is specified in \
13241324
RCUDbInfo.rcu_db_conn_string field or in command line argument '-rcu_database'.
1325-
1325+
WLSDPLY-12565=The archive file was not provided so there are no custom files to extract
1326+
WLSDPLY-12566=Installing {0} user custom files to domain home {1}
1327+
WLSDPLY-12567=The archive file {0} contains no user custom files to install
13261328

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

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

0 commit comments

Comments
 (0)