2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Import
|
|
|
|
module Exchange
|
|
|
|
class AttributeExamples < Sequencer::Unit::Base
|
2017-09-15 10:55:49 +00:00
|
|
|
include ::Sequencer::Unit::Exchange::Folders::Mixin::Folder
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
uses :ews_folder_ids
|
|
|
|
provides :ews_attributes_examples
|
|
|
|
|
|
|
|
def process
|
|
|
|
state.provide(:ews_attributes_examples) do
|
|
|
|
::Import::Helper::AttributesExamples.new do |extractor|
|
|
|
|
|
|
|
|
ews_folder_ids.collect do |folder_id|
|
|
|
|
|
2021-03-16 15:04:38 +00:00
|
|
|
ews_folder.find(folder_id).items.each do |item|
|
|
|
|
|
|
|
|
attributes = ::Import::Exchange::ItemAttributes.extract(item)
|
2019-06-27 18:26:28 +00:00
|
|
|
extractor.extract(attributes)
|
2021-03-16 15:04:38 +00:00
|
|
|
|
2019-06-27 18:26:28 +00:00
|
|
|
break if extractor.enough
|
2021-03-16 15:04:38 +00:00
|
|
|
rescue => e
|
|
|
|
Rails.logger.error 'Unable to process Exchange folder item'
|
|
|
|
Rails.logger.debug { item.inspect }
|
|
|
|
Rails.logger.error e
|
|
|
|
nil
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
2019-06-27 18:26:28 +00:00
|
|
|
rescue NoMethodError => e
|
2020-09-30 09:07:01 +00:00
|
|
|
raise if e.message.exclude?('Viewpoint::EWS::')
|
2019-06-27 18:26:28 +00:00
|
|
|
|
|
|
|
logger.error e
|
|
|
|
logger.error "Skipping folder_id '#{folder_id}' due to unsupported entries."
|
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
|
|
|
end.examples
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|