diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8731bc406..aa00078f7 100644 --- a/.rubocop_todo.yml +++ b/.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 @@ -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. @@ -42,7 +42,7 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Max: 11 -# Offense count: 27 +# Offense count: 26 # Configuration parameters: CountComments, ExcludedMethods. Metrics/MethodLength: Max: 43 @@ -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. @@ -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: @@ -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' @@ -193,7 +191,7 @@ RSpec/NamedSubject: Exclude: - 'spec/services/thumbnail_service_spec.rb' -# Offense count: 23 +# Offense count: 22 RSpec/NestedGroups: Max: 5 @@ -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: @@ -275,7 +265,7 @@ Style/ConditionalAssignment: Exclude: - 'spec/support/foxml_helper.rb' -# Offense count: 14 +# Offense count: 13 Style/Documentation: Exclude: - 'spec/**/*' @@ -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' diff --git a/app/controllers/objects_controller.rb b/app/controllers/objects_controller.rb index f912665a5..2d115d148 100644 --- a/app/controllers/objects_controller.rb +++ b/app/controllers/objects_controller.rb @@ -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 diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb deleted file mode 100644 index d66e2d64f..000000000 --- a/app/controllers/workflows_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class WorkflowsController < ApplicationController - def initial - Honeybadger.notify("Call to deprecated API #{request.path}. The workflow server now knows about initial_workflow") - render content_type: 'application/xml', body: Dor::WorkflowObject.initial_workflow(params[:wf_name]) - end -end diff --git a/app/models/registration_request.rb b/app/models/registration_request.rb index 05697cae6..e6fcc25a6 100644 --- a/app/models/registration_request.rb +++ b/app/models/registration_request.rb @@ -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] :seed_datastream datastream_names (only 'descMetadata' is a permitted value) - # @option params [Array] :initiate_workflow workflow_ids this parameter is deprecated # @option params [Array] :tags def initialize(params) @params = params @@ -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 diff --git a/app/services/registration_service.rb b/app/services/registration_service.rb index 53247ef70..abf24e4e8 100644 --- a/app/services/registration_service.rb +++ b/app/services/registration_service.rb @@ -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 @@ -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 @@ -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 diff --git a/config/routes.rb b/config/routes.rb index d5f82d30c..20151b633 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' @@ -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' diff --git a/spec/controllers/objects_controller_spec.rb b/spec/controllers/objects_controller_spec.rb index 29e6e931b..ce528f32b 100644 --- a/spec/controllers/objects_controller_spec.rb +++ b/spec/controllers/objects_controller_spec.rb @@ -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 diff --git a/spec/controllers/workflows_controller_spec.rb b/spec/controllers/workflows_controller_spec.rb deleted file mode 100644 index 49c52eb39..000000000 --- a/spec/controllers/workflows_controller_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe WorkflowsController do - before do - login - allow(Honeybadger).to receive(:notify) - end - - it "GET of /workflows/{wfname}/initial returns the an initial instance of the workflow's xml" do - expect(Dor::WorkflowObject).to receive(:initial_workflow).with('accessionWF') { - <<-XML - - - - - XML - } - - get :initial, params: { wf_name: 'accessionWF' } - - expect(response.content_type).to eq('application/xml') - expect(response.body).to match(/start-accession/) - expect(Honeybadger).to have_received(:notify).with(/Call to deprecated API/) - end -end diff --git a/spec/services/registration_service_spec.rb b/spec/services/registration_service_spec.rb index e88a3fab6..8a66d6dcd 100644 --- a/spec/services/registration_service_spec.rb +++ b/spec/services/registration_service_spec.rb @@ -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