|
52 | 52 | import com.cloud.consoleproxy.ConsoleProxyManager; |
53 | 53 | import com.cloud.network.router.VirtualNetworkApplianceManager; |
54 | 54 | import com.cloud.storage.secondary.SecondaryStorageVmManager; |
| 55 | +import com.cloud.utils.DomainHelper; |
55 | 56 | import com.cloud.vm.VirtualMachineManager; |
56 | 57 | import org.apache.cloudstack.acl.RoleType; |
57 | 58 | import org.apache.cloudstack.acl.SecurityChecker; |
@@ -398,6 +399,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati |
398 | 399 | ClusterDao _clusterDao; |
399 | 400 | @Inject |
400 | 401 | AlertManager _alertMgr; |
| 402 | + @Inject |
| 403 | + DomainHelper domainHelper; |
401 | 404 | List<SecurityChecker> _secChecker; |
402 | 405 | List<ExternalProvisioner> externalProvisioners; |
403 | 406 |
|
@@ -3509,7 +3512,7 @@ protected ServiceOfferingVO createServiceOffering(final long userId, final boole |
3509 | 3512 | final boolean isCustomized, final boolean encryptRoot, Long vgpuProfileId, Integer gpuCount, Boolean gpuDisplay, final boolean purgeResources, Integer leaseDuration, VMLeaseManager.ExpiryAction leaseExpiryAction) { |
3510 | 3513 |
|
3511 | 3514 | // Filter child domains when both parent and child domains are present |
3512 | | - List<Long> filteredDomainIds = filterChildSubDomains(domainIds); |
| 3515 | + List<Long> filteredDomainIds = domainHelper.filterChildSubDomains(domainIds); |
3513 | 3516 |
|
3514 | 3517 | // Check if user exists in the system |
3515 | 3518 | final User user = _userDao.findById(userId); |
@@ -3898,7 +3901,7 @@ public ServiceOffering updateServiceOffering(final UpdateServiceOfferingCmd cmd) |
3898 | 3901 | final Account account = _accountDao.findById(user.getAccountId()); |
3899 | 3902 |
|
3900 | 3903 | // Filter child domains when both parent and child domains are present |
3901 | | - List<Long> filteredDomainIds = filterChildSubDomains(domainIds); |
| 3904 | + List<Long> filteredDomainIds = domainHelper.filterChildSubDomains(domainIds); |
3902 | 3905 | Collections.sort(filteredDomainIds); |
3903 | 3906 |
|
3904 | 3907 | List<Long> filteredZoneIds = new ArrayList<>(); |
@@ -4102,7 +4105,7 @@ protected DiskOfferingVO createDiskOffering(final Long userId, final List<Long> |
4102 | 4105 | } |
4103 | 4106 |
|
4104 | 4107 | // Filter child domains when both parent and child domains are present |
4105 | | - List<Long> filteredDomainIds = filterChildSubDomains(domainIds); |
| 4108 | + List<Long> filteredDomainIds = domainHelper.filterChildSubDomains(domainIds); |
4106 | 4109 |
|
4107 | 4110 | // Check if user exists in the system |
4108 | 4111 | final User user = _userDao.findById(userId); |
@@ -4378,7 +4381,7 @@ public DiskOffering updateDiskOffering(final UpdateDiskOfferingCmd cmd) { |
4378 | 4381 | final Account account = _accountDao.findById(user.getAccountId()); |
4379 | 4382 |
|
4380 | 4383 | // Filter child domains when both parent and child domains are present |
4381 | | - List<Long> filteredDomainIds = filterChildSubDomains(domainIds); |
| 4384 | + List<Long> filteredDomainIds = domainHelper.filterChildSubDomains(domainIds); |
4382 | 4385 | Collections.sort(filteredDomainIds); |
4383 | 4386 |
|
4384 | 4387 | List<Long> filteredZoneIds = new ArrayList<>(); |
@@ -7385,7 +7388,7 @@ public NetworkOfferingVO doInTransaction(final TransactionStatus status) { |
7385 | 7388 | } |
7386 | 7389 | if (offering != null) { |
7387 | 7390 | // Filter child domains when both parent and child domains are present |
7388 | | - List<Long> filteredDomainIds = filterChildSubDomains(domainIds); |
| 7391 | + List<Long> filteredDomainIds = domainHelper.filterChildSubDomains(domainIds); |
7389 | 7392 | List<NetworkOfferingDetailsVO> detailsVO = new ArrayList<>(); |
7390 | 7393 | for (Long domainId : filteredDomainIds) { |
7391 | 7394 | detailsVO.add(new NetworkOfferingDetailsVO(offering.getId(), Detail.domainid, String.valueOf(domainId), false)); |
@@ -7851,7 +7854,7 @@ public NetworkOffering updateNetworkOffering(final UpdateNetworkOfferingCmd cmd) |
7851 | 7854 | } |
7852 | 7855 |
|
7853 | 7856 | // Filter child domains when both parent and child domains are present |
7854 | | - List<Long> filteredDomainIds = filterChildSubDomains(domainIds); |
| 7857 | + List<Long> filteredDomainIds = domainHelper.filterChildSubDomains(domainIds); |
7855 | 7858 | Collections.sort(filteredDomainIds); |
7856 | 7859 |
|
7857 | 7860 | List<Long> filteredZoneIds = new ArrayList<>(); |
@@ -8418,28 +8421,6 @@ private boolean checkOverlapPortableIpRange(final int regionId, final String new |
8418 | 8421 | return false; |
8419 | 8422 | } |
8420 | 8423 |
|
8421 | | - private List<Long> filterChildSubDomains(final List<Long> domainIds) { |
8422 | | - List<Long> filteredDomainIds = new ArrayList<>(); |
8423 | | - if (domainIds != null) { |
8424 | | - filteredDomainIds.addAll(domainIds); |
8425 | | - } |
8426 | | - if (filteredDomainIds.size() > 1) { |
8427 | | - for (int i = filteredDomainIds.size() - 1; i >= 1; i--) { |
8428 | | - for (int j = i - 1; j >= 0; j--) { |
8429 | | - if (_domainDao.isChildDomain(filteredDomainIds.get(i), filteredDomainIds.get(j))) { |
8430 | | - filteredDomainIds.remove(j); |
8431 | | - i--; |
8432 | | - } |
8433 | | - if (_domainDao.isChildDomain(filteredDomainIds.get(j), filteredDomainIds.get(i))) { |
8434 | | - filteredDomainIds.remove(i); |
8435 | | - break; |
8436 | | - } |
8437 | | - } |
8438 | | - } |
8439 | | - } |
8440 | | - return filteredDomainIds; |
8441 | | - } |
8442 | | - |
8443 | 8424 | protected void validateCacheMode(String cacheMode){ |
8444 | 8425 | if(cacheMode != null && |
8445 | 8426 | !Enums.getIfPresent(DiskOffering.DiskCacheMode.class, |
|
0 commit comments