dor-services 7.2.4 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/config_defaults.yml +24 -41
- data/config/dev_console_env.rb.example +0 -9
- data/lib/dor-services.rb +6 -9
- data/lib/dor/config.rb +2 -126
- data/lib/dor/datastreams/content_metadata_ds.rb +7 -0
- data/lib/dor/datastreams/embargo_metadata_ds.rb +1 -1
- data/lib/dor/datastreams/role_metadata_ds.rb +1 -1
- data/lib/dor/datastreams/workflow_definition_ds.rb +0 -22
- data/lib/dor/datastreams/workflow_ds.rb +2 -64
- data/lib/dor/indexers/workflows_indexer.rb +7 -1
- data/lib/dor/models/abstract.rb +2 -4
- data/lib/dor/models/workflow_object.rb +0 -46
- data/lib/dor/release_tags.rb +13 -0
- data/lib/dor/release_tags/identity_metadata.rb +202 -0
- data/lib/dor/release_tags/purl.rb +50 -0
- data/lib/dor/release_tags/purl_client.rb +44 -0
- data/lib/dor/services/release_tag_service.rb +9 -179
- data/lib/dor/services/state_service.rb +23 -0
- data/lib/dor/static_config.rb +108 -0
- data/lib/dor/static_config/fedora_config.rb +36 -0
- data/lib/dor/static_config/solr_config.rb +21 -0
- data/lib/dor/static_config/ssl_config.rb +33 -0
- data/lib/dor/static_config/stacks_config.rb +39 -0
- data/lib/dor/static_config/suri_config.rb +45 -0
- data/lib/dor/static_config/workflow_config.rb +51 -0
- data/lib/dor/version.rb +1 -1
- data/lib/dor/workflow/document.rb +0 -10
- metadata +26 -66
- data/lib/dor/services/cleanup_service.rb +0 -63
- data/lib/dor/services/create_workflow_service.rb +0 -53
- data/lib/dor/services/delete_service.rb +0 -60
- data/lib/dor/services/metadata_handlers/catalog_handler.rb +0 -27
- data/lib/dor/services/metadata_service.rb +0 -64
- data/lib/dor/services/mods2dc.xslt +0 -474
- data/lib/dor/services/public_desc_metadata_service.rb +0 -184
- data/lib/dor/services/purl_client.rb +0 -42
- data/lib/dor/services/thumbnail_service.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b23b30fbc918705e040049d04869e4ce0ca5d2c9060aa52cbc3cb17bcbf1efa
|
4
|
+
data.tar.gz: 75f7b272d2bd43b5cc6546f9881f15cd3f85f484bc5a219c710ac428efb8a558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0fb8fe1755b93d8257f74b17ebc822e287dbb9d69c2a2376b05b6a45bc0f7241f68d8ffb0b36b0294e42b5030af223e9660e48c116e6c86882cc88f25e1589c
|
7
|
+
data.tar.gz: 4de638d794ec9b372f3093c5ee432067c9ebca4fc213b7d4793a77f29b9d6bbde92cdf180e0f00844ac6cea89ed048639a2817e67f38743f21d03d199c74c327
|
data/config/config_defaults.yml
CHANGED
@@ -1,42 +1,25 @@
|
|
1
1
|
---
|
2
|
-
:
|
3
|
-
:
|
4
|
-
:
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
:
|
21
|
-
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:local_stacks_root: /stacks
|
27
|
-
:local_document_cache_root: /purl/document_cache
|
28
|
-
:url:
|
29
|
-
:iiif_profile: 'http://iiif.io/api/image/2/level1.json'
|
30
|
-
:suri:
|
31
|
-
:pass:
|
32
|
-
:id_namespace: druid
|
33
|
-
:url:
|
34
|
-
:user:
|
35
|
-
:mint_ids: false
|
36
|
-
:workflow:
|
37
|
-
:url:
|
38
|
-
:timeout: 60
|
39
|
-
:logfile: workflow_service.log
|
40
|
-
:shift_age: weekly
|
41
|
-
:dor_services:
|
42
|
-
:url:
|
2
|
+
ssl:
|
3
|
+
cert_file:
|
4
|
+
key_file:
|
5
|
+
key_pass: ""
|
6
|
+
fedora:
|
7
|
+
url:
|
8
|
+
solr:
|
9
|
+
url:
|
10
|
+
stacks:
|
11
|
+
local_workspace_root: /dor
|
12
|
+
document_cache_host:
|
13
|
+
local_stacks_root: /stacks
|
14
|
+
local_document_cache_root: /purl/document_cache
|
15
|
+
suri:
|
16
|
+
pass:
|
17
|
+
id_namespace: druid
|
18
|
+
url:
|
19
|
+
user:
|
20
|
+
mint_ids: false
|
21
|
+
workflow:
|
22
|
+
url:
|
23
|
+
timeout: 60
|
24
|
+
logfile: workflow_service.log
|
25
|
+
shift_age: weekly
|
@@ -21,24 +21,15 @@ Dor::Config.configure do
|
|
21
21
|
pass ''
|
22
22
|
end
|
23
23
|
|
24
|
-
metadata do
|
25
|
-
exist.url 'http://server/exist/rest/'
|
26
|
-
catalog.url 'http://lyberservices-prod.stanford.edu/catalog/mods'
|
27
|
-
end
|
28
|
-
|
29
24
|
stacks do
|
30
25
|
document_cache_host 'purl-dev.stanford.edu'
|
31
|
-
document_cache_user ''
|
32
26
|
local_workspace_root '/dor/workspace'
|
33
|
-
host 'host'
|
34
|
-
user ''
|
35
27
|
local_stacks_root '/stacks'
|
36
28
|
local_document_cache_root '/purl'
|
37
29
|
end
|
38
30
|
|
39
31
|
solr.url 'https://host/solr'
|
40
32
|
workflow.url 'https://workflow.example.edu/'
|
41
|
-
dor_services.url 'https://host/dor/v1'
|
42
33
|
|
43
34
|
cleanup do
|
44
35
|
local_workspace_root '/dor/workspace'
|
data/lib/dor-services.rb
CHANGED
@@ -36,6 +36,7 @@ module Dor
|
|
36
36
|
end
|
37
37
|
|
38
38
|
require 'dor/version'
|
39
|
+
require 'dor/static_config'
|
39
40
|
require 'dor/config'
|
40
41
|
require 'dor/exceptions'
|
41
42
|
|
@@ -87,6 +88,8 @@ module Dor
|
|
87
88
|
end
|
88
89
|
|
89
90
|
eager_autoload do
|
91
|
+
autoload :ReleaseTags
|
92
|
+
|
90
93
|
# ActiveFedora Classes
|
91
94
|
autoload_under 'models' do
|
92
95
|
autoload :Abstract
|
@@ -104,25 +107,19 @@ module Dor
|
|
104
107
|
|
105
108
|
# Services
|
106
109
|
autoload_under 'services' do
|
107
|
-
autoload :CleanupService
|
108
110
|
autoload :CollectionService
|
109
|
-
autoload :CreateWorkflowService
|
110
111
|
autoload :CreativeCommonsLicenseService
|
111
|
-
autoload :DeleteService
|
112
112
|
autoload :EmbargoService
|
113
|
-
autoload :
|
114
|
-
autoload :MetadataService
|
113
|
+
autoload :IdentityMetadataTagService
|
115
114
|
autoload :Ontology
|
116
115
|
autoload :OpenDataLicenseService
|
117
|
-
autoload :
|
118
|
-
autoload :PublishedRelationshipsFilter
|
119
|
-
autoload :PurlClient
|
116
|
+
autoload :PurlTagService
|
120
117
|
autoload :ReleaseTagService
|
121
118
|
autoload :SearchService
|
122
119
|
autoload :StatusService
|
120
|
+
autoload :StateService
|
123
121
|
autoload :SuriService
|
124
122
|
autoload :TagService
|
125
|
-
autoload :ThumbnailService
|
126
123
|
end
|
127
124
|
|
128
125
|
# Workflow Classes
|
data/lib/dor/config.rb
CHANGED
@@ -1,133 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'confstruct/configuration'
|
4
|
-
require 'rsolr'
|
5
3
|
require 'yaml'
|
6
|
-
require 'dor/certificate_authenticated_rest_resource_factory'
|
7
|
-
require 'dor/services/client'
|
8
4
|
|
9
5
|
module Dor
|
10
|
-
|
11
|
-
|
12
|
-
define_callbacks :initialize
|
13
|
-
define_callbacks :configure
|
14
|
-
|
15
|
-
def initialize(*args)
|
16
|
-
super *args
|
17
|
-
run_callbacks(:initialize) {}
|
18
|
-
end
|
19
|
-
|
20
|
-
# Call the super method with callbacks and with $VERBOSE temporarily disabled
|
21
|
-
def configure(*args)
|
22
|
-
result = self
|
23
|
-
temp_verbose = $VERBOSE
|
24
|
-
$VERBOSE = nil
|
25
|
-
begin
|
26
|
-
run_callbacks :configure do
|
27
|
-
result = super(*args)
|
28
|
-
end
|
29
|
-
ensure
|
30
|
-
$VERBOSE = temp_verbose
|
31
|
-
end
|
32
|
-
result
|
33
|
-
end
|
34
|
-
|
35
|
-
def sanitize
|
36
|
-
dup
|
37
|
-
end
|
38
|
-
|
39
|
-
def make_solr_connection(add_opts = {})
|
40
|
-
opts = Dor::Config.solr.opts.merge(add_opts).merge(
|
41
|
-
url: Dor::Config.solr.url
|
42
|
-
)
|
43
|
-
::RSolr.connect(opts)
|
44
|
-
end
|
45
|
-
|
46
|
-
set_callback :initialize, :after do |config|
|
47
|
-
config.deep_merge!(
|
48
|
-
fedora: {
|
49
|
-
client: Confstruct.deferred { |_c| CertificateAuthenticatedRestResourceFactory.create(:fedora) },
|
50
|
-
safeurl: Confstruct.deferred do |_c|
|
51
|
-
begin
|
52
|
-
fedora_uri = URI.parse(config.fedora.url)
|
53
|
-
fedora_uri.user = fedora_uri.password = nil
|
54
|
-
fedora_uri.to_s
|
55
|
-
rescue URI::InvalidURIError
|
56
|
-
nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
},
|
60
|
-
dor_services: {
|
61
|
-
rest_client: Confstruct.deferred { |_c| RestResourceFactory.create(:dor_services) }
|
62
|
-
},
|
63
|
-
purl_services: {
|
64
|
-
rest_client: Confstruct.deferred { |_c| RestResourceFactory.create(:purl_services) }
|
65
|
-
},
|
66
|
-
workflow: {
|
67
|
-
client: Confstruct.deferred do |c|
|
68
|
-
@wfs ||= Dor::Workflow::Client.new(url: c.url, logger: c.client_logger, timeout: c.timeout)
|
69
|
-
end,
|
70
|
-
client_logger: Confstruct.deferred do |c|
|
71
|
-
if c.logfile && c.shift_age
|
72
|
-
Logger.new(c.logfile, c.shift_age)
|
73
|
-
elsif c.logfile
|
74
|
-
Logger.new(c.logfile)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
}
|
78
|
-
)
|
79
|
-
true
|
80
|
-
end
|
81
|
-
|
82
|
-
set_callback :configure, :after do |config|
|
83
|
-
configure_client!(config)
|
84
|
-
|
85
|
-
if config.solr.url.present?
|
86
|
-
ActiveFedora::SolrService.register
|
87
|
-
ActiveFedora::SolrService.instance.instance_variable_set :@conn, make_solr_connection
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def configure_client!(config)
|
92
|
-
# Do not configure client if URL not specified
|
93
|
-
return if config.dor_services&.url.blank?
|
94
|
-
|
95
|
-
params = {
|
96
|
-
url: config.dor_services.url
|
97
|
-
}
|
98
|
-
params[:username] = config.dor_services.user if config.dor_services&.user.present?
|
99
|
-
params[:password] = config.dor_services.pass if config.dor_services&.pass.present?
|
100
|
-
params[:token] = config.dor_services.token if config.dor_services&.token.present?
|
101
|
-
params[:token_header] = config.dor_services.token_header if config.dor_services&.token_header.present?
|
102
|
-
|
103
|
-
Dor::Services::Client.configure(params)
|
104
|
-
end
|
105
|
-
|
106
|
-
# Act like an ActiveFedora.configurator
|
107
|
-
def init(*args); end
|
108
|
-
|
109
|
-
def fedora_config
|
110
|
-
fedora_uri = URI.parse(fedora.url)
|
111
|
-
connection_opts = { url: fedora.safeurl, user: fedora_uri.user, password: fedora_uri.password }
|
112
|
-
connection_opts[:ssl_client_cert] = OpenSSL::X509::Certificate.new(File.read(ssl.cert_file)) if ssl.cert_file.present?
|
113
|
-
connection_opts[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(ssl.key_file), ssl.key_pass) if ssl.key_file.present?
|
114
|
-
connection_opts[:ssl_cert_store] = default_ssl_cert_store
|
115
|
-
connection_opts
|
116
|
-
end
|
117
|
-
|
118
|
-
def solr_config
|
119
|
-
{ url: solr.url }
|
120
|
-
end
|
121
|
-
|
122
|
-
def predicate_config
|
123
|
-
YAML.load(File.read(File.expand_path('../../config/predicate_mappings.yml', __dir__)))
|
124
|
-
end
|
125
|
-
|
126
|
-
def default_ssl_cert_store
|
127
|
-
@default_ssl_cert_store ||= RestClient::Request.default_ssl_cert_store
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
Config = Configuration.new(YAML.load(File.read(File.expand_path('../../config/config_defaults.yml', __dir__))))
|
6
|
+
defaults = YAML.safe_load(File.read(File.expand_path('../../config/config_defaults.yml', __dir__))).deep_symbolize_keys
|
7
|
+
Config = StaticConfig.new(defaults)
|
132
8
|
ActiveFedora.configurator = Config
|
133
9
|
end
|
@@ -35,6 +35,9 @@ module Dor
|
|
35
35
|
t.shelved_file_id proxy: %i[resource shelved_file id], index_as: %i[displayable stored_searchable]
|
36
36
|
end
|
37
37
|
|
38
|
+
extend Deprecation
|
39
|
+
self.deprecation_horizon = '8.0'
|
40
|
+
|
38
41
|
### READ ONLY METHODS
|
39
42
|
|
40
43
|
# Only use this when you want the behavior of raising an exception if anything besides exactly one matching node
|
@@ -165,6 +168,7 @@ module Dor
|
|
165
168
|
file_node['role'] = file[:role] if file[:role]
|
166
169
|
file_node
|
167
170
|
end
|
171
|
+
deprecation_deprecate :add_file
|
168
172
|
|
169
173
|
# Copies the child's resource into the parent (self) as a virtual resource.
|
170
174
|
# Assumes the resource isn't a duplicate of an existing virtual or real resource.
|
@@ -231,6 +235,7 @@ module Dor
|
|
231
235
|
ng_xml.search('//contentMetadata').first.add_child(node)
|
232
236
|
node
|
233
237
|
end
|
238
|
+
deprecation_deprecate :add_resource
|
234
239
|
|
235
240
|
# @param [String] resource_name ID of the resource
|
236
241
|
def remove_resource(resource_name)
|
@@ -246,12 +251,14 @@ module Dor
|
|
246
251
|
position += 1
|
247
252
|
end
|
248
253
|
end
|
254
|
+
deprecation_deprecate :remove_resource
|
249
255
|
|
250
256
|
# @param [String] file_name ID of the file element
|
251
257
|
def remove_file(file_name)
|
252
258
|
ng_xml_will_change!
|
253
259
|
ng_xml.search('//file[@id=\'' + file_name + '\']').each(&:remove)
|
254
260
|
end
|
261
|
+
deprecation_deprecate :remove_file
|
255
262
|
|
256
263
|
# @param [String] file_name ID of the file element
|
257
264
|
# @param [String] publish
|
@@ -31,7 +31,7 @@ module Dor
|
|
31
31
|
def to_solr(solr_doc = {}, *args)
|
32
32
|
solr_doc = super
|
33
33
|
#::Solrizer.insert_field(solr_doc, field_name, value, *index_types)
|
34
|
-
rd1
|
34
|
+
rd1 = release_date
|
35
35
|
rd20 = twenty_pct_release_date
|
36
36
|
::Solrizer.insert_field(solr_doc, 'embargo_release', rd1.utc.strftime('%FT%TZ'), :dateable) unless rd1.blank?
|
37
37
|
::Solrizer.insert_field(solr_doc, 'twenty_pct_visibility_release', rd20.utc.strftime('%FT%TZ'), :dateable) unless rd20.blank?
|
@@ -40,7 +40,7 @@ module Dor
|
|
40
40
|
val = [actor.at_xpath('identifier/@type'), actor.at_xpath('identifier/text()')].join ':'
|
41
41
|
add_solr_value(solr_doc, "apo_role_#{actor.name}_#{role_type}", val, :string, [:symbol])
|
42
42
|
add_solr_value(solr_doc, "apo_role_#{role_type}", val, :string, [:symbol])
|
43
|
-
add_solr_value(solr_doc, 'apo_register_permissions', val, :string, %i[symbol stored_searchable]) if [
|
43
|
+
add_solr_value(solr_doc, 'apo_register_permissions', val, :string, %i[symbol stored_searchable]) if %w[dor-apo-manager dor-apo-depositor].include? role_type
|
44
44
|
end
|
45
45
|
solr_doc
|
46
46
|
end
|
@@ -53,28 +53,6 @@ module Dor
|
|
53
53
|
ng_xml.at_xpath('/workflow-def/@repository').to_s
|
54
54
|
end
|
55
55
|
|
56
|
-
# Creates the xml used by Dor::Workflow::Client#create_workflow
|
57
|
-
# @return [String] An object's initial workflow as defined by the <workflow-def> in content
|
58
|
-
def initial_workflow
|
59
|
-
doc = Nokogiri::XML('<workflow/>')
|
60
|
-
root = doc.root
|
61
|
-
root['id'] = name
|
62
|
-
processes.each do |proc|
|
63
|
-
doc.create_element 'process' do |node|
|
64
|
-
node['name'] = proc.name
|
65
|
-
if proc.status
|
66
|
-
node['status'] = proc.status
|
67
|
-
node['attempts'] = '1'
|
68
|
-
else
|
69
|
-
node['status'] = 'waiting'
|
70
|
-
end
|
71
|
-
node['lifecycle'] = proc.lifecycle if proc.lifecycle
|
72
|
-
root.add_child node
|
73
|
-
end
|
74
|
-
end
|
75
|
-
Nokogiri::XML(doc.to_xml, &:noblanks).to_xml(&:no_declaration)
|
76
|
-
end
|
77
|
-
|
78
56
|
def to_solr(solr_doc = {}, *args)
|
79
57
|
solr_doc = super(solr_doc, *args)
|
80
58
|
add_solr_value(solr_doc, 'workflow_name', name, :symbol, [:symbol])
|
@@ -1,23 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Dor
|
4
|
-
#
|
5
|
-
class WorkflowDs < ActiveFedora::
|
4
|
+
# Represents the datastream that just holds the location of the workflow service
|
5
|
+
class WorkflowDs < ActiveFedora::Datastream
|
6
6
|
before_save :build_location
|
7
|
-
set_terminology do |t|
|
8
|
-
t.root(path: 'workflows')
|
9
|
-
t.workflow do
|
10
|
-
t.workflowId(path: { attribute: 'id' })
|
11
|
-
t.process do
|
12
|
-
t.name_(path: { attribute: 'name' }, index_as: %i[displayable not_searchable])
|
13
|
-
t.status(path: { attribute: 'status' }, index_as: %i[displayable not_searchable])
|
14
|
-
t.timestamp(path: { attribute: 'datetime' }, index_as: %i[displayable not_searchable]) # , :data_type => :date)
|
15
|
-
t.elapsed(path: { attribute: 'elapsed' }, index_as: %i[displayable not_searchable])
|
16
|
-
t.lifecycle(path: { attribute: 'lifecycle' }, index_as: %i[displayable not_searchable])
|
17
|
-
t.attempts(path: { attribute: 'attempts' }, index_as: %i[displayable not_searchable])
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
7
|
|
22
8
|
# Called before saving, but after a pid has been assigned
|
23
9
|
def build_location
|
@@ -30,53 +16,5 @@ module Dor
|
|
30
16
|
def self.default_attributes
|
31
17
|
super.merge(mimeType: 'application/xml')
|
32
18
|
end
|
33
|
-
|
34
|
-
def ng_xml
|
35
|
-
@ng_xml ||= Nokogiri::XML::Document.parse(content)
|
36
|
-
end
|
37
|
-
|
38
|
-
# @param [Boolean] refresh The WorkflowDS caches the content retrieved from the workflow
|
39
|
-
# service. This flag will invalidate the cached content and refetch it from the workflow
|
40
|
-
# service directly
|
41
|
-
def content(refresh = false)
|
42
|
-
@content = nil if refresh
|
43
|
-
@content ||= Dor::Config.workflow.client.all_workflows_xml pid
|
44
|
-
rescue Dor::WorkflowException => e
|
45
|
-
# TODO: I don't understand when this would be useful as this block ends up calling the workflow service too.
|
46
|
-
# Why not just raise an exception here?
|
47
|
-
Dor.logger.warn "Unable to connect to the workflow service #{e}. Falling back to placeholder XML"
|
48
|
-
xml = Nokogiri::XML(%(<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<workflows objectId="#{pid}"/>))
|
49
|
-
digital_object.datastreams.keys.each do |dsid|
|
50
|
-
next unless dsid =~ /WF$/
|
51
|
-
|
52
|
-
ds_content = Nokogiri::XML(Dor::Config.workflow.client.workflow_xml('dor', pid, dsid))
|
53
|
-
xml.root.add_child(ds_content.root)
|
54
|
-
end
|
55
|
-
@content ||= xml.to_xml
|
56
|
-
end
|
57
|
-
|
58
|
-
def workflows
|
59
|
-
@workflows ||= workflow.nodeset.collect { |wf_node| Workflow::Document.new wf_node.to_xml }
|
60
|
-
end
|
61
|
-
|
62
|
-
# Finds the first workflow that is expedited, then returns the value of its priority
|
63
|
-
#
|
64
|
-
# @return [Integer] value of the priority. Defaults to 0 if none of the workflows are expedited
|
65
|
-
def current_priority
|
66
|
-
cp = workflows.detect(&:expedited?)
|
67
|
-
return 0 if cp.nil?
|
68
|
-
|
69
|
-
cp.priority.to_i
|
70
|
-
end
|
71
|
-
|
72
|
-
def to_solr(solr_doc = {}, *_args)
|
73
|
-
# noop - indexing is done by the WorkflowsIndexer
|
74
|
-
solr_doc
|
75
|
-
end
|
76
|
-
|
77
|
-
# maintain AF < 8 indexing behavior
|
78
|
-
def prefix
|
79
|
-
''
|
80
|
-
end
|
81
19
|
end
|
82
20
|
end
|