Class: Operaton::Bpm::Client::Impl::ExternalTaskClientLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/operaton/bpm/client/impl/external_task_client_logger.rb

Overview

Mirrors org.operaton.bpm.client.impl.ExternalTaskClientLogger

Constant Summary collapse

PROJECT_CODE =
"TASK/CLIENT"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component_id) ⇒ ExternalTaskClientLogger

Returns a new instance of ExternalTaskClientLogger.



35
36
37
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 35

def initialize(component_id)
  @component_id = component_id
end

Class Method Details

.client_loggerObject



23
24
25
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 23

def self.client_logger
  @client_logger ||= new("01")
end

.engine_client_loggerObject



27
28
29
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 27

def self.engine_client_logger
  @engine_client_logger ||= EngineClientLogger.new("02")
end

.topic_subscription_manager_loggerObject



31
32
33
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 31

def self.topic_subscription_manager_logger
  @topic_subscription_manager_logger ||= Topic::Impl::TopicSubscriptionManagerLogger.new("03")
end

Instance Method Details

#async_response_timeout_not_greater_than_zero_exception(async_response_timeout) ⇒ Object



154
155
156
157
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 154

def async_response_timeout_not_greater_than_zero_exception(async_response_timeout)
  ExternalTaskClientException.new(exception_message(
    "015", "Asynchronous response timeout must be greater than zero, but was '{}'", async_response_timeout))
end

#base_url_null_exceptionObject



61
62
63
64
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 61

def base_url_null_exception
  ExternalTaskClientException.new(exception_message(
    "001", "Base URL cannot be null or an empty string"))
end

#basic_auth_credentials_null_exceptionObject



139
140
141
142
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 139

def basic_auth_credentials_null_exception
  ExternalTaskClientException.new(exception_message(
    "012", "Basic authentication credentials (username, password) cannot be null"))
end

#cannot_get_hostname_exception(cause) ⇒ Object



66
67
68
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 66

def cannot_get_hostname_exception(cause)
  ExternalTaskClientException.new(exception_message("002", "Cannot get hostname"), cause)
end

#cannot_serialize_variable(variable_name, error) ⇒ Object



195
196
197
198
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 195

def cannot_serialize_variable(variable_name, error)
  ValueMapperException.new(exception_message(
    "025", "Cannot serialize variable '{}'", variable_name), error)
end

#create_message(id, action_name, message) ⇒ Object



135
136
137
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 135

def create_message(id, action_name, message)
  exception_message(id, "Exception while {}: {}", action_name, message)
end

#double_direction_config_exceptionObject



70
71
72
73
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 70

def double_direction_config_exception
  ExternalTaskClientException.new(
    "Invalid query: can specify only one direction desc() or asc() for an ordering constraint")
end

#exception_message(id, message_template, *args) ⇒ Object



39
40
41
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 39

def exception_message(id, message_template, *args)
  "#{PROJECT_CODE}-#{@component_id}#{id} #{format_template(message_template, *args)}"
end

#external_task_handler_null_exceptionObject



95
96
97
98
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 95

def external_task_handler_null_exception
  ExternalTaskClientException.new(exception_message(
    "005", "External task handler cannot be null"))
end

#format_template(template, *args) ⇒ Object



43
44
45
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 43

def format_template(template, *args)
  args.reduce(template) { |msg, arg| msg.sub("{}", arg.to_s) }
end

#handled_engine_client_exception(action_name, error) ⇒ Object

Mirrors handledEngineClientException: maps EngineClientException causes to the public exception hierarchy.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 107

def handled_engine_client_exception(action_name, error)
  caused = error.cause

  if caused.is_a?(RestException)
    message = caused.message
    status = caused.http_status_code

    return case status
           when 400 then BadRequestException.new(create_message("007", action_name, message), caused)
           when 404 then NotFoundException.new(create_message("008", action_name, message), caused)
           when 500 then EngineException.new(create_message("009", action_name, message), caused)
           else
             UnknownHttpErrorException.new(exception_message(
               "031", "Exception while {}: The request failed with status code {} and message: \"{}\"",
               action_name, status, message), caused)
           end
  end

  if io_error?(caused)
    return ConnectionLostException.new(exception_message(
      "010", "Exception while {}: Connection could not be established with message: \"{}\"",
      action_name, caused.message), caused)
  end

  ExternalTaskClientException.new(exception_message(
    "011", "Exception while {}: ", action_name), error)
end

#interceptor_null_exceptionObject



144
145
146
147
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 144

def interceptor_null_exception
  ExternalTaskClientException.new(exception_message(
    "013", "Interceptor cannot be null"))
end

#lock_duration_is_not_greater_than_zero_exception(lock_duration) ⇒ Object



90
91
92
93
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 90

def lock_duration_is_not_greater_than_zero_exception(lock_duration)
  ExternalTaskClientException.new(exception_message(
    "004", "Lock duration must be greater than 0, but was '{}'", lock_duration))
end

#log_data_format(data_format) ⇒ Object



205
206
207
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 205

def log_data_format(data_format)
  log_info("025", "Discovered data format: {}[name = {}]", data_format.class.name, data_format.name)
end

#log_data_format_configurator(configurator) ⇒ Object



209
210
211
212
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 209

def log_data_format_configurator(configurator)
  log_info("027", "Discovered data format configurator: {}[dataformat = {}]",
           configurator.class.name, configurator.data_format_class.name)
end

#log_data_format_provider(provider) ⇒ Object



200
201
202
203
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 200

def log_data_format_provider(provider)
  log_info("026", "Discovered data format provider: {}[name = {}]",
           provider.class.name, provider.data_format_name)
end

#log_debug(id, message_template, *args) ⇒ Object



57
58
59
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 57

def log_debug(id, message_template, *args)
  Client.logger.debug(exception_message(id, message_template, *args))
end

#log_error(id, message_template, error = nil, *args) ⇒ Object



47
48
49
50
51
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 47

def log_error(id, message_template, error = nil, *args)
  msg = exception_message(id, message_template, *args)
  msg += " : #{error.class}: #{error.message}" if error
  Client.logger.error(msg)
end

#log_info(id, message_template, *args) ⇒ Object



53
54
55
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 53

def log_info(id, message_template, *args)
  Client.logger.info(exception_message(id, message_template, *args))
end

#max_tasks_not_greater_than_zero_exception(max_tasks) ⇒ Object



149
150
151
152
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 149

def max_tasks_not_greater_than_zero_exception(max_tasks)
  ExternalTaskClientException.new(exception_message(
    "014", "Maximum amount of fetched tasks must be greater than zero, but was '{}'", max_tasks))
end

#missing_direction_exceptionObject



80
81
82
83
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 80

def missing_direction_exception
  ExternalTaskClientException.new(
    "Invalid query: call asc() or desc() after using orderByXX()")
end

#multiple_providers_for_dataformat(data_format_name) ⇒ Object



214
215
216
217
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 214

def multiple_providers_for_dataformat(data_format_name)
  ExternalTaskClientException.new(exception_message(
    "028", "Multiple providers found for dataformat '{}'", data_format_name))
end

#pass_null_value_parameter(parameter_name) ⇒ Object



219
220
221
222
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 219

def pass_null_value_parameter(parameter_name)
  ExternalTaskClientException.new(exception_message(
    "030", "Null value is not allowed as '{}'", parameter_name))
end

#topic_name_already_subscribed_exception(topic_name) ⇒ Object



100
101
102
103
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 100

def topic_name_already_subscribed_exception(topic_name)
  ExternalTaskClientException.new(exception_message(
    "006", "Topic name '{}' has already been subscribed", topic_name))
end

#topic_name_null_exceptionObject



85
86
87
88
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 85

def topic_name_null_exception
  ExternalTaskClientException.new(exception_message(
    "003", "Topic name cannot be null"))
end

#unspecified_order_by_method_exceptionObject



75
76
77
78
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 75

def unspecified_order_by_method_exception
  ExternalTaskClientException.new(
    "Invalid query: You should call any of the orderBy methods first before specifying a direction")
end

#value_mapper_exception_due_to_no_object_type_nameObject



164
165
166
167
168
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 164

def value_mapper_exception_due_to_no_object_type_name
  ValueMapperException.new(exception_message(
    "019", "Exception while mapping value: " \
           "Cannot write serialized value for variable: no 'objectTypeName' provided for non-null value."))
end

#value_mapper_exception_due_to_serializer_not_found_for_typed_value(typed_value) ⇒ Object



185
186
187
188
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 185

def value_mapper_exception_due_to_serializer_not_found_for_typed_value(typed_value)
  ValueMapperException.new(exception_message(
    "023", "Cannot find serializer for value '{}'", typed_value))
end

#value_mapper_exception_due_to_serializer_not_found_for_typed_value_field(value) ⇒ Object



190
191
192
193
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 190

def value_mapper_exception_due_to_serializer_not_found_for_typed_value_field(value)
  ValueMapperException.new(exception_message(
    "024", "Cannot find serializer for value '{}'", value))
end

#value_mapper_exception_while_deserializing_object(error) ⇒ Object



175
176
177
178
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 175

def value_mapper_exception_while_deserializing_object(error)
  ValueMapperException.new(exception_message(
    "021", "Exception while mapping value: Cannot deserialize object in variable."), error)
end

#value_mapper_exception_while_parsing_date(date, error) ⇒ Object



159
160
161
162
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 159

def value_mapper_exception_while_parsing_date(date, error)
  ValueMapperException.new(exception_message(
    "018", "Exception while mapping value: Cannot parse date '{}'", date), error)
end

#value_mapper_exception_while_serializing_abstract_value(name) ⇒ Object



180
181
182
183
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 180

def value_mapper_exception_while_serializing_abstract_value(name)
  ValueMapperException.new(exception_message(
    "022", "Cannot serialize value of abstract type '{}'", name))
end

#value_mapper_exception_while_serializing_object(error) ⇒ Object



170
171
172
173
# File 'lib/operaton/bpm/client/impl/external_task_client_logger.rb', line 170

def value_mapper_exception_while_serializing_object(error)
  ValueMapperException.new(exception_message(
    "020", "Exception while mapping value: Cannot serialize object in variable."), error)
end