|
19 | 19 | import java.util.HashMap; |
20 | 20 | import java.util.List; |
21 | 21 | import java.util.Map; |
| 22 | +import java.util.Optional; |
22 | 23 |
|
23 | 24 | import javax.inject.Inject; |
24 | 25 |
|
@@ -133,17 +134,19 @@ public String getConfigValue(long id, ConfigKey<?> key) { |
133 | 134 | // check if we can traverse till ROOT domain to get the value |
134 | 135 | String enableDomainSettingsForChildDomain = _configDao.getValue("enable.domain.settings.for.child.domain"); |
135 | 136 | if (Boolean.parseBoolean(enableDomainSettingsForChildDomain)) { |
136 | | - AccountVO account = _accountDao.findById(id); |
137 | | - DomainVO domain = _domainDao.findById(account.getDomainId()); |
138 | | - while (domain != null) { |
139 | | - DomainDetailVO domainVO = _domainDetailsDao.findDetail(domain.getId(), key.key()); |
140 | | - if (domainVO != null) { |
141 | | - value = domainVO.getValue(); |
142 | | - break; |
143 | | - } else if (domain.getParent() != null) { |
144 | | - domain = _domainDao.findById(domain.getParent()); |
145 | | - } else { |
146 | | - break; |
| 137 | + Optional<AccountVO> account = Optional.ofNullable(_accountDao.findById(id)); |
| 138 | + if (account.isPresent()) { |
| 139 | + DomainVO domain = _domainDao.findById(account.get().getDomainId()); |
| 140 | + while (domain != null) { |
| 141 | + DomainDetailVO domainVO = _domainDetailsDao.findDetail(domain.getId(), key.key()); |
| 142 | + if (domainVO != null) { |
| 143 | + value = domainVO.getValue(); |
| 144 | + break; |
| 145 | + } else if (domain.getParent() != null) { |
| 146 | + domain = _domainDao.findById(domain.getParent()); |
| 147 | + } else { |
| 148 | + break; |
| 149 | + } |
147 | 150 | } |
148 | 151 | } |
149 | 152 | } |
|
0 commit comments