Trace.trace(Activator.PLUGIN_ID, DnsSdDebugOptions.METHODS_TRACING, this.getClass(), "getAuthoritativeNameServer(Name zone)", "Trying to find authoritative name server"); //$NON-NLS-1$ //$NON-NLS-2$
final Set result = new HashSet();
final Name name = new Name(_DNS_UPDATE + zone);
//query for NS records
Lookup query = new Lookup(zone, Type.NS);
query.setResolver(resolver);
Record[] queryResult = query.run();
//TODO file bug upstream that queryResult may never be null
int length = queryResult == null ? 0 : queryResult.length;
for (int j = 0; j < length; j++) {
final Record record = queryResult[j];
if(record instanceof NSRecord) {
final NSRecord nsRecord = (NSRecord) record;
final Name target = nsRecord.getTarget();
result.add(new SRVRecord(name, DClass.IN, nsRecord.getTTL(), 0, 0, SimpleResolver.DEFAULT_PORT, target));
}
}
//query for primary ns in SOA record (may overwrite/be equal to one of the ns records)
query = new Lookup(zone, Type.SOA);
query.setResolver(resolver);
queryResult = query.run();
//TODO file bug upstream that queryResult may never be null
length = queryResult == null ? 0 : queryResult.length;
for (int j = 0; j < length; j++) {
final Record record = queryResult[j];
if(record instanceof SOARecord) {