active_cmis 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ActiveCMIS Release 0.3.1 #
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.2
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')
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{active_cmis}
8
- s.version = "0.3.1"
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 = %q{2012-02-15}
13
- s.description = %q{A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS.}
14
- s.email = %q{joeri@xaop.com}
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 = %q{http://xaop.com/labs/activecmis/}
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 = %q{1.3.7}
56
- s.summary = %q{A library to interact with CMIS repositories through the AtomPub/REST binding}
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
@@ -1,7 +1,6 @@
1
1
  require 'nokogiri'
2
2
  require 'net/http'
3
3
  require 'net/https'
4
- require 'net/ntlm_http'
5
4
  require 'yaml'
6
5
  require 'logger'
7
6
  require 'require_relative'
@@ -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
@@ -224,7 +224,7 @@ module ActiveCMIS
224
224
 
225
225
 
226
226
  def updated_aspects(checkin = nil)
227
- if working_copy? && !(checkin || repository.pwc_ubdatable)
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 = http.request(req)
58
- logger.debug "GOT (#{response.code}) #{url}"
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
- catch(:retry) do
175
- logger.debug "#{req.method} #{uri}"
176
- http = authenticate_request(uri, req)
177
-
178
- status, body, headers = nil
179
- http.request(req) { |resp|
180
- status = resp.code.to_i
181
- body = resp.body
182
- headers = resp
183
- }
184
-
185
- logger.debug "RECEIVED #{status}"
186
-
187
- if 200 <= status && status < 300
188
- return body
189
- elsif 300 <= status && status < 400
190
- # follow the redirected a limited number of times
191
- retry_count = (retry_count || 0) + 1
192
- location = headers["location"]
193
- logger.debug "REDIRECTING: #{location.inspect}"
194
- if retry_count <= 3
195
- new_uri = URI.parse(location)
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
- elsif 500 <= status
219
- raise HTTPError::ServerError.new("The server encountered an internal error #{status} (this could be a client error though):\n" + body)
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
@@ -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
@@ -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 = self.authentcation_info)
71
- cached_repositories[[repository_id, authentication_info]] ||= begin
72
- repository_data = repository_info.
73
- xpath("/app:service/app:workspace[cra:repositoryInfo/c:repositoryId[child::text() = '#{repository_id}']]", NS::COMBINED)
74
- if repository_data.empty?
75
- raise Error::ObjectNotFound.new("The repository #{repository_id} doesn't exist")
76
- else
77
- Repository.new(self, conn.dup, logger.dup, repository_data, authentication_info)
78
- end
79
- end
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
  #
@@ -2,7 +2,7 @@ module ActiveCMIS
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- PATCH = 1
5
+ PATCH = 2
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
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
- hash: 17
5
- prerelease: false
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
- date: 2012-02-15 00:00:00 +01:00
19
- default_executable:
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
- prerelease: false
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
- requirement: &id002 !ruby/object:Gem::Requirement
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
- requirement: &id003 !ruby/object:Gem::Requirement
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
- version_requirements: *id003
69
- description: A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS.
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
- hash: 3
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.3.7
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
-