cmis-ruby 0.4.7 → 0.4.8
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 +4 -4
- data/lib/cmis/connection.rb +24 -19
- data/lib/cmis/server.rb +26 -1
- data/lib/cmis/version.rb +1 -1
- metadata +2 -3
- data/lib/cmis/connection/url_resolver.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d7de0653ac57178aae304281dcd8ec41c7b5688
|
4
|
+
data.tar.gz: 6b408d6290cd17fdbe81e4327d37fd6aa7eea251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 823583dc1ffb9b66fa1909a47a4224d322b1c2b0d2638279ac9b8bf7208b1104bc00261c64e5ff76a9c1d6b1d4a8ea74c9276df8801896161335d6652d5a14af
|
7
|
+
data.tar.gz: 4146bfe8c67f079767d962573a3eb4176aaaf30ee1fc48209b620f51ca5cd2ac71359035e17421a34b39dd89ba41f2c38d4499b95539e7d533f0bbf1367a9993
|
data/lib/cmis/connection.rb
CHANGED
@@ -1,18 +1,13 @@
|
|
1
1
|
require 'cmis/connection/request_modifier'
|
2
2
|
require 'cmis/connection/response_parser'
|
3
|
-
require 'cmis/connection/url_resolver'
|
4
3
|
require 'cmis/version'
|
5
4
|
require 'faraday'
|
6
5
|
|
7
6
|
module CMIS
|
8
7
|
class Connection
|
9
8
|
def initialize(options)
|
10
|
-
options.symbolize_keys!
|
11
|
-
|
12
9
|
message = "option `service_url` must be set"
|
13
|
-
service_url = options[:service_url] or raise message
|
14
|
-
|
15
|
-
options[:adapter] ||= :net_http
|
10
|
+
@service_url = options[:service_url] or raise message
|
16
11
|
|
17
12
|
@http = Faraday.new(connection_options(options)) do |builder|
|
18
13
|
builder.use RequestModifier
|
@@ -23,35 +18,30 @@ module CMIS
|
|
23
18
|
builder.basic_auth(options[:username], options[:password])
|
24
19
|
end
|
25
20
|
|
26
|
-
builder.adapter options[:adapter].to_sym
|
21
|
+
builder.adapter (options[:adapter] || :net_http).to_sym
|
27
22
|
builder.response :logger if options[:log_requests]
|
28
23
|
builder.use ResponseParser
|
29
24
|
end
|
30
25
|
|
31
|
-
@
|
26
|
+
@repository_infos = {}
|
32
27
|
end
|
33
28
|
|
34
|
-
def
|
35
|
-
params.
|
36
|
-
|
37
|
-
|
38
|
-
query = options.fetch(:query, {})
|
39
|
-
headers = options.fetch(:headers, {})
|
40
|
-
url = @url_resolver.url(params.delete(:repositoryId), params[:objectId])
|
29
|
+
def do_request(params, query, headers)
|
30
|
+
repository_id = params.delete(:repositoryId)
|
31
|
+
url = infer_url(repository_id, params[:objectId])
|
41
32
|
|
42
|
-
|
33
|
+
if params[:cmisaction]
|
43
34
|
@http.post(url, params, headers)
|
44
35
|
else
|
45
36
|
@http.get(url, params.merge(query), headers)
|
46
37
|
end
|
47
|
-
|
48
|
-
response.body
|
49
38
|
end
|
50
39
|
|
51
40
|
private
|
52
41
|
|
53
42
|
def connection_options(options)
|
54
|
-
|
43
|
+
adapter = (options[:adapter] || :net_http).to_sym
|
44
|
+
headers = { user_agent: "cmis-ruby/#{VERSION} [#{adapter}]" }
|
55
45
|
headers.merge!(options[:headers]) if options[:headers]
|
56
46
|
|
57
47
|
conn_opts = { headers: headers }
|
@@ -59,5 +49,20 @@ module CMIS
|
|
59
49
|
|
60
50
|
conn_opts
|
61
51
|
end
|
52
|
+
|
53
|
+
def infer_url(repository_id, object_id)
|
54
|
+
return @service_url unless repository_id
|
55
|
+
|
56
|
+
unless @repository_infos.key?(repository_id)
|
57
|
+
@repository_infos = @http.get(@service_url).body
|
58
|
+
end
|
59
|
+
|
60
|
+
if @repository_infos.key?(repository_id)
|
61
|
+
key = object_id ? 'rootFolderUrl' : 'repositoryUrl'
|
62
|
+
@repository_infos[repository_id][key]
|
63
|
+
else
|
64
|
+
raise Exceptions::ObjectNotFound, "repositoryId: #{repository_id}"
|
65
|
+
end
|
66
|
+
end
|
62
67
|
end
|
63
68
|
end
|
data/lib/cmis/server.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
module CMIS
|
2
2
|
class Server < Connection
|
3
3
|
def initialize(options = {})
|
4
|
-
|
4
|
+
@options = options.symbolize_keys
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute!(params = {}, options = {})
|
8
|
+
params.symbolize_keys!
|
9
|
+
|
10
|
+
options.symbolize_keys!
|
11
|
+
query = options.fetch(:query, {})
|
12
|
+
headers = options.fetch(:headers, {})
|
13
|
+
|
14
|
+
response = connection.do_request(params, query, headers)
|
15
|
+
response.body
|
5
16
|
end
|
6
17
|
|
7
18
|
def repositories(opts = {})
|
@@ -25,5 +36,19 @@ module CMIS
|
|
25
36
|
rescue Exceptions::ObjectNotFound
|
26
37
|
false
|
27
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def connection
|
43
|
+
@connection ||= Connection.new(@options)
|
44
|
+
end
|
45
|
+
|
46
|
+
def marshal_dump
|
47
|
+
@options
|
48
|
+
end
|
49
|
+
|
50
|
+
def marshal_load(options)
|
51
|
+
@options = options
|
52
|
+
end
|
28
53
|
end
|
29
54
|
end
|
data/lib/cmis/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmis-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenneth Geerts
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -50,7 +50,6 @@ files:
|
|
50
50
|
- lib/cmis/connection.rb
|
51
51
|
- lib/cmis/connection/request_modifier.rb
|
52
52
|
- lib/cmis/connection/response_parser.rb
|
53
|
-
- lib/cmis/connection/url_resolver.rb
|
54
53
|
- lib/cmis/document.rb
|
55
54
|
- lib/cmis/exceptions.rb
|
56
55
|
- lib/cmis/folder.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module CMIS
|
2
|
-
class Connection
|
3
|
-
class URLResolver
|
4
|
-
def initialize(http, service_url)
|
5
|
-
@http = http
|
6
|
-
@service_url = service_url
|
7
|
-
@repository_infos = {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def url(repository_id, object_id)
|
11
|
-
return @service_url unless repository_id
|
12
|
-
|
13
|
-
unless @repository_infos.key?(repository_id)
|
14
|
-
@repository_infos = @http.get(@service_url).body
|
15
|
-
end
|
16
|
-
|
17
|
-
if @repository_infos.key?(repository_id)
|
18
|
-
key = object_id ? 'rootFolderUrl' : 'repositoryUrl'
|
19
|
-
@repository_infos[repository_id][key]
|
20
|
-
else
|
21
|
-
raise Exceptions::ObjectNotFound, "repositoryId: #{repository_id}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|