active_cmis 0.3.1 → 0.3.2
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.
- data/README.md +11 -2
- data/active_cmis.gemspec +8 -9
- data/lib/active_cmis.rb +0 -1
- data/lib/active_cmis/atomic_types.rb +1 -1
- data/lib/active_cmis/document.rb +1 -1
- data/lib/active_cmis/internal/connection.rb +49 -48
- data/lib/active_cmis/object.rb +1 -1
- data/lib/active_cmis/rendition.rb +6 -0
- data/lib/active_cmis/server.rb +16 -10
- data/lib/active_cmis/version.rb +1 -1
- metadata +41 -77
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# ActiveCMIS Release 0.3.
|
1
|
+
# ActiveCMIS Release 0.3.2 #
|
2
2
|
**Homepage**: <http://xaop.com/labs/activecmis>
|
3
3
|
**Git**: <http://github.com/xaop/activecmis>
|
4
4
|
**Documentation**: <http://rdoc.info/github/xaop/activecmis/master/frames>
|
@@ -12,6 +12,12 @@ ActiveCMIS is Ruby library aimed at easing the interaction with various CMIS pro
|
|
12
12
|
- Write support and the ability to create new objects.
|
13
13
|
- Support for paging
|
14
14
|
|
15
|
+
## Changes since 0.3.1 ##
|
16
|
+
- Does not require ntlm-http unless needed for authentication
|
17
|
+
- Fix some issues with authentication (thanks to @beno)
|
18
|
+
- Follow redirects for renditions (thanks to @timfel)
|
19
|
+
|
20
|
+
|
15
21
|
## Changes since 0.2.6 ##
|
16
22
|
The way authentication works has changed. If you previously used ActiveCMIS.connect then you're fine, otherwise the authentication changes will affect you: the authenticate methods on ActiveCMIS::Server and ActiveCMIS::Repository now return a new object, and don't change the authentication on the object itself. You can also specify optional authentication when connecting to a Server, or when calling the repository method.
|
17
23
|
|
@@ -20,7 +26,10 @@ If you haven't installed Nokogiri yet it will be installed automatically, you wi
|
|
20
26
|
|
21
27
|
> gem install active_cmis
|
22
28
|
|
23
|
-
ActiveCMIS also depends on ntlm-http for ntlm authentication, unfortunately ntlm-http is broken on ruby 1.9.
|
29
|
+
ActiveCMIS also depends on ntlm-http for ntlm authentication, unfortunately ntlm-http is broken on ruby 1.9.x
|
30
|
+
This isn't a problem as long as you don't actually try to connect with NTLM authentication.
|
31
|
+
If you actually need NTLM authentication you can use https://github.com/xaop/ntlm-http (or any other fixed version of the library), although you may need to use bundler for this to work.
|
32
|
+
|
24
33
|
## Usage ##
|
25
34
|
require 'active_cmis'
|
26
35
|
repository = ActiveCMIS.load_config('configuration', 'optional_filename_for_config')
|
data/active_cmis.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.3.
|
7
|
+
s.name = "active_cmis"
|
8
|
+
s.version = "0.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joeri Samson"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2012-11-05"
|
13
|
+
s.description = "A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS."
|
14
|
+
s.email = "joeri@xaop.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
17
|
"README.md",
|
@@ -49,14 +49,13 @@ Gem::Specification.new do |s|
|
|
49
49
|
"lib/active_cmis/type.rb",
|
50
50
|
"lib/active_cmis/version.rb"
|
51
51
|
]
|
52
|
-
s.homepage =
|
52
|
+
s.homepage = "http://xaop.com/labs/activecmis/"
|
53
53
|
s.require_paths = ["lib"]
|
54
54
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
|
55
|
-
s.rubygems_version =
|
56
|
-
s.summary =
|
55
|
+
s.rubygems_version = "1.8.11"
|
56
|
+
s.summary = "A library to interact with CMIS repositories through the AtomPub/REST binding"
|
57
57
|
|
58
58
|
if s.respond_to? :specification_version then
|
59
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
59
|
s.specification_version = 3
|
61
60
|
|
62
61
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/lib/active_cmis.rb
CHANGED
@@ -35,7 +35,7 @@ module ActiveCMIS
|
|
35
35
|
end
|
36
36
|
def _rb2cmis(xml, value)
|
37
37
|
v = value.to_s
|
38
|
-
if max_length && v.length > max_length
|
38
|
+
if max_length && max_length > 0 && v.length > max_length #xCMIS says maxLength=0
|
39
39
|
raise Error::InvalidArgument.new("String representation is longer than maximum (max: #{max_length}, string: \n'\n#{v}\n')\n")
|
40
40
|
end
|
41
41
|
xml["c"].value v
|
data/lib/active_cmis/document.rb
CHANGED
@@ -224,7 +224,7 @@ module ActiveCMIS
|
|
224
224
|
|
225
225
|
|
226
226
|
def updated_aspects(checkin = nil)
|
227
|
-
if working_copy? && !(checkin || repository.
|
227
|
+
if working_copy? && !(checkin || repository.pwc_updatable?)
|
228
228
|
raise Error::NotSupported.new("Updating a PWC without checking in is not supported by repository")
|
229
229
|
end
|
230
230
|
unless working_copy? || checkin.nil?
|
@@ -27,6 +27,7 @@ module ActiveCMIS
|
|
27
27
|
@authentication = {:method => :basic_auth, :params => params}
|
28
28
|
@user = params.first
|
29
29
|
when :ntlm, "ntlm"
|
30
|
+
require 'net/ntlm_http'
|
30
31
|
@authentication = {:method => :ntlm_auth, :params => params}
|
31
32
|
@user = params.first
|
32
33
|
else raise "Authentication method not supported"
|
@@ -54,8 +55,11 @@ module ActiveCMIS
|
|
54
55
|
|
55
56
|
req = Net::HTTP::Get.new(uri.request_uri)
|
56
57
|
http = authenticate_request(uri, req)
|
57
|
-
response =
|
58
|
-
|
58
|
+
response = nil
|
59
|
+
http.request(req) do |res|
|
60
|
+
logger.debug "GOT (#{res.code}) #{url}"
|
61
|
+
response = res
|
62
|
+
end
|
59
63
|
response
|
60
64
|
end
|
61
65
|
|
@@ -170,54 +174,51 @@ module ActiveCMIS
|
|
170
174
|
end
|
171
175
|
end
|
172
176
|
|
173
|
-
def handle_request(uri, req)
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
if
|
195
|
-
new_uri =
|
196
|
-
if new_uri.relative?
|
197
|
-
uri = uri + location
|
198
|
-
end
|
199
|
-
req = req.class.new(uri.request_uri)
|
200
|
-
throw(:retry)
|
201
|
-
else
|
202
|
-
raise HTTPError.new("Too many redirects")
|
203
|
-
end
|
204
|
-
elsif 400 <= status && status < 500
|
205
|
-
# Problem: some codes 400, 405, 403, 409, 500 have multiple meanings
|
206
|
-
logger.error "Error occurred when handling request:\n#{body}"
|
207
|
-
case status
|
208
|
-
when 400; raise Error::InvalidArgument.new(body)
|
209
|
-
# FIXME: can also be filterNotValid
|
210
|
-
when 401; raise HTTPError::AuthenticationError.new(body)
|
211
|
-
when 404; raise Error::ObjectNotFound.new(body)
|
212
|
-
when 403; raise Error::PermissionDenied.new(body)
|
213
|
-
# FIXME: can also be streamNotSupported (?? shouldn't that be 405??)
|
214
|
-
when 405; raise Error::NotSupported.new(body)
|
215
|
-
else
|
216
|
-
raise HTTPError::ClientError.new("A HTTP #{status} error occured, for more precision update the code:\n" + body)
|
177
|
+
def handle_request(uri, req, retry_count = 0)
|
178
|
+
logger.debug "#{req.method} #{uri}"
|
179
|
+
http = authenticate_request(uri, req)
|
180
|
+
|
181
|
+
status, body, headers = nil
|
182
|
+
http.request(req) { |resp|
|
183
|
+
status = resp.code.to_i
|
184
|
+
body = resp.body
|
185
|
+
headers = resp
|
186
|
+
}
|
187
|
+
|
188
|
+
logger.debug "RECEIVED #{status}"
|
189
|
+
|
190
|
+
if 200 <= status && status < 300
|
191
|
+
return body
|
192
|
+
elsif 300 <= status && status < 400
|
193
|
+
# follow the redirected a limited number of times
|
194
|
+
location = headers["location"]
|
195
|
+
logger.debug "REDIRECTING: #{location.inspect}"
|
196
|
+
if retry_count <= 3
|
197
|
+
new_uri = URI.parse(location)
|
198
|
+
if new_uri.relative?
|
199
|
+
new_uri = uri + location
|
217
200
|
end
|
218
|
-
|
219
|
-
|
201
|
+
new_req = req.class.new(uri.request_uri)
|
202
|
+
handle_request(new_uri, new_req, retry_count + 1)
|
203
|
+
else
|
204
|
+
raise HTTPError.new("Too many redirects")
|
205
|
+
end
|
206
|
+
elsif 400 <= status && status < 500
|
207
|
+
# Problem: some codes 400, 405, 403, 409, 500 have multiple meanings
|
208
|
+
logger.error "Error occurred when handling request:\n#{body}"
|
209
|
+
case status
|
210
|
+
when 400; raise Error::InvalidArgument.new(body)
|
211
|
+
# FIXME: can also be filterNotValid
|
212
|
+
when 401; raise HTTPError::AuthenticationError.new(body)
|
213
|
+
when 404; raise Error::ObjectNotFound.new(body)
|
214
|
+
when 403; raise Error::PermissionDenied.new(body)
|
215
|
+
# FIXME: can also be streamNotSupported (?? shouldn't that be 405??)
|
216
|
+
when 405; raise Error::NotSupported.new(body)
|
217
|
+
else
|
218
|
+
raise HTTPError::ClientError.new("A HTTP #{status} error occured, for more precision update the code:\n" + body)
|
220
219
|
end
|
220
|
+
elsif 500 <= status
|
221
|
+
raise HTTPError::ServerError.new("The server encountered an internal error #{status} (this could be a client error though):\n" + body)
|
221
222
|
end
|
222
223
|
end
|
223
224
|
end
|
data/lib/active_cmis/object.rb
CHANGED
@@ -392,7 +392,7 @@ module ActiveCMIS
|
|
392
392
|
result << {:message => :save_folders, :parameters => [parent_folders, checkin && !updated_attributes]}
|
393
393
|
end
|
394
394
|
end
|
395
|
-
if acl && acl.updated # We need to be able to do this for newly created documents and merge the two
|
395
|
+
if acl && acl.updated? # We need to be able to do this for newly created documents and merge the two
|
396
396
|
result << {:message => :save_acl, :parameters => [acl]}
|
397
397
|
end
|
398
398
|
|
@@ -63,6 +63,12 @@ module ActiveCMIS
|
|
63
63
|
status = response.code.to_i
|
64
64
|
if 200 <= status && status < 300
|
65
65
|
data = response.body
|
66
|
+
elsif 300 <= status && status < 400
|
67
|
+
location = response["location"]
|
68
|
+
new_url = URI.parse(location)
|
69
|
+
new_url = @url + location if new_url.relative?
|
70
|
+
@url = new_url
|
71
|
+
get_data
|
66
72
|
else
|
67
73
|
raise HTTPError.new("Problem downloading rendition: status: #{status}, message: #{response.body}")
|
68
74
|
end
|
data/lib/active_cmis/server.rb
CHANGED
@@ -41,7 +41,9 @@ module ActiveCMIS
|
|
41
41
|
@endpoint = endpoint
|
42
42
|
@logger = logger
|
43
43
|
|
44
|
+
|
44
45
|
method, *params = authentication_info
|
46
|
+
@authentication_info = authentication_info
|
45
47
|
if method
|
46
48
|
conn.authenticate(method, *params)
|
47
49
|
end
|
@@ -67,17 +69,21 @@ module ActiveCMIS
|
|
67
69
|
# @param [String] repository_id
|
68
70
|
# @param [Array] authentication_info
|
69
71
|
# @return [Repository]
|
70
|
-
def repository(repository_id, authentication_info =
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
def repository(repository_id, authentication_info = @authentication_info)
|
73
|
+
key = [repository_id, authentication_info]
|
74
|
+
cached_repositories[key] ||= uncached_repository(*key)
|
75
|
+
end
|
76
|
+
|
77
|
+
def uncached_repository(repository_id, authentication_info)
|
78
|
+
path = "/app:service/app:workspace[cra:repositoryInfo/c:repositoryId[child::text() = '#{repository_id}']]"
|
79
|
+
repository_data = repository_info.xpath(path, NS::COMBINED)
|
80
|
+
if repository_data.empty?
|
81
|
+
raise Error::ObjectNotFound.new("The repository #{repository_id} doesn't exist")
|
82
|
+
else
|
83
|
+
Repository.new(self, conn.dup, logger.dup, repository_data, authentication_info)
|
84
|
+
end
|
80
85
|
end
|
86
|
+
private :uncached_repository
|
81
87
|
|
82
88
|
# Reset cache of Repository objects
|
83
89
|
#
|
data/lib/active_cmis/version.rb
CHANGED
metadata
CHANGED
@@ -1,82 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_cmis
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 1
|
10
|
-
version: 0.3.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Joeri Samson
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-11-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: nokogiri
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70335761070080 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 4
|
33
|
-
- 1
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 1.4.1
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: ntlm-http
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *70335761070080
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: ntlm-http
|
27
|
+
requirement: &70335760996720 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
29
|
+
requirements:
|
43
30
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 25
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 1
|
49
|
-
- 1
|
31
|
+
- !ruby/object:Gem::Version
|
50
32
|
version: 0.1.1
|
51
33
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: require_relative
|
55
34
|
prerelease: false
|
56
|
-
|
35
|
+
version_requirements: *70335760996720
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: require_relative
|
38
|
+
requirement: &70335760994260 !ruby/object:Gem::Requirement
|
57
39
|
none: false
|
58
|
-
requirements:
|
40
|
+
requirements:
|
59
41
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
hash: 19
|
62
|
-
segments:
|
63
|
-
- 1
|
64
|
-
- 0
|
65
|
-
- 2
|
42
|
+
- !ruby/object:Gem::Version
|
66
43
|
version: 1.0.2
|
67
44
|
type: :runtime
|
68
|
-
|
69
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70335760994260
|
47
|
+
description: A CMIS library implementing both reading and updating capabilities through
|
48
|
+
the AtomPub/REST binding to CMIS.
|
70
49
|
email: joeri@xaop.com
|
71
50
|
executables: []
|
72
|
-
|
73
51
|
extensions: []
|
74
|
-
|
75
|
-
extra_rdoc_files:
|
52
|
+
extra_rdoc_files:
|
76
53
|
- LICENSE
|
77
54
|
- README.md
|
78
55
|
- TODO
|
79
|
-
files:
|
56
|
+
files:
|
80
57
|
- LICENSE
|
81
58
|
- README.md
|
82
59
|
- Rakefile
|
@@ -107,41 +84,28 @@ files:
|
|
107
84
|
- lib/active_cmis/server.rb
|
108
85
|
- lib/active_cmis/type.rb
|
109
86
|
- lib/active_cmis/version.rb
|
110
|
-
has_rdoc: true
|
111
87
|
homepage: http://xaop.com/labs/activecmis/
|
112
88
|
licenses: []
|
113
|
-
|
114
89
|
post_install_message:
|
115
90
|
rdoc_options: []
|
116
|
-
|
117
|
-
require_paths:
|
91
|
+
require_paths:
|
118
92
|
- lib
|
119
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
94
|
none: false
|
121
|
-
requirements:
|
122
|
-
- -
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
hash: 59
|
125
|
-
segments:
|
126
|
-
- 1
|
127
|
-
- 8
|
128
|
-
- 6
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
129
98
|
version: 1.8.6
|
130
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
100
|
none: false
|
132
|
-
requirements:
|
133
|
-
- -
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
|
136
|
-
segments:
|
137
|
-
- 0
|
138
|
-
version: "0"
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
139
105
|
requirements: []
|
140
|
-
|
141
106
|
rubyforge_project:
|
142
|
-
rubygems_version: 1.
|
107
|
+
rubygems_version: 1.8.11
|
143
108
|
signing_key:
|
144
109
|
specification_version: 3
|
145
110
|
summary: A library to interact with CMIS repositories through the AtomPub/REST binding
|
146
111
|
test_files: []
|
147
|
-
|