Commit d1d5c0544c873b8ed33d919b32fb970bf0eae747
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'virtuoso_integration' of gitlab.com:participa/noosfero into virtuoso_integration
Showing
2 changed files
with
13 additions
and
2 deletions
Show diff stats
plugins/virtuoso/lib/virtuoso_plugin/dspace_harvest.rb
| @@ -35,14 +35,18 @@ class VirtuosoPlugin::DspaceHarvest | @@ -35,14 +35,18 @@ class VirtuosoPlugin::DspaceHarvest | ||
| 35 | def run | 35 | def run |
| 36 | harvest_time = Time.now.utc | 36 | harvest_time = Time.now.utc |
| 37 | params = settings.last_harvest ? {:from => settings.last_harvest.utc} : {} | 37 | params = settings.last_harvest ? {:from => settings.last_harvest.utc} : {} |
| 38 | - puts "starting harvest #{params}" | 38 | + puts "starting harvest #{params} #{settings.dspace_uri} #{settings.virtuoso_uri}" |
| 39 | begin | 39 | begin |
| 40 | records = dspace_client.list_records(params) | 40 | records = dspace_client.list_records(params) |
| 41 | records.each do |record| | 41 | records.each do |record| |
| 42 | triplify(record) | 42 | triplify(record) |
| 43 | end | 43 | end |
| 44 | - rescue Exception => ex | 44 | + rescue OAI::Exception => ex |
| 45 | puts ex.to_s | 45 | puts ex.to_s |
| 46 | + if ex.code != 'noRecordsMatch' | ||
| 47 | + puts "unexpected error" | ||
| 48 | + raise ex | ||
| 49 | + end | ||
| 46 | end | 50 | end |
| 47 | settings.last_harvest = harvest_time | 51 | settings.last_harvest = harvest_time |
| 48 | settings.save! | 52 | settings.save! |
plugins/virtuoso/test/functional/virtuoso_plugin_admin_controller_test.rb
| @@ -35,4 +35,11 @@ class VirtuosoPluginAdminControllerTest < ActionController::TestCase | @@ -35,4 +35,11 @@ class VirtuosoPluginAdminControllerTest < ActionController::TestCase | ||
| 35 | assert harvest.find_job.present? | 35 | assert harvest.find_job.present? |
| 36 | end | 36 | end |
| 37 | 37 | ||
| 38 | + should 'force harvest from start' do | ||
| 39 | + get :force_harvest, :from_start => true | ||
| 40 | + harvest = VirtuosoPlugin::DspaceHarvest.new(environment) | ||
| 41 | + assert harvest.find_job.present? | ||
| 42 | + assert_equal nil, harvest.settings.last_harvest | ||
| 43 | + end | ||
| 44 | + | ||
| 38 | end | 45 | end |