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