Exemplo n.º 1
0
 @Override
 @Nullable
 public RpslObject getByKeyOrNull(final ObjectType type, final String key) {
   final RpslObjectInfo rpslObjectInfo = findByKeyOrNull(type, key);
   if (rpslObjectInfo == null) {
     return null;
   }
   return getById(rpslObjectInfo.getObjectId());
 }
Exemplo n.º 2
0
  @Test
  public void find_in_index() {
    RpslObject rpslObject = RpslObject.parse("inet-rtr: test\nifaddr: 10.2.3.4 masklen 32");
    addObject(rpslObject);

    final List<RpslObjectInfo> found = subject.findInIndex(whoisTemplate, "10.2.3.4");

    assertThat(found.size(), is(1));
    final RpslObjectInfo objectInfo = found.get(0);
    assertThat(objectInfo.getObjectId(), is(1));
    assertThat(objectInfo.getObjectType(), is(ObjectType.INET_RTR));
    assertThat(objectInfo.getKey(), is("test"));
  }
Exemplo n.º 3
0
  @Override
  public Collection<RpslObjectInfo> relatedTo(
      final RpslObject identifiable, final Set<ObjectType> excludeObjectTypes) {
    final LinkedHashSet<RpslObjectInfo> result = Sets.newLinkedHashSet();

    for (final RpslAttribute attribute : identifiable.findAttributes(RELATED_TO_ATTRIBUTES)) {
      for (final CIString referenceValue : attribute.getReferenceValues()) {
        for (final ObjectType objectType : attribute.getType().getReferences(referenceValue)) {
          if (excludeObjectTypes.contains(objectType)) {
            continue;
          }

          for (RpslObjectInfo rpslObjectInfo :
              findByKeyInIndex(objectType, referenceValue.toString())) {
            if (rpslObjectInfo.getObjectId() != identifiable.getObjectId()) {
              result.add(rpslObjectInfo);
            }
          }
        }
      }
    }

    return result;
  }