lib/blinkbox/common_mapping.rb
# Collects the mappings from the storage service specified when initialised.
# 
# @return [Boolean] Returns true if the mapping file was updated, false if the mapping already stored was the same or more recent.
# @raise StorageServiceUnavailableError if the response from the server isn't 200, isn't JSON or (if the schema are available) isn't a valid mapping document.
Collects the mappings from the storage service specified when initialised.
Collects the mappings from the storage service specified when initialised .
def retrieve_mapping!
      response = ss_get("/mappings")
      raise StorageServiceUnavailableError, "Storage service gave #{response.code} response code, cannot update the mapping details." unless response.code == "200"
      mapping = JSON.parse(response.body)
      CommonMessaging::MappingUpdateV1.new(mapping) if CommonMessaging.const_defined?('MappingUpdateV1')
      timestamp = response['Date'].nil? ? Time.now : Time.parse(response['Date'])
      update_mapping!(timestamp, mapping)
    rescue JSON::ParserError, JSON::Schema::ValidationError
      raise StorageServiceUnavailableError, "The response from the storage service wasn't a valid mapping update."
    end
def retrieve_mapping! response = ss_get ( "/mappings" ) raise StorageServiceUnavailableError , "Storage service gave #{response.code} response code, cannot update the mapping details." unless response . code == "200" mapping = JSON . parse ( response . body ) CommonMessaging :: MappingUpdateV1 . new ( mapping ) if CommonMessaging . const_defined? ( 'MappingUpdateV1' ) timestamp = response [ 'Date' ] . nil? ? Time . now : Time . parse ( response [ 'Date' ] ) update_mapping! ( timestamp , mapping ) rescue JSON :: ParserError , JSON :: Schema :: ValidationError raise StorageServiceUnavailableError , "The response from the storage service wasn't a valid mapping update." end
Collects the mappings from the storage service specified when initialised.
Collects the mappings from the storage service specified when initialised .
# This will raise a JSON::Schema::ValidationError if the mapping file isn't valid
Returns true if the mapping file was updated, false if the mapping already stored was the same or more recent.
Returns true if the mapping file was updated false if the mapping already stored was the same or more recent .
Boolean
StorageServiceUnavailableError if the response from the server isn't 200, isn't JSON or (if the schema are available) isn't a valid mapping document.
StorageServiceUnavailableError if the response from the server isn ' t 200 isn ' t JSON or ( if the schema are available ) isn ' t a valid mapping document .