|
18 | 18 |
|
19 | 19 | import java.util.List; |
20 | 20 |
|
| 21 | +import javax.annotation.PostConstruct; |
21 | 22 | import javax.inject.Inject; |
22 | 23 |
|
23 | 24 | import org.springframework.stereotype.Component; |
@@ -121,6 +122,18 @@ protected FirewallRulesDaoImpl() { |
121 | 122 | RoutingFirewallRulesSearch.done(); |
122 | 123 | } |
123 | 124 |
|
| 125 | + @PostConstruct |
| 126 | + public void init() { |
| 127 | + SearchBuilder<IPAddressVO> IpSearch = _ipDao.createSearchBuilder(); |
| 128 | + IpSearch.and("associatedWithVmId", IpSearch.entity().getAssociatedWithVmId(), SearchCriteria.Op.EQ); |
| 129 | + IpSearch.and("oneToOneNat", IpSearch.entity().isOneToOneNat(), SearchCriteria.Op.NNULL); |
| 130 | + |
| 131 | + VmSearch = createSearchBuilder(); |
| 132 | + VmSearch.and("purpose", VmSearch.entity().getPurpose(), Op.EQ); |
| 133 | + VmSearch.join("ipSearch", IpSearch, VmSearch.entity().getSourceIpAddressId(), IpSearch.entity().getId(), JoinBuilder.JoinType.INNER); |
| 134 | + VmSearch.done(); |
| 135 | + } |
| 136 | + |
124 | 137 | @Override |
125 | 138 | public List<FirewallRuleVO> listSystemRules() { |
126 | 139 | SearchCriteria<FirewallRuleVO> sc = SystemRuleSearch.create(); |
@@ -216,17 +229,6 @@ public boolean revoke(FirewallRuleVO rule) { |
216 | 229 |
|
217 | 230 | @Override |
218 | 231 | public List<FirewallRuleVO> listStaticNatByVmId(long vmId) { |
219 | | - if (VmSearch == null) { |
220 | | - SearchBuilder<IPAddressVO> IpSearch = _ipDao.createSearchBuilder(); |
221 | | - IpSearch.and("associatedWithVmId", IpSearch.entity().getAssociatedWithVmId(), SearchCriteria.Op.EQ); |
222 | | - IpSearch.and("oneToOneNat", IpSearch.entity().isOneToOneNat(), SearchCriteria.Op.NNULL); |
223 | | - |
224 | | - VmSearch = createSearchBuilder(); |
225 | | - VmSearch.and("purpose", VmSearch.entity().getPurpose(), Op.EQ); |
226 | | - VmSearch.join("ipSearch", IpSearch, VmSearch.entity().getSourceIpAddressId(), IpSearch.entity().getId(), JoinBuilder.JoinType.INNER); |
227 | | - VmSearch.done(); |
228 | | - } |
229 | | - |
230 | 232 | SearchCriteria<FirewallRuleVO> sc = VmSearch.create(); |
231 | 233 | sc.setParameters("purpose", Purpose.StaticNat); |
232 | 234 | sc.setJoinParameters("ipSearch", "associatedWithVmId", vmId); |
|
0 commit comments