Class: RazorRisk::Cassini::Applications::RouteVerbAdaptors::RiskPointData::Navigation::Domains::ItemGet
- Inherits:
-
RESTFramework::VerbHandler
- Object
- RESTFramework::VerbHandler
- RazorRisk::Cassini::Applications::RouteVerbAdaptors::RiskPointData::Navigation::Domains::ItemGet
- Includes:
- Cassini::Mixin::RazorResponseValidator, Cassini::Util::ConversionUtil, Razor::Connectivity::Razor3::EntityConnectors::RiskPointData, RazorRisk::Core::Diagnostics::Logger
- Defined in:
- lib/razor_risk/cassini/applications/route_verb_adaptors/rpd/navigation/domains/item_get.rb
Overview
Handler for GET requests for a specific navigation domain.
Constant Summary collapse
- HTTP_VERB =
########################################################## Constants
:get
- HTTP_ACCEPTS =
[ 'application/xml', 'application/json', 'text/xml', ].freeze
- QUERY_PARAMETERS =
[].freeze
- ROUTE_VARIABLES =
%w[ name type ].freeze
Instance Method Summary collapse
- #handle(env, params, request, response) ⇒ Object
-
#initialize(*args, **options) ⇒ ItemGet
constructor
########################################################## methods.
Constructor Details
#initialize(*args, **options) ⇒ ItemGet
########################################################## methods
64 65 66 67 68 |
# File 'lib/razor_risk/cassini/applications/route_verb_adaptors/rpd/navigation/domains/item_get.rb', line 64 def initialize *args, ** @connector_class = [:connector_class] || NavigationDomainConnector super end |
Instance Method Details
#handle(env, params, request, response) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/razor_risk/cassini/applications/route_verb_adaptors/rpd/navigation/domains/item_get.rb', line 70 def handle env, params, request, response trace ParamNames[:env, :params, :request, :response], env, params, request, response name = check_option params, 'name', type: ::String type = check_option params, 'type', type: ::String ec = @connector_class.new settings.razor_requester, credentials: get_required_credentials qr = ec. name, type, indicate_result_by: :qualified_result log :debug1, "qr(#{qr.class})='#{qr}'" # Check the request succeeded validate_qualified_razor_response qr error HTTP_STATUS_NAMES::NOT_FOUND, "Naviagation domain '#{name}' not found" if qr.result.nil? if qr.failed? log :warning, 'Failed to retrieve snapshot progress information for an unkown reason' error HTTP_STATUS_NAMES::INTERNAL_SERVER_ERROR, 'Oops! Something went wrong' end status HTTP_STATUS_NAMES::OK if request.accept?('application/xml') log :debug1, 'application/xml' content_type 'application/xml' qr.result.to_s elsif request.accept?('text/xml') log :debug1, 'text/xml' content_type 'text/xml' qr.result.to_s elsif request.accept?('application/json') log :debug1, 'application/json' content_type 'application/json' convert_XML_to_JSON qr.result, scheme: :gdata else log :violation, "unexpected failure to match given 'Accept' header '#{request.accept}'" error HTTP_STATUS_NAMES::INTERNAL_SERVER_ERROR, 'Oops! Something went wrong' end end |