<commit_before>class MiddlewareServerController < ApplicationController
  include EmsCommon
  include ContainersCommonMixin
  include MiddlewareCommonMixin

  before_action :check_privileges
  before_action :get_session_data
  after_action :cleanup_action
  after_action :set_session_data

  OPERATIONS = {
    :middleware_server_reload   => {:op   => :reload_middleware_server,
                                    :skip => true,
                                    :hawk => N_('reloading'),
                                    :msg  => N_('Reload')
  },
    :middleware_server_stop     => {:op   => :stop_middleware_server,
                                    :skip => true,
                                    :hawk => N_('stopping'),
                                    :msg  => N_('Stop')
    },
    :middleware_server_restart  => {:op   => :restart_middleware_server,
                                    :skip => true,
                                    :hawk => N_('restarting'),
                                    :msg  => N_('Restart')
    },
    :middleware_server_shutdown => {:op    => :shutdown_middleware_server,
                                    :skip  => true,
                                    :hawk  => N_('shutting down'),
                                    :msg   => N_('Shutdown'),
                                    :param => :timeout
    },
    :middleware_server_suspend  => {:op    => :suspend_middleware_server,
                                    :skip  => true,
                                    :hawk  => N_('suspending'),
                                    :msg   => N_('Suspend'),
                                    :param => :timeout
    },
    :middleware_server_resume   => {:op   => :resume_middleware_server,
                                    :skip => true,
                                    :hawk => N_('resuming'),
                                    :msg  => N_('Resume')
    },
    :middleware_add_deployment  => {:op    => :add_middleware_deployment,
                                    :skip  => false,
                                    :hawk  => N_('Not deploying to Hawkular server'),
                                    :msg   => N_('Deployment initiated for selected server(s)'),
                                    :param => :file
    }
  }.freeze

  def add_deployment
    selected_servers = identify_selected_servers

    params[:file] = {
      :file         => params["file"],
      :enabled      => params["enabled"],
      :runtime_name => params["runtimeName"]
    }
    run_server_operation(OPERATIONS.fetch(:middleware_add_deployment), selected_servers)

    render :update do |page|
      page << javascript_prologue
      page.replace("flash_msg_div", :partial => "layouts/flash_msg")
    end
  end

  def show
    clear_topology_breadcrumb
    @display = params[:display] || "main" unless control_selected?
    @lastaction = "show"
    @showtype = "main"
    @record = identify_record(params[:id], ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareServer)

    if @display == 'middleware_datasources'
      show_container_display(@record, 'middleware_datasource', MiddlewareDatasource)
    elsif @display == 'middleware_deployments'
      show_container_display(@record, 'middleware_deployment', MiddlewareDeployment)
    else
      show_container(@record, controller_name, display_name)
    end
  end

  def listicon_image(item, _view)
    item.decorate.try(:listicon_image)
  end

  def button
    selected_operation = params[:pressed].to_sym

    if OPERATIONS.key?(selected_operation)
      selected_servers = identify_selected_servers<commit_msg>Fix 9055: @gtl_url wasn't set in the controller (transferred from ManageIQ/manageiq@3<PASSWORD>)<commit_after>class MiddlewareServerController < ApplicationController
  include EmsCommon
  include ContainersCommonMixin
  include MiddlewareCommonMixin

  before_action :check_privileges
  before_action :get_session_data
  after_action :cleanup_action
  after_action :set_session_data

  OPERATIONS = {
    :middleware_server_reload   => {:op   => :reload_middleware_server,
                                    :skip => true,
                                    :hawk => N_('reloading'),
                                    :msg  => N_('Reload')
  },
    :middleware_server_stop     => {:op   => :stop_middleware_server,
                                    :skip => true,
                                    :hawk => N_('stopping'),
                                    :msg  => N_('Stop')
    },
    :middleware_server_restart  => {:op   => :restart_middleware_server,
                                    :skip => true,
                                    :hawk => N_('restarting'),
                                    :msg  => N_('Restart')
    },
    :middleware_server_shutdown => {:op    => :shutdown_middleware_server,
                                    :skip  => true,
                                    :hawk  => N_('shutting down'),
                                    :msg   => N_('Shutdown'),
                                    :param => :timeout
    },
    :middleware_server_suspend  => {:op    => :suspend_middleware_server,
                                    :skip  => true,
                                    :hawk  => N_('suspending'),
                                    :msg   => N_('Suspend'),
                                    :param => :timeout
    },
    :middleware_server_resume   => {:op   => :resume_middleware_server,
                                    :skip => true,
                                    :hawk => N_('resuming'),
                                    :msg  => N_('Resume')
    },
    :middleware_add_deployment  => {:op    => :add_middleware_deployment,
                                    :skip  => false,
                                    :hawk  => N_('Not deploying to Hawkular server'),
                                    :msg   => N_('Deployment initiated for selected server(s)'),
                                    :param => :file
    }
  }.freeze

  def add_deployment
    selected_servers = identify_selected_servers

    params[:file] = {
      :file         => params["file"],
      :enabled      => params["enabled"],
      :runtime_name => params["runtimeName"]
    }
    run_server_operation(OPERATIONS.fetch(:middleware_add_deployment), selected_servers)

    render :update do |page|
      page << javascript_prologue
      page.replace("flash_msg_div", :partial => "layouts/flash_msg")
    end
  end

  def show
    clear_topology_breadcrumb
    @display = params[:display] || "main" unless control_selected?
    @lastaction = "show"
    @showtype = "main"
    @record = identify_record(params[:id], ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareServer)

    if @display == 'middleware_datasources'
      @gtl_url = '/show'
      show_container_display(@record, 'middleware_datasource', MiddlewareDatasource)
    elsif @display == 'middleware_deployments'
      @gtl_url = '/show'
      show_container_display(@record, 'middleware_deployment', MiddlewareDeployment)
    else
      show_container(@record, controller_name, display_name)
    end
  end

  def listicon_image(item, _view)
    item.decorate.try(:listicon_image)
  end

  def button
    selected_operation = params[:pressed].to_sym

    if OPERATIONS.key?(selected_operation)
      selected_servers = identify_selected_servers
{'fraction_non_alphanumeric': 0.10328068043742406, 'fraction_numerical': 0.0006750371270419874, 'mean_word_length': 1.6476054324517513, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 88, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 62, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '363014', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1958, 'n_words': 347}