BdxlLocator extends AbstractLocator { @Override public URI lookup(ParticipantIdentifier participantIdentifier) throws LookupException { String hostname = hostnameGenerator.generate(participantIdentifier).replaceAll("=*", ""); try { final Lookup lookup = new Lookup(hostname, Type.NAPTR); Record[] records = lookup.run(); if (records == null) { if(lookup.getResult() == Lookup.HOST_NOT_FOUND) { throw new NotFoundException( String.format("Identifier '%s' is not registered in SML.", participantIdentifier.toString())); } else { throw new LookupException( String.format("Error when looking up identifier '%s' in SML.", participantIdentifier.toString())); } } for (Record record : records) { NAPTRRecord naptrRecord = (NAPTRRecord) record; if ("Meta:SMP".equals(naptrRecord.getService()) && "U".equalsIgnoreCase(naptrRecord.getFlags())) { String result = handleRegex(naptrRecord.getRegexp(), hostname); if (result != null) return URI.create(result); } } } catch (TextParseException e) { throw new LookupException("Error when handling DNS lookup for BDXL.", e); } throw new NotFoundException("Record for SMP not found in SML."); } BdxlLocator(Mode mode); @SuppressWarnings("unused")  BdxlLocator(String hostname);  BdxlLocator(String hostname, String digestAlgorithm);  BdxlLocator(String prefix, String hostname, String digestAlgorithm);  BdxlLocator(String prefix, String hostname, String digestAlgorithm, BaseEncoding encoding); @Override URI lookup(ParticipantIdentifier participantIdentifier); static String handleRegex(String naptrRegex, String hostname);  }
@Test public void simple() throws Exception { MetadataLocator locator = new BdxlLocator(Mode.of("TEST")); Assert.assertEquals( locator.lookup(ParticipantIdentifier.of("9908:810418052")), URI.create("http: ); }