Rack - Error Posting Redmine Plugin

0

I'm creating a plugin for Redmine that will act as a generator and publisher of projects within a repository, however I'm having trouble accessing my Publish project button.

The function I created to publish the project is in the same file inside the /gerar_versao_projeto/lib/client directory of the plugin. It will have to communicate with a server_versao.java file that is on my server and is responsible for doing the entire publishing process and returning error or success for Redmine. But all the data was coded and debugged. I think it's a problem with Rack because the same hash that is generated for the Generate button is being used by the Publish button.

I've checked for other error possibilities and the most possible one at the moment would be this one.

Would anyone have any ideas?

    
asked by anonymous 25.02.2014 / 15:44

1 answer

1

PROJECT GENERATION FUNCTION

def exec_client

begin
  hostname = Setting.plugin_gerar_versao_projeto['ip_number']
  port = Setting.plugin_gerar_versao_projeto['port_number']
  s = TCPSocket.open(hostname, port)
  s.puts "MSG_RV"
  @project = Project.find_by_identifier(params[:id])
  @repositories = @project.repositories
  @repository = @repositories.first

  if params[:branch] == nil
    s.puts @repository.name
  else
    s.puts params[:branch]
  end

  msg_final = s.read
  puts "MSG_FINAL = #{msg_final}"
  if msg_final =~ /MSG_ERR/
     display_alert l(:alert_error)
  elsif msg_final =~ /MSG_SUC/
      display_alert l(:release_done)
  end

  s.close               # Close the socket when done
rescue
  display_alert l(:alert_error)
end

end

The same applies to the Publication function, changing only the condition of Final Message:

msg_final = s.read
      puts "MSG_FINAL = #{msg_final}"
      if msg_final =~ /MSG_ERR/
         display_alert l(:alert_error)
      elsif msg_final =~ /MSG_SUC/
          display_alert l(:publish_done)

end

Both functions create a socket and make a connection through port 13000 of my application server / repository. When the functions are executed, they return a message to REDMINE, which in turn returns SUCESSFULL or ERROR.

What I'm noticing is that by clicking the buttons, both are using the same parameters in the RACK concept:

started POST "/projects/teste/repository/exec_client" for 127.0.0.1 at 2014-02-26 08:44:07 -0300
Processing by RepositoriesController#exec_client as JS
  Parameters: {"authenticity_token"=>"ta+3n7z4wGBjnBBaovBAEc9D3oAePYwSLUIhVpciR2c=", "id"=>"teste"}

and

  Started POST "/projects/teste/repository/exec_release" for 127.0.0.1 at 2014-02-26 08:43:31 -0300
Processing by RepositoriesController#exec_release as JS
  Parameters: {"authenticity_token"=>"ta+3n7z4wGBjnBBaovBAEc9D3oAePYwSLUIhVpciR2c=", "id"=>"teste"}

If you need any more sources, I'll be here.

    
26.02.2014 / 12:55