Changeset 615

Show
Ignore:
Timestamp:
05/03/07 10:30:05 (2 years ago)
Author:
sacha
Message:

added comments
changed to use the shell script to send an ebXML message (requires much less memory than the ruby implementation)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/hefeweizen_library_business_logic.rb

    r604 r615  
    7878        @b2b_system = b2b_system 
    7979        @b2b_system_name = @b2b_system.system_name 
    80  
     80         
    8181        @ebMS_message_manager = HefeWeizen::HefeWeizenLibrary::EBMessageManager.new @config, @b2b_system_name 
    8282        if @ebMS_message_manager.nil? then 
     
    113113        @command_hash = command_hash 
    114114         
     115        ######################################################## 
     116        # new directive                                        # 
     117        ######################################################## 
    115118        if @command == 'new directive' then 
    116119          @logger.debug "#{me}: Received new directive!" if @debug 
     
    149152              say_to_ania result 
    150153            else 
    151               @logger.warn "#{me}: Problems processing new directive: #{result}" if @warn 
    152               # ??? what TODO? 
     154              msg = "#{me}: Problems processing new directive: #{result}" 
     155              @logger.warn  msg if @warn 
     156              create_error_directive more_info 
     157              @transaction.fail msg 
    153158              return false 
    154159            end 
    155160          end 
    156161 
     162          ######################################################## 
     163          # start ebXML message delivery                         # 
     164          ######################################################## 
    157165        elsif command == 'start ebXML message delivery' then 
    158166          @logger.debug "#{me}: Received start ebXML message delivery command." if @debug 
     
    170178          end 
    171179           
     180          ######################################################## 
     181          # signing of ebXML message done                        # 
     182          ######################################################## 
    172183        elsif command == 'sign ebXML message done' then 
    173184          @logger.debug "#{me}: Received signing ebXML message is done." if @debug 
     
    220231          return true, new_command 
    221232           
     233          ######################################################## 
     234          # encryption of ebXML message done                     # 
     235          ######################################################## 
    222236        elsif command == 'encrypt ebXML message done' then 
    223237          @logger.debug "#{me}: Received encrypt ebXML message is done." if @debug 
     
    257271          return true, command 
    258272           
     273          ######################################################## 
     274          # decryption of ebXML message done                     # 
     275          ######################################################## 
    259276        elsif command == 'decrypt ebXML message done' 
    260277          # TODO the decryption task has to be moved to a tasker. 
     
    264281 
    265282 
     283          ######################################################## 
     284          # send ebXML message done                              # 
     285          ######################################################## 
    266286        elsif command == 'send ebXML message done' 
    267287          # called from the HTTP client 
     
    289309          end 
    290310           
     311          ######################################################## 
     312          # send ebXML message response done                     # 
     313          #   HTTP response leg                                  # 
     314          ######################################################## 
    291315        elsif command == 'send ebXML message response done' then 
    292316          # called from the HTTP server 
     
    309333           
    310334           
     335          ######################################################## 
     336          # new ebXML message received                           # 
     337          ######################################################## 
    311338        elsif command == 'new ebXML message received' then 
    312339          @logger.debug "#{me}: Received new ebXML message!" if @debug 
     
    326353          end 
    327354           
     355          ######################################################## 
     356          # wake up call                                         # 
     357          ######################################################## 
    328358        elsif command == 'wake up call' then 
    329359          @logger.debug "#{me}: Received a wake up call." if @debug 
     
    348378          end 
    349379        else 
    350           @logger.warn "#{me}: I dont know what the fuck to do with this '#{command}' command." if @warn 
     380          @logger.warn "#{me}: I dont know what to do with this '#{command}' command." if @warn 
    351381        end 
    352382         
     
    732762          "to" => "ania",  
    733763          "command" => "start_tasker", 
    734           "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_send_ebXML_message.rb", 
    735           "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}", 
     764          # "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_send_ebXML_message.rb", 
     765          # "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}", 
     766 
     767          "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_send_ebXML_message.sh", 
     768          "tasker arguments" => "#{@config['CONFIG_DIR']}/hefeweizen.conf #{@b2b_system_name} #{@transaction.transaction_id} #{@config['PIPE_TO_ANIA']} #{ebXML_message_file_path} #{expectation} #{ebXML_message_parameters_file_path}", 
    736769          "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid 
    737770        } 
     
    12931326         
    12941327        #add information about actual ebXML message to ebMS info 
     1328        # THIS SEEMS TO FAIL IF THERE IS A PROBLEM WITH THE MESSAGE 
    12951329        dev = ebMS_message_info['ebXML_message'] = Hash.new 
    12961330        dev['ebXML_message_id'] = ebXML_message_object.message_id 
     
    25582592            @logger.debug "#{me}: ebXML message with id '#{ebXML_message_object.message_id}' is digitally signed. Validating digital signature." if @debug 
    25592593 
     2594            # HACK ALERT 
     2595            # this should be run in a tasker 
    25602596            # TODO Blocking system call to validate XML Digital Signature. 
    25612597            binary = "hefeweizen_validate_signature_ebXML_user_message" 
     
    28432879    end 
    28442880 
    2845       def start_a_signing_tasker metadata 
    2846         expectation = "signed_ebXML_message_done" 
    2847         command_hash = { 
    2848           "from" => "big_ania",  
    2849           "to" => "ania",  
    2850           "command" => "start_tasker", 
    2851           "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_sign_ebXML_message.rb", 
    2852           "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.transaction_id} --state-expectation #{expectation}", 
    2853           "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid 
    2854         } 
    2855         @logger.debug "Call tasker to send ebXML message." if @debug 
    2856         command = "#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}" 
    2857          
    2858         return command, expectation 
    2859          
    2860       end 
     2881    def start_a_signing_tasker metadata 
     2882      expectation = "signed_ebXML_message_done" 
     2883      command_hash = { 
     2884        "from" => "big_ania",  
     2885        "to" => "ania",  
     2886        "command" => "start_tasker", 
     2887        "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_sign_ebXML_message.rb", 
     2888        "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.transaction_id} --state-expectation #{expectation}", 
     2889        "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid 
     2890      } 
     2891      @logger.debug "Call tasker to send ebXML message." if @debug 
     2892      command = "#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}" 
    28612893       
    2862       def start_an_encrypting_tasker metadata 
    2863         expectation = "encrypt_ebXML_message_done" 
    2864         command_hash = { 
    2865           "from" => "big_ania",  
    2866           "to" => "ania",  
    2867           "command" => "start_tasker", 
    2868           "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_encrypt_ebXML_message.rb", 
    2869           "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.transaction_id} --state-expectation #{expectation}", 
    2870           "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid 
    2871         } 
    2872         @logger.debug "Call tasker to send ebXML message." if @debug 
    2873         command = "#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}" 
    2874          
    2875         return command, expectation 
    2876          
    2877       end 
     2894      return command, expectation 
    28782895       
     2896    end 
     2897     
     2898    def start_an_encrypting_tasker metadata 
     2899      expectation = "encrypt_ebXML_message_done" 
     2900      command_hash = { 
     2901        "from" => "big_ania",  
     2902        "to" => "ania",  
     2903        "command" => "start_tasker", 
     2904        "tasker" => "#{@config['BIN_DIR']}/hefeweizen_tasker_application_encrypt_ebXML_message.rb", 
     2905        "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.transaction_id} --state-expectation #{expectation}", 
     2906        "uuid" => HefeWeizen::HefeWeizenLibrary::HefeWeizenUUID.uuid 
     2907      } 
     2908      @logger.debug "Call tasker to send ebXML message." if @debug 
     2909      command = "#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}" 
    28792910       
    2880       def get_ebXML_message_parameters_file_content ebXML_message_id 
    2881         file_path = @message_state_manager.get_ebXML_message_info_file_path ebXML_message_id 
    2882         if FileTest.exists? file_path and FileTest.readable? file_path then 
    2883           return YAML.load((File.open file_path, "r")) 
     2911      return command, expectation 
     2912       
     2913    end 
     2914     
     2915     
     2916    def get_ebXML_message_parameters_file_content ebXML_message_id 
     2917      file_path = @message_state_manager.get_ebXML_message_info_file_path ebXML_message_id 
     2918      if FileTest.exists? file_path and FileTest.readable? file_path then 
     2919        return YAML.load((File.open file_path, "r")) 
     2920      else 
     2921        @logger.warn "#{me}: There is no ebXML message parameters file for ebXML message with id '#{ebXML_message_id}' in the path of '#{file_path}'." if @warn 
     2922        return nil 
     2923      end 
     2924    end 
     2925     
     2926     
     2927    def exists_ebXML_message_by_id? referenced_ebXML_message_id 
     2928      path = @message_state_manager.get_ebXML_message_directory referenced_ebXML_message_id 
     2929      if FileTest.exists? path and FileTest.directory? path then 
     2930        ebXML_message = path + "/ebXML_message.ebMS2" 
     2931        if FileTest.exists? ebXML_message then 
     2932          return true 
    28842933        else 
    2885           @logger.warn "#{me}: There is no ebXML message parameters file for ebXML message with id '#{ebXML_message_id}' in the path of '#{file_path}'." if @warn 
    2886           return nil 
    2887         end 
    2888       end 
    2889  
    2890        
    2891       def exists_ebXML_message_by_id? referenced_ebXML_message_id 
    2892         path = @message_state_manager.get_ebXML_message_directory referenced_ebXML_message_id 
    2893         if FileTest.exists? path and FileTest.directory? path then 
    2894           ebXML_message = path + "/ebXML_message.ebMS2" 
    2895           if FileTest.exists? ebXML_message then 
    2896             return true 
    2897           else 
    2898             @logger.warn "#{me}: Message with id #{referenced_ebXML_message_id} does have a directory but does not contain an ebXML_message.ebMS2 message." if @warn 
    2899             return false 
    2900           end 
    2901         else 
    2902           @logger.warn "#{me}: Message with id #{referenced_ebXML_message_id} does not exist in the message store" if @warn 
     2934          @logger.warn "#{me}: Message with id #{referenced_ebXML_message_id} does have a directory but does not contain an ebXML_message.ebMS2 message." if @warn 
    29032935          return false 
    29042936        end 
    2905       end 
    2906  
    2907       ######################################################################## 
    2908       ######################################################################## 
    2909       ##     end   utilities 
    2910       ######################################################################## 
    2911       ######################################################################## 
    2912  
     2937      else 
     2938        @logger.warn "#{me}: Message with id #{referenced_ebXML_message_id} does not exist in the message store" if @warn 
     2939        return false 
     2940      end 
    29132941    end 
    2914  
    2915   end 
    2916 end 
     2942     
     2943    ######################################################################## 
     2944    ######################################################################## 
     2945    ##     end   utilities 
     2946    ######################################################################## 
     2947    ######################################################################## 
     2948     
     2949    end 
     2950  end # class 
     2951end # module