@@ -2563,7 +2563,7 @@ public Pair<List<? extends Network>, Integer> searchForNetworks(ListNetworksCmd
25632563 } else {
25642564 SearchCriteria <NetworkVO > additionalSC = _networksDao .createSearchCriteria ();
25652565
2566- addAccountSpecificNetworksToSearch (additionalSC , sb , networkFilter , skipProjectNetworks , permittedAccounts , path , isRecursive );
2566+ addAccountSpecificNetworksToSearch (additionalSC , sb , networkFilter , skipProjectNetworks , permittedAccounts , path , isRecursive , projectId );
25672567 addDomainSpecificNetworksToSearch (additionalSC , sb , networkFilter , permittedAccounts , domainId , path , isRecursive );
25682568 addSharedNetworksToSearch (additionalSC , sb , networkFilter , permittedAccounts , path , isRecursive );
25692569
@@ -2623,7 +2623,7 @@ public Pair<List<? extends Network>, Integer> searchForNetworks(ListNetworksCmd
26232623
26242624 private void addAccountSpecificNetworksToSearch (SearchCriteria <NetworkVO > additionalSC , SearchBuilder <NetworkVO > sb ,
26252625 Network .NetworkFilter networkFilter , boolean skipProjectNetworks ,
2626- List <Long > permittedAccounts , String path , boolean isRecursive ) {
2626+ List <Long > permittedAccounts , String path , boolean isRecursive , Long projectId ) {
26272627 if (!Arrays .asList (Network .NetworkFilter .Account , Network .NetworkFilter .AccountDomain , Network .NetworkFilter .All ).contains (networkFilter )) {
26282628 return ;
26292629 }
@@ -2642,7 +2642,7 @@ private void addAccountSpecificNetworksToSearch(SearchCriteria<NetworkVO> additi
26422642 } else {
26432643 accountSC .addAnd ("accountId" , SearchCriteria .Op .IN , permittedAccounts .toArray ());
26442644 }
2645- addProjectNetworksConditionToSearch (accountSC , skipProjectNetworks );
2645+ addProjectNetworksConditionToSearch (accountSC , skipProjectNetworks , projectId );
26462646 additionalSC .addOr ("id" , SearchCriteria .Op .SC , accountSC );
26472647 }
26482648
@@ -2823,8 +2823,17 @@ private void addDomainNetworksByDomainPathToSearch(SearchCriteria<NetworkVO> add
28232823 }
28242824 }
28252825
2826- private void addProjectNetworksConditionToSearch (SearchCriteria <NetworkVO > sc , boolean skipProjectNetworks ) {
2827- sc .getJoin ("account" ).addAnd ("type" , skipProjectNetworks ? Op .NEQ : Op .EQ , Account .Type .PROJECT );
2826+ protected void addProjectNetworksConditionToSearch (SearchCriteria <NetworkVO > sc , boolean skipProjectNetworks ) {
2827+ addProjectNetworksConditionToSearch (sc , skipProjectNetworks , null );
2828+ }
2829+
2830+ protected void addProjectNetworksConditionToSearch (SearchCriteria <NetworkVO > sc , boolean skipProjectNetworks ,
2831+ Long projectId ) {
2832+ if (!skipProjectNetworks && projectId == -1 ) {
2833+ sc .getJoin ("account" ).addAnd ("type" , Op .NNULL );
2834+ } else {
2835+ sc .getJoin ("account" ).addAnd ("type" , skipProjectNetworks ? Op .NEQ : Op .EQ , Account .Type .PROJECT );
2836+ }
28282837 sc .addAnd ("id" , Op .SC , sc .getJoin ("account" ));
28292838 }
28302839
0 commit comments