private FlexOfferRevocationResponse buildResponse(FlexOfferRevocation flexOfferRevocation) { FlexOfferRevocationResponse response = new FlexOfferRevocationResponse(); response.setSequence(flexOfferRevocation.getSequence()); MessageMetadata metadata = new MessageMetadataBuilder() .messageID() .timeStamp() .conversationID(flexOfferRevocation.getMessageMetadata().getConversationID()) .senderDomain(config.getProperty(ConfigParam.HOST_DOMAIN)) .senderRole(USEFRole.DSO) .recipientDomain(flexOfferRevocation.getMessageMetadata().getSenderDomain()) .recipientRole(flexOfferRevocation.getMessageMetadata().getSenderRole()) .precedence(ROUTINE) .build(); response.setMessageMetadata(metadata); return response; }
/** {@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); }