diff --git a/Gemfile b/Gemfile index bf492d6e..4ab99783 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master' gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development' gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development' -gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development' +gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/parse-diff-files' group :development do # bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42 diff --git a/Gemfile.lock b/Gemfile.lock index 0dab4ec7..f8e14446 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,8 +57,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 651d2f4226004c2311120e900a936101ee509865 - branch: development + revision: d69ede0a0b3e3c5dee64fa75cb09cc6e16e0f4b5 + branch: feature/parse-diff-files specs: ontologies_linked_data (0.0.1) activesupport @@ -202,7 +202,7 @@ GEM google-protobuf (>= 3.18, < 5.a) googleapis-common-protos-types (~> 1.7) grpc (~> 1.41) - googleapis-common-protos-types (1.15.0) + googleapis-common-protos-types (1.16.0) google-protobuf (>= 3.18, < 5.a) googleauth (1.11.0) faraday (>= 1.0, < 3.a) @@ -231,7 +231,7 @@ GEM rdf (>= 2.2.8, < 4.0) json-schema (2.8.1) addressable (>= 2.4) - jwt (2.8.2) + jwt (2.9.0) base64 kgio (2.11.4) libxml-ruby (5.0.3) diff --git a/controllers/ontology_submissions_controller.rb b/controllers/ontology_submissions_controller.rb index 0068a5f1..6b5818b5 100644 --- a/controllers/ontology_submissions_controller.rb +++ b/controllers/ontology_submissions_controller.rb @@ -140,6 +140,25 @@ class OntologySubmissionsController < ApplicationController end end + get '/:ontology_submission_id/diff' do + acronym = params["acronym"] + submission_attributes = [:submissionId, :submissionStatus, :diffFilePath] + ont = Ontology.find(acronym).include(:submissions => submission_attributes).first + error 422, "You must provide an existing `acronym` to download" if ont.nil? + ont.bring(:viewingRestriction) + check_access(ont) + ont_restrict_downloads = LinkedData::OntologiesAPI.settings.restrict_download + error 403, "License restrictions on download for #{acronym}" if ont_restrict_downloads.include? acronym + submission = ont.submission(params['ontology_submission_id'].to_i) + error 404, "There is no such submission for download" if submission.nil? + file_path = submission.diffFilePath + if File.readable? file_path + reply submission.parse_diff_report + else + error 500, "Cannot read submission diff file: #{file_path}" + end + end + ## # Download a submission diff file get '/:ontology_submission_id/download_diff' do diff --git a/test/controllers/test_ontology_submissions_controller.rb b/test/controllers/test_ontology_submissions_controller.rb index 095d0339..1e5014f6 100644 --- a/test/controllers/test_ontology_submissions_controller.rb +++ b/test/controllers/test_ontology_submissions_controller.rb @@ -474,6 +474,16 @@ def test_submissions_param_include test_submissions_custom_includes end + def test_submission_diff + num_onts_created, created_ont_acronyms, onts = create_ontologies_and_submissions(ont_count: 1, submission_count: 2, + process_submission: true, + process_options: { process_rdf: true, extract_metadata: false, diff: true} ) + + ont = onts.first + sub = ont.latest_submission(status: :any) + + get "/ontologies/#{ont.acronym}/submissions/#{sub.submissionId}/diff" + end private def submission_keys(sub) sub.to_hash.keys - %w[@id @type id]