Sha256: 91e36f79370895210f56f1842e98884376a4cf2e108741353dffd20868c35b8b

Contents?: true

Size: 1.97 KB

Versions: 22

Compression:

Stored size: 1.97 KB

Contents

module Actions
  module Katello
    module Product
      class Destroy < Actions::EntryAction
        # rubocop:disable MethodLength
        def plan(product, options = {})
          organization_destroy = options.fetch(:organization_destroy, false)

          unless organization_destroy || product.user_deletable?
            fail _("Cannot delete a Red Hat Products or Products with Repositories published in a Content View")
          end

          action_subject(product)

          sequence do
            unless organization_destroy
              concurrence do
                product.repositories.in_default_view.each do |repo|
                  repo_options = options.clone
                  repo_options[:planned_destroy] = true
                  plan_action(Katello::Repository::Destroy, repo, repo_options)
                end
              end
              concurrence do
                plan_action(Candlepin::Product::DeletePools,
                              cp_id: product.cp_id, organization_label: product.organization.label)
                plan_action(Candlepin::Product::DeleteSubscriptions,
                              cp_id: product.cp_id, organization_label: product.organization.label)
              end
            end

            if !product.used_by_another_org? && !organization_destroy
              concurrence do
                product.productContent.each do |pc|
                  plan_action(Candlepin::Product::ContentRemove,
                              product_id: product.cp_id,
                              content_id: pc.content.id)
                end
              end
              plan_action(Candlepin::Product::Destroy, cp_id: product.cp_id)
            end

            plan_self(:product_id => product.id)
          end
        end

        def finalize
          product = ::Katello::Product.find(input[:product_id])
          product.destroy!
        end

        def humanized_name
          _("Delete Product")
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
katello-3.1.0.1 app/lib/actions/katello/product/destroy.rb
katello-3.1.0 app/lib/actions/katello/product/destroy.rb
katello-3.1.0.rc2.1 app/lib/actions/katello/product/destroy.rb
katello-3.0.2 app/lib/actions/katello/product/destroy.rb
katello-2.4.5 app/lib/actions/katello/product/destroy.rb
katello-3.1.0.rc1 app/lib/actions/katello/product/destroy.rb
katello-3.0.1 app/lib/actions/katello/product/destroy.rb
katello-2.4.4 app/lib/actions/katello/product/destroy.rb
katello-3.0.0 app/lib/actions/katello/product/destroy.rb
katello-2.4.3 app/lib/actions/katello/product/destroy.rb
katello-3.0.0.rc7 app/lib/actions/katello/product/destroy.rb
katello-3.0.0.rc5 app/lib/actions/katello/product/destroy.rb
katello-2.4.2 app/lib/actions/katello/product/destroy.rb
katello-3.0.0.rc4 app/lib/actions/katello/product/destroy.rb
katello-3.0.0.rc3 app/lib/actions/katello/product/destroy.rb
katello-3.0.0.rc2 app/lib/actions/katello/product/destroy.rb
katello-3.0.0.rc1 app/lib/actions/katello/product/destroy.rb
katello-2.4.1 app/lib/actions/katello/product/destroy.rb
katello-2.4.0 app/lib/actions/katello/product/destroy.rb
katello-2.4.0.rc3 app/lib/actions/katello/product/destroy.rb