diff --git a/peppol-lookup/src/main/java/network/oxalis/vefa/peppol/lookup/locator/BdxlLocator.java b/peppol-lookup/src/main/java/network/oxalis/vefa/peppol/lookup/locator/BdxlLocator.java index 2ab5a86d..da14bde4 100644 --- a/peppol-lookup/src/main/java/network/oxalis/vefa/peppol/lookup/locator/BdxlLocator.java +++ b/peppol-lookup/src/main/java/network/oxalis/vefa/peppol/lookup/locator/BdxlLocator.java @@ -74,7 +74,7 @@ public BdxlLocator(Mode mode) { CLOUDFLARE_PRIMARY_DNS = InetAddress.getByAddress((new byte[]{(byte) (1 & 0xff), (byte) (1 & 0xff), (byte) (1 & 0xff), (byte) (1 & 0xff)})); CLOUDFLARE_SECONDARY_DNS = InetAddress.getByAddress((new byte[]{(byte) (1 & 0xff), (byte) (0 & 0xff), (byte) (0 & 0xff), (byte) (1 & 0xff)})); } catch (UnknownHostException e) { - //Unable to initialize Custom DNS server Primary DNS lookup fail, now try with default resolver + //Unable to initialize Custom DNS server } customDNSServers.add(GOOGLE_PRIMARY_DNS); @@ -161,10 +161,14 @@ public URI lookup(ParticipantIdentifier participantIdentifier) throws LookupExce if (naptrLookup.getResult() != Lookup.SUCCESSFUL) { switch (naptrLookup.getResult()) { - case Lookup.HOST_NOT_FOUND: // HOST_NOT_FOUND = The host does not exist - case Lookup.TYPE_NOT_FOUND: // TYPE_NOT_FOUND = The host exists, but has no records associated with the queried type - throw new NotFoundException(String.format("Identifier '%s' is not registered in SML.", participantIdentifier.getIdentifier())); - case Lookup.TRY_AGAIN: // Since we already tried a couple of times with TRY_AGAIN for TCP and UDP, now giving up ... + case Lookup.HOST_NOT_FOUND: // The host does not exist + throw new NotFoundException(String.format("Identifier '%s' is not registered in SML. The host '%s' does not exist", participantIdentifier.getIdentifier(), hostname)); + case Lookup.TYPE_NOT_FOUND: // The host exists, but has no records associated with the queried type + throw new NotFoundException(String.format("Identifier '%s' is not registered in SML. The Host '%s' exists, but has no records associated with the queried type", participantIdentifier.getIdentifier(), hostname)); + case Lookup.TRY_AGAIN: // The lookup failed due to a network error. Repeating the lookup may be helpful. + throw new LookupException(String.format("Error when looking up identifier '%s' in SML due to network error. Retry after sometime... DNS-Lookup-Err: %s", participantIdentifier.getIdentifier(), naptrLookup.getErrorString())); + case Lookup.UNRECOVERABLE: // The lookup failed due to a data or server error. Repeating the lookup would not be helpful. + throw new LookupException(String.format("Error when looking up identifier '%s' in SML due to a data or server error. Repeating the lookup immediately would not be helpful. DNS-Lookup-Err: %s", participantIdentifier.getIdentifier(), naptrLookup.getErrorString())); default: throw new LookupException(String.format("Error when looking up identifier '%s' in SML. DNS-Lookup-Err: %s", participantIdentifier.getIdentifier(), naptrLookup.getErrorString())); } diff --git a/peppol-lookup/src/main/java/network/oxalis/vefa/peppol/lookup/locator/BusdoxLocator.java b/peppol-lookup/src/main/java/network/oxalis/vefa/peppol/lookup/locator/BusdoxLocator.java index 7530d8db..2dfecff8 100644 --- a/peppol-lookup/src/main/java/network/oxalis/vefa/peppol/lookup/locator/BusdoxLocator.java +++ b/peppol-lookup/src/main/java/network/oxalis/vefa/peppol/lookup/locator/BusdoxLocator.java @@ -65,9 +65,8 @@ public BusdoxLocator(Mode mode) { CLOUDFLARE_PRIMARY_DNS = InetAddress.getByAddress((new byte[]{(byte) (1 & 0xff), (byte) (1 & 0xff), (byte) (1 & 0xff), (byte) (1 & 0xff)})); CLOUDFLARE_SECONDARY_DNS = InetAddress.getByAddress((new byte[]{(byte) (1 & 0xff), (byte) (0 & 0xff), (byte) (0 & 0xff), (byte) (1 & 0xff)})); -// CLOUDFLARE_SECONDARY_DNS = InetAddress.getByAddress((new byte[]{(byte) (1 & 0xff), (byte) (0), (byte) (0), (byte) (1 & 0xff)})); } catch (UnknownHostException e) { - //Unable to initialize Custom DNS server Primary DNS lookup fail, now try with default resolver + //Unable to initialize Custom DNS server } customDNSServers.add(GOOGLE_PRIMARY_DNS); @@ -99,7 +98,7 @@ public URI lookup(ParticipantIdentifier participantIdentifier) throws LookupExce lookup.setResolver(extendedResolver); int retryCountLeft = maxRetries; - // Retry = The lookup may fail due to a network error. Repeating the lookup might be helpful + // Retry, The lookup may fail due to a network error. Repeating the lookup might be helpful do { lookup.run(); --retryCountLeft; @@ -118,10 +117,14 @@ public URI lookup(ParticipantIdentifier participantIdentifier) throws LookupExce if (lookup.getResult() != Lookup.SUCCESSFUL) { switch (lookup.getResult()) { - case Lookup.HOST_NOT_FOUND: // HOST_NOT_FOUND = The host does not exist - case Lookup.TYPE_NOT_FOUND: // TYPE_NOT_FOUND = The host exists, but has no records associated with the queried type - throw new NotFoundException(String.format("Identifier '%s' is not registered in SML.", participantIdentifier.getIdentifier())); - case Lookup.TRY_AGAIN: // Since we already tried a couple of times with TRY_AGAIN for TCP and UDP, now giving up ... + case Lookup.HOST_NOT_FOUND: // The host does not exist + throw new NotFoundException(String.format("Identifier '%s' is not registered in SML. The host '%s' does not exist", participantIdentifier.getIdentifier(), hostname)); + case Lookup.TYPE_NOT_FOUND: // The host exists, but has no records associated with the queried type + throw new NotFoundException(String.format("Identifier '%s' is not registered in SML. The Host '%s' exists, but has no records associated with the queried type", participantIdentifier.getIdentifier(), hostname)); + case Lookup.TRY_AGAIN: // The lookup failed due to a network error. Repeating the lookup may be helpful. + throw new LookupException(String.format("Error when looking up identifier '%s' in SML due to network error. Retry after sometime... DNS-Lookup-Err: %s", participantIdentifier.getIdentifier(), lookup.getErrorString())); + case Lookup.UNRECOVERABLE: // The lookup failed due to a data or server error. Repeating the lookup would not be helpful. + throw new LookupException(String.format("Error when looking up identifier '%s' in SML due to a data or server error. Repeating the lookup immediately would not be helpful. DNS-Lookup-Err: %s", participantIdentifier.getIdentifier(), lookup.getErrorString())); default: throw new LookupException(String.format("Error when looking up identifier '%s' in SML. DNS-Lookup-Err: %s", participantIdentifier.getIdentifier(), lookup.getErrorString())); }