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;
  }
示例#3
0
  public Collection<RpslObjectInfo> getReferencedIrtsInHierarchy(final RpslObject rpslObject) {
    final Collection<RpslObjectInfo> irts = getReferencedIrts(rpslObject);
    if (!irts.isEmpty()) {
      return irts;
    }

    final K resource = createResource(rpslObject.getKey());
    final List<V> entries = ipTree.findAllLessSpecific(resource);
    for (final V entry : entries) {
      final RpslObject object = rpslObjectDao.getById(entry.getObjectId());
      final Collection<RpslObjectInfo> referencedIrts = getReferencedIrts(object);
      if (!referencedIrts.isEmpty()) {
        return referencedIrts;
      }
    }

    return Collections.emptyList();
  }