Class: Alfresco4r::DocumentDownload
- Inherits:
-
AbstractAlfrescoService
- Object
- AbstractAlfrescoService
- Alfresco4r::DocumentDownload
- Defined in:
- lib/alfresco4r/document_download.rb
Constant Summary collapse
- EXPECTED_PARAMS =
[:download_url,:node]
Constants inherited from AbstractAlfrescoService
AbstractAlfrescoService::BOUNDARY
Instance Attribute Summary collapse
-
#data_stream ⇒ Object
readonly
Returns the value of attribute data_stream.
Attributes inherited from AbstractAlfrescoService
#http, #options, #request, #uri
Instance Method Summary collapse
- #download_document ⇒ Object
-
#initialize(options) ⇒ DocumentDownload
constructor
A new instance of DocumentDownload.
- #response ⇒ Object
- #verify_params ⇒ Object
Methods inherited from AbstractAlfrescoService
#containerid, #filedata, #full_file_name, #get_object, #mime_type, #node, #post_object, #siteid, #uploaddirectory
Constructor Details
#initialize(options) ⇒ DocumentDownload
Returns a new instance of DocumentDownload.
16 17 18 19 20 21 |
# File 'lib/alfresco4r/document_download.rb', line 16 def initialize() @options = return verify_params if verify_params.kind_of?(Alfresco4r::AlfError) super download_document end |
Instance Attribute Details
#data_stream ⇒ Object (readonly)
Returns the value of attribute data_stream.
14 15 16 |
# File 'lib/alfresco4r/document_download.rb', line 14 def data_stream @data_stream end |
Instance Method Details
#download_document ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/alfresco4r/document_download.rb', line 36 def download_document begin @http.request(@request) do |response| @data_stream = response.read_body end @http.finish if @http.started? @res_obj = Alfresco4r::AlfSucessStream.new(@data_stream) rescue => e @res_obj = Alfresco4r::AlfError.new(e.) end end |
#response ⇒ Object
48 49 50 |
# File 'lib/alfresco4r/document_download.rb', line 48 def response return @res_obj end |
#verify_params ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/alfresco4r/document_download.rb', line 23 def verify_params begin raise "Empty Parameter" if @options.empty? missing_params = EXPECTED_PARAMS - @options.keys unless missing_params.empty? msg = "Expected paramerter #{missing_params} are missing. Expected parameters are :download_url,:node" raise "#{msg}" end rescue => e @res_obj = Alfresco4r::AlfError.new(e.) end end |