This repository has been archived by the owner on May 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spawn a background export job when a new export is created
- Loading branch information
Showing
9 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,81 @@ | ||
# grocer | ||
Backup manager for Fedora's produce. | ||
|
||
## Installation | ||
|
||
* Add Grocer to your Gemfile | ||
|
||
``` | ||
gem 'grocer', github: 'pulibrary/grocer' | ||
``` | ||
|
||
* Then run the Grocer installation | ||
|
||
``` | ||
bundle install | ||
rails g grocer:install | ||
rake db:migrate | ||
``` | ||
|
||
* If your application is based on CurationConcerns 2.0 or Hyrax, you can trigger a Grocer export on | ||
workflow changes by adding this service call to an action: | ||
|
||
``` | ||
"methods": ["Grocer::ExportObject"] | ||
``` | ||
|
||
and then reloading your workflow: | ||
|
||
``` | ||
rake curation_concerns:workflow:load | ||
``` | ||
|
||
|
||
## Configuration | ||
|
||
To configure Grocer's behavior, you can add an initializer: | ||
|
||
``` | ||
Grocer.configure do |conf| | ||
conf.export_dir = ENV['GROCER_EXPORT_DIR'] || Rails.root.join('tmp', 'export') | ||
end | ||
``` | ||
|
||
The available configuration options are: | ||
|
||
* `baseurl`: Fedora base URL, defaults to using ActiveFedora settings | ||
|
||
* `export_dir`: Base directory to export resources to, defaults to `/pub/export` | ||
|
||
* `metadata_template`: YAML file defining Bag metadata, defaults to `[export_dir]/metadata.yml` | ||
|
||
* `jar`: Import/Export Java JAR file, defaults to `[export_dir]/export.jar` | ||
|
||
* `predicates`: Comma-separated list of membership predicates to follow when retrieving a resources, | ||
defaults to `pcdm:hasMember,ldp:contains` | ||
|
||
See the [Fedora Import/Export README](https://github.com/fcrepo4-labs/fcrepo-import-export) for more | ||
information about BagIt metadata, membership predicates, and the Import/Export tool in general. | ||
|
||
## Required files | ||
|
||
You must create two files required by the import/export tool: | ||
|
||
* The Import/Export JAR file, which can be downloaded from the [Import/Export releases] | ||
(https://github.com/fcrepo4-labs/fcrepo-import-export/releases). | ||
|
||
* A Bag metadata config file, such as: | ||
|
||
``` | ||
bag-info.txt: | ||
Source-Organization: York University Libraries | ||
Organization-Address: 4700 Keele Street Toronto, Ontario M3J 1P3 Canada | ||
Contact-Name: Nick Ruest | ||
Contact-Phone: +14167362100 | ||
Contact-Email: ruestn@yorku.ca | ||
External-Description: Sample bag exported from fcrepo | ||
External-Identifier: SAMPLE_001 | ||
Bag-Group-Identifier: SAMPLE | ||
Internal-Sender-Identifier: SAMPLE_001 | ||
Internal-Sender-Description: Sample bag exported from fcrepo | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Grocer | ||
class ExportObject | ||
def self.call(target:, user: nil, comment: nil) | ||
Rails.logger.info "Exporting #{target.id}, user: #{user}, comment: #{comment}" | ||
Grocer::ExportJob.perform_later(target.id, target.identifier) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
Grocer::Engine.routes.draw do | ||
resources :exports, only: [:create, :index, :new, :show] | ||
root to: 'exports#index' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddArkToGrocerExports < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :grocer_exports, :ark, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Grocer::ExportObject do | ||
let(:obj) { double('object', id: 'obj1', identifier: 'ark:/12345/x12345678x') } | ||
let(:job) { class_double(Grocer::ExportJob).as_stubbed_const } | ||
|
||
before do | ||
allow(job).to receive(:perform_later) | ||
end | ||
|
||
it 'triggers an export job' do | ||
described_class.call(target: obj) | ||
expect(job).to have_received(:perform_later).with('obj1', 'ark:/12345/x12345678x') | ||
end | ||
end |