Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

sys_controller.rb 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2012 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class SysController < ActionController::Base
  18. before_filter :check_enabled
  19. def projects
  20. p = Project.active.has_module(:repository).find(
  21. :all,
  22. :include => :repository,
  23. :order => "#{Project.table_name}.identifier"
  24. )
  25. # extra_info attribute from repository breaks activeresource client
  26. render :xml => p.to_xml(
  27. :only => [:id, :identifier, :name, :is_public, :status],
  28. :include => {:repository => {:only => [:id, :url]}}
  29. )
  30. end
  31. def create_project_repository
  32. project = Project.find(params[:id])
  33. if project.repository
  34. render :nothing => true, :status => 409
  35. else
  36. logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}."
  37. repository = Repository.factory(params[:vendor], params[:repository])
  38. repository.project = project
  39. if repository.save
  40. render :xml => {repository.class.name.underscore.gsub('/', '-') => {:id => repository.id, :url => repository.url}}, :status => 201
  41. else
  42. render :nothing => true, :status => 422
  43. end
  44. end
  45. end
  46. def fetch_changesets
  47. projects = []
  48. scope = Project.active.has_module(:repository)
  49. if params[:id]
  50. project = nil
  51. if params[:id].to_s =~ /^\d*$/
  52. project = scope.find(params[:id])
  53. else
  54. project = scope.find_by_identifier(params[:id])
  55. end
  56. raise ActiveRecord::RecordNotFound unless project
  57. projects << project
  58. else
  59. projects = scope.all
  60. end
  61. projects.each do |project|
  62. project.repositories.each do |repository|
  63. repository.fetch_changesets
  64. end
  65. end
  66. render :nothing => true, :status => 200
  67. rescue ActiveRecord::RecordNotFound
  68. render :nothing => true, :status => 404
  69. end
  70. protected
  71. def check_enabled
  72. User.current = nil
  73. unless Setting.sys_api_enabled? && params[:key].to_s == Setting.sys_api_key
  74. render :text => 'Access denied. Repository management WS is disabled or key is invalid.', :status => 403
  75. return false
  76. end
  77. end
  78. end