Skip to content

Commit ae63b24

Browse files
committed
add logic to capture the mime mappings file
1 parent fb840e3 commit ae63b24

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public class WLSDeployArchive {
2929
public static final String WLSDPLY_ARCHIVE_BINARY_DIR = "wlsdeploy";
3030

3131

32+
/**
33+
* Top-level archive subdirectory where the config
34+
* will be extracted.
35+
*/
36+
public static final String ARCHIVE_CONFIG_TARGET_DIR = WLSDPLY_ARCHIVE_BINARY_DIR + "/config";
37+
3238
/**
3339
* Top-level archive subdirectory where the atp wallet is stored
3440
*/
@@ -817,6 +823,25 @@ public String addServerKeyStoreFile(String serverName, File keystoreFile) throws
817823
return newName;
818824
}
819825

826+
/**
827+
* Add a WebAppContainer mime mapping file to the archive.
828+
*
829+
* @param mimeMappingFile the file to add
830+
* @return the new location of the file to use in the model
831+
* @throws WLSDeployArchiveIOException if an error occurs while archiving the file
832+
* @throws IllegalArgumentException if the file does not exist or the clusterName is empty or null
833+
*/
834+
public String addMimeMappingFile(File mimeMappingFile) throws WLSDeployArchiveIOException {
835+
final String METHOD = "addMimeMappingFile";
836+
837+
LOGGER.entering(CLASS, METHOD, mimeMappingFile);
838+
839+
validateExistingFile(mimeMappingFile, "mimeMappingFile", getArchiveFileName(), METHOD);
840+
String newName = addItemToZip(ARCHIVE_CONFIG_TARGET_DIR + ZIP_SEP , mimeMappingFile);
841+
LOGGER.exiting(CLASS, METHOD, newName);
842+
return newName;
843+
}
844+
820845
/**
821846
* Add a Coherence configuration file to the archive.
822847
*

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@
304304
INSTALL_DIR = 'InstallDir'
305305
LISTEN_ADDRESS = 'ListenAddress'
306306
LISTEN_PORT = 'ListenPort'
307+
MIME_MAPPING_FILE = 'MimeMappingFile'
307308
NAME = 'Name'
308309
NOTIFICATION = 'Notification'
309310
PASSWORD = 'Password'

core/src/main/python/wlsdeploy/tool/discover/global_resources_discoverer.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
5+
import os
6+
from java.io import File
57
from oracle.weblogic.deploy.util import PyOrderedDict as OrderedDict
68

79
from wlsdeploy.aliases import model_constants
@@ -147,7 +149,31 @@ def get_webapp_container(self):
147149
location.add_name_token(self._alias_helper.get_name_token(location), webapp_container)
148150
self._populate_model_parameters(result, location)
149151
self._discover_subfolders(result, location)
152+
new_name = self._add_mimemapping_file_to_archive(result)
153+
if new_name:
154+
result[model_constants.MIME_MAPPING_FILE] = new_name
150155

151156
_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
152157
return model_top_folder_name, result
153158

159+
def _add_mimemapping_file_to_archive(self, web_app_container):
160+
_method_name = '_add_mimemapping_file_to_archive'
161+
_logger.entering(web_app_container, class_name=_class_name, method_name=_method_name)
162+
new_name = None
163+
if web_app_container:
164+
if model_constants.MIME_MAPPING_FILE in web_app_container:
165+
model_value = web_app_container[model_constants.MIME_MAPPING_FILE]
166+
file_path = self._convert_path(model_value)
167+
if os.path.exists(file_path):
168+
# There is indeed a mime properties file
169+
# we need to change the different path in the model
170+
# and add file to the archive similar to apps
171+
archive_file = self._model_context.get_archive_file()
172+
base_name = os.path.basename(file_path)
173+
new_name = archive_file.ARCHIVE_CONFIG_TARGET_DIR + '/' + base_name
174+
archive_file.addMimeMappingFile(File(file_path))
175+
176+
_logger.exiting(class_name=_class_name, method_name=_method_name, result=new_name)
177+
return new_name
178+
179+

0 commit comments

Comments
 (0)