| 419 | | end |
|---|
| 420 | | |
|---|
| 421 | | ############################################################ |
|---|
| 422 | | ############################################################ |
|---|
| 423 | | ####### BUSINESS LOGIC ###### |
|---|
| 424 | | ############################################################ |
|---|
| 425 | | ############################################################ |
|---|
| 426 | | |
|---|
| 427 | | # This method executes on the commands |
|---|
| 428 | | # Must return a true in case some code did deal with the command. |
|---|
| 429 | | def process_command_with_transaction transaction, command, command_hash |
|---|
| 430 | | @logger.debug "Transaction state: #{transaction.get_current_state_name}" |
|---|
| 431 | | |
|---|
| 432 | | if command == 'new directive' then |
|---|
| 433 | | @logger.debug "Received new directive!" |
|---|
| 434 | | if !transaction.open_and_new? then |
|---|
| 435 | | @logger.warn "A transaction must be new and open for command '#{command}'." |
|---|
| 436 | | return false |
|---|
| 437 | | else |
|---|
| 438 | | result = process_new_directive command, command_hash, transaction |
|---|
| 439 | | @logger.debug "Processed directive." |
|---|
| 440 | | |
|---|
| 441 | | # if there is a tasker to be started for digital signature then |
|---|
| 442 | | # the result variable will hold the command to start that |
|---|
| 443 | | # tasker |
|---|
| 444 | | if result.class == TrueClass or result.class == FalseClass then |
|---|
| 445 | | if result == true |
|---|
| 446 | | @logger.debug "Successfully processed new directive." |
|---|
| 447 | | |
|---|
| 448 | | @logger.debug "Its time to deliver the ebXML message." |
|---|
| 449 | | command, expectation = start_delivery( transaction, command_hash['b2b_system_name'] ) |
|---|
| 450 | | if command.nil? then |
|---|
| 451 | | @logger.warn "Unable to proceed with start delivery." |
|---|
| 452 | | transaction.fail "Error starting delivery." |
|---|
| 453 | | return true |
|---|
| 454 | | else |
|---|
| 455 | | transaction.set_next_expectation(expectation) |
|---|
| 456 | | say_to_ania command |
|---|
| 457 | | return true |
|---|
| 458 | | end |
|---|
| 459 | | elsif result == false then |
|---|
| 460 | | msg = "Problems processing new directive. Check the logs." |
|---|
| 461 | | @logger.debug msg |
|---|
| 462 | | transaction.fail msg |
|---|
| 463 | | return true |
|---|
| 464 | | end |
|---|
| 465 | | elsif result.class == String then |
|---|
| 466 | | @logger.debug "Successfully processed new directive and a tasker must be started." |
|---|
| 467 | | say_to_ania result |
|---|
| 468 | | else |
|---|
| 469 | | @logger.warn "Problems processing new directive: #{result}" |
|---|
| 470 | | # ??? what TODO? |
|---|
| 471 | | return false |
|---|
| 472 | | end |
|---|
| 473 | | end |
|---|
| 474 | | elsif command == 'sign ebXML message done' then |
|---|
| 475 | | @logger.debug "Received signing ebXML message is done." |
|---|
| 476 | | transaction.transition_to_new_state "sign ebXML message done" |
|---|
| 477 | | if ((encryption = true) == true) then |
|---|
| 478 | | @logger.debug "ebXML message must be encrypted. Starting encrpytion tasker" |
|---|
| 479 | | |
|---|
| 480 | | metadata = {'complete_ebXML_message_file_path' => command_hash['ebXML_message_file_path'], |
|---|
| 481 | | 'complete_ebXML_message_parameters_file_path' => command_hash['ebXML_message_parameters_file_path']} |
|---|
| 482 | | |
|---|
| 483 | | command, expectation = start_an_encrypting_tasker metadata, transaction.transaction_id, command_hash['b2b_system_name'] |
|---|
| 484 | | if command.nil? then |
|---|
| 485 | | @logger.warn "Unable to proceed with start deliervy." |
|---|
| 486 | | transaction.fail "Error starting delivery" |
|---|
| 487 | | return true |
|---|
| 488 | | else |
|---|
| 489 | | # SET EXPECTED NEW STATE |
|---|
| 490 | | transaction.set_next_expectation(expectation) |
|---|
| 491 | | say_to_ania command |
|---|
| 492 | | return true |
|---|
| 493 | | end |
|---|
| 494 | | else |
|---|
| 495 | | @logger.debug "ebXML message must NOT be encrypted." |
|---|
| 496 | | end |
|---|
| 497 | | |
|---|
| 498 | | @logger.debug "Its time to deliver the ebXML message." |
|---|
| 499 | | command, expectation = start_delivery( transaction, command_hash['b2b_system_name'] ) |
|---|
| 500 | | if command.nil? then |
|---|
| 501 | | @logger.warn "Unable to proceed with start deliervy." |
|---|
| 502 | | transaction.fail "Error starting delivery" |
|---|
| 503 | | return true |
|---|
| 504 | | else |
|---|
| 505 | | # SET EXPECTED NEW STATE |
|---|
| 506 | | transaction.set_next_expectation(expectation) |
|---|
| 507 | | say_to_ania command |
|---|
| 508 | | return true |
|---|
| 509 | | end |
|---|
| 510 | | elsif command == 'encrypt ebXML message done' then |
|---|
| 511 | | @logger.debug "Received encrypt ebXML message is done." |
|---|
| 512 | | transaction.transition_to_new_state "encrypt ebXML message done" |
|---|
| 513 | | |
|---|
| 514 | | @logger.debug "Its time to deliver the ebXML message." |
|---|
| 515 | | command, expectation = start_delivery( transaction, command_hash['b2b_system_name'] ) |
|---|
| 516 | | if command.nil? then |
|---|
| 517 | | @logger.warn "Unable to proceed with start deliervy." |
|---|
| 518 | | transaction.fail "Error starting delivery" |
|---|
| 519 | | return true |
|---|
| 520 | | else |
|---|
| 521 | | # SET EXPECTED NEW STATE |
|---|
| 522 | | transaction.set_next_expectation(expectation) |
|---|
| 523 | | say_to_ania command |
|---|
| 524 | | return true |
|---|
| 525 | | end |
|---|
| 526 | | |
|---|
| 527 | | elsif command == 'start ebXML message delivery' then |
|---|
| 528 | | @logger.debug "Received start ebXML message delivery command." |
|---|
| 529 | | command, expectation = deliver_ebXML_message transaction, command, command_hash |
|---|
| 530 | | if command == false then |
|---|
| 531 | | msg = "It is not possible to start the delivery process." |
|---|
| 532 | | @logger.warn msg |
|---|
| 533 | | transaction.fail msg |
|---|
| 534 | | return false |
|---|
| 535 | | else |
|---|
| 536 | | @logger.debug "Start of delivery of ebXML message can start." |
|---|
| 537 | | transaction.set_next_expectation(expectation) |
|---|
| 538 | | say_to_ania command |
|---|
| 539 | | return true |
|---|
| 540 | | end |
|---|
| 541 | | |
|---|
| 542 | | elsif command == 'send ebXML message done' |
|---|
| 543 | | # called from the HTTP client |
|---|
| 544 | | @logger.debug "Send ebXML message done." |
|---|
| 545 | | # this does not yet mean that the message is delivered. This means that the ebXML message was sent off. |
|---|
| 546 | | # Things that can happen now are |
|---|
| 547 | | # o nothing |
|---|
| 548 | | # o synchronous or asynchronous ebXML error message for this ebXML message is received. |
|---|
| 549 | | # o an acknowledgment may be required for the ebXML message. |
|---|
| 550 | | success, comment = process_send_ebXML_message_response transaction, command, command_hash, "client" |
|---|
| 551 | | if command == false then |
|---|
| 552 | | msg = "It is not possible to process response of sending an ebXML message." |
|---|
| 553 | | @logger.warn msg + comment |
|---|
| 554 | | transaction.fail msg + comment |
|---|
| 555 | | return false |
|---|
| 556 | | else |
|---|
| 557 | | @logger.debug "Successfully processed response of sending an ebXML message." |
|---|
| 558 | | transaction.succeed comment |
|---|
| 559 | | return true |
|---|
| 560 | | end |
|---|
| 561 | | |
|---|
| 562 | | elsif command == 'send ebXML message response done' then |
|---|
| 563 | | # called from the HTTP server |
|---|
| 564 | | @logger.debug "sending response (could be empty) done." |
|---|
| 565 | | success, comment = process_send_ebXML_message_response transaction, command, command_hash, "server" |
|---|
| 566 | | if command == false then |
|---|
| 567 | | msg = "It is not possible to process response of sending an ebXML message." |
|---|
| 568 | | @logger.warn msg + comment |
|---|
| 569 | | transaction.fail msg + comment |
|---|
| 570 | | return false |
|---|
| 571 | | else |
|---|
| 572 | | @logger.debug "Successfully processed response of sending an ebXML message response." |
|---|
| 573 | | transaction.succeed "job done" |
|---|
| 574 | | return true |
|---|
| 575 | | end |
|---|
| 576 | | |
|---|
| 577 | | |
|---|
| 578 | | elsif command == 'new ebXML message received' then |
|---|
| 579 | | @logger.debug "Received new ebXML message!" |
|---|
| 580 | | if !transaction.open_and_new? then |
|---|
| 581 | | @logger.warn "A transaction must be new and open for a new ebXML message." |
|---|
| 582 | | return false |
|---|
| 583 | | else |
|---|
| 584 | | result = process_new_ebXML_message command, command_hash, transaction |
|---|
| 585 | | if result == false then |
|---|
| 586 | | @logger.error "Error processing incoming ebXML Message" |
|---|
| 587 | | transaction.fail "Failed to process ebXML message." if transaction.is_open? |
|---|
| 588 | | return false |
|---|
| 589 | | else |
|---|
| 590 | | return true |
|---|
| 591 | | end |
|---|
| 592 | | end |
|---|
| 593 | | else |
|---|
| 594 | | @logger.warn "I dont know what the fuck to do with this '#{command}' command." |
|---|
| 595 | | end |
|---|
| 596 | | |
|---|
| 597 | | # if transaction still open and noone processed it ....... I may have to close it. |
|---|
| 598 | | |
|---|
| 599 | | end |
|---|
| 600 | | |
|---|
| 601 | | def get_ebMS_info ebXML_message_id, b2b_system_name |
|---|
| 602 | | ebXML_message_parameters_file_path = "#{@config['MESSAGE_DIR']}/#{b2b_system_name}/#{ebXML_message_id}/ebXML_message_parameters.yml" |
|---|
| 603 | | return read_ebXML_message_info( ebXML_message_parameters_file_path ) |
|---|
| 604 | | end |
|---|
| 605 | | |
|---|
| 606 | | def store_ebMS_info ebMS_info, b2b_system_name |
|---|
| 607 | | path = "#{@config['MESSAGE_DIR']}/#{b2b_system_name}/#{ebMS_info['ebXML_message']['ebXML_message_id']}/ebXML_message_parameters.yml" |
|---|
| 608 | | file = File.new(path, "w") |
|---|
| 609 | | YAML.dump ebMS_info, file |
|---|
| 610 | | file.close |
|---|
| 611 | | return true |
|---|
| 612 | | end |
|---|
| 613 | | |
|---|
| 614 | | def read_ebXML_message_info ebXML_message_parameters_file_path |
|---|
| 615 | | if (FileTest.exists?(ebXML_message_parameters_file_path) && FileTest.readable?(ebXML_message_parameters_file_path)) then |
|---|
| 616 | | return YAML.load(File.open(ebXML_message_parameters_file_path)) |
|---|
| 617 | | else |
|---|
| 618 | | return nil |
|---|
| 619 | | end |
|---|
| 620 | | end |
|---|
| 621 | | |
|---|
| 622 | | =begin |
|---|
| 623 | | def get_delivery_info ebMS_info |
|---|
| 624 | | ebMS_delivery_info = get_delivery_info ebMS_info |
|---|
| 625 | | if ebMS_info['delivery'].nil? then |
|---|
| 626 | | dev = ebMS_info['delivery'] = Hash.new |
|---|
| 627 | | dev['delivery_process_started'] = Time.now.to_s |
|---|
| 628 | | tries = dev['delivery_tries'] = Array.new |
|---|
| 629 | | tries[0] = Time.now.to_s |
|---|
| 630 | | else |
|---|
| 631 | | ebMS_info['delivery']['delivery_tries'] << Time.now.to_s |
|---|
| 632 | | end |
|---|
| 633 | | end |
|---|
| 634 | | =end |
|---|
| 635 | | |
|---|
| 636 | | def deliver_ebXML_message transaction, command, command_hash |
|---|
| 637 | | @logger.debug "Starting ebXML message delivery process." |
|---|
| 638 | | transaction.transition_to_new_state command |
|---|
| 639 | | b2b_system_name = command_hash['b2b_system_name'] |
|---|
| 640 | | ebXML_message_id = transaction.get_ebXML_message_reference |
|---|
| 641 | | if ebXML_message_id.nil? then |
|---|
| 642 | | @logger.debug "Unable to get ebXML message reference from transaction with id '#{transaction.transaction_id}'." |
|---|
| 643 | | return false |
|---|
| 644 | | end |
|---|
| 645 | | @logger.debug "Start of delivery of ebXML message with id: #{ebXML_message_id}" |
|---|
| 646 | | ebMS_info = get_ebMS_info ebXML_message_id, b2b_system_name |
|---|
| 647 | | if ebMS_info.nil? then |
|---|
| 648 | | @logger.warn "Problems gettig the ebXML Message Info structure from the message data store for ebXML message with id #{ebXML_message_id}" |
|---|
| 649 | | return false |
|---|
| 650 | | end |
|---|
| 651 | | @logger.debug "Successfully read the ebXML message info structure for ebXML message with id #{ebXML_message_id}." |
|---|
| 652 | | |
|---|
| 653 | | # # adding delivery informationn to the ebMS_info |
|---|
| 654 | | delivery = ebMS_info['delivery'] = Hash.new |
|---|
| 655 | | delivery['start delivery'] = Time.now.to_s |
|---|
| 656 | | store_ebMS_info ebMS_info, b2b_system_name |
|---|
| 657 | | |
|---|
| 658 | | ebXML_message_file_path = "#{@config['MESSAGE_DIR']}/#{b2b_system_name}/#{ebMS_info['ebXML_message']['ebXML_message_id']}/ebXML_message.ebMS2" |
|---|
| 659 | | ebXML_message_parameters_file_path = "#{@config['MESSAGE_DIR']}/#{b2b_system_name}/#{ebMS_info['ebXML_message']['ebXML_message_id']}/ebXML_message_parameters.yml" |
|---|
| 660 | | |
|---|
| 661 | | #call tasker to send ebXML message |
|---|
| 662 | | # SEND ebXML MESSAGE |
|---|
| 663 | | # ------------------ |
|---|
| 664 | | expectation = "send_ebXML_message_done" |
|---|
| 665 | | command_hash = { |
|---|
| 666 | | "from" => "big_ania", |
|---|
| 667 | | "to" => "ania", |
|---|
| 668 | | "command" => "start_tasker", |
|---|
| 669 | | "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_send_ebXML_message.rb", |
|---|
| 670 | | "tasker arguments" => "--b2b-system-name #{b2b_system_name} --pipe-to-ania #{@config['PIPE_TO_ANIA']} --config #{@config['CONFIG_DIR']}/hefeweizen.conf --ebXML-message-file-path #{ebXML_message_file_path} --parameters-file-path #{ebXML_message_parameters_file_path} --transaction-id #{transaction.transaction_id} --state-expectation #{expectation}", |
|---|
| 671 | | "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid |
|---|
| 672 | | } |
|---|
| 673 | | |
|---|
| 674 | | return HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command(command_hash), expectation |
|---|
| 675 | | end |
|---|
| 676 | | |
|---|
| 677 | | def delivery_ack_requested? ebMS_info |
|---|
| 678 | | (ebMS_info['info']['mc-ackRequested'] == 'always' or ( ebMS_info['info']['mc-ackRequested'] == 'perMessage' and !ebMS_info['directive']['ackRequested'].nil? ) ) ? true : false |
|---|
| 679 | | end |
|---|
| 680 | | |
|---|
| 681 | | def delivery_reliable_messaging_requested? ebMS_info |
|---|
| 682 | | delivery_ack_requested? ebMS_info |
|---|
| 683 | | end |
|---|
| 684 | | |
|---|
| 685 | | # This method starts the delivery of an ebXML message. |
|---|
| 686 | | def start_delivery transaction, b2b_system_name |
|---|
| 687 | | @logger.debug "Starting the delivery process." |
|---|
| 688 | | |
|---|
| 689 | | expectation = "start_ebXML_message_delivery" |
|---|
| 690 | | command_hash = { |
|---|
| 691 | | "from" => "big_ania", |
|---|
| 692 | | "to" => "big ania", |
|---|
| 693 | | "b2b_system_name" => b2b_system_name, |
|---|
| 694 | | "command" => "start ebXML message delivery", |
|---|
| 695 | | "transaction_id" => transaction.transaction_id, |
|---|
| 696 | | "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid |
|---|
| 697 | | } |
|---|
| 698 | | |
|---|
| 699 | | command = "#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}" |
|---|
| 700 | | return command, expectation |
|---|
| 701 | | end |
|---|
| 702 | | |
|---|
| 703 | | # This meesage processes the response of sending an ebXML message. |
|---|
| 704 | | # o when the message was sent via SMTP then there is no info here. |
|---|
| 705 | | # o when the message was sent via HTTP and there was no sync response then there is no info here. |
|---|
| 706 | | # o when the message was sent via HTPT and there was a sync response then we have to process the response. |
|---|
| 707 | | def process_send_ebXML_message_response transaction, command, command_hash, server_or_client |
|---|
| 708 | | @logger.debug "sending of ebXML message done. confirmation of '#{command_hash['transport_protocol']}' client." if server_or_client == "client" |
|---|
| 709 | | @logger.debug "sending of ebXML message done. confirmation of '#{command_hash['transport_protocol']}' server." if server_or_client == "server" |
|---|
| 710 | | |
|---|
| 711 | | transaction.transition_to_new_state "ebXML message sent and processing response if any." if server_or_client == "client" |
|---|
| 712 | | transaction.transition_to_new_state "response message sent." if server_or_client == "server" |
|---|
| 713 | | |
|---|
| 714 | | transaction.attach_file command_hash['transfer_info_path'], "transfer information" if command_hash['transfer_info_path'] |
|---|
| 715 | | transaction.remember_file_to_remove command_hash['transfer_info_path'] if command_hash['transfer_info_path'] |
|---|
| 716 | | transaction.attach_file command_hash['response_file_path'], "outgoing ebXML message response" if command_hash['response_file_path'] |
|---|
| 717 | | transaction.remember_file_to_remove command_hash['response_file_path'] if command_hash['response_file_path'] |
|---|
| 718 | | |
|---|
| 719 | | b2b_system = @b2b_systems[command_hash['b2b_system_name']] |
|---|
| 720 | | if b2b_system.nil? then |
|---|
| 721 | | @logger.warn "There is no B2B system with the name #{command_hash['b2b_system_name']}." |
|---|
| 722 | | return false |
|---|
| 723 | | end |
|---|
| 724 | | |
|---|
| 725 | | if command_hash['status'].upcase == "OK" then |
|---|
| 726 | | @logger.debug "Received Success OK from the ebXML message sending client tasker." if server_or_client == "client" |
|---|
| 727 | | @logger.debug "Received Success OK from the sending response (ebXML message or simply closing) server tasker." if server_or_client == "server" |
|---|
| 728 | | |
|---|
| 729 | | # --------------------------- |
|---|
| 730 | | # set new ebXML message state |
|---|
| 731 | | # --------------------------- |
|---|
| 732 | | b2b_system.set_ebXML_message_state command_hash['ebXML_message_id'], "sent" if server_or_client == "client" |
|---|
| 733 | | |
|---|
| 734 | | else |
|---|
| 735 | | msg = "Received a FAILURE as status from the ebXML message sending tasker." if server_or_client == 'client' |
|---|
| 736 | | msg = "Received a FAILURE as status from the ebXML message server tasker." if server_or_client == 'server' |
|---|
| 737 | | @logger.warn msg |
|---|
| 738 | | |
|---|
| 739 | | # --------------------------- |
|---|
| 740 | | # set new ebXML message state |
|---|
| 741 | | # --------------------------- |
|---|
| 742 | | b2b_system.set_ebXML_message_state command_hash['ebXML_message_id'], "failed_to_send" |
|---|
| 743 | | |
|---|
| 744 | | # ----------------------------- |
|---|
| 745 | | # set final ebXML message state |
|---|
| 746 | | # ----------------------------- |
|---|
| 747 | | # TODO |
|---|
| 748 | | # -> reliable messaging retries! will set the final state of original messages. |
|---|
| 749 | | |
|---|
| 750 | | return false, msg |
|---|
| 751 | | end |
|---|
| 752 | | |
|---|
| 753 | | ######################################### |
|---|
| 754 | | ## TODO |
|---|
| 755 | | ## UGLY UGLY |
|---|
| 756 | | ######################################### |
|---|
| 757 | | |
|---|
| 758 | | # ----------------------------- |
|---|
| 759 | | # set final ebXML message state |
|---|
| 760 | | # ----------------------------- |
|---|
| 761 | | do_check = true |
|---|
| 762 | | if server_or_client == "server" then |
|---|
| 763 | | if command_hash['ebXML_message_id'].nil? then |
|---|
| 764 | | do_check = false |
|---|
| 765 | | end |
|---|
| 766 | | end |
|---|
| 767 | | |
|---|
| 768 | | if command_hash['ebXML_message_id'].nil? then |
|---|
| 769 | | do_check = false |
|---|
| 770 | | end |
|---|
| 771 | | |
|---|
| 772 | | if do_check == true then |
|---|
| 773 | | @logger.debug "Searching for the ebXML info content for ebXML message with id '#{command_hash['ebXML_message_id']}'." |
|---|
| 774 | | info = get_ebMS_info command_hash['ebXML_message_id'], command_hash['b2b_system_name'] |
|---|
| 775 | | # check if user message: |
|---|
| 776 | | if !info.nil? and !info['ebXML_message'].nil? and !info['ebXML_message']['ebXML_message_has_ack_requested'].nil? and |
|---|
| 777 | | info['ebXML_message']['ebXML_message_has_ack_requested'] == false then |
|---|
| 778 | | # we can set the message status to delivered. any error message will later fail it. |
|---|
| 779 | | b2b_system.set_ebXML_message_state command_hash['ebXML_message_id'], "delivered" |
|---|
| 780 | | end |
|---|
| 781 | | |
|---|
| 782 | | # b2b_system.set_ebXML_message_state command_hash['ref_ebXML_message_id'], "delivered" unless command_hash['ebXML_message_is_ack_for_message_id'].nil? |
|---|
| 783 | | # b2b_system.set_ebXML_message_state command_hash['ref_ebXML_message_id'], "failed" unless command_hash['ebXML_message_is_error_for_message_id'].nil? |
|---|
| 784 | | # b2b_system.set_ebXML_message_state command_hash['ref_ebXML_message_id'], "delivered" unless command_hash['ebXML_message_is_pong_for_message_id'].nil? |
|---|
| 785 | | |
|---|
| 786 | | end |
|---|
| 787 | | |
|---|
| 788 | | if command_hash['transport_protocol'].upcase == "SMTP" then |
|---|
| 789 | | @logger.debug "The SMTP transport protocol was used so no direct response (ebXML MS signal) possible." |
|---|
| 790 | | |
|---|
| 791 | | return true, "Successfully completed transaction." |
|---|
| 792 | | |
|---|
| 793 | | else |
|---|
| 794 | | |
|---|
| 795 | | # The server does not have a ebXML response possible. |
|---|
| 796 | | if server_or_client == 'server' then |
|---|
| 797 | | return true, "Success" |
|---|
| 798 | | end |
|---|
| 799 | | |
|---|
| 800 | | transfer_info_file = command_hash['transfer_info_path'] |
|---|
| 801 | | response_file = command_hash['response_file_path'] |
|---|
| 802 | | |
|---|
| 803 | | has_content = true |
|---|
| 804 | | if FileTest.exists? transfer_info_file and FileTest.readable? transfer_info_file then |
|---|
| 805 | | transfer_info = File.read transfer_info_file |
|---|
| 806 | | transfer_info.each_line{ | line | |
|---|
| 807 | | if line =~ /.*HTTP\/1\.1 204 No Content/ then |
|---|
| 808 | | has_content = false |
|---|
| 809 | | break |
|---|
| 810 | | end |
|---|
| 811 | | } |
|---|
| 812 | | |
|---|
| 813 | | if has_content == false then |
|---|
| 814 | | if FileTest.exists? response_file and !FileTest.zero? response_file then |
|---|
| 815 | | @logger.warn "HTTP response indicates that there is no content (response code 204) but the response file exists and is not empty." |
|---|
| 816 | | @logger.debug "Continuing with processing response file." |
|---|
| 817 | | result = process_new_ebXML_message command, command_hash, transaction |
|---|
| 818 | | if result == false then |
|---|
| 819 | | msg = "Error processing response from sending an ebXML Message." |
|---|
| 820 | | @logger.warn msg |
|---|
| 821 | | return false, msg |
|---|
| 822 | | end |
|---|
| 823 | | return true, "Succesfully processed response ebXML message." |
|---|
| 824 | | else |
|---|
| 825 | | @logger.debug 'There was no response from sending ebXML message.' |
|---|
| 826 | | # TODO validate if that is OK. |
|---|
| 827 | | return true, "I ASSUME THIS EBXML MESSAGE IS OK." |
|---|
| 828 | | end |
|---|
| 829 | | |
|---|
| 830 | | elsif has_content == true then |
|---|
| 831 | | if FileTest.exists? response_file and FileTest.zero? response_file then |
|---|
| 832 | | msg = "HTTP response indicates that there is content but the response file is empty." |
|---|
| 833 | | @logger.warn msg |
|---|
| 834 | | @logger.debug "Failing transaction" |
|---|
| 835 | | return false, msg |
|---|
| 836 | | else |
|---|
| 837 | | @logger.debug "Processing response from sending ebXML message." |
|---|
| 838 | | result = process_new_ebXML_message command, command_hash, transaction |
|---|
| 839 | | if result == false then |
|---|
| 840 | | msg = "Error processing response from sending an ebXML Message." |
|---|
| 841 | | @logger.warn msg |
|---|
| 842 | | return false, msg |
|---|
| 843 | | end |
|---|
| 844 | | return true, "Succesfully processed response ebXML message." |
|---|
| 845 | | end |
|---|
| 846 | | end |
|---|
| 847 | | |
|---|
| 848 | | else |
|---|
| 849 | | msg = "Unable to read transfer log of HTTP ebXML sending tasker to determine if there is a response." |
|---|
| 850 | | @logger.warn msg |
|---|
| 851 | | return false, msg |
|---|
| 852 | | end |
|---|
| 853 | | |
|---|
| 854 | | |
|---|
| 855 | | end |
|---|
| 856 | | |
|---|
| 857 | | end |
|---|
| 858 | | |
|---|
| 859 | | |
|---|
| 860 | | # This method processes a new directive. |
|---|
| 861 | | # This method will forward the request to process the directive |
|---|
| 862 | | # to the the b2b_system. If the b2b system could process the directive |
|---|
| 863 | | # then this method updates the transaction to know about the new ebXML message |
|---|
| 864 | | # and ebXML message info. |
|---|
| 865 | | def process_new_directive command, command_hash, transaction |
|---|
| 866 | | |
|---|
| 867 | | b2b_system = @b2b_systems[command_hash['b2b_system_name']] |
|---|
| 868 | | if b2b_system.nil? then |
|---|
| 869 | | @logger.warn "There is no B2B system with the name #{command_hash['b2b_system_name']}." |
|---|
| 870 | | return false |
|---|
| 871 | | end |
|---|
| 872 | | |
|---|
| 873 | | begin |
|---|
| 874 | | directive = HefeWeizen::HefeWeizenLibrary::HefeWeizenDirective.new(@config, command_hash['file']) |
|---|
| 875 | | rescue Exception => e |
|---|
| 876 | | |
|---|
| 877 | | @logger.warn "Unable to process Directive: #{e.to_s}" |
|---|
| 878 | | target_directory = b2b_system.get_error_directory |
|---|
| 879 | | success = HefeWeizen::HefeWeizenLibrary::HefeWeizenDirective.create_error_directive_and_save target_directory, "HefeWeizen system is unable to process a directive.", e.to_s, command_hash['file'] |
|---|
| 880 | | if success == false then |
|---|
| 881 | | @logger.error "Unable to create and store Error Directive" |
|---|
| 882 | | end |
|---|
| 883 | | transaction.close_transaction("failed", "Unable to process directive") |
|---|
| 884 | | return false |
|---|
| 885 | | end |
|---|
| 886 | | |
|---|
| 887 | | # @logger.debug "Directive successfully read" |
|---|
| 888 | | # directive.print_directive_tags |
|---|
| 889 | | # @logger.debug "The directive is a ebMS signal: #{directive.is_a_ebMS_signal?.to_s}" |
|---|
| 890 | | |
|---|
| 891 | | # This is a new transaction so we have to set the root cause of this new transaction. |
|---|
| 892 | | if !transaction.set_root_cause directive then |
|---|
| 893 | | @logger.error "Unable to store the directive as root cause to the new transaction" |
|---|
| 894 | | return false |
|---|
| 895 | | else |
|---|
| 896 | | @logger.debug "Succesfully stored the directive as root cause" |
|---|
| 897 | | end |
|---|
| 898 | | |
|---|
| 899 | | # TODO have a better validate! |
|---|
| 900 | | if !b2b_system.supports_directive? directive then |
|---|
| 901 | | @logger.warn "B2BSystem #{b2b_system.system_name} does not support the directive." |
|---|
| 902 | | return false |
|---|
| 903 | | end |
|---|
| 904 | | |
|---|
| 905 | | begin |
|---|
| 906 | | # this creates a plain ebXML message |
|---|
| 907 | | ebMS_info = b2b_system.process_directive directive |
|---|
| 908 | | rescue Exception => e |
|---|
| 909 | | @logger.warn "B2BSystem #{b2b_system.system_name} is unable to create an ebXML message: #{e.to_s}; #{e.backtrace}" |
|---|
| 910 | | return false |
|---|
| 911 | | end |
|---|
| 912 | | |
|---|
| 913 | | add_ebXML_message_info_to_transaction transaction, b2b_system.system_name, ebMS_info |
|---|
| 914 | | |
|---|
| 915 | | transaction.transition_to_new_state "directive processed." |
|---|
| 916 | | |
|---|
| 917 | | # Continue with processing |
|---|
| 918 | | |
|---|
| 919 | | # signing first |
|---|
| 920 | | if ((signing = false) == true) then |
|---|
| 921 | | @logger.debug "ebXML message must be signed. Starting a signer tasker" |
|---|
| 922 | | command, expectation = start_a_signing_tasker metadata, transaction.transaction_id, b2b_system.system_name |
|---|
| 923 | | # SET EXPECTED NEW STATE |
|---|
| 924 | | transaction.set_next_expectation(expectation) |
|---|
| 925 | | return command |
|---|
| 926 | | else |
|---|
| 927 | | @logger.debug "ebXML message must NOT be signed." |
|---|
| 928 | | end |
|---|
| 929 | | |
|---|
| 930 | | # very interesting ... if the above code thinks the ebXML message must be signed then |
|---|
| 931 | | # this code will never be called. only in the case the ebXML message must not be signed then |
|---|
| 932 | | # this code will be called. |
|---|
| 933 | | if ((encryption = false) == true) then |
|---|
| 934 | | @logger.debug "ebXML message must be encrypted. Starting an encrypting tasker" |
|---|
| 935 | | command, expectation = start_an_encrypting_tasker metadata, transaction.transaction_id, b2b_system.system_name |
|---|
| 936 | | # SET EXPECTED NEW STATE |
|---|
| 937 | | transaction.set_next_expectation(expectation) |
|---|
| 938 | | return command |
|---|
| 939 | | else |
|---|
| 940 | | @logger.debug "ebXML message must NOT be encrypted." |
|---|
| 941 | | end |
|---|
| 942 | | |
|---|
| 943 | | return true |
|---|
| 944 | | end |
|---|
| 945 | | |
|---|
| 946 | | |
|---|
| 947 | | |
|---|
| 948 | | # Add the information of an ebXML message to a transaction. |
|---|
| 949 | | def add_ebXML_message_info_to_transaction transaction, b2b_system_name, ebMS_info |
|---|
| 950 | | @logger.debug "Adding ebXML message information to transaction" |
|---|
| 951 | | path = "#{@config['MESSAGE_DIR']}/#{b2b_system_name}/#{ebMS_info['ebXML_message']['ebXML_message_id']}" |
|---|
| 952 | | complete_ebXML_message_file_path = "#{path}/ebXML_message.ebMS2" |
|---|
| 953 | | complete_ebXML_message_parameters_file_path = "#{path}/ebXML_message_parameters.yml" |
|---|
| 954 | | |
|---|
| 955 | | transaction.attach_file complete_ebXML_message_file_path, "outgoing ebXML message" |
|---|
| 956 | | transaction.attach_file complete_ebXML_message_parameters_file_path, "outgoing ebXML message parameters" |
|---|
| 957 | | |
|---|
| 958 | | # attach the ebXML message to the transaction |
|---|
| 959 | | @logger.debug "Setting ebXML message id '#{ebMS_info['ebXML_message']['ebXML_message_id']}' to transaction." |
|---|
| 960 | | transaction.add_ebXML_message_id_reference ebMS_info['ebXML_message']['ebXML_message_id'] |
|---|
| 961 | | |
|---|
| 962 | | return true |
|---|
| 963 | | end |
|---|
| 964 | | |
|---|
| 965 | | def start_a_signing_tasker metadata, transaction_id, b2b_system_name |
|---|
| 966 | | expectation = "signed_ebXML_message_done" |
|---|
| 967 | | command_hash = { |
|---|
| 968 | | "from" => "big_ania", |
|---|
| 969 | | "to" => "ania", |
|---|
| 970 | | "command" => "start_tasker", |
|---|
| 971 | | "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_sign_ebXML_message.rb", |
|---|
| 972 | | "tasker arguments" => "--b2b-system-name #{b2b_system_name} --pipe-to-ania #{@config['PIPE_TO_ANIA']} --config #{@config['CONFIG_DIR']}/hefeweizen.conf --ebXML-message-file-path #{metadata['complete_ebXML_message_file_path']} --parameters-file-path #{metadata['complete_ebXML_message_parameters_file_path']} --transaction-id #{transaction_id} --state-expectation #{expectation}", |
|---|
| 973 | | "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid |
|---|
| 974 | | } |
|---|
| 975 | | @logger.debug "Call tasker to send ebXML message." |
|---|
| 976 | | command = "#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}" |
|---|
| 977 | | |
|---|
| 978 | | return command, expectation |
|---|
| 979 | | |
|---|
| 980 | | end |
|---|
| 981 | | |
|---|
| 982 | | def start_an_encrypting_tasker metadata, transaction_id, b2b_system_name |
|---|
| 983 | | expectation = "encrypt_ebXML_message_done" |
|---|
| 984 | | command_hash = { |
|---|
| 985 | | "from" => "big_ania", |
|---|
| 986 | | "to" => "ania", |
|---|
| 987 | | "command" => "start_tasker", |
|---|
| 988 | | "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_encrypt_ebXML_message.rb", |
|---|
| 989 | | "tasker arguments" => "--b2b-system-name #{b2b_system_name} --pipe-to-ania #{@config['PIPE_TO_ANIA']} --config #{@config['CONFIG_DIR']}/hefeweizen.conf --ebXML-message-file-path #{metadata['complete_ebXML_message_file_path']} --parameters-file-path #{metadata['complete_ebXML_message_parameters_file_path']} --transaction-id #{transaction_id} --state-expectation #{expectation}", |
|---|
| 990 | | "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid |
|---|
| 991 | | } |
|---|
| 992 | | @logger.debug "Call tasker to send ebXML message." |
|---|
| 993 | | command = "#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}" |
|---|
| 994 | | |
|---|
| 995 | | return command, expectation |
|---|
| 996 | | |
|---|
| 997 | | end |
|---|
| 998 | | |
|---|
| 999 | | # This method receives an ebXML message and starts to process it. |
|---|
| 1000 | | def process_new_ebXML_message command, command_hash, transaction |
|---|
| 1001 | | @logger.debug "Reading received ebXML message." |
|---|
| 1002 | | |
|---|
| 1003 | | # depends whether this is received on server or is a response from a client. |
|---|
| 1004 | | if command_hash['file_full'] then |
|---|
| 1005 | | @logger.debug "This ebXML message seems to be received by an server" |
|---|
| 1006 | | # setting root cause of this new transaction. |
|---|
| 1007 | | transaction.set_root_cause command_hash['file_full'] |
|---|
| 1008 | | |
|---|
| 1009 | | # DUPLICATE! ok for now. -> add link_to in transaction class |
|---|
| 1010 | | transaction.attach_file command_hash['file_full'], "incoming ebXML message" |
|---|
| 1011 | | |
|---|
| 1012 | | transaction.remember_file_to_remove [command_hash['file_full'], command_hash['file_body'], command_hash['file_header']] |
|---|
| 1013 | | else |
|---|
| 1014 | | @logger.debug "This ebXML message seems to be received by an client" |
|---|
| 1015 | | # setting root cause of this new transaction. |
|---|
| 1016 | | transaction.set_root_cause command_hash['response_file_path'] |
|---|
| 1017 | | |
|---|
| 1018 | | # DUPLICATE! ok for now. -> add link_to in transaction class |
|---|
| 1019 | | transaction.attach_file command_hash['response_file_path'], "incoming ebXML message response" |
|---|
| 1020 | | |
|---|
| 1021 | | transaction.remember_file_to_remove command_hash['response_file_path'] |
|---|
| 1022 | | end |
|---|
| 1023 | | |
|---|
| 1024 | | b2b_system = @b2b_systems[command_hash['b2b_system_name']] |
|---|
| 1025 | | if b2b_system.nil? then |
|---|
| 1026 | | @logger.warn "There is no B2B system with the name #{command_hash['b2b_system_name']}." |
|---|
| 1027 | | return false |
|---|
| 1028 | | end |
|---|
| 1029 | | |
|---|
| 1030 | | @logger.debug "Creating an ebXML message object from the received ebXML message." |
|---|
| 1031 | | # this parses the incoming message and creates an ebXML message object |
|---|
| 1032 | | # this includes to validate the ebXML message against the CPA. |
|---|
| 1033 | | ebXML_message_object, ebMS_info, validation_errors = b2b_system.create_and_process_incoming_ebXML_message command_hash |
|---|
| 1034 | | if ebXML_message_object.nil? then |
|---|
| 1035 | | @logger.warn "Error creating an ebXML object from the ebXML message from file #{command_hash['file_full']}." |
|---|
| 1036 | | return false |
|---|
| 1037 | | end |
|---|
| 1038 | | |
|---|
| 1039 | | # Some transaction stuff |
|---|
| 1040 | | path = "#{@config['MESSAGE_DIR']}/#{b2b_system.system_name}/#{ebMS_info['ebXML_message']['ebXML_message_id']}" |
|---|
| 1041 | | complete_ebXML_message_file_path = "#{path}/ebXML_message.ebMS2" |
|---|
| 1042 | | complete_ebXML_message_parameters_file_path = "#{path}/ebXML_message_parameters.yml" |
|---|
| 1043 | | |
|---|
| 1044 | | transaction.attach_file complete_ebXML_message_file_path, "incoming ebXML message" |
|---|
| 1045 | | transaction.attach_file complete_ebXML_message_parameters_file_path, "incoming ebXML message parameters" |
|---|
| 1046 | | |
|---|
| 1047 | | # attach the ebXML message to the transaction |
|---|
| 1048 | | transaction.transition_to_new_state "plain incoming ebXML message created." |
|---|
| 1049 | | @logger.debug "Setting ebXML message id '#{ebMS_info['ebXML_message']['ebXML_message_id']}' to transaction." |
|---|
| 1050 | | transaction.add_ebXML_message_id_reference ebMS_info['ebXML_message']['ebXML_message_id'] |
|---|
| 1051 | | |
|---|
| 1052 | | if ebXML_message_object.is_user_message? then |
|---|
| 1053 | | # decrypt if encrypted if encrypted |
|---|
| 1054 | | # start tasker |
|---|
| 1055 | | |
|---|
| 1056 | | # validate signature if signature |
|---|
| 1057 | | # start tasker |
|---|
| 1058 | | |
|---|
| 1059 | | # -> may need an ebXML Error Message in case decryption or signature validation fails |
|---|
| 1060 | | end |
|---|
| 1061 | | |
|---|
| 1062 | | if ebXML_message_object.is_ebMS_signal? then |
|---|
| 1063 | | # validate signature if signature |
|---|
| 1064 | | # start tasker |
|---|
| 1065 | | end |
|---|
| 1066 | | |
|---|
| 1067 | | |
|---|
| 1068 | | # CONTINUE WITH PROCESSING |
|---|
| 1069 | | # ------------------------ |
|---|
| 1070 | | |
|---|
| 1071 | | new_ebXML_message_object = nil |
|---|
| 1072 | | new_ebXML_message_info = nil |
|---|
| 1073 | | new_delivery = false |
|---|
| 1074 | | |
|---|
| 1075 | | if !validation_errors.nil? and validation_errors.class == Array and validation_errors.size > 0 then |
|---|
| 1076 | | @logger.debug "WARNING there are validation errors so an error message must be created." |
|---|
| 1077 | | # an ebXML Error Message must be created. |
|---|
| 1078 | | new_ebXML_message_object, new_ebXML_message_info = b2b_system.create_and_process_new_ebXML_signal_message ebXML_message_object, "MessageError", validation_errors |
|---|
| 1079 | | if new_ebXML_message_object.nil? then |
|---|
| 1080 | | @logger.warn "Error creating an ebXML Error message for the ebXML message: #{ebXML_message_object.summary}. The erros are: #{validation_errors.to_s}" |
|---|
| 1081 | | # --------------------------- |
|---|
| 1082 | | # Set new ebXML Message state |
|---|
| 1083 | | # --------------------------- |
|---|
| 1084 | | b2b_system.set_ebXML_message_state ebXML_message_object.message_id, "failed" |
|---|
| 1085 | | # TODO delete stuff?? |
|---|
| 1086 | | return false |
|---|
| 1087 | | end |
|---|
| 1088 | | |
|---|
| 1089 | | # Interesting point here: |
|---|
| 1090 | | # o we have an ebXML message (the one recieved) |
|---|
| 1091 | | # o we create an new ebXML message (one that responds to the one received) |
|---|
| 1092 | | # -> so we will have two ebXML messages! |
|---|
| 1093 | | |
|---|
| 1094 | | # Some transaction stuff |
|---|
| 1095 | | path = "#{@config['MESSAGE_DIR']}/#{b2b_system.system_name}/#{new_ebXML_message_object.message_id}" |
|---|
| 1096 | | complete_ebXML_message_file_path = "#{path}/ebXML_MessageError_message.ebMS2" |
|---|
| 1097 | | complete_ebXML_message_parameters_file_path = "#{path}/ebXML_MessageError_message_parameters.yml" |
|---|
| 1098 | | |
|---|
| 1099 | | transaction.attach_file complete_ebXML_message_file_path, "error message for incoming ebXML message" |
|---|
| 1100 | | transaction.attach_file complete_ebXML_message_parameters_file_path, "error message parameters for incoming ebXML message" |
|---|
| 1101 | | |
|---|
| 1102 | | # attach the ebXML message to the transaction |
|---|
| 1103 | | transaction.add_ebXML_message_id_reference new_ebXML_message_object.message_id, "ErrorMessage" |
|---|
| 1104 | | |
|---|
| 1105 | | # some more metadata |
|---|
| 1106 | | new_ebXML_message_info['ebXML_message']['ebXML_message_is_error_for_message_id'] = true |
|---|
| 1107 | | new_ebXML_message_info['ebXML_message']['ref_ebXML_message_id'] = ebXML_message_object.message_id |
|---|
| 1108 | | store_ebMS_info new_ebMS_info, b2b_system_name |
|---|
| 1109 | | |
|---|
| 1110 | | new_delivery = true |
|---|
| 1111 | | |
|---|
| 1112 | | elsif !validation_errors.nil? and validation_errors.class == String then |
|---|
| 1113 | | # I must create a HTTP fault or something!!! |
|---|
| 1114 | | # ?????????????? |
|---|
| 1115 | | @logger.error validation_errors |
|---|
| 1116 | | @logger.error '!!!!!!!!!!!!!!!! fix me' |
|---|
| 1117 | | return true |
|---|
| 1118 | | |
|---|
| 1119 | | else |
|---|
| 1120 | | |
|---|
| 1121 | | # no validation errors |
|---|
| 1122 | | |
|---|
| 1123 | | if ebXML_message_object.is_user_message? or ebXML_message_object.is_pig? then |
|---|
| 1124 | | # creating HefeWeizenDirective about new incoming ebXML message. |
|---|
| 1125 | | @logger.debug "No errors processing incoming ebXML message. so we produce a directive for the user." |
|---|
| 1126 | | path = HefeWeizen::HefeWeizenLibrary::HefeWeizenDirective.create_user_message_directive_and_save( b2b_system.get_incoming_directive_directory, |
|---|
| 1127 | | b2b_system.get_incoming_payloads_directory, |
|---|
| 1128 | | ebXML_message_object) |
|---|
| 1129 | | transaction.transition_to_new_state "Receiving ebXML user message information sent to integration point." |
|---|
| 1130 | | @logger.debug "Created incoming directive at : #{path}" |
|---|
| 1131 | | |
|---|
| 1132 | | end |
|---|
| 1133 | | |
|---|
| 1134 | | # CONTINUE PROCESSING |
|---|
| 1135 | | # ------------------- |
|---|
| 1136 | | |
|---|
| 1137 | | # Check if there is something else to do. |
|---|
| 1138 | | action_required, action = action_required? ebXML_message_object, ebMS_info |
|---|
| 1139 | | |
|---|
| 1140 | | if action_required == true then |
|---|
| 1141 | | @logger.debug "Requires further action: #{action}" |
|---|
| 1142 | | # includes to set the state of the ebXML messages. |
|---|
| 1143 | | new_ebXML_message_object, new_ebXML_message_info = b2b_system.create_and_process_new_ebXML_signal_message ebXML_message_object, action |
|---|
| 1144 | | if new_ebXML_message_object.nil? then |
|---|
| 1145 | | @logger.warn "Error creating an ebXML Acknowledgment Message for the ebXML message: #{ebXML_message_object.summary}." |
|---|
| 1146 | | # TODO delete stuff?? |
|---|
| 1147 | | return false |
|---|
| 1148 | | end |
|---|
| 1149 | | |
|---|
| 1150 | | # Interesting point here: |
|---|
| 1151 | | # o we have an ebXML message (the one recieved) |
|---|
| 1152 | | # o we create an new ebXML message (one that responds to the one received) |
|---|
| 1153 | | # -> so we will have two ebXML messages! |
|---|
| 1154 | | |
|---|
| 1155 | | # some transaction stuff |
|---|
| 1156 | | path = "#{@config['MESSAGE_DIR']}/#{b2b_system.system_name}/#{new_ebXML_message_object.message_id}" |
|---|
| 1157 | | complete_ebXML_message_file_path = "#{path}/ebXML_#{action}_message.ebMS2" |
|---|
| 1158 | | complete_ebXML_message_parameters_file_path = "#{path}/ebXML_#{action}_message_parameters.yml" |
|---|
| 1159 | | |
|---|
| 1160 | | transaction.attach_file complete_ebXML_message_file_path, "#{action} message for incoming ebXML message" |
|---|
| 1161 | | transaction.attach_file complete_ebXML_message_parameters_file_path, "#{action} message parameters for incoming ebXML message" |
|---|
| 1162 | | |
|---|
| 1163 | | # attach the ebXML message to the transaction |
|---|
| 1164 | | transaction.add_ebXML_message_id_reference new_ebXML_message_object.message_id, "Acknowledgment" |
|---|
| 1165 | | |
|---|
| 1166 | | # some more metadata |
|---|
| 1167 | | if action == "Acknowledgment" then |
|---|
| 1168 | | new_ebXML_message_info['ebXML_message']['ebXML_message_is_ack_for_message_id'] = true |
|---|
| 1169 | | new_ebXML_message_info['ebXML_message']['ref_ebXML_message_id'] = ebXML_message_object.message_id |
|---|
| 1170 | | elsif action == "Pong" then |
|---|
| 1171 | | new_ebXML_message_info['ebXML_message']['ebXML_message_is_pong_for_message_id'] = true |
|---|
| 1172 | | new_ebXML_message_info['ebXML_message']['ref_ebXML_message_id'] = ebXML_message_object.message_id |
|---|
| 1173 | | # elsif action == "StatusResponse" then |
|---|
| 1174 | | end |
|---|
| 1175 | | store_ebMS_info new_ebXML_message_info, b2b_system.system_name |
|---|
| 1176 | | |
|---|
| 1177 | | new_delivery = true |
|---|
| 1178 | | |
|---|
| 1179 | | else |
|---|
| 1180 | | @logger.debug "No futher action required for ebXML message '#{ebXML_message_object.summary}'." |
|---|
| 1181 | | end |
|---|
| 1182 | | end |
|---|
| 1183 | | |
|---|
| 1184 | | instruction_pipe = command_hash['pipe_for_instructions'] |
|---|
| 1185 | | |
|---|
| 1186 | | if new_delivery == true then |
|---|
| 1187 | | |
|---|
| 1188 | | @logger.debug "There are responses to be delivered." |
|---|
| 1189 | | |
|---|
| 1190 | | if ebMS_info['info']['transport-protocol-name'].upcase != "HTTP" then |
|---|
| 1191 | | @logger.debug "If we do not have the HTTP transport protocol then we can close the connection." |
|---|
| 1192 | | close_open_connection instruction_pipe, transaction |
|---|
| 1193 | | |
|---|
| 1194 | | # start new sending tasker. |
|---|
| 1195 | | @logger.error "Sending non HTTP transport protocol is not yet implemented." |
|---|
| 1196 | | return false |
|---|
| 1197 | | |
|---|
| 1198 | | else |
|---|
| 1199 | | |
|---|
| 1200 | | @logger.debug "Sending an ebXML response message via the HTTP transport protocol." |
|---|
| 1201 | | |
|---|
| 1202 | | # new_ebXML_message_object |
|---|
| 1203 | | # new_ebXML_message_info |
|---|
| 1204 | | |
|---|
| 1205 | | # -> sign messages? |
|---|
| 1206 | | # start delivery? command? |
|---|
| 1207 | | |
|---|
| 1208 | | if new_ebXML_message_object.is_ebMS_signal? then |
|---|
| 1209 | | # <enumeration value="mshSignalsOnly"/> |
|---|
| 1210 | | # <enumeration value="responseOnly"/> |
|---|
| 1211 | | # <enumeration value="signalsAndResponse"/> |
|---|
| 1212 | | # <enumeration value="signalsOnly"/> |
|---|
| 1213 | | # <enumeration value="none"/> |
|---|
| 1214 | | |
|---|
| 1215 | | if ebMS_info['info']['mc-syncReplyMode'] == 'none' then |
|---|
| 1216 | | @logger.debug "The CPA indicates that the response ebXML message must be sent asynchronously. So closing connection first (if there is a connection)." |
|---|
| 1217 | | close_open_connection command_hash, instruction_pipe, transaction |
|---|
| 1218 | | @logger.debug "The response ebXML message must be sent asynchronously ... so starting the delivery process for this new ebXML message." |
|---|
| 1219 | | |
|---|
| 1220 | | # CREATING A NEW TRANSACTION FOR NEW ASYNC EBXML MESSAGE |
|---|
| 1221 | | # ------------------------------------------------------ |
|---|
| 1222 | | |
|---|
| 1223 | | new_transaction = @transaction_manager.get_new_transaction b2b_system.system_name |
|---|
| 1224 | | |
|---|
| 1225 | | if new_transaction.nil? then |
|---|
| 1226 | | @logger.debug "Error creating a new transaction." |
|---|
| 1227 | | return false |
|---|
| 1228 | | end |
|---|
| 1229 | | |
|---|
| 1230 | | @logger.debug "Created a new transaction for outgoing ebXML response message. Transaction id: #{new_transaction.transaction_id}" |
|---|
| 1231 | | |
|---|
| 1232 | | |
|---|