2626import org .apache .cloudstack .api .*;
2727import org .apache .cloudstack .api .response .NetworkACLResponse ;
2828import org .apache .cloudstack .api .response .NetworkResponse ;
29+ import org .apache .cloudstack .api .response .PrivateGatewayResponse ;
2930import org .apache .cloudstack .api .response .SuccessResponse ;
3031import org .apache .log4j .Logger ;
3132
32- @ APICommand (name = "replaceNetworkACLList" , description ="Replaces ACL associated with a Network" , responseObject =SuccessResponse .class )
33+ @ APICommand (name = "replaceNetworkACLList" , description ="Replaces ACL associated with a Network or private gateway " , responseObject =SuccessResponse .class )
3334public class ReplaceNetworkACLListCmd extends BaseAsyncCmd {
3435 public static final Logger s_logger = Logger .getLogger (ReplaceNetworkACLListCmd .class .getName ());
3536 private static final String s_name = "replacenetworkacllistresponse" ;
@@ -43,8 +44,12 @@ public class ReplaceNetworkACLListCmd extends BaseAsyncCmd {
4344 private long aclId ;
4445
4546 @ Parameter (name =ApiConstants .NETWORK_ID , type =CommandType .UUID , entityType = NetworkResponse .class ,
46- required =true , description ="the ID of the network" )
47- private long networkId ;
47+ description ="the ID of the network" )
48+ private Long networkId ;
49+
50+ @ Parameter (name =ApiConstants .GATEWAY_ID , type =CommandType .UUID , entityType = PrivateGatewayResponse .class ,
51+ description ="the ID of the private gateway" )
52+ private Long privateGatewayId ;
4853
4954 /////////////////////////////////////////////////////
5055 /////////////////// Accessors ///////////////////////
@@ -54,10 +59,14 @@ public long getAclId() {
5459 return aclId ;
5560 }
5661
57- public long getNetworkId (){
62+ public Long getNetworkId (){
5863 return networkId ;
5964 }
6065
66+ public Long getPrivateGatewayId () {
67+ return privateGatewayId ;
68+ }
69+
6170 /////////////////////////////////////////////////////
6271 /////////////// API Implementation///////////////////
6372 /////////////////////////////////////////////////////
@@ -84,8 +93,21 @@ public long getEntityOwnerId() {
8493
8594 @ Override
8695 public void execute () throws ResourceUnavailableException {
96+ if (getNetworkId () == null && getPrivateGatewayId () == null ) {
97+ throw new ServerApiException (ApiErrorCode .INTERNAL_ERROR , "Network id and private gateway can't be null at the same time" );
98+ }
99+
100+ if (getNetworkId () != null && getPrivateGatewayId () != null ) {
101+ throw new ServerApiException (ApiErrorCode .INTERNAL_ERROR , "Network id and private gateway can't be passed at the same time" );
102+ }
103+
87104 UserContext .current ().setEventDetails ("Network ACL Id: " + aclId );
88- boolean result = _networkACLService .replaceNetworkACL (aclId , networkId );
105+ boolean result = false ;
106+ if (getPrivateGatewayId () != null ) {
107+ result = _networkACLService .replaceNetworkACLonPrivateGw (aclId , privateGatewayId );
108+ } else {
109+ result = _networkACLService .replaceNetworkACL (aclId , networkId );
110+ }
89111
90112 if (result ) {
91113 SuccessResponse response = new SuccessResponse (getCommandName ());
0 commit comments