diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 59a45a57..a6f68434 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -273,13 +273,22 @@ class DmsfController < ApplicationController end end - if @folder.save - flash[:notice] = l(:notice_folder_created) - redirect_to dmsf_folder_path(:id => @project, :folder_id => @folder) - else - @pathfolder = @parent - render :action => 'edit' - end + saved = @folder.save + + respond_to do |format| + format.js + format.api { render_validation_errors(@folder) } + format.html { + if saved + flash[:notice] = l(:notice_folder_created) + redirect_to dmsf_folder_path(:id => @project, :folder_id => @folder) + else + @pathfolder = @parent + render :action => 'edit' + end + } + end + end def edit diff --git a/extra/api/api_client.rb b/extra/api/api_client.rb index cb9554b9..cde89f69 100644 --- a/extra/api/api_client.rb +++ b/extra/api/api_client.rb @@ -26,13 +26,13 @@ require 'active_resource' # Dmsf file class DmsfFile < ActiveResource::Base - self.site = 'http://localhost:3000/' + self.site = 'https://localhost:3000/' self.user = ARGV[0] self.password = ARGV[1] end # 2. Get a document -FILE_ID = 17216 +FILE_ID = 41532 file = DmsfFile.find FILE_ID if file puts file.id @@ -42,4 +42,4 @@ if file puts file.content_url else puts "No file with id = #{FILE_ID} found" -end \ No newline at end of file +end diff --git a/extra/api/api_client.sh b/extra/api/api_client.sh index 43e5f79b..bb7a112b 100644 --- a/extra/api/api_client.sh +++ b/extra/api/api_client.sh @@ -28,15 +28,16 @@ # Just replace .xml with .json # 1. List of documents in a given folder or the root folder -curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000//projects/12/dmsf.xml -#curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000//projects/12/dmsf.xml?folder_id=5155 +curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/projects/12/dmsf.xml +#curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/projects/12/dmsf.xml?folder_id=5155 # 2. Get a document #curl -v -H "Content-Type: application/xml" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/17216.xml +#curl -v -H "Content-Type: application/octet-stream" -X GET -u ${1}:${2} http://localhost:3000/dmsf/files/41532/download > file.txt # 3. Create a folder -#curl -v -H "Content-Type: application/xml" -X POST --data "@folder.xml" -u ${1}:${2} http://localhost:3000//projects/12/dmsf/create.xml +#curl -v -H "Content-Type: application/xml" -X POST --data "@folder.xml" -u ${1}:${2} http://localhost:3000/projects/12/dmsf/create.xml # 4. Upload a document into a given folder or the root folder -#curl --data-binary "@cat.gif" -H "Content-Type: application/octet-stream" -X POST -u ${1}:${2} http://localhost:3000//projects/12/dmsf/upload.xml?filename=cat.gif -#curl -v -H "Content-Type: application/xml" -X POST --data "@file.xml" -u ${1}:${2} http://localhost:3000//projects/12/dmsf/commit.xml \ No newline at end of file +#curl --data-binary "@cat.gif" -H "Content-Type: application/octet-stream" -X POST -u ${1}:${2} http://localhost:3000/projects/12/dmsf/upload.xml?filename=cat.gif +#curl -v -H "Content-Type: application/xml" -X POST --data "@file.xml" -u ${1}:${2} http://localhost:3000/projects/12/dmsf/commit.xml \ No newline at end of file