To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / a3 / a30059c9223b592d756029845dc7d985a8e70d73.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (2.5 KB)
| 1 |
# Redmine - project management software |
|---|---|
| 2 |
# Copyright (C) 2006-2011 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 |
|
| 18 |
class SysController < ActionController::Base |
| 19 |
before_filter :check_enabled |
| 20 |
|
| 21 |
def projects |
| 22 |
p = Project.active.has_module(:repository).find(:all, :include => :repository, :order => 'identifier') |
| 23 |
# 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]}})
|
| 25 |
end |
| 26 |
|
| 27 |
def create_project_repository |
| 28 |
project = Project.find(params[:id]) |
| 29 |
if project.repository |
| 30 |
render :nothing => true, :status => 409 |
| 31 |
else |
| 32 |
logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}."
|
| 33 |
project.repository = Repository.factory(params[:vendor], params[:repository]) |
| 34 |
if project.repository && project.repository.save |
| 35 |
render :xml => project.repository.to_xml(:only => [:id, :url]), :status => 201 |
| 36 |
else |
| 37 |
render :nothing => true, :status => 422 |
| 38 |
end |
| 39 |
end |
| 40 |
end |
| 41 |
|
| 42 |
def fetch_changesets |
| 43 |
projects = [] |
| 44 |
if params[:id] |
| 45 |
projects << Project.active.has_module(:repository).find(params[:id]) |
| 46 |
else |
| 47 |
projects = Project.active.has_module(:repository).find(:all, :include => :repository) |
| 48 |
end |
| 49 |
projects.each do |project| |
| 50 |
if project.repository |
| 51 |
project.repository.fetch_changesets |
| 52 |
end |
| 53 |
end |
| 54 |
render :nothing => true, :status => 200 |
| 55 |
rescue ActiveRecord::RecordNotFound |
| 56 |
render :nothing => true, :status => 404 |
| 57 |
end |
| 58 |
|
| 59 |
protected |
| 60 |
|
| 61 |
def check_enabled |
| 62 |
User.current = nil |
| 63 |
unless Setting.sys_api_enabled? && params[:key].to_s == Setting.sys_api_key |
| 64 |
render :text => 'Access denied. Repository management WS is disabled or key is invalid.', :status => 403 |
| 65 |
return false |
| 66 |
end |
| 67 |
end |
| 68 |
end |