Skip to content

Commit

Permalink
Remove workflow initiation
Browse files Browse the repository at this point in the history
This behavior was previously deprecated
  • Loading branch information
jcoyne committed Jun 4, 2019
1 parent 2afe375 commit 7fbc137
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 134 deletions.
29 changes: 9 additions & 20 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-05-31 17:18:29 -0500 using RuboCop version 0.65.0.
# on 2019-06-04 08:56:27 -0500 using RuboCop version 0.65.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -29,9 +29,9 @@ Lint/UriEscapeUnescape:
- 'app/controllers/sdr_controller.rb'
- 'spec/controllers/sdr_controller_spec.rb'

# Offense count: 24
# Offense count: 22
Metrics/AbcSize:
Max: 94
Max: 91

# Offense count: 3
# Configuration parameters: CountComments.
Expand All @@ -42,7 +42,7 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Max: 11

# Offense count: 27
# Offense count: 26
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 43
Expand Down Expand Up @@ -100,14 +100,13 @@ RSpec/Be:
Exclude:
- 'spec/services/public_xml_service_spec.rb'

# Offense count: 2
# Offense count: 1
RSpec/BeforeAfterAll:
Exclude:
- 'spec/spec_helper.rb'
- 'spec/rails_helper.rb'
- 'spec/support/**/*.rb'
- 'spec/dor/update_marc_record_service_spec.rb'
- 'spec/services/cleanup_reset_service_spec.rb'

# Offense count: 31
# Configuration parameters: Prefixes.
Expand Down Expand Up @@ -165,7 +164,7 @@ RSpec/ExpectInHook:
- 'spec/services/publish_metadata_service_spec.rb'
- 'spec/services/registration_service_spec.rb'

# Offense count: 237
# Offense count: 240
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
Expand All @@ -175,13 +174,12 @@ RSpec/InstanceVariable:
- 'spec/services/cleanup_reset_service_spec.rb'
- 'spec/services/registration_service_spec.rb'

# Offense count: 40
# Offense count: 39
# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Exclude:
- 'spec/controllers/objects_controller_spec.rb'
- 'spec/controllers/workflows_controller_spec.rb'
- 'spec/dor/update_marc_record_service_spec.rb'
- 'spec/services/public_desc_metadata_service_spec.rb'
- 'spec/services/registration_service_spec.rb'
Expand All @@ -193,7 +191,7 @@ RSpec/NamedSubject:
Exclude:
- 'spec/services/thumbnail_service_spec.rb'

# Offense count: 23
# Offense count: 22
RSpec/NestedGroups:
Max: 5

Expand All @@ -205,14 +203,6 @@ RSpec/PredicateMatcher:
Exclude:
- 'spec/dor/update_marc_record_service_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: and_return, block
RSpec/ReturnFromStub:
Exclude:
- 'spec/controllers/workflows_controller_spec.rb'

# Offense count: 2
RSpec/ScatteredLet:
Exclude:
Expand Down Expand Up @@ -275,7 +265,7 @@ Style/ConditionalAssignment:
Exclude:
- 'spec/support/foxml_helper.rb'

# Offense count: 14
# Offense count: 13
Style/Documentation:
Exclude:
- 'spec/**/*'
Expand All @@ -284,7 +274,6 @@ Style/Documentation:
- 'app/controllers/objects_controller.rb'
- 'app/controllers/sdr_controller.rb'
- 'app/controllers/versions_controller.rb'
- 'app/controllers/workflows_controller.rb'
- 'app/models/dor/registration_response.rb'
- 'app/models/dor/service_item.rb'
- 'app/models/dor/update_marc_record_service.rb'
Expand Down
15 changes: 0 additions & 15 deletions app/controllers/objects_controller.rb
Expand Up @@ -66,21 +66,6 @@ def release_tags
end
end

# Initiate a workflow by name
# This service is called by several different clients (e.g. was-archiving-robots, preservation-catalog, GIS, Goobi)
def apo_workflows
workflow = if params[:wf_name].ends_with? 'WF'
params[:wf_name]
else
"#{params[:wf_name]}WF"
end

Honeybadger.notify("Call to deprecated API #{request.path}. Use workflow-service instead")
Dor::Config.workflow.client.create_workflow_by_name(@item.pid, workflow)

head :created
end

private

def fedora_base
Expand Down
8 changes: 0 additions & 8 deletions app/controllers/workflows_controller.rb

This file was deleted.

10 changes: 0 additions & 10 deletions app/models/registration_request.rb
Expand Up @@ -14,9 +14,7 @@ class RegistrationRequest
# @option params [Hash{String => String}] :source_id Primary ID from another system, max one key/value pair!
# @option params [Hash] :other_ids including :uuid if known
# @option params [String] :pid Fully qualified PID if you don't want one generated for you
# @option params [Integer] :workflow_priority]
# @option params [Array<String>] :seed_datastream datastream_names (only 'descMetadata' is a permitted value)
# @option params [Array<String>] :initiate_workflow workflow_ids this parameter is deprecated
# @option params [Array] :tags
def initialize(params)
@params = params
Expand Down Expand Up @@ -47,14 +45,6 @@ def rights
params[:rights]
end

def initiate_workflow
Array(params[:initiate_workflow])
end

def workflow_priority
params[:workflow_priority] ? params[:workflow_priority].to_i : 0
end

def object_type
params[:object_type]
end
Expand Down
17 changes: 2 additions & 15 deletions app/services/registration_service.rb
Expand Up @@ -22,13 +22,12 @@ def registration_request_params(params)
other_ids = namespace_identifiers(Array(params[:other_id]))
handle_auto_label(params, other_ids)

params.slice(:pid, :admin_policy, :label, :object_type, :parent, :seed_datastream, :rights, :metadata_source, :collection, :workflow_priority)
params.slice(:pid, :admin_policy, :label, :object_type, :parent, :seed_datastream, :rights, :metadata_source, :collection)
.merge(
content_model: params[:model],
other_ids: ids_to_hash(other_ids),
source_id: ids_to_hash(params[:source_id]),
tags: params[:tag] || [],
initiate_workflow: Array(params[:initiate_workflow]) + Array(params[:workflow_id])
tags: params[:tag] || []
)
.reject { |_k, v| v.nil? }
end
Expand Down Expand Up @@ -122,10 +121,6 @@ def register_object(request)
end

new_item.save

# Once we save, then it's safe to start any workflows. Otherwise there could be a race condition
initiate_workflow(workflows: request.initiate_workflow, item: new_item, priority: request.workflow_priority)

new_item
end

Expand All @@ -135,14 +130,6 @@ def ids_to_hash(ids)
Hash[Array(ids).map { |id| id.split(':', 2) }]
end

def initiate_workflow(workflows:, item:, priority:)
Honeybadger.notify("RegistrationService received deprecated parameter `initiate_workflow' with: `#{workflows.inspect}'") if workflows.present?

workflows.each do |workflow_id|
Dor::Config.workflow.client.create_workflow_by_name(item.pid, workflow_id, priority: priority, version: item.current_version)
end
end

def build_desc_metadata_from_label(new_item, label)
builder = Nokogiri::XML::Builder.new do |xml|
xml.mods(Dor::DescMetadataDS::MODS_HEADER_CONFIG) do
Expand Down
6 changes: 0 additions & 6 deletions config/routes.rb
Expand Up @@ -14,10 +14,6 @@
get 'content/:filename', to: 'sdr#file_content', format: false, constraints: { filename: /.+/ }
end

scope '/workflows/:wf_name' do
get 'initial', to: 'workflows#initial'
end

scope :catalog do
get 'marcxml', to: 'marcxml#marcxml'
get 'mods', to: 'marcxml#mods'
Expand All @@ -31,8 +27,6 @@
post 'update_marc_record'
post 'notify_goobi'
post 'release_tags'
post 'apo_workflows/:wf_name', action: 'apo_workflows'

post 'refresh_metadata', to: 'metadata_refresh#refresh'

get 'contents', to: 'content#list'
Expand Down
18 changes: 0 additions & 18 deletions spec/controllers/objects_controller_spec.rb
Expand Up @@ -129,22 +129,4 @@
expect(response.status).to eq(400)
end
end

describe 'apo-workflow initalization' do
let(:workflow_client) { instance_double(Dor::Workflow::Client, create_workflow_by_name: true) }

before do
allow(Dor::Config.workflow).to receive(:client).and_return(workflow_client)
end

it 'initiates assemblyWF' do
post 'apo_workflows', params: { id: item.pid, wf_name: 'assemblyWF' }
expect(workflow_client).to have_received(:create_workflow_by_name).with(item.pid, 'assemblyWF')
end

it "handles workflow names without 'WF' appended to the end" do
post 'apo_workflows', params: { id: item.pid, wf_name: 'accession' }
expect(workflow_client).to have_received(:create_workflow_by_name).with(item.pid, 'accessionWF')
end
end
end
27 changes: 0 additions & 27 deletions spec/controllers/workflows_controller_spec.rb

This file was deleted.

15 changes: 0 additions & 15 deletions spec/services/registration_service_spec.rb
Expand Up @@ -340,21 +340,6 @@
obj = register
expect(obj.label).to eq('a' * 254)
end

context 'when initiate workflow is passed in' do
let(:workflow_client) { instance_double(Dor::Workflow::Client, create_workflow_by_name: true) }

before do
allow(Dor::Config.workflow).to receive(:client).and_return(workflow_client)
end

it 'sets priority' do
@params[:workflow_priority] = 50
@params[:initiate_workflow] = 'digitizationWF'
register
expect(workflow_client).to have_received(:create_workflow_by_name).with(String, 'digitizationWF', priority: 50, version: '1')
end
end
end # context common cases
end

Expand Down

0 comments on commit 7fbc137

Please sign in to comment.