Class: Alfresco4r::AbstractAlfrescoService

Inherits:
Object
  • Object
show all
Defined in:
lib/alfresco4r/abstract_service.rb

Direct Known Subclasses

DocumentDownload, DocumentUpload

Constant Summary collapse

BOUNDARY =
"AaB03x"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ AbstractAlfrescoService

Returns a new instance of AbstractAlfrescoService.



10
11
12
13
14
15
16
17
# File 'lib/alfresco4r/abstract_service.rb', line 10

def initialize(options)
  @options = options
  self_class = self.class.name
  klass_url = self_class.concat("Url")
  @auth_obj = DocumentAuth.new(options)
  @url_obj = klass_url == "Alfresco4r::DocumentDownloadUrl" ? DocumentDownloadUrl.new(options) : DocumentUploadUrl.new(options)
  self_class.include?('Upload') ? post_object : get_object
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



8
9
10
# File 'lib/alfresco4r/abstract_service.rb', line 8

def http
  @http
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/alfresco4r/abstract_service.rb', line 8

def options
  @options
end

#requestObject (readonly)

Returns the value of attribute request.



8
9
10
# File 'lib/alfresco4r/abstract_service.rb', line 8

def request
  @request
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/alfresco4r/abstract_service.rb', line 8

def uri
  @uri
end

Instance Method Details

#containeridObject



37
38
39
# File 'lib/alfresco4r/abstract_service.rb', line 37

def containerid
  @containerid = options[:containerid]
end

#filedataObject



45
46
47
# File 'lib/alfresco4r/abstract_service.rb', line 45

def filedata
  @filedata = options[:filedata]
end

#full_file_nameObject



53
54
55
# File 'lib/alfresco4r/abstract_service.rb', line 53

def full_file_name
  @full_file_name = options[:full_file_name]
end

#get_objectObject



25
26
27
28
29
30
31
# File 'lib/alfresco4r/abstract_service.rb', line 25

def get_object
 @uri = URI(@url_obj.url(node))
 @uri.query = URI.encode_www_form( { :a => 'true' } )
 @http = Net::HTTP.new(@uri.host, @uri.port)
 @request = Net::HTTP::Get.new(@uri.request_uri)
 @request.basic_auth @auth_obj.username, @auth_obj.password
end

#mime_typeObject



49
50
51
# File 'lib/alfresco4r/abstract_service.rb', line 49

def mime_type
  @mime_type = options[:mime_type]
end

#nodeObject



57
58
59
# File 'lib/alfresco4r/abstract_service.rb', line 57

def node
  @node = options[:node]
end

#post_objectObject



19
20
21
22
23
# File 'lib/alfresco4r/abstract_service.rb', line 19

def post_object
  @uri = URI(@url_obj.url)
  @request = Net::HTTP::Post.new(@uri.path)
  @request.basic_auth @auth_obj.username, @auth_obj.password
end

#siteidObject



33
34
35
# File 'lib/alfresco4r/abstract_service.rb', line 33

def siteid
  @siteid = options[:siteid]
end

#uploaddirectoryObject



41
42
43
# File 'lib/alfresco4r/abstract_service.rb', line 41

def uploaddirectory
  @uploaddirectory = options[:uploaddirectory]
end