Skip to content

Commit 5c50ae7

Browse files
authored
Merge pull request #221 from oracle/Issue#168-Arrays-needed-to-version-folders
Issue#168 arrays needed to version folders
2 parents 1927a87 + 2516653 commit 5c50ae7

File tree

10 files changed

+302
-49
lines changed

10 files changed

+302
-49
lines changed

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

+21-1
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
package oracle.weblogic.deploy.util;
@@ -52,6 +52,26 @@ public static InputStream getResourceAsStream(String fileName) {
5252
return FileUtils.class.getClassLoader().getResourceAsStream(fileName);
5353
}
5454

55+
/**
56+
* Get the specified file as an InputStream. This method will first
57+
* resolve the name to an absolute path and then get the InputStream
58+
*
59+
* @param fileName of the file to get
60+
* @return the InputStream, or null if it was not found.
61+
*
62+
* @param fileName
63+
* @return
64+
* @throws IOException
65+
*/
66+
public static InputStream getFileAsStream(String fileName) throws IOException {
67+
File file = validateExistingFile(fileName);
68+
InputStream inputStream = null;
69+
if (file != null) {
70+
inputStream = new FileInputStream(getCanonicalFile(file));
71+
}
72+
return inputStream;
73+
}
74+
5575
/**
5676
* Convert a file path into one that Jython will handle.
5777
*

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

+2-1
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
These constants are internal to the aliases module and should not be used, as they are not part of the public API.
@@ -14,6 +14,7 @@
1414
DEFAULT_NAME_VALUE = 'default_name_value'
1515
FLATTENED_FOLDER_DATA = 'flattened_folder_data'
1616
FOLDERS = 'folders'
17+
FOLDER_PARAMS = 'folder_params'
1718
GET_MBEAN_TYPE = 'get_mbean_type'
1819
GET_METHOD = 'get_method'
1920
MERGE = 'merge'

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

+101-39
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 copy
@@ -26,6 +26,7 @@
2626
from wlsdeploy.aliases.alias_constants import CONTAINS
2727
from wlsdeploy.aliases.alias_constants import DEFAULT_NAME_VALUE
2828
from wlsdeploy.aliases.alias_constants import FLATTENED_FOLDER_DATA
29+
from wlsdeploy.aliases.alias_constants import FOLDER_PARAMS
2930
from wlsdeploy.aliases.alias_constants import FOLDERS
3031
from wlsdeploy.aliases.alias_constants import GET_MBEAN_TYPE
3132
from wlsdeploy.aliases.alias_constants import GET_METHOD
@@ -590,7 +591,7 @@ def get_name_token_for_location(self, location):
590591
path = location.get_folder_path()
591592

592593
err_location = LocationContext(location)
593-
if not err_location.is_empty():
594+
if not err_location.is_empty():
594595
folder_name = err_location.pop_location()
595596
code, message = self.is_valid_model_folder_name_for_location(err_location, folder_name)
596597
if code == ValidationCodes.VERSION_INVALID:
@@ -790,7 +791,7 @@ def is_valid_model_folder_name_for_location(self, location, model_folder_name):
790791
folder_dict = self.__get_dictionary_for_location(sub_location, False)
791792
if folder_dict is None:
792793
if UNRESOLVED_FOLDERS_MAP in self._category_dict and \
793-
model_folder_name in self._category_dict[UNRESOLVED_FOLDERS_MAP]:
794+
model_folder_name in self._category_dict[UNRESOLVED_FOLDERS_MAP]:
794795
result = ValidationCodes.VERSION_INVALID
795796
valid_version_range = self._category_dict[UNRESOLVED_FOLDERS_MAP][model_folder_name]
796797
else:
@@ -1091,42 +1092,8 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
10911092
#
10921093
# First, determine if this dictionary is even relevant to the current WLS version.
10931094
#
1094-
if VERSION in alias_dict:
1095-
dict_version_range = alias_dict[VERSION]
1096-
try:
1097-
_logger.finer('WLSDPLY-08123', path_name, dict_version_range,
1098-
self._wls_helper.get_actual_weblogic_version(),
1099-
class_name=_class_name, method_name=_method_name)
1100-
if not self.__version_in_range(dict_version_range):
1101-
_logger.finer('WLSDPLY-08124', path_name, dict_version_range,
1102-
self._wls_helper.get_actual_weblogic_version(),
1103-
class_name=_class_name, method_name=_method_name)
1104-
if UNRESOLVED_FOLDERS_MAP not in parent_dict:
1105-
parent_dict[UNRESOLVED_FOLDERS_MAP] = dict()
1106-
alias_dict_folder_name = alias_utils.compute_folder_name_from_path(path_name)
1107-
parent_dict[UNRESOLVED_FOLDERS_MAP][alias_dict_folder_name] = dict_version_range
1108-
return None
1109-
else:
1110-
_logger.finer('WLSDPLY-08125', path_name, dict_version_range,
1111-
self._wls_helper.get_actual_weblogic_version(),
1112-
class_name=_class_name, method_name=_method_name)
1113-
except VersionException, ve:
1114-
ex = exception_helper.create_alias_exception('WLSDPLY-08126', path_name, dict_version_range,
1115-
ve.getLocalizedMessage(), error=ve)
1116-
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
1117-
raise ex
1118-
1119-
if WLST_MODE in alias_dict:
1120-
dict_wlst_mode = alias_dict[WLST_MODE]
1121-
mode = WlstModes.from_value(self._wlst_mode)
1122-
if not self.__wlst_mode_matches(dict_wlst_mode):
1123-
_logger.finer('WLSDPLY-08132', path_name, dict_wlst_mode, mode, class_name=_class_name,
1124-
method_name=_method_name)
1125-
if UNRESOLVED_FOLDERS_MAP not in parent_dict:
1126-
parent_dict[UNRESOLVED_FOLDERS_MAP] = dict()
1127-
alias_dict_folder_name = alias_utils.compute_folder_name_from_path(path_name)
1128-
parent_dict[UNRESOLVED_FOLDERS_MAP][alias_dict_folder_name] = mode
1129-
return None
1095+
if not self.__use_alias_dict(path_name, alias_dict, parent_dict):
1096+
return None
11301097

11311098
result = dict()
11321099
if FOLDERS in alias_dict:
@@ -1227,6 +1194,94 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
12271194

12281195
return result
12291196

1197+
def __is_version(self, path_name, alias_dict):
1198+
_method_name = '__is_version'
1199+
is_version = True
1200+
dict_version_range = alias_utils.get_dictionary_version(alias_dict)
1201+
if dict_version_range:
1202+
try:
1203+
_logger.finer('WLSDPLY-08123', path_name, dict_version_range,
1204+
self._wls_helper.get_actual_weblogic_version(),
1205+
class_name=_class_name, method_name=_method_name)
1206+
is_version = self.__version_in_range(dict_version_range)
1207+
1208+
except VersionException, ve:
1209+
ex = exception_helper.create_alias_exception('WLSDPLY-08126', path_name, dict_version_range,
1210+
ve.getLocalizedMessage(), error=ve)
1211+
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
1212+
raise ex
1213+
else:
1214+
dict_version_range = 'All'
1215+
1216+
if is_version:
1217+
_logger.finer('WLSDPLY-08125', path_name, dict_version_range,
1218+
self._wls_helper.get_actual_weblogic_version(),
1219+
class_name=_class_name, method_name=_method_name)
1220+
1221+
return is_version
1222+
1223+
def __is_wlst_mode(self, path_name, alias_dict):
1224+
_method_name = '__is_wlst_mode'
1225+
is_mode = True
1226+
mode = WlstModes.from_value(self._wlst_mode)
1227+
dict_wlst_mode = alias_utils.get_dictionary_mode(alias_dict)
1228+
if dict_wlst_mode:
1229+
if not self.__wlst_mode_matches(dict_wlst_mode):
1230+
_logger.finer('WLSDPLY-08132', path_name, dict_wlst_mode, mode, class_name=_class_name,
1231+
method_name=_method_name)
1232+
is_mode = False
1233+
else:
1234+
dict_wlst_mode = 'Both'
1235+
1236+
if is_mode:
1237+
_logger.finer('WLSDPLY-08133', path_name, dict_wlst_mode, class_name=_class_name,
1238+
method_name=_method_name)
1239+
return is_mode
1240+
1241+
def __test_dictionary(self, path_name, alias_dict):
1242+
return self.__is_version(path_name, alias_dict) and self.__is_wlst_mode(path_name, alias_dict)
1243+
1244+
def __use_alias_dict(self, path_name, alias_dict, parent_dict):
1245+
self.__resolve_folder_params(path_name, alias_dict)
1246+
if not self.__is_version(path_name, alias_dict):
1247+
_add_to_unresolved_folders(path_name, parent_dict, alias_utils.get_dictionary_version(alias_dict))
1248+
return False
1249+
if not self.__is_wlst_mode(path_name, alias_dict):
1250+
_add_to_unresolved_folders(path_name, parent_dict, alias_utils.get_dictionary_version(alias_dict))
1251+
return False
1252+
1253+
return True
1254+
1255+
def __resolve_folder_params(self, path_name, alias_dict):
1256+
"""
1257+
The folder params has a two-fold purpose. To identify valid version / wlst mode
1258+
combinations (all version / wlst mode combinations must be represented). And to
1259+
contain folder parameters that are different depending on the combination. Once
1260+
a folder parameter version has been selected, then all the folder parameters in the
1261+
valid entry are added to the alias_dict dictionary parameters.
1262+
:param alias_dict:
1263+
:return:
1264+
"""
1265+
_method_name = '__resolve_folder_params'
1266+
if FOLDER_PARAMS in alias_dict:
1267+
folder_params = alias_dict[FOLDER_PARAMS]
1268+
1269+
if not isinstance(folder_params, list):
1270+
ex = exception_helper.create_alias_exception('WLSDPLY-08134', path_name, class_name=_class_name,
1271+
method_name=_method_name)
1272+
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
1273+
raise ex
1274+
1275+
if folder_params:
1276+
add_entry = folder_params[0]
1277+
for folder_set in folder_params:
1278+
if self.__test_dictionary(path_name, folder_set):
1279+
_logger.finer('WLSDPLY-08135', path_name, class_name=_class_name, method_name=_method_name)
1280+
add_entry = folder_set
1281+
break
1282+
for key, value in add_entry.iteritems():
1283+
alias_dict[key] = value
1284+
12301285
def __resolve_attribute_by_wlst_context(self, path_name, attr_name, attrs_dict):
12311286
"""
12321287
Find the attribute list element that applies to the current WLS version and WLST mode.
@@ -1436,3 +1491,10 @@ def __get_path_for_location(self, location, path_type=WLST_ATTRIBUTES_PATH):
14361491

14371492
_logger.exiting(class_name=_class_name, method_name=_method_name, result=tokenized_path)
14381493
return tokenized_path
1494+
1495+
1496+
def _add_to_unresolved_folders(path_name, parent_dict, unresolved):
1497+
if UNRESOLVED_FOLDERS_MAP not in parent_dict:
1498+
parent_dict[UNRESOLVED_FOLDERS_MAP] = dict()
1499+
alias_dict_folder_name = alias_utils.compute_folder_name_from_path(path_name)
1500+
parent_dict[UNRESOLVED_FOLDERS_MAP][alias_dict_folder_name] = unresolved

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

+26-3
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 copy
@@ -31,21 +31,21 @@
3131
from wlsdeploy.aliases.alias_constants import ATTRIBUTES
3232
from wlsdeploy.aliases.alias_constants import COMMA_DELIMITED_STRING
3333
from wlsdeploy.aliases.alias_constants import DELIMITED_STRING
34-
from wlsdeploy.aliases.alias_constants import DICTIONARY
3534
from wlsdeploy.aliases.alias_constants import JARRAY
3635
from wlsdeploy.aliases.alias_constants import JAVA_LANG_BOOLEAN
3736
from wlsdeploy.aliases.alias_constants import LIST
3837
from wlsdeploy.aliases.alias_constants import LONG
3938
from wlsdeploy.aliases.alias_constants import PATH_SEPARATOR_DELIMITED_STRING
40-
from wlsdeploy.aliases.alias_constants import PROPERTIES
4139
from wlsdeploy.aliases.alias_constants import PREFERRED_MODEL_TYPE
4240
from wlsdeploy.aliases.alias_constants import SECURITY_PROVIDER_FOLDER_PATHS
4341
from wlsdeploy.aliases.alias_constants import SECURITY_PROVIDER_MBEAN_NAME_MAP
4442
from wlsdeploy.aliases.alias_constants import SEMI_COLON_DELIMITED_STRING
4543
from wlsdeploy.aliases.alias_constants import SPACE_DELIMITED_STRING
44+
from wlsdeploy.aliases.alias_constants import VERSION
4645
from wlsdeploy.aliases.alias_constants import WLST_ATTRIBUTES_PATH
4746
from wlsdeploy.aliases.alias_constants import WLST_CREATE_PATH
4847
from wlsdeploy.aliases.alias_constants import WLST_LIST_PATH
48+
from wlsdeploy.aliases.alias_constants import WLST_MODE
4949
from wlsdeploy.aliases.alias_constants import WLST_PATH
5050
from wlsdeploy.aliases.alias_constants import WLST_PATHS
5151
from wlsdeploy.aliases.alias_constants import WLST_READ_TYPE
@@ -806,6 +806,29 @@ def get_security_provider_model_folder_name(mbean_name):
806806
return result
807807

808808

809+
def get_dictionary_version(alias_dict):
810+
"""
811+
Return the version in the alias dictionary, if present. Not present
812+
means all versions. The alias dictionary can represent a folder or an attribute.
813+
:param alias_dict: in which to find the version
814+
:return: alias_dict VERSION or None if not present
815+
"""
816+
if VERSION in alias_dict:
817+
return alias_dict[VERSION]
818+
return None
819+
820+
821+
def get_dictionary_mode(alias_dict):
822+
"""
823+
Return the wlst mode in the alias dictionary, if present. Not present means both offline
824+
and online. The alias dictionary can represent a folder or an attribute.
825+
:param alias_dict: in which to find the wlst mode
826+
:return: alias_dict mode or None if not present
827+
"""
828+
if WLST_MODE in alias_dict:
829+
return alias_dict[WLST_MODE]
830+
return None
831+
809832
###############################################################################
810833
# Private functions #
811834
###############################################################################

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

+2-1
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

@@ -190,6 +190,7 @@
190190
SAF_ERROR_HANDLING = 'SAFErrorHandling'
191191
SAF_IMPORTED_DESTINATION = 'SAFImportedDestinations'
192192
SAF_LOGIN_CONTEXT = 'SAFLoginContext'
193+
SAF_MESSAGE_LOG_FILE = 'JmssafMessageLogFile'
193194
SAF_QUEUE = 'SAFQueue'
194195
SAF_REMOTE_CONTEXT = 'SAFRemoteContext'
195196
SAF_TOPIC = 'SAFTopic'

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
{
2-
"copyright": "Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.",
2+
"copyright": "Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.",
33
"license": "The Universal Permissive License (UPL), Version 1.0",
44
"wlst_type": "SAFAgent${:s}",
55
"child_folders_type": "multiple",
66
"folders": {
77
"JmssafMessageLogFile": {
8+
"folder_params": [{
9+
"version": "[10,12.2.1)",
10+
"wlst_mode": "online"
11+
}, {
12+
"version": "[12.2.1,)"
13+
}],
814
"folders": {},
915
"attributes": {
1016
"BufferSizeKb": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "BufferSize${Kb:KB}", "wlst_path": "WP001", "value": {"default": 8 }, "wlst_type": "integer" } ],

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

+8
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ WLSDPLY-06142=The online attribute {0} is in the lsa() list but is a folder not
464464
WLSDPLY-06143=Attribute {0} at location {1} is not writable and is deprecated
465465
WLSDPLY-06144=Folder {0} at location {1} is not an online folder. Removing from online subfolder list
466466
WLSDPLY-06145=Subfolder list {0} at location {1} does not match the mbi containment folder list {2}
467+
WLSDPLY-06146=Discovered WLST MBean names {0} at location {1}
468+
WLSDPLY-06147=Call method {0} to get the value for wlst attribute {1} at wlst path {2}
467469

468470
# resources_discoverer.py
469471
WLSDPLY-06300=Discovering domain model resources
@@ -710,6 +712,10 @@ WLSDPLY-08130=Unable to compute the name token for folder {0} because the folder
710712
WLSDPLY-08131=Unable to compute the name token for folder {0} because the folder is not valid in \
711713
WebLogic Server version {1}
712714
WLSDPLY-08132=Folder {0} present only for {1} mode is not relevant for WLST in {2} mode
715+
WLSDPLY-08133=Folder {0} present for {1} mode is relevant in WebLogic Server version {2}
716+
WLSDPLY-08134=Folder parameters for Folder {0} are invalid and cannot be processed
717+
WLSDPLY-08135=Found a valid parameters for Folder {0} in the array of folder parameters
718+
713719
#
714720
# Empty slots to fill up...
715721
#
@@ -1082,6 +1088,8 @@ WLSDPLY-19030=Failed to get the model attribute list that use path tokens for mo
10821088
WLSDPLY-19031=Failed to determine if the model attribute name {0} at location ({1}) is valid: {2}
10831089
WLSDPLY-19032=Failed to get the default value for model attribute {0} at location ({1}): {2}
10841090
WLSDPLY-19033=Failed to determine if location ({0}) is version valid, or not
1091+
WLSDPLY-19034=Failed to get the model attribute list that require a special processing via a method for model \
1092+
folder ({0}) at location ({1}): {2}
10851093

10861094
# wlsdeploy/tool/util/wlst_helper.py
10871095
WLSDPLY-19100=Failed to change to the WLST directory {0}: {1}

0 commit comments

Comments
 (0)