dor-services 8.3.0 → 8.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 122c50609b2053d3b4083b985fcc128fd89726687a5bdf1230a4bbfafb55355f
4
- data.tar.gz: 5c375fe22a648e6a697902a056b6752962cd78d7ecaa6c58d3b7c7049b1181fc
3
+ metadata.gz: 211ce0eefc758823b5dced495a74a980025d82884639a720a30ff97f20179cf6
4
+ data.tar.gz: f21f78c40a74231051b08762cea0c4c49f7cb47663ec5c6b9f24bc4189fef4f0
5
5
  SHA512:
6
- metadata.gz: 073f7a22dfe87e282a156ea6f1b14ad1971bafa79e29334d95da14a89c094b0c0e68f7b706519b0ea5d928de665383846c33563e8f4c98a6d9e7b291192c07aa
7
- data.tar.gz: 8c5424ada3a28d7acee8061d398a436f8cc9b214a299d40e4ad15a8337967ff176f5a376b59eed55239a0e412c0f99ef0870b3865e515627fd2a12f655bfe338
6
+ metadata.gz: 36a41ca02293ad622536768705b960ffa68bacb291cf6ef787b3181fcf0b5222050f29b0f5fd23ad350ba64a815cbcce9ddcb37c71004ebfc8cc96c1f666c527
7
+ data.tar.gz: ab9e98f31624be15f00701d24184e357014c2e5f9f0fdc3d7042293610fe6939b1323865bd882733638f98e2584df2749ac209e8e07770f30efa43273e1de9e7
data/lib/dor-services.rb CHANGED
@@ -57,6 +57,7 @@ module Dor
57
57
  autoload :EditableIndexer
58
58
  autoload :IdentifiableIndexer
59
59
  autoload :ProcessableIndexer
60
+ autoload :ProcessIndexer
60
61
  autoload :ReleasableIndexer
61
62
  autoload :WorkflowIndexer
62
63
  autoload :WorkflowsIndexer
@@ -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
- index_process(solr_doc, process)
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(workflow), errors, repository].join('|')
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
- # @param [Workflow::Response::Process] process
44
- def index_process(solr_doc, process)
45
- return unless process.status
46
-
47
- # add a record of the robot having operated on this item, so we can track robot activity
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 process_has_time?(process)
63
- process.datetime && process.status && (process.status == 'completed' || process.status == 'error')
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(workflow)
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 type [Symbol] the type of connection to create (e.g. :fedora)
8
+ # @param url [String] the url to connect to
9
9
  # @return [RestClient::Resource]
10
- def self.create(type)
11
- instance.create(type)
10
+ def self.create(url)
11
+ instance.create(url)
12
12
  end
13
13
 
14
- # @param type [Symbol] the type of connection to create (e.g. :fedora)
14
+ # @param url [String] the url to connect to
15
15
  # @return [RestClient::Resource]
16
- def create(type)
17
- RestClient::Resource.new(url_for(type), connection_options)
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)
@@ -15,7 +15,7 @@ module Dor
15
15
  end
16
16
 
17
17
  def client
18
- CertificateAuthenticatedRestResourceFactory.create(:fedora)
18
+ CertificateAuthenticatedRestResourceFactory.create(url)
19
19
  end
20
20
 
21
21
  def url(new_value = nil)
data/lib/dor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dor
4
- VERSION = '8.3.0'
4
+ VERSION = '8.4.0'
5
5
  end
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.3.0
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-01-08 00:00:00.000000000 Z
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