Control DMSF via REST API #78

This commit is contained in:
Karel Pičman 2015-02-24 14:39:40 +01:00
parent 0986ee4c56
commit b19897ca2d
2 changed files with 32 additions and 5 deletions

View File

@ -1,4 +1,8 @@
api.file do
api.id @file.id
api.name @file.name
api.project_id @file.project_id
api.dmsf_folder_id @file.folder ? @file.dmsf_folder_id : -1
api.version "#{@file.last_revision.major_version}.#{@file.last_revision.minor_version}"
api.content_url url_for(:controller => :dmsf_files, :action => 'show', :download => '', :id => @file, :only_path => false)
end

View File

@ -1,17 +1,40 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-15 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'rubygems'
require 'active_resource'
# Dmsf file
class DmsfFile < ActiveResource::Base
self.site = 'http://localhost:3000/'
self.user = '***'
self.password = '***'
self.user = 'kpicman'
self.password = 'Kontron2014+'
end
# Retrieving a file
file = DmsfFile.find 1
file = DmsfFile.find 17200
if file
puts file.id
puts file.name
puts file.version
puts file.project_id
puts file.dmsf_folder_id
puts file.content_url
else
puts 'No file with id = 1 found'
end