/** Any imcp rules created without ports should have the values updated to -1 (any) */ private void setPortsForIcmpRules() { try (final TransactionResource tx = Entities.distinctTransactionFor(NetworkRule.class)) { for (final NetworkRule rule : Entities.criteriaQuery( Entities.restriction(NetworkRule.class) .any( Entities.restriction(NetworkRule.class) .isNull(NetworkRule_.lowPort) .build(), Entities.restriction(NetworkRule.class) .isNull(NetworkRule_.highPort) .build()) .equal(NetworkRule_.protocol, Protocol.icmp)) .list()) { logger.info( "Updating ports for icmp rule in group " + rule.getGroup().getGroupId() + "/" + rule.getGroup().getDisplayName()); if (rule.getLowPort() == null) { rule.setLowPort(-1); } if (rule.getHighPort() == null) { rule.setHighPort(-1); } } tx.commit(); } catch (Exception ex) { logger.error("Error updating ports for icmp rules", ex); } }
public Integer extractLowPort(NetworkRule rule) { return rule.getLowPort(); }
@Override public Integer extractIcmpType(final NetworkRule rule) { return rule.getLowPort(); }