attribute_examples.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Exchange::AttributeExamples < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Exchange::Folders::Mixin::Folder
  4. uses :ews_folder_ids
  5. provides :ews_attributes_examples
  6. def process
  7. state.provide(:ews_attributes_examples) do
  8. ::Import::Helper::AttributesExamples.new do |extractor|
  9. ews_folder_ids.collect do |folder_id|
  10. ews_folder.find(folder_id).items.each do |item|
  11. attributes = ::Import::Exchange::ItemAttributes.extract(item)
  12. extractor.extract(attributes)
  13. break if extractor.enough
  14. rescue => e
  15. Rails.logger.error 'Unable to process Exchange folder item'
  16. Rails.logger.debug { item.inspect }
  17. Rails.logger.error e
  18. nil
  19. end
  20. rescue NoMethodError => e
  21. raise if e.message.exclude?('Viewpoint::EWS::')
  22. logger.error e
  23. logger.error "Skipping folder_id '#{folder_id}' due to unsupported entries."
  24. end
  25. end.examples
  26. end
  27. end
  28. end