Esempio n. 1
0
  private void validateIntersections(
      final PreparedUpdate update,
      final UpdateContext updateContext,
      final IpInterval ipInterval,
      final IpTree ipTree) {
    final List<IpEntry> parent = ipTree.findFirstLessSpecific(ipInterval);
    Validate.notEmpty(parent, "Should always have a parent");

    Interval firstIntersecting = null;
    final List<IpEntry> childEntries =
        ipTree.findFirstMoreSpecific((IpInterval) parent.get(0).getKey());
    for (final IpEntry childEntry : childEntries) {
      final Interval child = childEntry.getKey();

      if (child.intersects(ipInterval)
          && !(child.contains(ipInterval) || ipInterval.contains(child))) {
        if (firstIntersecting == null
            || firstIntersecting
                    .singletonIntervalAtLowerBound()
                    .compareUpperBound(child.singletonIntervalAtLowerBound())
                > 0) {
          firstIntersecting = child;
        }
      }
    }

    if (firstIntersecting != null) {
      updateContext.addMessage(update, UpdateMessages.intersectingRange(firstIntersecting));
    }
  }
  @SuppressWarnings("unchecked")
  private List<RpslObject> getIpObjects(final IpTree ipTree, final IpInterval addressPrefix) {
    final List<IpEntry> ipEntries = ipTree.findExactOrFirstLessSpecific(addressPrefix);
    final List<RpslObject> ipObjects = Lists.newArrayListWithCapacity(ipEntries.size());
    for (final IpEntry ipEntry : ipEntries) {
      ipObjects.add(objectDao.getById(ipEntry.getObjectId()));
    }

    return ipObjects;
  }