Skip to content

Commit f406cb3

Browse files
Merge branch 'master' into Issue#86-discover-with-variables
2 parents 63abedd + f4e16ce commit f406cb3

File tree

12 files changed

+729
-21
lines changed

12 files changed

+729
-21
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public PyOrderedDict() {
5151
*/
5252
public PyOrderedDict(PyOrderedDict other) {
5353
this();
54+
super.update(other);
5455
update(other);
5556
}
5657

@@ -279,6 +280,9 @@ public void __setitem__(PyObject key, PyObject value) {
279280
synchronized (this.linkedHashMap) {
280281
this.linkedHashMap.put(key, value);
281282
}
283+
synchronized (super.table) {
284+
super.table.put(key, value);
285+
}
282286
}
283287

284288
/**
@@ -287,6 +291,7 @@ public void __setitem__(PyObject key, PyObject value) {
287291
@Override
288292
public void clear() {
289293
this.linkedHashMap.clear();
294+
super.table.clear();;
290295
}
291296

292297
/**
@@ -476,6 +481,7 @@ private void doUpdate(PyDictionary od) {
476481
for (int i = 0; i < pylist.size(); i++) {
477482
PyTuple tuple = (PyTuple) pylist.get(i);
478483
this.__setitem__(Py.java2py(tuple.get(0)), Py.java2py(tuple.get(1)));
484+
super.__setitem__(Py.java2py(tuple.get(0)), Py.java2py(tuple.get(1)));
479485
}
480486
}
481487

core/src/main/python/discover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __verify_required_args_present(required_arg_map):
9696

9797
for req_arg in __required_arguments:
9898
if req_arg not in required_arg_map:
99-
ex = exception_helper.create_cla_exception('WLSDPLY-09040', _program_name, req_arg)
99+
ex = exception_helper.create_cla_exception('WLSDPLY-20005', _program_name, req_arg)
100100
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
101101
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
102102
raise ex

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
import copy
66
import javaos as os
77
from sets import Set
8-
import zipfile
98

109
from java.io import File
1110
from java.io import IOException
11+
from java.io import FileNotFoundException
12+
from java.util.zip import ZipException
1213
from java.security import NoSuchAlgorithmException
14+
from java.util.jar import JarFile
15+
from java.util.jar import Manifest
16+
from java.lang import IllegalStateException
17+
from java.io import ByteArrayOutputStream
1318

1419
import oracle.weblogic.deploy.util.FileUtils as FileUtils
1520
import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict
@@ -776,9 +781,14 @@ def __get_deployable_library_versioned_name(self, source_path, model_name):
776781
old_name_tuple = deployer_utils.get_library_name_components(model_name, self.wlst_mode)
777782
try:
778783
source_path = self.model_context.replace_token_string(source_path)
779-
archive = zipfile.ZipFile(source_path)
780-
manifest = archive.read('META-INF/MANIFEST.MF')
781-
tokens = manifest.split()
784+
archive = JarFile(source_path)
785+
manifest_object = archive.getManifest()
786+
tokens = []
787+
if manifest_object is not None:
788+
bao = ByteArrayOutputStream()
789+
manifest_object.write(bao)
790+
manifest = bao.toString('UTF-8')
791+
tokens = manifest.split()
782792

783793
if 'Extension-Name:' in tokens:
784794
extension_index = tokens.index('Extension-Name:')
@@ -812,7 +822,7 @@ def __get_deployable_library_versioned_name(self, source_path, model_name):
812822
raise ex
813823
self.logger.info('WLSDPLY-09324', model_name, versioned_name,
814824
class_name=self._class_name, method_name=_method_name)
815-
except (zipfile.BadZipfile, IOError), e:
825+
except (IOException, FileNotFoundException, ZipException, IllegalStateException), e:
816826
ex = exception_helper.create_deploy_exception('WLSDPLY-09325', model_name, source_path, str(e), error=e)
817827
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
818828
raise ex

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,20 @@ def get_model_topology_top_level_folder_names(self):
522522
"""
523523
return self.__aliases.get_model_topology_top_level_folder_names()
524524

525+
def get_model_resources_top_level_folder_names(self):
526+
"""
527+
Get the model resources top-level folder names.
528+
:return: the list of top-level resources folders
529+
"""
530+
return self.__aliases.get_model_resources_top_level_folder_names()
531+
532+
def get_model_app_deployments_top_level_folder_names(self):
533+
"""
534+
Get the model app_deployments top-level folder names.
535+
:return: the list of top-level app_deployments folders
536+
"""
537+
return self.__aliases.get_model_app_deployments_top_level_folder_names()
538+
525539
def get_model_attribute_names(self, location):
526540
"""
527541
Get the model attribute names.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self, model, model_context, aliases, domain_home, exception_type, l
2626
self.alias_helper = AliasHelper(aliases, self.logger, exception_type)
2727
self.wlst_helper = WlstHelper(self.logger, exception_type)
2828

29+
self.archive_helper = None
2930
archive_file_name = self.model_context.get_archive_file_name()
3031
if archive_file_name is not None:
3132
self.archive_helper = ArchiveHelper(archive_file_name, self.domain_home, self.logger, exception_type)

core/src/main/python/wlsdeploy/tool/validate/validator.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import os
6+
import copy
67

78
from oracle.weblogic.deploy.util import WLSDeployArchive
89
from oracle.weblogic.deploy.util import VariableException
@@ -108,9 +109,15 @@ def validate_in_standalone_mode(self, model_dict, variables_file_name=None, arch
108109
"""
109110
_method_name = 'validate_in_standalone_mode'
110111

112+
# We need to make a deep copy of model_dict here, to ensure it's
113+
# treated as a "read-only'" reference variable, during the variable
114+
# file validation process. The variable file validation process could
115+
# actually require changes to be made to the cloned model dictionary
116+
cloned_model_dict = copy.deepcopy(model_dict)
117+
111118
self._logger.entering(variables_file_name, archive_file_name, class_name=_class_name, method_name=_method_name)
112119
self._validation_mode = _ValidationModes.STANDALONE
113-
self.__validate_model_file(model_dict, variables_file_name, archive_file_name)
120+
self.__validate_model_file(cloned_model_dict, variables_file_name, archive_file_name)
114121

115122
self._logger.exiting(class_name=_class_name, method_name=_method_name)
116123
return self._validation_results
@@ -137,10 +144,16 @@ def validate_in_tool_mode(self, model_dict, variables_file_name=None, archive_fi
137144
"""
138145
_method_name = 'validate_in_tool_mode'
139146

147+
# We need to make a deep copy of model_dict here, to ensure it's
148+
# treated as a "read-only'" reference variable, during the variable
149+
# file validation process. The variable file validation process could
150+
# actually require changes to be made to the cloned model dictionary
151+
cloned_model_dict = copy.deepcopy(model_dict)
152+
140153
self._logger.entering(variables_file_name, archive_file_name, class_name=_class_name, method_name=_method_name)
141154
return_code = Validator.ReturnCode.STOP
142155
self._validation_mode = _ValidationModes.TOOL
143-
self.__validate_model_file(model_dict, variables_file_name, archive_file_name)
156+
self.__validate_model_file(cloned_model_dict, variables_file_name, archive_file_name)
144157

145158
status = Validator.ValidationStatus.VALID
146159

@@ -212,8 +225,7 @@ def __validate_model_file(self, model_dict, variables_file_name, archive_file_na
212225
if variables_file_name is not None:
213226
self._logger.info('WLSDPLY-05004', variables_file_name, class_name=_class_name, method_name=_method_name)
214227
try:
215-
if self._model_context.get_variable_file():
216-
self._variable_properties = variables.load_variables(self._model_context.get_variable_file())
228+
self._variable_properties = variables.load_variables(variables_file_name)
217229
variables.substitute(model_dict, self._variable_properties)
218230
except VariableException, ve:
219231
ex = exception_helper.create_validate_exception('WLSDPLY-20004', 'validateModel',

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/Server.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
"wlst_attributes_path": "WP001",
4545
"wlst_paths": {
46-
"WP001": "/Server${:s}/%SERVER%/COM/${NO_NAME_0:%SERVER%}"
46+
"WP001": "/Server${:s}/%SERVER%/COM/%SERVER%"
4747
}
4848
},
4949
"ConfigurationProperty" : {
@@ -259,7 +259,7 @@
259259
},
260260
"wlst_attributes_path": "WP001",
261261
"wlst_paths": {
262-
"WP001": "/Server${:s}/%SERVER%/Log/${NO_NAME_0:%SERVER%}"
262+
"WP001": "/Server${:s}/%SERVER%/Log/%SERVER%"
263263
}
264264
},
265265
"NetworkAccessPoint": {
@@ -913,7 +913,7 @@
913913
},
914914
"wlst_attributes_path": "WP001",
915915
"wlst_paths": {
916-
"WP001": "/Server${:s}/%SERVER%/ServerStart/${NO_NAME_0:%SERVER%}"
916+
"WP001": "/Server${:s}/%SERVER%/ServerStart/%SERVER%"
917917
}
918918
},
919919
"SingleSignOnServices" : {
@@ -1020,7 +1020,7 @@
10201020
},
10211021
"wlst_attributes_path": "WP001",
10221022
"wlst_paths": {
1023-
"WP001": "/Server${:s}/%SERVER%/SSL/${NO_NAME_0:%SERVER%}"
1023+
"WP001": "/Server${:s}/%SERVER%/SSL/%SERVER%"
10241024
}
10251025
},
10261026
"TransactionLogJDBCStore": {
@@ -1071,6 +1071,8 @@
10711071
"folders": {
10721072
"WebServerLog": {
10731073
"wlst_type": "WebServerLog",
1074+
"child_folders_type": "single_unpredictable",
1075+
"default_name_value": "%SERVER%",
10741076
"folders": {},
10751077
"attributes": {
10761078
"BufferSizeKb": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "BufferSizeKb", "wlst_path": "WP001", "value": {"default": 8 }, "wlst_type": "integer", "get_method": "LSA"} ],
@@ -1094,7 +1096,7 @@
10941096
},
10951097
"wlst_attributes_path": "WP001",
10961098
"wlst_paths": {
1097-
"WP001": "/Server${:s}/%SERVER%/WebServer/${NO_NAME_0:%SERVER%}/WebServerLog/${NO_NAME_0:%SERVER%}"
1099+
"WP001": "/Server${:s}/%SERVER%/WebServer/%SERVER%/WebServerLog/%WEBSERVERLOG%"
10981100
}
10991101
}
11001102
},
@@ -1133,8 +1135,8 @@
11331135
},
11341136
"wlst_attributes_path": "WP001",
11351137
"wlst_paths": {
1136-
"WP001": "/Server${:s}/%SERVER%/WebServer/${NO_NAME_0:%SERVER%}",
1137-
"WP002": "/Server${:s}/%SERVER%/WebServer/${NO_NAME_0:%SERVER%}/Targets"
1138+
"WP001": "/Server${:s}/%SERVER%/WebServer/%SERVER%",
1139+
"WP002": "/Server${:s}/%SERVER%/WebServer/%SERVER%/Targets"
11381140
}
11391141
},
11401142
"WebService": {

core/src/test/python/collections_test.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,51 @@ def testCopyDeepcopyKeyOrdering(self):
151151
new_list.extend([6, 7, 8, 9, 10])
152152
self.assertEqual(len(my_list), 5, 'expected deepcopy to make a copy of my_list but it did not')
153153

154+
def testDictDictUpdate(self):
155+
dict1 = dict()
156+
dict1['entry1'] = 'you'
157+
dict2 = dict()
158+
dict2['entry2'] = 'me'
159+
print 'Before: dict() dict1=', dict1
160+
print ' dict() dict2=', dict2
161+
dict1.update(dict2)
162+
self.assertEqual('entry1' in dict1 and 'entry2' in dict1, True,
163+
"expected dict1 to contain 'entry1' and 'entry2' keys")
164+
165+
def testOrderedDictOrderedDictUpdate(self):
166+
dict1 = OrderedDict()
167+
dict1['entry1'] = 'you'
168+
dict2 = OrderedDict()
169+
dict2['entry2'] = 'me'
170+
print 'Before: OrderedDict() dict1=', dict1
171+
print ' OrderedDict() dict2=', dict2
172+
dict1.update(dict2)
173+
self.assertEqual('entry1' in dict1 and 'entry2' in dict1, True,
174+
"expected ordereddict1 to contain 'entry1' and 'entry2' keys")
175+
176+
def testOrderedDictDictUpdate(self):
177+
dict1 = OrderedDict()
178+
dict1['entry1'] = 'you'
179+
dict2 = dict()
180+
dict2['entry2'] = 'me'
181+
print 'Before: OrderedDict() dict1=', dict1
182+
print ' dict() dict2=', dict2
183+
print
184+
dict1.update(dict2)
185+
self.assertEqual('entry1' in dict1 and 'entry2' in dict1, True,
186+
"expected ordereddict1 to contain 'entry1' and 'entry2' keys")
187+
188+
def testDictOrderedDictUpdate(self):
189+
dict1 = dict()
190+
dict1['entry1'] = 'you'
191+
dict2 = OrderedDict()
192+
dict2['entry2'] = 'me'
193+
print 'Before: dict() dict1=', dict1
194+
print ' OrderedDict() dict2=', dict2
195+
print
196+
dict1.update(dict2)
197+
self.assertEqual('entry1' in dict1 and 'entry2' in dict1, True,
198+
"expected ordereddict1 to contain 'entry1' and 'entry2' keys")
199+
154200
if __name__ == '__main__':
155201
unittest.main()

0 commit comments

Comments
 (0)