@@ -2623,26 +2623,7 @@ protected DiskOfferingVO createDiskOffering(final Long userId, final List<Long>
26232623 }
26242624
26252625 // Filter child domains when both parent and child domains are present
2626- List <Long > filteredDomainIds = new ArrayList <>();
2627- if (domainIds != null ) {
2628- filteredDomainIds .addAll (domainIds );
2629- }
2630- if (filteredDomainIds .size () > 1 ) {
2631- for (int i = filteredDomainIds .size () - 1 ; i >= 1 ; i --) {
2632- long first = filteredDomainIds .get (i );
2633- for (int j = i - 1 ; j >= 0 ; j --) {
2634- long second = filteredDomainIds .get (j );
2635- if (_domainDao .isChildDomain (filteredDomainIds .get (i ), filteredDomainIds .get (j ))) {
2636- filteredDomainIds .remove (j );
2637- i --;
2638- }
2639- if (_domainDao .isChildDomain (filteredDomainIds .get (j ), filteredDomainIds .get (i ))) {
2640- filteredDomainIds .remove (i );
2641- break ;
2642- }
2643- }
2644- }
2645- }
2626+ List <Long > filteredDomainIds = filterChildSubDomains (domainIds );
26462627
26472628 // Check if user exists in the system
26482629 final User user = _userDao .findById (userId );
@@ -2840,26 +2821,7 @@ public DiskOffering updateDiskOffering(final UpdateDiskOfferingCmd cmd) {
28402821 final List <Long > domainIds = cmd .getDomainIds ();
28412822
28422823 // Filter child domains when both parent and child domains are present
2843- List <Long > filteredDomainIds = new ArrayList <>();
2844- if (domainIds != null ) {
2845- filteredDomainIds .addAll (domainIds );
2846- }
2847- if (filteredDomainIds .size () > 1 ) {
2848- for (int i = filteredDomainIds .size () - 1 ; i >= 1 ; i --) {
2849- long first = filteredDomainIds .get (i );
2850- for (int j = i - 1 ; j >= 0 ; j --) {
2851- long second = filteredDomainIds .get (j );
2852- if (_domainDao .isChildDomain (filteredDomainIds .get (i ), filteredDomainIds .get (j ))) {
2853- filteredDomainIds .remove (j );
2854- i --;
2855- }
2856- if (_domainDao .isChildDomain (filteredDomainIds .get (j ), filteredDomainIds .get (i ))) {
2857- filteredDomainIds .remove (i );
2858- break ;
2859- }
2860- }
2861- }
2862- }
2824+ List <Long > filteredDomainIds = filterChildSubDomains (domainIds );
28632825
28642826 if (account .getType () == Account .ACCOUNT_TYPE_DOMAIN_ADMIN ) {
28652827 if (filteredDomainIds .isEmpty ()) {
@@ -5841,6 +5803,30 @@ private boolean checkOverlapPortableIpRange(final int regionId, final String new
58415803 return false ;
58425804 }
58435805
5806+ private List <Long > filterChildSubDomains (final List <Long > domainIds ) {
5807+ List <Long > filteredDomainIds = new ArrayList <>();
5808+ if (domainIds != null ) {
5809+ filteredDomainIds .addAll (domainIds );
5810+ }
5811+ if (filteredDomainIds .size () > 1 ) {
5812+ for (int i = filteredDomainIds .size () - 1 ; i >= 1 ; i --) {
5813+ long first = filteredDomainIds .get (i );
5814+ for (int j = i - 1 ; j >= 0 ; j --) {
5815+ long second = filteredDomainIds .get (j );
5816+ if (_domainDao .isChildDomain (filteredDomainIds .get (i ), filteredDomainIds .get (j ))) {
5817+ filteredDomainIds .remove (j );
5818+ i --;
5819+ }
5820+ if (_domainDao .isChildDomain (filteredDomainIds .get (j ), filteredDomainIds .get (i ))) {
5821+ filteredDomainIds .remove (i );
5822+ break ;
5823+ }
5824+ }
5825+ }
5826+ }
5827+ return filteredDomainIds ;
5828+ }
5829+
58445830 public List <SecurityChecker > getSecChecker () {
58455831 return _secChecker ;
58465832 }
0 commit comments