/**
   * HAVE message notification handler.
   *
   * @param message the message
   * @ssdd
   */
  @Override
  public void haveMessageNotificationHandler(Core2CoreMessage message) {

    log.debug("haveMessageNotificationHandler: received messagefrom " + message.getFromCore());
    // =[" + message.getMessage()+ "]

    XmlObject xmlObj;
    try {

      EDXLDistributionDocument edxlDoc =
          EDXLDistributionDocument.Factory.parse(message.getMessage());

      if (edxlDoc.getEDXLDistribution().sizeOfExplicitAddressArray() > 0) {
        // Find core name for each explicit address.
        for (ValueSchemeType type : edxlDoc.getEDXLDistribution().getExplicitAddressArray()) {
          if (type.getExplicitAddressScheme()
              .equals(CommunicationsService.UICDSExplicitAddressScheme)) {
            for (String address : type.getExplicitAddressValueArray()) {
              xmlObj = XmlObject.Factory.parse(edxlDoc.toString());
              // log.debug("broadcastMessageNotificationHandler: sending notification ["
              // + xmlObj.toString() + "]  to " + address);
              sendMessageNotification(xmlObj, address);
            }
          }
        }
      }

    } catch (Throwable e) {
      log.error(
          "resourceMessageNotificationHandler: Error parsing message - not a valid XML string");
      throw new IllegalArgumentException("Message is not a valid XML string");
    }
  }
  private void sendEdxlDeMessage(EDXLDistribution edxl)
      throws IllegalArgumentException, EmptyCoreNameListException, SendMessageErrorException,
          LocalCoreNotOnlineException {

    HashSet<String> cores = BroadcastUtil.getCoreList(edxl);

    // Send the message to each core that has a user in an explictAddress
    // element
    if (cores.size() == 0) {
      return;
    } else {
      SendMessageErrorException errorException = new SendMessageErrorException();
      for (String core : cores) {
        try {
          log.info("sendMessage to: " + core);
          EDXLDistributionDocument doc = EDXLDistributionDocument.Factory.newInstance();
          doc.setEDXLDistribution(edxl);
          communicationsService.sendMessage(
              doc.xmlText(), CommunicationsService.CORE2CORE_MESSAGE_TYPE.RESOURCE_MESSAGE, core);
          log.debug("called communicationsService.sendMessage");
        } catch (RemoteCoreUnknownException e1) {
          errorException
              .getErrors()
              .put(core, SendMessageErrorException.SEND_MESSAGE_ERROR_TYPE.CORE_UNKNOWN);
        } catch (RemoteCoreUnavailableException e2) {
          errorException
              .getErrors()
              .put(core, SendMessageErrorException.SEND_MESSAGE_ERROR_TYPE.CORE_UNAVAILABLE);
        } catch (LocalCoreNotOnlineException e) {
          // TODO: this short circuit for the local core should be in the
          // CommunicationService
          log.info("Sending to local core");
          Core2CoreMessage message = new Core2CoreMessage();

          message.setFromCore(core);
          message.setToCore(core);
          message.setMessageType(
              CommunicationsService.CORE2CORE_MESSAGE_TYPE.RESOURCE_MESSAGE.toString());
          // Core2CoreMessageDocument doc =
          // Core2CoreMessageDocument.Factory.newInstance();
          // doc.addNewCore2CoreMessage().set(edxl);
          // message.setMessage(doc.toString());
          EDXLDistributionDocument doc = EDXLDistributionDocument.Factory.newInstance();
          doc.setEDXLDistribution(edxl);
          message.setMessage(doc.toString());
          haveMessageNotificationHandler(message);
          // communicationsService.core2CoreMessageNotificationHandler(message);
        } catch (NoShareAgreementException e) {
          errorException
              .getErrors()
              .put(core, SendMessageErrorException.SEND_MESSAGE_ERROR_TYPE.NO_SHARE_AGREEMENT);
        } catch (NoShareRuleInAgreementException e) {
          errorException
              .getErrors()
              .put(
                  core,
                  SendMessageErrorException.SEND_MESSAGE_ERROR_TYPE.NO_SHARE_RULE_IN_AGREEMENT);
        }
      }

      if (errorException.getErrors().size() > 0) {
        throw errorException;
      }
    }
  }