1616// under the License.
1717package org .apache .cloudstack .api .command .user .firewall ;
1818
19- import org .apache .log4j .Logger ;
20-
2119import org .apache .cloudstack .acl .RoleType ;
2220import org .apache .cloudstack .api .APICommand ;
2321import org .apache .cloudstack .api .ApiConstants ;
2725import org .apache .cloudstack .api .response .FirewallRuleResponse ;
2826import org .apache .cloudstack .api .response .IPAddressResponse ;
2927import org .apache .cloudstack .api .response .UserVmResponse ;
28+ import org .apache .log4j .Logger ;
3029
3130import com .cloud .event .EventTypes ;
3231import com .cloud .exception .InvalidParameterValueException ;
33- import com .cloud .network .IpAddress ;
3432import com .cloud .network .rules .FirewallRule ;
3533import com .cloud .network .rules .PortForwardingRule ;
3634import com .cloud .user .Account ;
@@ -94,10 +92,6 @@ public String getProtocol() {
9492 return protocol ;
9593 }
9694
97- public Long getPublicIpId () {
98- return publicIpId ;
99- }
100-
10195 public String getPublicPort () {
10296 return publicPort ;
10397 }
@@ -109,21 +103,26 @@ public Long getVirtualMachineId() {
109103 public Boolean getDisplay () {
110104 return display ;
111105 }
106+ public Long getId () {
107+ return id ;
108+ }
112109
113110 /////////////////////////////////////////////////////
114111 /////////////// API Implementation///////////////////
115112 /////////////////////////////////////////////////////
116113
114+
115+
117116 @ Override
118117 public String getCommandName () {
119118 return s_name ;
120119 }
121120
122121 @ Override
123122 public long getEntityOwnerId () {
124- IpAddress addr = _entityMgr .findById (IpAddress .class , getPublicIpId ());
125- if (addr != null ) {
126- return addr .getAccountId ();
123+ PortForwardingRule rule = _entityMgr .findById (PortForwardingRule .class , getId ());
124+ if (rule != null ) {
125+ return rule .getAccountId ();
127126 }
128127
129128 // bad address given, parent this command to SYSTEM so ERROR events are tracked
@@ -173,14 +172,11 @@ public String getSyncObjType() {
173172
174173 @ Override
175174 public Long getSyncObjId () {
176- return getIp ().getAssociatedWithNetworkId ();
177- }
178-
179- private IpAddress getIp () {
180- IpAddress ip = _networkService .getIp (publicIpId );
181- if (ip == null ) {
182- throw new InvalidParameterValueException ("Unable to find ip address by id " + publicIpId );
175+ PortForwardingRule rule = _entityMgr .findById (PortForwardingRule .class , getId ());
176+ if (rule != null ) {
177+ return rule .getNetworkId ();
178+ } else {
179+ throw new InvalidParameterValueException ("Unable to find the rule by id" );
183180 }
184- return ip ;
185181 }
186182}
0 commit comments