/** {@inheritDoc} */
  public void handleEvent(@Observes FlexOfferRevocationEvent event) {
    LOGGER.info(LOG_COORDINATOR_START_HANDLING_EVENT, event);
    FlexOfferRevocation flexOfferRevocation = event.getFlexOfferRevocation();

    DispositionAcceptedRejected responseResult = DispositionAcceptedRejected.ACCEPTED;
    String responseResultMessage = "Flex Offer has been revoked.";

    List<PlanboardMessage> flexOfferMessages = null;

    try {
      long flexOfferSequence = flexOfferRevocation.getSequence();
      String senderDomain = flexOfferRevocation.getMessageMetadata().getSenderDomain();

      // Retrieving related flex offer details.
      Map<Integer, PtuFlexOffer> flexOffers =
          planboardBusinessService.findPtuFlexOffer(flexOfferSequence, senderDomain);

      // Checking whether flex offers exist
      planboardValidatorService.checkRelatedFlexOffersExist(flexOfferRevocation, flexOffers);

      // Retrieving related plan board messages
      flexOfferMessages =
          planboardBusinessService.findPlanboardMessages(
              flexOfferSequence, DocumentType.FLEX_OFFER, senderDomain);

      validateIfOrdered(flexOfferSequence, senderDomain);

      // Checking whether plan board messages exist
      planboardValidatorService.checkRelatedPlanboardMessagesExist(
          flexOfferRevocation, flexOfferMessages);

      // Checking that no flex offer has a PTU in the operate or later phase.
      // Making sure that all PTUs are not in the operate or later phase we make sure that all PTUs
      // are in the future
      planboardValidatorService.checkPtuPhase(flexOfferRevocation, flexOffers);
    } catch (BusinessValidationException e) {
      LOGGER.warn("Validation error for a flex offer: " + e.getMessage(), e);
      responseResult = DispositionAcceptedRejected.REJECTED;
      responseResultMessage = e.getMessage();
    }

    // Setting the status REVOKED
    if (responseResult == DispositionAcceptedRejected.ACCEPTED) {
      setPlanboardMessageStatus(flexOfferMessages);
    }

    // Sending the response
    FlexOfferRevocationResponse response = buildResponse(flexOfferRevocation);
    response.setResult(responseResult);
    response.setMessage(responseResultMessage);
    jmsHelperService.sendMessageToOutQueue(XMLUtil.messageObjectToXml(response));
    LOGGER.info(LOG_COORDINATOR_FINISHED_HANDLING_EVENT, event);
  }
コード例 #2
0
 private void putMessageIntoOutgoingQueue(PrognosisResponse xmlObject) {
   String xml = XMLUtil.messageObjectToXml(xmlObject);
   jmsHelperService.sendMessageToOutQueue(xml);
 }