Class: Qa::LinkedDataTermsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Qa::LinkedDataTermsController
- Defined in:
- app/controllers/qa/linked_data_terms_controller.rb
Overview
This controller is used for all requests to linked data authorities. It will verify params and figure out which linked data authority to query based on the ‘vocab’ param.
Instance Method Summary collapse
-
#fetch ⇒ Object
Return all the information for a given term given a URI get “/fetch/linked_data/:vocab”.
-
#index ⇒ Object
Provide a warning if there is a request for all terms.
-
#list ⇒ Object
Return a list of supported authority names get “/list/linked_data/authorities”.
-
#reload ⇒ Object
Reload authority configurations get “/reload/linked_data/authorities?auth_token=YOUR_AUTH_TOKEN_DEFINED_HERE”.
-
#search ⇒ Object
Return a list of terms based on a query get “/search/linked_data/:vocab(/:subauthority)”.
-
#show ⇒ Object
Return all the information for a given term given an id or URI get “/show/linked_data/:vocab/:id” get “/show/linked_data/:vocab/:subauthority/:id.
Instance Method Details
#fetch ⇒ Object
Return all the information for a given term given a URI get “/fetch/linked_data/:vocab”
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/qa/linked_data_terms_controller.rb', line 80 def fetch # rubocop:disable Metrics/MethodLength, Metrics/AbcSize term = @authority.find(uri, subauth: , language: language, replacements: replacement_params, jsonld: jsonld?) cors_allow_origin_header(response) content_type = jsonld? ? 'application/ld+json' : 'application/json' render json: term, content_type: content_type rescue Qa::TermNotFound logger.warn "Term Not Found - Fetch term #{uri} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}" head :not_found rescue Qa::ServiceUnavailable logger.warn "Service Unavailable - Fetch term #{uri} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}" head :service_unavailable rescue Qa::ServiceError logger.warn "Internal Server Error - Fetch term #{uri} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}" head :internal_server_error rescue RDF::FormatError logger.warn "RDF Format Error - Results from fetch term #{uri} for#{subauth_warn_msg} authority #{vocab_param} " \ "was not identified as a valid RDF format. You may need to include the linkeddata gem." head :internal_server_error end |
#index ⇒ Object
Provide a warning if there is a request for all terms.
14 15 16 17 |
# File 'app/controllers/qa/linked_data_terms_controller.rb', line 14 def index logger.warn 'Linked data authorities do not support retrieving all terms.' head :not_found end |
#list ⇒ Object
Return a list of supported authority names get “/list/linked_data/authorities”
22 23 24 |
# File 'app/controllers/qa/linked_data_terms_controller.rb', line 22 def list render json: Qa::Authorities::LinkedData::AuthorityService..to_json end |
#reload ⇒ Object
Reload authority configurations get “/reload/linked_data/authorities?auth_token=YOUR_AUTH_TOKEN_DEFINED_HERE”
29 30 31 32 |
# File 'app/controllers/qa/linked_data_terms_controller.rb', line 29 def reload Qa::Authorities::LinkedData::AuthorityService. list end |
#search ⇒ Object
Return a list of terms based on a query get “/search/linked_data/:vocab(/:subauthority)”
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/qa/linked_data_terms_controller.rb', line 37 def search terms = @authority.search(query, subauth: , language: language, replacements: replacement_params) cors_allow_origin_header(response) render json: terms rescue Qa::ServiceUnavailable logger.warn "Service Unavailable - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}" head :service_unavailable rescue Qa::ServiceError logger.warn "Internal Server Error - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}" head :internal_server_error rescue RDF::FormatError logger.warn "RDF Format Error - Results from search query #{query} for#{subauth_warn_msg} authority #{vocab_param} " \ "was not identified as a valid RDF format. You may need to include the linkeddata gem." head :internal_server_error end |
#show ⇒ Object
Return all the information for a given term given an id or URI get “/show/linked_data/:vocab/:id” get “/show/linked_data/:vocab/:subauthority/:id
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/qa/linked_data_terms_controller.rb', line 57 def show # rubocop:disable Metrics/MethodLength, Metrics/AbcSize term = @authority.find(id, subauth: , language: language, replacements: replacement_params, jsonld: jsonld?) cors_allow_origin_header(response) content_type = jsonld? ? 'application/ld+json' : 'application/json' render json: term, content_type: content_type rescue Qa::TermNotFound logger.warn "Term Not Found - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}" head :not_found rescue Qa::ServiceUnavailable logger.warn "Service Unavailable - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}" head :service_unavailable rescue Qa::ServiceError logger.warn "Internal Server Error - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}" head :internal_server_error rescue RDF::FormatError logger.warn "RDF Format Error - Results from fetch term #{id} for#{subauth_warn_msg} authority #{vocab_param} " \ "was not identified as a valid RDF format. You may need to include the linkeddata gem." head :internal_server_error end |