dor-services 8.3.0 → 8.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dor-services.rb +1 -0
- data/lib/dor/indexers/identifiable_indexer.rb +1 -0
- data/lib/dor/indexers/process_indexer.rb +58 -0
- data/lib/dor/indexers/workflow_indexer.rb +12 -43
- data/lib/dor/release_tags/identity_metadata.rb +2 -0
- data/lib/dor/rest_resource_factory.rb +6 -20
- data/lib/dor/services/release_tag_service.rb +0 -2
- data/lib/dor/static_config/fedora_config.rb +1 -1
- data/lib/dor/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 211ce0eefc758823b5dced495a74a980025d82884639a720a30ff97f20179cf6
|
4
|
+
data.tar.gz: f21f78c40a74231051b08762cea0c4c49f7cb47663ec5c6b9f24bc4189fef4f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36a41ca02293ad622536768705b960ffa68bacb291cf6ef787b3181fcf0b5222050f29b0f5fd23ad350ba64a815cbcce9ddcb37c71004ebfc8cc96c1f666c527
|
7
|
+
data.tar.gz: ab9e98f31624be15f00701d24184e357014c2e5f9f0fdc3d7042293610fe6939b1323865bd882733638f98e2584df2749ac209e8e07770f30efa43273e1de9e7
|
data/lib/dor-services.rb
CHANGED
@@ -25,6 +25,7 @@ module Dor
|
|
25
25
|
solr_doc[INDEX_VERSION_FIELD] = Dor::VERSION
|
26
26
|
solr_doc['indexed_at_dtsi'] = Time.now.utc.xmlschema
|
27
27
|
resource.datastreams.values.each do |ds|
|
28
|
+
# This is used to draw the table of datastreams in Argo
|
28
29
|
add_solr_value(solr_doc, 'ds_specs', ds.datastream_spec_string, :string, [:symbol]) unless ds.new?
|
29
30
|
end
|
30
31
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dor
|
4
|
+
# Indexes the process for a workflow
|
5
|
+
class ProcessIndexer
|
6
|
+
ERROR_OMISSION = '... (continued)'
|
7
|
+
private_constant :ERROR_OMISSION
|
8
|
+
|
9
|
+
# see https://lucene.apache.org/core/7_3_1/core/org/apache/lucene/util/BytesRefHash.MaxBytesLengthExceededException.html
|
10
|
+
MAX_ERROR_LENGTH = 32_768 - 2 - ERROR_OMISSION.length
|
11
|
+
private_constant :MAX_ERROR_LENGTH
|
12
|
+
|
13
|
+
# @param [WorkflowSolrDocument] solr_doc
|
14
|
+
# @param [String] workflow_name
|
15
|
+
# @param [Dor::Workflow::Response::Process] process
|
16
|
+
def initialize(solr_doc:, workflow_name:, process:)
|
17
|
+
@solr_doc = solr_doc
|
18
|
+
@workflow_name = workflow_name
|
19
|
+
@process = process
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Hash] the partial solr document for the workflow document
|
23
|
+
def to_solr
|
24
|
+
return unless status
|
25
|
+
|
26
|
+
# add a record of the robot having operated on this item, so we can track robot activity
|
27
|
+
solr_doc.add_process_time(workflow_name, name, Time.parse(process.datetime)) if has_time?
|
28
|
+
|
29
|
+
index_error_message
|
30
|
+
|
31
|
+
# workflow name, process status then process name
|
32
|
+
solr_doc.add_wsp("#{workflow_name}:#{status}", "#{workflow_name}:#{status}:#{name}")
|
33
|
+
|
34
|
+
# workflow name, process name then process status
|
35
|
+
solr_doc.add_wps("#{workflow_name}:#{name}", "#{workflow_name}:#{name}:#{status}")
|
36
|
+
|
37
|
+
# process status, workflowname then process name
|
38
|
+
solr_doc.add_swp(process.status.to_s, "#{status}:#{workflow_name}", "#{status}:#{workflow_name}:#{name}")
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
attr_reader :process, :workflow_name, :solr_doc
|
44
|
+
delegate :status, :name, :state, :error_message, :datetime, to: :process
|
45
|
+
|
46
|
+
def has_time?
|
47
|
+
datetime && (status == 'completed' || status == 'error')
|
48
|
+
end
|
49
|
+
|
50
|
+
# index the error message without the druid so we hopefully get some overlap
|
51
|
+
# truncate to avoid org.apache.lucene.util.BytesRefHash$MaxBytesLengthExceededException
|
52
|
+
def index_error_message
|
53
|
+
return unless error_message
|
54
|
+
|
55
|
+
solr_doc.error = "#{workflow_name}:#{name}:#{error_message}".truncate(MAX_ERROR_LENGTH, omission: ERROR_OMISSION)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -3,13 +3,6 @@
|
|
3
3
|
module Dor
|
4
4
|
# Indexes the objects position in workflows
|
5
5
|
class WorkflowIndexer
|
6
|
-
ERROR_OMISSION = '... (continued)'
|
7
|
-
private_constant :ERROR_OMISSION
|
8
|
-
|
9
|
-
# see https://lucene.apache.org/core/7_3_1/core/org/apache/lucene/util/BytesRefHash.MaxBytesLengthExceededException.html
|
10
|
-
MAX_ERROR_LENGTH = 32_768 - 2 - ERROR_OMISSION.length
|
11
|
-
private_constant :MAX_ERROR_LENGTH
|
12
|
-
|
13
6
|
# @param [Workflow::Response::Workflow] workflow the workflow document to index
|
14
7
|
def initialize(workflow:)
|
15
8
|
@workflow = workflow
|
@@ -18,20 +11,14 @@ module Dor
|
|
18
11
|
# @return [Hash] the partial solr document for the workflow document
|
19
12
|
def to_solr
|
20
13
|
WorkflowSolrDocument.new do |solr_doc|
|
21
|
-
definition = Dor::Config.workflow.client.workflow_template(workflow_name)
|
22
14
|
solr_doc.name = workflow_name
|
23
|
-
definition_process_names = definition['processes'].map { |p| p['name'] }
|
24
15
|
|
25
16
|
errors = 0 # The error count is used by the Report class in Argo
|
26
|
-
processes = definition_process_names.map do |process_name|
|
27
|
-
workflow.process_for_recent_version(name: process_name)
|
28
|
-
end
|
29
|
-
|
30
17
|
processes.each do |process|
|
31
|
-
|
18
|
+
ProcessIndexer.new(solr_doc: solr_doc, workflow_name: workflow_name, process: process).to_solr
|
32
19
|
errors += 1 if process.status == 'error'
|
33
20
|
end
|
34
|
-
solr_doc.status = [workflow_name, workflow_status
|
21
|
+
solr_doc.status = [workflow_name, workflow_status, errors, repository].join('|')
|
35
22
|
end
|
36
23
|
end
|
37
24
|
|
@@ -40,39 +27,21 @@ module Dor
|
|
40
27
|
attr_reader :workflow
|
41
28
|
delegate :workflow_name, :repository, to: :workflow
|
42
29
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
solr_doc.add_process_time(workflow_name, process.name, Time.parse(process.datetime)) if process_has_time?(process)
|
49
|
-
|
50
|
-
index_error_message(solr_doc, process)
|
51
|
-
|
52
|
-
# workflow name, process status then process name
|
53
|
-
solr_doc.add_wsp("#{workflow_name}:#{process.status}", "#{workflow_name}:#{process.status}:#{process.name}")
|
54
|
-
|
55
|
-
# workflow name, process name then process status
|
56
|
-
solr_doc.add_wps("#{workflow_name}:#{process.name}", "#{workflow_name}:#{process.name}:#{process.status}")
|
57
|
-
|
58
|
-
# process status, workflowname then process name
|
59
|
-
solr_doc.add_swp(process.status.to_s, "#{process.status}:#{workflow_name}", "#{process.status}:#{workflow_name}:#{process.name}")
|
30
|
+
def definition_process_names
|
31
|
+
@definition_process_names ||= begin
|
32
|
+
definition = Dor::Config.workflow.client.workflow_template(workflow_name)
|
33
|
+
definition['processes'].map { |p| p['name'] }
|
34
|
+
end
|
60
35
|
end
|
61
36
|
|
62
|
-
def
|
63
|
-
|
37
|
+
def processes
|
38
|
+
@processes ||= definition_process_names.map do |process_name|
|
39
|
+
workflow.process_for_recent_version(name: process_name)
|
40
|
+
end
|
64
41
|
end
|
65
42
|
|
66
|
-
def workflow_status
|
43
|
+
def workflow_status
|
67
44
|
workflow.complete? ? 'completed' : 'active'
|
68
45
|
end
|
69
|
-
|
70
|
-
# index the error message without the druid so we hopefully get some overlap
|
71
|
-
# truncate to avoid org.apache.lucene.util.BytesRefHash$MaxBytesLengthExceededException
|
72
|
-
def index_error_message(solr_doc, process)
|
73
|
-
return unless process.error_message
|
74
|
-
|
75
|
-
solr_doc.error = "#{workflow_name}:#{process.name}:#{process.error_message}".truncate(MAX_ERROR_LENGTH, omission: ERROR_OMISSION)
|
76
|
-
end
|
77
46
|
end
|
78
47
|
end
|
@@ -181,6 +181,8 @@ module Dor
|
|
181
181
|
# @return [Hash] same form as new_tags, with all missing tags not in new_tags, but in current_tag_names, added in with a Boolean value of false
|
182
182
|
def add_tags_from_purl(new_tags)
|
183
183
|
missing_tags = release_tags_from_purl.map(&:downcase) - new_tags.keys.map(&:downcase)
|
184
|
+
Honeybadger.notify("Found missing release tags on PURL for #{pid}: #{missing_tags.inspect}") if missing_tags.present? && defined? Honeybadger
|
185
|
+
|
184
186
|
missing_tags.each do |missing_tag|
|
185
187
|
new_tags[missing_tag.capitalize] = { 'release' => false }
|
186
188
|
end
|
@@ -5,34 +5,20 @@ module Dor
|
|
5
5
|
class RestResourceFactory
|
6
6
|
include Singleton
|
7
7
|
|
8
|
-
# @param
|
8
|
+
# @param url [String] the url to connect to
|
9
9
|
# @return [RestClient::Resource]
|
10
|
-
def self.create(
|
11
|
-
instance.create(
|
10
|
+
def self.create(url)
|
11
|
+
instance.create(url)
|
12
12
|
end
|
13
13
|
|
14
|
-
# @param
|
14
|
+
# @param url [String] the url to connect to
|
15
15
|
# @return [RestClient::Resource]
|
16
|
-
def create(
|
17
|
-
RestClient::Resource.new(
|
16
|
+
def create(url)
|
17
|
+
RestClient::Resource.new(url, connection_options)
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
# @param type [Symbol] the type of connection to create (e.g. :fedora)
|
23
|
-
# @return [String] the url to connect to.
|
24
|
-
def url_for(type)
|
25
|
-
connection_configuration(type).url
|
26
|
-
end
|
27
|
-
|
28
|
-
# @param type [Symbol] the type of connection to create (e.g. :fedora)
|
29
|
-
# @return [#url] the configuration for the connection
|
30
|
-
def connection_configuration(type)
|
31
|
-
Dor::Config.fetch(type)
|
32
|
-
rescue KeyError
|
33
|
-
raise "ERROR: Unable to find a configuration for #{type}"
|
34
|
-
end
|
35
|
-
|
36
22
|
# @return [Hash] options for creating a RestClient::Resource
|
37
23
|
def connection_options
|
38
24
|
{}
|
@@ -12,8 +12,6 @@ module Dor
|
|
12
12
|
def initialize(item)
|
13
13
|
@identity_metadata_service = ReleaseTags::IdentityMetadata.new(item)
|
14
14
|
@purl_service = ReleaseTags::Purl.new(pid: item.pid, purl_host: Dor::Config.stacks.document_cache_host)
|
15
|
-
|
16
|
-
@item = item
|
17
15
|
end
|
18
16
|
|
19
17
|
# Called in Dor::UpdateMarcRecordService (in dor-services-app too)
|
data/lib/dor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klein
|
@@ -20,7 +20,7 @@ authors:
|
|
20
20
|
autorequire:
|
21
21
|
bindir: bin
|
22
22
|
cert_chain: []
|
23
|
-
date: 2020-
|
23
|
+
date: 2020-02-05 00:00:00.000000000 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: active-fedora
|
@@ -483,6 +483,7 @@ files:
|
|
483
483
|
- lib/dor/indexers/describable_indexer.rb
|
484
484
|
- lib/dor/indexers/editable_indexer.rb
|
485
485
|
- lib/dor/indexers/identifiable_indexer.rb
|
486
|
+
- lib/dor/indexers/process_indexer.rb
|
486
487
|
- lib/dor/indexers/processable_indexer.rb
|
487
488
|
- lib/dor/indexers/releasable_indexer.rb
|
488
489
|
- lib/dor/indexers/workflow_indexer.rb
|