1
1
"""
2
- Copyright (c) 2017, 2019 , Oracle Corporation and/or its affiliates. All rights reserved.
2
+ Copyright (c) 2017, 2020 , Oracle Corporation and/or its affiliates. All rights reserved.
3
3
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
4
"""
5
5
import os
@@ -23,6 +23,7 @@ class ModelContext(object):
23
23
__ORACLE_HOME_TOKEN = '@@ORACLE_HOME@@'
24
24
__WL_HOME_TOKEN = '@@WL_HOME@@'
25
25
__DOMAIN_HOME_TOKEN = '@@DOMAIN_HOME@@'
26
+ __JAVA_HOME_TOKEN = '@@JAVA_HOME@@'
26
27
__CURRENT_DIRECTORY_TOKEN = '@@PWD@@'
27
28
__TEMP_DIRECTORY_TOKEN = '@@TMP@@'
28
29
@@ -501,10 +502,11 @@ def has_token_prefix(self, path):
501
502
:return: true if the path begins with a known prefix, false otherwise
502
503
"""
503
504
return path .startswith (self .__ORACLE_HOME_TOKEN ) or \
504
- path .startswith (self .__WL_HOME_TOKEN ) or \
505
- path .startswith (self .__DOMAIN_HOME_TOKEN ) or \
506
- path .startswith (self .__CURRENT_DIRECTORY_TOKEN ) or \
507
- path .startswith (self .__TEMP_DIRECTORY_TOKEN )
505
+ path .startswith (self .__WL_HOME_TOKEN ) or \
506
+ path .startswith (self .__DOMAIN_HOME_TOKEN ) or \
507
+ path .startswith (self .__JAVA_HOME_TOKEN ) or \
508
+ path .startswith (self .__CURRENT_DIRECTORY_TOKEN ) or \
509
+ path .startswith (self .__TEMP_DIRECTORY_TOKEN )
508
510
509
511
def replace_tokens (self , resource_type , resource_name , attribute_name , resource_dict ):
510
512
"""
@@ -532,6 +534,12 @@ def replace_tokens(self, resource_type, resource_name, attribute_name, resource_
532
534
self .get_domain_home (), class_name = self ._class_name , method_name = '_replace_tokens' )
533
535
resource_dict [attribute_name ] = attribute_value .replace (self .__DOMAIN_HOME_TOKEN ,
534
536
self .get_domain_home ())
537
+ elif attribute_value .startswith (self .__JAVA_HOME_TOKEN ):
538
+ message = "Replacing {0} in {1} {2} {3} with {4}"
539
+ self ._logger .fine (message , self .__JAVA_HOME_TOKEN , resource_type , resource_name , attribute_name ,
540
+ self .get_domain_home (), class_name = self ._class_name , method_name = '_replace_tokens' )
541
+ resource_dict [attribute_name ] = attribute_value .replace (self .__JAVA_HOME_TOKEN ,
542
+ self .get_java_home ())
535
543
elif attribute_value .startswith (self .__CURRENT_DIRECTORY_TOKEN ):
536
544
cwd = path_utils .fixup_path (os .getcwd ())
537
545
message = "Replacing {0} in {1} {2} {3} with {4}"
@@ -561,6 +569,8 @@ def replace_token_string(self, string_value):
561
569
result = _replace (string_value , self .__WL_HOME_TOKEN , self .get_wl_home ())
562
570
elif string_value .startswith (self .__DOMAIN_HOME_TOKEN ):
563
571
result = _replace (string_value , self .__DOMAIN_HOME_TOKEN , self .get_domain_home ())
572
+ elif string_value .startswith (self .__JAVA_HOME_TOKEN ):
573
+ result = _replace (string_value , self .__JAVA_HOME_TOKEN , self .get_java_home ())
564
574
elif string_value .startswith (self .__CURRENT_DIRECTORY_TOKEN ):
565
575
result = _replace (string_value , self .__CURRENT_DIRECTORY_TOKEN , path_utils .fixup_path (os .getcwd ()))
566
576
elif string_value .startswith (self .__TEMP_DIRECTORY_TOKEN ):
@@ -582,6 +592,7 @@ def tokenize_path(self, path):
582
592
wl_home = path_utils .fixup_path (self .get_wl_home ())
583
593
domain_home = path_utils .fixup_path (self .get_domain_home ())
584
594
oracle_home = path_utils .fixup_path (self .get_oracle_home ())
595
+ java_home = path_utils .fixup_path (self .get_java_home ())
585
596
tmp_dir = path_utils .fixup_path (tempfile .gettempdir ())
586
597
cwd = path_utils .fixup_path (os .path .dirname (os .path .abspath (__file__ )))
587
598
@@ -594,6 +605,8 @@ def tokenize_path(self, path):
594
605
result = my_path .replace (domain_home , self .__DOMAIN_HOME_TOKEN )
595
606
elif oracle_home is not None and my_path .startswith (oracle_home ):
596
607
result = my_path .replace (oracle_home , self .__ORACLE_HOME_TOKEN )
608
+ elif java_home is not None and my_path .startswith (java_home ):
609
+ result = my_path .replace (java_home , self .__JAVA_HOME_TOKEN )
597
610
elif my_path .startswith (cwd ):
598
611
result = my_path .replace (cwd , self .__CURRENT_DIRECTORY_TOKEN )
599
612
elif my_path .startswith (tmp_dir ):
0 commit comments