2727import javax .inject .Inject ;
2828import javax .naming .ConfigurationException ;
2929
30- import org .apache .log4j .Logger ;
31- import org .springframework .stereotype .Component ;
32- import org .apache .cloudstack .api .command .user .firewall .ListEgressFirewallRulesCmd ;
3330import org .apache .cloudstack .api .command .user .firewall .ListFirewallRulesCmd ;
3431import org .apache .cloudstack .context .CallContext ;
3532import org .apache .cloudstack .engine .orchestration .service .NetworkOrchestrationService ;
3633import org .apache .cloudstack .framework .config .dao .ConfigurationDao ;
34+ import org .apache .log4j .Logger ;
35+ import org .springframework .stereotype .Component ;
3736
3837import com .cloud .configuration .Config ;
3938import com .cloud .domain .dao .DomainDao ;
7069import com .cloud .network .rules .FirewallRuleVO ;
7170import com .cloud .network .rules .PortForwardingRule ;
7271import com .cloud .network .rules .PortForwardingRuleVO ;
73- import com .cloud .network .rules .StaticNat ;
7472import com .cloud .network .rules .dao .PortForwardingRulesDao ;
7573import com .cloud .network .vpc .VpcManager ;
7674import com .cloud .projects .Project .ListProjectResourcesCriteria ;
8886import com .cloud .utils .db .JoinBuilder ;
8987import com .cloud .utils .db .SearchBuilder ;
9088import com .cloud .utils .db .SearchCriteria ;
89+ import com .cloud .utils .db .SearchCriteria .Op ;
90+ import com .cloud .utils .db .Transaction ;
9191import com .cloud .utils .db .TransactionCallbackNoReturn ;
9292import com .cloud .utils .db .TransactionCallbackWithException ;
9393import com .cloud .utils .db .TransactionStatus ;
94- import com .cloud .utils .db .SearchCriteria .Op ;
95- import com .cloud .utils .db .Transaction ;
9694import com .cloud .utils .exception .CloudRuntimeException ;
9795import com .cloud .utils .net .NetUtils ;
9896import com .cloud .vm .UserVmVO ;
@@ -256,7 +254,7 @@ public FirewallRuleVO doInTransaction(TransactionStatus status) throws NetworkRu
256254 public Pair <List <? extends FirewallRule >, Integer > listFirewallRules (ListFirewallRulesCmd cmd ) {
257255 Long ipId = cmd .getIpAddressId ();
258256 Long id = cmd .getId ();
259- Long networkId = null ;
257+ Long networkId = cmd . getNetworkId () ;
260258 Map <String , String > tags = cmd .getTags ();
261259 FirewallRule .TrafficType trafficType = cmd .getTrafficType ();
262260
@@ -283,15 +281,10 @@ public Pair<List<? extends FirewallRule>, Integer> listFirewallRules(ListFirewal
283281
284282 sb .and ("id" , sb .entity ().getId (), Op .EQ );
285283 sb .and ("trafficType" , sb .entity ().getTrafficType (), Op .EQ );
286- if (cmd instanceof ListEgressFirewallRulesCmd ) {
287- networkId =((ListEgressFirewallRulesCmd )cmd ).getNetworkId ();
288- sb .and ("networkId" , sb .entity ().getNetworkId (), Op .EQ );
289- } else {
284+ sb .and ("networkId" , sb .entity ().getNetworkId (), Op .EQ );
290285 sb .and ("ip" , sb .entity ().getSourceIpAddressId (), Op .EQ );
291- }
292286 sb .and ("purpose" , sb .entity ().getPurpose (), Op .EQ );
293287
294-
295288 if (tags != null && !tags .isEmpty ()) {
296289 SearchBuilder <ResourceTagVO > tagSearch = _resourceTagDao .createSearchBuilder ();
297290 for (int count =0 ; count < tags .size (); count ++) {
@@ -323,10 +316,10 @@ public Pair<List<? extends FirewallRule>, Integer> listFirewallRules(ListFirewal
323316
324317 if (ipId != null ) {
325318 sc .setParameters ("ip" , ipId );
326- } else if ( cmd instanceof ListEgressFirewallRulesCmd ) {
327- if ( networkId != null ) {
328- sc . setParameters ( " networkId" , networkId );
329- }
319+ }
320+
321+ if ( networkId != null ) {
322+ sc . setParameters ( "networkId" , networkId );
330323 }
331324
332325 sc .setParameters ("purpose" , Purpose .Firewall );
0 commit comments