alfresco4r 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/alfresco4r.rb +3 -0
- data/lib/alfresco4r/abstract_service.rb +140 -0
- data/lib/alfresco4r/document_download.rb +2 -2
- data/lib/alfresco4r/document_upload.rb +2 -2
- data/lib/alfresco4r/version.rb +1 -1
- metadata +11 -11
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c4e2564764b7d34e2d964a3e5b6b3902ac5ae509
|
4
|
+
data.tar.gz: 689227a6441f259bc6cee1e0caa29a477e0e16be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 048b75c29e331be0869cee05a63ccd8c4a4e9a578217b8a89adbfc0c3fc0cff7efa59fe801716d1e4f59bb3141b8096471ff52eb94a737c9b2bfbe20902cc3ce
|
7
|
+
data.tar.gz: 8e0806659e4333338fa7a7ae7571f46b78c17fce3c5a5b8bd2c70c8e7a742926db6b92a005b5d157c45af6529285e3b8050e1f6e98708c8e0417c72df7422e1e
|
data/lib/alfresco4r.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Alfresco4r
|
6
|
+
class AbstractAlfrescoService
|
7
|
+
BOUNDARY = "AaB03x"
|
8
|
+
attr_reader :options,:request,:uri,:http
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@options = options
|
12
|
+
self_class = self.class.name
|
13
|
+
klass_url = self_class.concat("Url")
|
14
|
+
@auth_obj = DocumentAuth.new(options)
|
15
|
+
@url_obj = klass_url == "Alfresco4r::DocumentDownloadUrl" ? DocumentDownloadUrl.new(options) : DocumentUploadUrl.new(options)
|
16
|
+
self_class.include?('Upload') ? post_object : get_object
|
17
|
+
end
|
18
|
+
|
19
|
+
def post_object
|
20
|
+
@uri = URI(@url_obj.url)
|
21
|
+
@request = Net::HTTP::Post.new(@uri.path)
|
22
|
+
@request.basic_auth @auth_obj.username, @auth_obj.password
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_object
|
26
|
+
@uri = URI(@url_obj.url(node))
|
27
|
+
@uri.query = URI.encode_www_form( { :a => 'true' } )
|
28
|
+
@http = Net::HTTP.new(@uri.host, @uri.port)
|
29
|
+
@request = Net::HTTP::Get.new(@uri.request_uri)
|
30
|
+
@request.basic_auth @auth_obj.username, @auth_obj.password
|
31
|
+
end
|
32
|
+
|
33
|
+
def siteid
|
34
|
+
@siteid = options[:siteid]
|
35
|
+
end
|
36
|
+
|
37
|
+
def containerid
|
38
|
+
@containerid = options[:containerid]
|
39
|
+
end
|
40
|
+
|
41
|
+
def uploaddirectory
|
42
|
+
@uploaddirectory = options[:uploaddirectory]
|
43
|
+
end
|
44
|
+
|
45
|
+
def filedata
|
46
|
+
@filedata = options[:filedata]
|
47
|
+
end
|
48
|
+
|
49
|
+
def mime_type
|
50
|
+
@mime_type = options[:mime_type]
|
51
|
+
end
|
52
|
+
|
53
|
+
def full_file_name
|
54
|
+
@full_file_name = options[:full_file_name]
|
55
|
+
end
|
56
|
+
|
57
|
+
def node
|
58
|
+
@node = options[:node]
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
class DocumentAuth
|
65
|
+
def initialize(options)
|
66
|
+
@options = options
|
67
|
+
end
|
68
|
+
|
69
|
+
def username
|
70
|
+
username = @options.has_key?(:username) ? @options[:username] : ""
|
71
|
+
return username
|
72
|
+
end
|
73
|
+
|
74
|
+
def password
|
75
|
+
password = @options.has_key?(:password) ? @options[:password] : ""
|
76
|
+
return password
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class DocumentUploadUrl
|
81
|
+
def initialize(options)
|
82
|
+
@options = options
|
83
|
+
end
|
84
|
+
|
85
|
+
def url
|
86
|
+
upload_url = @options[:upload_url]
|
87
|
+
return upload_url.to_s
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class DocumentDownloadUrl
|
92
|
+
def initialize(options)
|
93
|
+
@options = options
|
94
|
+
end
|
95
|
+
|
96
|
+
def url(node_id)
|
97
|
+
download_url = @options[:download_url].concat("/").concat(node_id).strip
|
98
|
+
return download_url.to_s
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
class AlfUnknownException
|
105
|
+
attr_reader :message,:status
|
106
|
+
def initialize(msg)
|
107
|
+
@message = msg
|
108
|
+
@status = "Failure"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class AlfSucess
|
113
|
+
attr_reader :node,:filename,:message,:status,:uploaddirectory
|
114
|
+
def initialize(node,filename,desc)
|
115
|
+
@node = node.split("/").last
|
116
|
+
@filename = filename
|
117
|
+
@message = desc
|
118
|
+
@status = "Success"
|
119
|
+
@uploaddirectory = ''
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class AlfError
|
124
|
+
attr_reader :message,:status
|
125
|
+
def initialize(msg)
|
126
|
+
@message = msg
|
127
|
+
@status = "Failure"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class AlfSucessStream
|
132
|
+
attr_reader :data_stream,:message,:status
|
133
|
+
def initialize(data_stream,desc=nil)
|
134
|
+
@data_stream = data_stream
|
135
|
+
@message = desc
|
136
|
+
@status = "Success"
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
@@ -5,10 +5,10 @@
|
|
5
5
|
# Description: This file gives ability to download document from Alfresco
|
6
6
|
################################################################################
|
7
7
|
|
8
|
-
require 'alfresco4r'
|
8
|
+
require 'alfresco4r/abstract_service'
|
9
9
|
|
10
10
|
module Alfresco4r
|
11
|
-
class DocumentDownload < AbstractAlfrescoService
|
11
|
+
class DocumentDownload < Alfresco4r::AbstractAlfrescoService
|
12
12
|
EXPECTED_PARAMS = [:download_url,:node]
|
13
13
|
|
14
14
|
attr_reader :data_stream
|
@@ -6,10 +6,10 @@
|
|
6
6
|
################################################################################
|
7
7
|
|
8
8
|
require 'json'
|
9
|
-
require 'alfresco4r'
|
9
|
+
require 'alfresco4r/abstract_service'
|
10
10
|
|
11
11
|
module Alfresco4r
|
12
|
-
class DocumentUpload < AbstractAlfrescoService
|
12
|
+
class DocumentUpload < Alfresco4r::AbstractAlfrescoService
|
13
13
|
EXPECTED_PARAMS = [:siteid,:containerid,:uploaddirectory,:mime_type,:full_file_name,:filedata,:upload_url]
|
14
14
|
|
15
15
|
|
data/lib/alfresco4r/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alfresco4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sivaprakasam Boopathy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-02-27 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: This gem provides the capability to ruby to interact with Alfresco CMS.
|
15
14
|
This gem is providing two methods upload document to Alfresco and download/retrieve
|
@@ -20,32 +19,33 @@ executables: []
|
|
20
19
|
extensions: []
|
21
20
|
extra_rdoc_files: []
|
22
21
|
files:
|
23
|
-
- lib/alfresco4r
|
24
|
-
- lib/alfresco4r/
|
22
|
+
- lib/alfresco4r.rb
|
23
|
+
- lib/alfresco4r/abstract_service.rb
|
25
24
|
- lib/alfresco4r/document_download.rb
|
25
|
+
- lib/alfresco4r/document_upload.rb
|
26
|
+
- lib/alfresco4r/version.rb
|
26
27
|
homepage: https://github.com/sivaprakasamboopathy/alfresco4r
|
27
28
|
licenses: []
|
29
|
+
metadata: {}
|
28
30
|
post_install_message:
|
29
31
|
rdoc_options: []
|
30
32
|
require_paths:
|
31
33
|
- lib
|
32
34
|
- lib/alfresco4r
|
33
35
|
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
36
|
requirements:
|
36
|
-
- -
|
37
|
+
- - ">="
|
37
38
|
- !ruby/object:Gem::Version
|
38
39
|
version: '0'
|
39
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
45
|
requirements: []
|
46
46
|
rubyforge_project:
|
47
|
-
rubygems_version:
|
47
|
+
rubygems_version: 2.2.2
|
48
48
|
signing_key:
|
49
|
-
specification_version:
|
49
|
+
specification_version: 4
|
50
50
|
summary: Interaction with Alfresco from Ruby
|
51
51
|
test_files: []
|