Class: CmisServer::AtomPub::ContentController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- CmisServer::ApplicationController
- BaseController
- CmisServer::AtomPub::ContentController
- Includes:
- RepositoryScopable
- Defined in:
- app/controllers/cmis_server/atom_pub/content_controller.rb
Instance Method Summary collapse
-
#append ⇒ Object
POST /content/id/append Implémentation de appendContentStream pour CMIS 1.1.
-
#delete_content_stream ⇒ Object
DELETE /content/id - deleteContentStream.
-
#set_content_stream ⇒ Object
PUT /content/id - setContentStream.
- #show ⇒ Object
Methods included from RepositoryScopable
Methods inherited from BaseController
#raw_post_body, #render_standard_error, #request_entry_parser
Methods inherited from CmisServer::ApplicationController
Instance Method Details
#append ⇒ Object
POST /content/id/append Implémentation de appendContentStream pour CMIS 1.1
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/cmis_server/atom_pub/content_controller.rb', line 26 def append content_id = params[:id] doc_id = content_id[3..-1] document = CmisServer::DocumentAdapter::ClassAdapter.new(context: context).find(doc_id) raise CmisServer::ObjectNotFound.new unless document # Vérifier que l'objet est un document raise CmisServer::InvalidOperation.new("Object is not a document") unless document.is_a?(CmisServer::DocumentObject) # Vérifier que le document a déjà un content stream raise CmisServer::InvalidOperation.new("Document has no content stream") unless document.content_stream # Utiliser le service dédié pour l'opération content_service = CmisServer::ContentStreamService.new(context: context) new_content = parse_content_from_request updated_document = content_service.append_content_stream(document, new_content) respond_to do |format| format.atom_entry { render "cmis_server/atom_pub/document_entry", locals: { document: updated_document } } format.json { render json: updated_document.to_json } end rescue => e render_error(e) end |
#delete_content_stream ⇒ Object
DELETE /content/id - deleteContentStream
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/controllers/cmis_server/atom_pub/content_controller.rb', line 76 def delete_content_stream content_id = params[:id] doc_id = content_id[3..-1] document = CmisServer::DocumentAdapter::ClassAdapter.new(context: context).find(doc_id) raise CmisServer::ObjectNotFound.new unless document content_service = CmisServer::ContentStreamService.new(context: context) updated_document = content_service.delete_content_stream(document) respond_to do |format| format.atom_entry { render "cmis_server/atom_pub/document_entry", locals: { document: updated_document } } format.json { render json: updated_document.to_json } end rescue => e render_error(e) end |
#set_content_stream ⇒ Object
PUT /content/id - setContentStream
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/cmis_server/atom_pub/content_controller.rb', line 54 def set_content_stream content_id = params[:id] doc_id = content_id[3..-1] document = CmisServer::DocumentAdapter::ClassAdapter.new(context: context).find(doc_id) raise CmisServer::ObjectNotFound.new unless document overwrite_flag = params[:overwriteFlag] != 'false' new_content = parse_content_from_request content_service = CmisServer::ContentStreamService.new(context: context) updated_document = content_service.set_content_stream(document, new_content, overwrite_flag) respond_to do |format| format.atom_entry { render "cmis_server/atom_pub/document_entry", locals: { document: updated_document } } format.json { render json: updated_document.to_json } end rescue => e render_error(e) end |
#show ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/cmis_server/atom_pub/content_controller.rb', line 10 def show content_id=params[:id] doc_id =content_id[3..-1] document =CmisServer::DocumentAdapter::ClassAdapter.new(context: context).find(doc_id) if document&&(cs=document.content_stream) send_data(cs.content, filename: cs.filename, type: cs.media_type ) else head :not_found end end |