Skip to content

Commit 32baa34

Browse files
authored
Merge pull request #301 from oracle/add-webapp-container2
Add webapp container2
2 parents 7cc7c5f + 7e6efeb commit 32baa34

File tree

7 files changed

+167
-4
lines changed

7 files changed

+167
-4
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
*/
@@ -813,6 +819,25 @@ public String addServerKeyStoreFile(String serverName, File keystoreFile) throws
813819
return newName;
814820
}
815821

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class AliasEntries(object):
112112
'UnixMachine': 'UnixMachine',
113113
'VirtualHost': 'VirtualHost',
114114
'VirtualTarget': 'VirtualTarget',
115+
'WebAppContainer': 'WebAppContainer',
115116
'WLDFSystemResource': 'WLDFSystemResource',
116117
'WSReliableDeliveryPolicy': 'WSReliableDeliveryPolicy',
117118
'XMLEntityCache': 'XMLEntityCache',
@@ -161,6 +162,7 @@ class AliasEntries(object):
161162
'SelfTuning',
162163
'ShutdownClass',
163164
'StartupClass',
165+
'WebAppContainer',
164166
'WLDFSystemResource'
165167
]
166168

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@
250250
VIRTUAL_USER_AUTHENTICATOR = 'VirtualUserAuthenticator'
251251
WATCH = 'Watch'
252252
WATCH_NOTIFICATION = 'WatchNotification'
253+
WEBAPP_CONTAINER = 'WebAppContainer'
253254
WEB_SERVER = 'WebServer'
254255
WEB_SERVER_LOG = 'WebServerLog'
255256
WEB_SERVICE = 'WebService'
@@ -303,6 +304,7 @@
303304
INSTALL_DIR = 'InstallDir'
304305
LISTEN_ADDRESS = 'ListenAddress'
305306
LISTEN_PORT = 'ListenPort'
307+
MIME_MAPPING_FILE = 'MimeMappingFile'
306308
NAME = 'Name'
307309
NOTIFICATION = 'Notification'
308310
PASSWORD = 'Password'

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55

@@ -15,11 +15,12 @@
1515
from wlsdeploy.aliases.model_constants import SAF_AGENT
1616
from wlsdeploy.aliases.model_constants import SELF_TUNING
1717
from wlsdeploy.aliases.model_constants import WORK_MANAGER
18+
from wlsdeploy.aliases.model_constants import WEBAPP_CONTAINER
19+
from wlsdeploy.aliases.model_constants import MIME_MAPPING_FILE
1820
from wlsdeploy.aliases.wlst_modes import WlstModes
1921
from wlsdeploy.tool.deploy.deployer import Deployer
2022
from wlsdeploy.util import dictionary_utils
2123

22-
2324
class CommonResourcesDeployer(Deployer):
2425
"""
2526
class docstring
@@ -166,3 +167,20 @@ def add_coherence_clusters(self, parent_dict, location):
166167
"""
167168
file_stores = dictionary_utils.get_dictionary_element(parent_dict, COHERENCE_CLUSTER_SYSTEM_RESOURCE)
168169
self._add_named_elements(COHERENCE_CLUSTER_SYSTEM_RESOURCE, file_stores, location)
170+
171+
def add_webapp_container(self, parent_dict, location):
172+
"""
173+
Deploy the web-app-container in the dictionary at the specified location.
174+
:param parent_dict: the dictionary possibly containing web-app-container elements
175+
:param location: the location to deploy the elements
176+
"""
177+
web_app_container = dictionary_utils.get_dictionary_element(parent_dict, WEBAPP_CONTAINER)
178+
if len(web_app_container) != 0:
179+
self._add_model_elements(WEBAPP_CONTAINER, web_app_container, location)
180+
if self.archive_helper is not None:
181+
if MIME_MAPPING_FILE in web_app_container:
182+
file_path = web_app_container[MIME_MAPPING_FILE]
183+
if self.archive_helper.contains_file(file_path):
184+
self.archive_helper.extract_file(file_path)
185+
186+
return

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import wlsdeploy.util.dictionary_utils as dictionary_utils
@@ -71,6 +71,7 @@ def _add_resources(self, location):
7171
wldf_deployer.add_wldf_modules(self._resources, location)
7272

7373
common_deployer.add_coherence_clusters(self._resources, location)
74+
common_deployer.add_webapp_container(self._resources, location)
7475
return
7576

7677
def _add_startup_classes(self, location):

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, 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
@@ -45,6 +47,8 @@ def discover(self):
4547
discoverer.add_to_model_if_not_empty(self._dictionary, model_top_folder_name, startups)
4648
model_top_folder_name, shutdowns = self.get_shutdown_classes()
4749
discoverer.add_to_model_if_not_empty(self._dictionary, model_top_folder_name, shutdowns)
50+
model_top_folder_name, shutdowns = self.get_webapp_container()
51+
discoverer.add_to_model_if_not_empty(self._dictionary, model_top_folder_name, shutdowns)
4852

4953
_logger.exiting(class_name=_class_name, method_name=_method_name)
5054
return self._dictionary
@@ -127,3 +131,49 @@ def get_shutdown_classes(self):
127131

128132
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
129133
return model_top_folder_name, result
134+
135+
def get_webapp_container(self):
136+
"""
137+
Discover the WebAppContainer global resource settings
138+
:return: model name for the folder: dictionary containing the discovered WebAppContainer
139+
"""
140+
_method_name = '_get_webapp_container'
141+
_logger.entering(class_name=_class_name, method_name=_method_name)
142+
model_top_folder_name = model_constants.WEBAPP_CONTAINER
143+
result = OrderedDict()
144+
location = LocationContext(self._base_location)
145+
location.append_location(model_top_folder_name)
146+
webapp_container = self._find_singleton_name_in_folder(location)
147+
if webapp_container is not None:
148+
_logger.info('WLSDPLY-06615', class_name=_class_name, method_name=_method_name)
149+
location.add_name_token(self._alias_helper.get_name_token(location), webapp_container)
150+
self._populate_model_parameters(result, location)
151+
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
155+
156+
_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
157+
return model_top_folder_name, result
158+
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+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"copyright": "Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.",
3+
"license": "The Universal Permissive License (UPL), Version 1.0",
4+
"wlst_type": "WebAppContainer",
5+
"child_folders_type": "single_unpredictable",
6+
"default_name_value": "${NO_NAME_0:%DOMAIN%}",
7+
"folders": {
8+
"GzipCompression" : {
9+
"wlst_type": "GzipCompression",
10+
"version": "[12.2.1.3,)",
11+
"child_folders_type": "single_unpredictable",
12+
"default_name_value": "${NO_NAME_0:%DOMAIN%}",
13+
"folders": {},
14+
"attributes": {
15+
"DynamicallyCreated": [ {"version": "[12.2.1.3,)", "wlst_mode": "both", "wlst_name": "DynamicallyCreated", "wlst_path": "WP002", "value": {"default": false }, "wlst_type": "boolean" } ],
16+
"GzipCompressionContentType": [ {"version": "[12.2.1.3,)", "wlst_mode": "both", "wlst_name": "GzipCompressionContentType", "wlst_path": "WP002", "value": {"default": "None" }, "wlst_type": "${list:jarray}", "wlst_read_type": "delimited_string[semicolon]", "get_method": "${LSA:GET}", "preferred_model_type": "list" } ],
17+
"GzipCompressionEnabled": [ {"version": "[12.2.1.3,)", "wlst_mode": "both", "wlst_name": "GzipCompressionEnabled", "wlst_path": "WP002", "value": {"default": false }, "wlst_type": "boolean" } ],
18+
"GzipCompressionMinContentLength": [ {"version": "[12.2.1.3,)", "wlst_mode": "both", "wlst_name": "GzipCompressionMinContentLength", "wlst_path": "WP002", "value": {"default": 2048 }, "wlst_type": "integer" } ],
19+
"Notes": [ {"version": "[12.2.1.3,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP002", "value": {"default": "None" }, "wlst_type": "string" } ]
20+
},
21+
"wlst_attributes_path": "WP002",
22+
"wlst_paths": {
23+
"WP002": "/WebAppContainer/%WEBAPPCONTAINER%/GzipCompression/%GZIPCOMPRESSION%"
24+
}
25+
26+
27+
}
28+
},
29+
"attributes": {
30+
"AllowAllRoles": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AllowAllRoles", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
31+
"AuthCookieEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AuthCookieEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
32+
"ChangeSessionIDOnAuthentication": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ChangeSessionIDOnAuthentication", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
33+
"ClientCertProxyEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ClientCertProxyEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
34+
"DynamicallyCreated": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DynamicallyCreated", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
35+
"FilterDispatchedRequestsEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FilterDispatchedRequestsEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
36+
"HttpTraceSupportEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "HttpTraceSupportEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
37+
"JSPCompilerBackwardsCompatible": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "JSPCompilerBackwardsCompatible", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
38+
"JaxRsMonitoringDefaultBehavior": [ {"version": "[12.2,)", "wlst_mode": "both", "wlst_name": "JaxRsMonitoringDefaultBehavior", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
39+
"MaxPostSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "MaxPostSize", "wlst_path": "WP001", "value": {"default": -1 }, "wlst_type": "integer" } ],
40+
"MaxPostTimeSecs": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "MaxPostTimeSecs", "wlst_path": "WP001", "value": {"default": -1 }, "wlst_type": "integer" } ],
41+
"MaxRequestParamterCount": [ {"version": "[10]", "wlst_mode": "both", "wlst_name": "MaxRequestParamterCount", "wlst_path": "WP001", "value": {"default": 10000 }, "wlst_type": "integer" } ],
42+
"MaxRequestParameterCount": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "MaxRequestParameterCount", "wlst_path": "WP001", "value": {"default": 10000 }, "wlst_type": "integer" } ],
43+
"MimeMappingFile": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "MimeMappingFile", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
44+
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
45+
"OptimisticSerialization": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "OptimisticSerialization", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
46+
"OverloadProtectionEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "OverloadProtectionEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
47+
"P3PHeaderValue": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "P3PHeaderValue", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
48+
"PostTimeoutSecs": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "PostTimeoutSecs", "wlst_path": "WP001", "value": {"default": 30 }, "wlst_type": "integer" } ],
49+
"ReloginEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ReloginEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
50+
"RetainOriginalURL": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RetainOriginalURL", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
51+
"RtexprvalueJspParamName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RtexprvalueJspParamName", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
52+
"ServletAuthenticationFormURL": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServletAuthenticationFormURL", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
53+
"ServletReloadCheckSecs": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServletReloadCheckSecs", "wlst_path": "WP001", "value": {"default": -1 }, "wlst_type": "integer" } ],
54+
"ShowArchivedRealPathEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ShowArchivedRealPathEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
55+
"WAPEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "WAPEnabled", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
56+
"WeblogicPluginEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "WeblogicPluginEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
57+
"WorkContextPropagationEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "WorkContextPropagationEnabled", "wlst_path": "WP001", "value": {"default": false }, "wlst_type": "boolean" } ],
58+
"XPoweredByHeaderLevel": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "XPoweredByHeaderLevel", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ]
59+
60+
},
61+
"wlst_attributes_path": "WP001",
62+
"wlst_paths": {
63+
"WP001": "/WebAppContainer/%WEBAPPCONTAINER%"
64+
}
65+
}

0 commit comments

Comments
 (0)