/**
  * Constructs the URL used to obtain meta data for a given document type identifier of a given
  * participant identifier.
  */
 URL constructDocumentTypeURL(
     ParticipantId participantId, PeppolDocumentTypeId documentTypeIdentifier) {
   String scheme = ParticipantId.getScheme();
   String value = participantId.stringValue();
   String hostname = null;
   String urlString = null;
   try {
     hostname = "B-" + Util.calculateMD5(value.toLowerCase()) + "." + scheme + "." + smlHost;
     String encodedParticipant = URLEncoder.encode(scheme + "::" + value, "UTF-8");
     String encodedDocumentId =
         URLEncoder.encode(
             PeppolDocumentTypeIdAcronym.getScheme() + "::" + documentTypeIdentifier.toString(),
             "UTF-8");
     urlString =
         "http://" + hostname + "/" + encodedParticipant + "/services/" + encodedDocumentId;
     return new URL(urlString);
   } catch (MessageDigestException e) {
     throw new IllegalStateException(
         "Unable to calculate message digest for: "
             + participantId
             + ", doc.type:"
             + documentTypeIdentifier,
         e);
   } catch (UnsupportedEncodingException e) {
     throw new IllegalStateException("Unable to encode _" + scheme + "::" + value, e);
   } catch (MalformedURLException e) {
     throw new IllegalArgumentException("Unable to create URL from string:" + urlString, e);
   }
 }
 /**
  * Constructs the URL used to look up all the service groups for a given participant identifier.
  *
  * @param participantId participant for which we should perform the lookup
  * @return URL instance, which can be used to obtain service groups
  * @throws SmpLookupException
  */
 URL constructServiceGroupURL(ParticipantId participantId) throws SmpLookupException {
   String scheme = ParticipantId.getScheme();
   String value = participantId.stringValue();
   try {
     String hostname =
         "B-" + Util.calculateMD5(value.toLowerCase()) + "." + scheme + "." + smlHost;
     // Example: iso6523-actorid-upis%3A%3A9908:810017902
     String encodedParticipant = URLEncoder.encode(scheme + "::", "UTF-8") + value;
     return new URL("http://" + hostname + "/" + encodedParticipant);
   } catch (Exception e) {
     throw new SmpLookupException(participantId, e);
   }
 }