yaccl 0.1.5 → 1.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yaccl/children.rb +55 -0
- data/lib/yaccl/connection.rb +147 -0
- data/lib/yaccl/document.rb +62 -0
- data/lib/yaccl/folder.rb +76 -0
- data/lib/yaccl/helpers.rb +59 -0
- data/lib/yaccl/item.rb +11 -0
- data/lib/yaccl/object.rb +122 -0
- data/lib/yaccl/object_factory.rb +27 -0
- data/lib/yaccl/policy.rb +26 -0
- data/lib/yaccl/property_definition.rb +32 -0
- data/lib/yaccl/query.rb +53 -0
- data/lib/yaccl/query_result.rb +15 -0
- data/lib/yaccl/relationship.rb +18 -0
- data/lib/yaccl/repository.rb +108 -0
- data/lib/yaccl/server.rb +37 -0
- data/lib/yaccl/type.rb +106 -0
- data/lib/yaccl/version.rb +1 -1
- data/lib/yaccl.rb +21 -11
- data/readme.md +0 -3
- data/spec/{model/document_spec.rb → document_spec.rb} +4 -4
- data/spec/{model/folder_spec.rb → folder_spec.rb} +6 -6
- data/spec/helper.rb +12 -12
- data/spec/{model/object_spec.rb → object_spec.rb} +6 -6
- data/spec/relationship_spec.rb +19 -0
- data/spec/repository_spec.rb +150 -0
- data/spec/server_spec.rb +22 -0
- data/spec/{model/type_spec.rb → type_spec.rb} +6 -4
- data/yaccl.gemspec +1 -0
- metadata +48 -50
- data/examples/create_type_manual.rb +0 -40
- data/lib/yaccl/model/document.rb +0 -68
- data/lib/yaccl/model/folder.rb +0 -74
- data/lib/yaccl/model/item.rb +0 -9
- data/lib/yaccl/model/object.rb +0 -159
- data/lib/yaccl/model/object_factory.rb +0 -24
- data/lib/yaccl/model/policy.rb +0 -20
- data/lib/yaccl/model/property_definition.rb +0 -66
- data/lib/yaccl/model/relationship.rb +0 -22
- data/lib/yaccl/model/repository.rb +0 -155
- data/lib/yaccl/model/server.rb +0 -13
- data/lib/yaccl/model/type.rb +0 -146
- data/lib/yaccl/model.rb +0 -11
- data/lib/yaccl/services/acl_services.rb +0 -23
- data/lib/yaccl/services/discovery_services.rb +0 -29
- data/lib/yaccl/services/internal/browser_binding_service.rb +0 -170
- data/lib/yaccl/services/internal/simple_cache.rb +0 -103
- data/lib/yaccl/services/multi_filing_services.rb +0 -22
- data/lib/yaccl/services/navigation_services.rb +0 -84
- data/lib/yaccl/services/object_services.rb +0 -211
- data/lib/yaccl/services/policy_services.rb +0 -30
- data/lib/yaccl/services/relationship_services.rb +0 -18
- data/lib/yaccl/services/repository_services.rb +0 -67
- data/lib/yaccl/services/versioning_services.rb +0 -69
- data/lib/yaccl/services.rb +0 -34
- data/spec/model/relationship_spec.rb +0 -15
- data/spec/model/repository_spec.rb +0 -138
- data/spec/model/server_spec.rb +0 -16
- data/spec/services/navigation_services_spec.rb +0 -64
- data/spec/services/object_services_spec.rb +0 -44
- data/spec/services/repository_services_spec.rb +0 -35
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative './helper'
|
2
2
|
|
3
|
-
describe YACCL::
|
3
|
+
describe YACCL::Type do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@repo = create_repository('test')
|
@@ -11,7 +11,7 @@ describe YACCL::Model::Type do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'shoud update types' do
|
14
|
-
type = YACCL::
|
14
|
+
type = YACCL::Type.new
|
15
15
|
type.id = 'apple'
|
16
16
|
type.local_name = 'apple'
|
17
17
|
type.query_name = 'apple'
|
@@ -46,7 +46,7 @@ describe YACCL::Model::Type do
|
|
46
46
|
|
47
47
|
full_type = @repo.create_type(type)
|
48
48
|
|
49
|
-
new_prop = YACCL::
|
49
|
+
new_prop = YACCL::PropertyDefinition.new(
|
50
50
|
id: 'taste',
|
51
51
|
localName: 'taste',
|
52
52
|
queryName: 'taste',
|
@@ -62,6 +62,8 @@ describe YACCL::Model::Type do
|
|
62
62
|
)
|
63
63
|
|
64
64
|
full_type.update([new_prop])
|
65
|
+
|
66
|
+
full_type.delete
|
65
67
|
end
|
66
68
|
|
67
69
|
end
|
data/yaccl.gemspec
CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_dependency 'typhoeus', '~> 0.6'
|
16
16
|
s.add_dependency 'multipart-post', '~> 1.1'
|
17
17
|
s.add_dependency 'multi_json', '~> 1.5'
|
18
|
+
s.add_dependency 'activesupport', '>= 3.2'
|
18
19
|
|
19
20
|
s.files = `git ls-files`.split("\n")
|
20
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaccl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.pre.alpha
|
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-
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|
@@ -53,6 +53,20 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.5'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: activesupport
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.2'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.2'
|
56
70
|
description: A Ruby CMIS browser binding client library implementation.
|
57
71
|
email:
|
58
72
|
- gem@up-nxt.com
|
@@ -64,45 +78,33 @@ files:
|
|
64
78
|
- Gemfile
|
65
79
|
- LICENSE
|
66
80
|
- Rakefile
|
67
|
-
- examples/create_type_manual.rb
|
68
81
|
- lib/yaccl.rb
|
69
|
-
- lib/yaccl/
|
70
|
-
- lib/yaccl/
|
71
|
-
- lib/yaccl/
|
72
|
-
- lib/yaccl/
|
73
|
-
- lib/yaccl/
|
74
|
-
- lib/yaccl/
|
75
|
-
- lib/yaccl/
|
76
|
-
- lib/yaccl/
|
77
|
-
- lib/yaccl/
|
78
|
-
- lib/yaccl/
|
79
|
-
- lib/yaccl/
|
80
|
-
- lib/yaccl/
|
81
|
-
- lib/yaccl/
|
82
|
-
- lib/yaccl/
|
83
|
-
- lib/yaccl/
|
84
|
-
- lib/yaccl/
|
85
|
-
- lib/yaccl/services/internal/simple_cache.rb
|
86
|
-
- lib/yaccl/services/multi_filing_services.rb
|
87
|
-
- lib/yaccl/services/navigation_services.rb
|
88
|
-
- lib/yaccl/services/object_services.rb
|
89
|
-
- lib/yaccl/services/policy_services.rb
|
90
|
-
- lib/yaccl/services/relationship_services.rb
|
91
|
-
- lib/yaccl/services/repository_services.rb
|
92
|
-
- lib/yaccl/services/versioning_services.rb
|
82
|
+
- lib/yaccl/children.rb
|
83
|
+
- lib/yaccl/connection.rb
|
84
|
+
- lib/yaccl/document.rb
|
85
|
+
- lib/yaccl/folder.rb
|
86
|
+
- lib/yaccl/helpers.rb
|
87
|
+
- lib/yaccl/item.rb
|
88
|
+
- lib/yaccl/object.rb
|
89
|
+
- lib/yaccl/object_factory.rb
|
90
|
+
- lib/yaccl/policy.rb
|
91
|
+
- lib/yaccl/property_definition.rb
|
92
|
+
- lib/yaccl/query.rb
|
93
|
+
- lib/yaccl/query_result.rb
|
94
|
+
- lib/yaccl/relationship.rb
|
95
|
+
- lib/yaccl/repository.rb
|
96
|
+
- lib/yaccl/server.rb
|
97
|
+
- lib/yaccl/type.rb
|
93
98
|
- lib/yaccl/version.rb
|
94
99
|
- readme.md
|
100
|
+
- spec/document_spec.rb
|
101
|
+
- spec/folder_spec.rb
|
95
102
|
- spec/helper.rb
|
96
|
-
- spec/
|
97
|
-
- spec/
|
98
|
-
- spec/
|
99
|
-
- spec/
|
100
|
-
- spec/
|
101
|
-
- spec/model/server_spec.rb
|
102
|
-
- spec/model/type_spec.rb
|
103
|
-
- spec/services/navigation_services_spec.rb
|
104
|
-
- spec/services/object_services_spec.rb
|
105
|
-
- spec/services/repository_services_spec.rb
|
103
|
+
- spec/object_spec.rb
|
104
|
+
- spec/relationship_spec.rb
|
105
|
+
- spec/repository_spec.rb
|
106
|
+
- spec/server_spec.rb
|
107
|
+
- spec/type_spec.rb
|
106
108
|
- yaccl.gemspec
|
107
109
|
homepage: https://github.com/UP-nxt
|
108
110
|
licenses: []
|
@@ -118,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
120
|
version: '0'
|
119
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
122
|
requirements:
|
121
|
-
- - "
|
123
|
+
- - ">"
|
122
124
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
125
|
+
version: 1.3.1
|
124
126
|
requirements: []
|
125
127
|
rubyforge_project:
|
126
128
|
rubygems_version: 2.2.1
|
@@ -128,15 +130,11 @@ signing_key:
|
|
128
130
|
specification_version: 4
|
129
131
|
summary: CMIS browser binding client lib.
|
130
132
|
test_files:
|
133
|
+
- spec/document_spec.rb
|
134
|
+
- spec/folder_spec.rb
|
131
135
|
- spec/helper.rb
|
132
|
-
- spec/
|
133
|
-
- spec/
|
134
|
-
- spec/
|
135
|
-
- spec/
|
136
|
-
- spec/
|
137
|
-
- spec/model/server_spec.rb
|
138
|
-
- spec/model/type_spec.rb
|
139
|
-
- spec/services/navigation_services_spec.rb
|
140
|
-
- spec/services/object_services_spec.rb
|
141
|
-
- spec/services/repository_services_spec.rb
|
142
|
-
has_rdoc:
|
136
|
+
- spec/object_spec.rb
|
137
|
+
- spec/relationship_spec.rb
|
138
|
+
- spec/repository_spec.rb
|
139
|
+
- spec/server_spec.rb
|
140
|
+
- spec/type_spec.rb
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'yaccl'
|
2
|
-
|
3
|
-
repository = YACCL::Model::Server.repository('blueprint')
|
4
|
-
|
5
|
-
type = YACCL::Model::Type.new
|
6
|
-
type.id = 'apple'
|
7
|
-
type.local_name = 'apple'
|
8
|
-
type.query_name = 'apple'
|
9
|
-
type.display_name = 'Apple'
|
10
|
-
type.parent_id = 'cmis:document'
|
11
|
-
type.base_id = 'cmis:document'
|
12
|
-
type.description = 'The apple fruit.'
|
13
|
-
type.creatable = true
|
14
|
-
type.fileable = true
|
15
|
-
type.queryable = true
|
16
|
-
type.controllable_policy = true
|
17
|
-
type.controllable_acl = true
|
18
|
-
type.fulltext_indexed = true
|
19
|
-
type.included_in_supertype_query = true
|
20
|
-
type.content_stream_allowed = 'allowed'
|
21
|
-
type.versionable = false
|
22
|
-
|
23
|
-
type.add_property_definition(
|
24
|
-
id: 'color',
|
25
|
-
localName: 'color',
|
26
|
-
queryName: 'color',
|
27
|
-
displayName: 'Color',
|
28
|
-
description: 'The color.',
|
29
|
-
propertyType: 'string',
|
30
|
-
cardinality: 'single',
|
31
|
-
updatability: 'readwrite',
|
32
|
-
inherited: false,
|
33
|
-
required: false,
|
34
|
-
queryable: true,
|
35
|
-
orderable: true
|
36
|
-
)
|
37
|
-
|
38
|
-
full_type = repository.create_type(type)
|
39
|
-
# puts full_type.to_hash
|
40
|
-
full_type.delete
|
data/lib/yaccl/model/document.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
module YACCL
|
2
|
-
module Model
|
3
|
-
class Document < Object
|
4
|
-
attr_reader :is_immutable
|
5
|
-
attr_reader :is_latest_version
|
6
|
-
attr_reader :is_major_version
|
7
|
-
attr_reader :is_latest_major_version
|
8
|
-
attr_reader :is_private_working_copy
|
9
|
-
attr_reader :version_label
|
10
|
-
attr_reader :version_series_id
|
11
|
-
attr_reader :version_series_checked_out
|
12
|
-
attr_reader :version_series_checked_out_by
|
13
|
-
attr_reader :version_series_checked_out_id
|
14
|
-
attr_reader :checkin_comment
|
15
|
-
attr_reader :content_stream_length
|
16
|
-
attr_reader :content_stream_mime_type
|
17
|
-
attr_reader :content_stream_file_name
|
18
|
-
attr_reader :content_stream_id
|
19
|
-
|
20
|
-
def initialize(repository_id, raw={})
|
21
|
-
super
|
22
|
-
@is_immutable = @properties[:'cmis:isImmutable']
|
23
|
-
@is_latest_version = @properties[:'cmis:isLatestVersion']
|
24
|
-
@is_major_version = @properties[:'cmis:isMajorVersion']
|
25
|
-
@is_lastest_major_version = @properties[:'cmis:isLatestMajorVersion']
|
26
|
-
@is_private_working_copy = @properties[:'cmis:isPrivateWorkingCopy']
|
27
|
-
@version_label = @properties[:'cmis:versionLabel']
|
28
|
-
@version_series_id = @properties[:'cmis:versionSeriesId']
|
29
|
-
@version_series_checked_out = @properties[:'cmis:isVersionSeriesCheckedOut']
|
30
|
-
@version_series_checked_out_by = @properties[:'cmis:versionSeriesCheckedOutBy']
|
31
|
-
@version_series_checked_out_id = @properties[:'cmis:versionSeriesCheckedOutId']
|
32
|
-
@checkin_comment = @properties[:'cmis:checkinComment']
|
33
|
-
@content_stream_length = @properties[:'cmis:contentStreamLength']
|
34
|
-
@content_stream_mime_type = @properties[:'cmis:contentStreamMimeType']
|
35
|
-
@content_stream_file_name = @properties[:'cmis:contentStreamFileName']
|
36
|
-
@content_stream_id = @properties[:'cmis:contentStreamId']
|
37
|
-
end
|
38
|
-
|
39
|
-
def copy_in_folder(folder)
|
40
|
-
new_cmis_object_id = Services.create_document_from_source(repository_id, cmis_object_id, nil, folder.cmis_object_id, nil, nil, nil, nil)
|
41
|
-
repository.object(new_cmis_object_id)
|
42
|
-
end
|
43
|
-
|
44
|
-
def content
|
45
|
-
begin
|
46
|
-
Services.get_content_stream(repository_id, cmis_object_id, nil, nil, nil)
|
47
|
-
rescue Services::CMISRequestError
|
48
|
-
nil
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def set_content(stream, mime_type, filename)
|
53
|
-
content = {stream: stream, mime_type: mime_type, filename: filename}
|
54
|
-
if detached?
|
55
|
-
@local_content = content
|
56
|
-
else
|
57
|
-
r = Services.set_content_stream(repository_id, cmis_object_id, nil, change_token, content)
|
58
|
-
update_change_token(r)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def create_in_folder(folder_id)
|
63
|
-
hash = Services.create_document(repository_id, create_properties, folder_id, @local_content, nil, nil, nil, nil)
|
64
|
-
ObjectFactory.create(repository_id, hash)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/lib/yaccl/model/folder.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
module YACCL
|
2
|
-
module Model
|
3
|
-
class Folder < Object
|
4
|
-
attr_reader :parent_id
|
5
|
-
attr_reader :path
|
6
|
-
attr_reader :allowed_child_object_type_ids
|
7
|
-
|
8
|
-
def initialize(repository_id, raw={})
|
9
|
-
super
|
10
|
-
@parent_id = @properties[:'cmis:parentId']
|
11
|
-
@path = @properties[:'cmis:path']
|
12
|
-
@allowed_child_object_type_ids = @properties[:'cmis:allowedChildObjectTypeIds']
|
13
|
-
end
|
14
|
-
|
15
|
-
def parent
|
16
|
-
repository.object(parent_id) unless parent_id.nil?
|
17
|
-
end
|
18
|
-
|
19
|
-
def allowed_child_object_types
|
20
|
-
return nil if allowed_child_object_type_ids.nil?
|
21
|
-
allowed_child_object_type_ids.map do |type_id|
|
22
|
-
repository.type(type_id)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def children(options={})
|
27
|
-
children = Services.get_children(repository_id, cmis_object_id, options[:filter], options[:order_by], options[:include_allowable_actions], options[:include_relations], options[:rendition_filter], options[:include_path_segment], options[:max_items], options[:skip_count])
|
28
|
-
if children[:objects]
|
29
|
-
children[:objects].map! { |o| ObjectFactory.create(repository_id, o[:object]) }
|
30
|
-
else
|
31
|
-
children[:objects] = []
|
32
|
-
end
|
33
|
-
children[:num_items] = children.delete(:numItems).to_i
|
34
|
-
children[:has_more_items] = children.delete(:hasMoreItems)
|
35
|
-
|
36
|
-
yield(children) if block_given?
|
37
|
-
children[:objects]
|
38
|
-
end
|
39
|
-
|
40
|
-
def tree(depth)
|
41
|
-
end
|
42
|
-
|
43
|
-
def create(object)
|
44
|
-
properties = object.create_properties
|
45
|
-
if object.is_a? Folder
|
46
|
-
o = Services.create_folder(repository_id, properties, cmis_object_id, nil, nil, nil)
|
47
|
-
elsif object.is_a? Document
|
48
|
-
return object.create_in_folder(cmis_object_id)
|
49
|
-
elsif object.is_a? Relationship
|
50
|
-
raise 'relationship is not fileable'
|
51
|
-
elsif object.is_a? Policy
|
52
|
-
o = Services.create_policy(repository_id, properties, cmis_object_id, nil, nil, nil)
|
53
|
-
elsif object.is_a? Item
|
54
|
-
o = Services.create_item(repository_id, properties, cmis_object_id, nil, nil, nil)
|
55
|
-
else
|
56
|
-
raise "Unexpected base_type_id: #{object.base_type_id}"
|
57
|
-
end
|
58
|
-
ObjectFactory.create(repository_id, o)
|
59
|
-
end
|
60
|
-
|
61
|
-
def delete_tree
|
62
|
-
Services.delete_tree(repository_id, cmis_object_id, nil, nil, nil)
|
63
|
-
end
|
64
|
-
|
65
|
-
def add(object)
|
66
|
-
Services.add_object_to_folder(repository_id, object.cmis_object_id, cmis_object_id, nil)
|
67
|
-
end
|
68
|
-
|
69
|
-
def remove(object)
|
70
|
-
Services.remove_object_from_folder(repository_id, object.cmis_object_id, cmis_object_id)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
data/lib/yaccl/model/item.rb
DELETED
data/lib/yaccl/model/object.rb
DELETED
@@ -1,159 +0,0 @@
|
|
1
|
-
module YACCL
|
2
|
-
module Model
|
3
|
-
class Object
|
4
|
-
attr_reader :repository_id
|
5
|
-
attr_reader :cmis_object_id
|
6
|
-
attr_reader :base_type_id
|
7
|
-
attr_accessor :object_type_id
|
8
|
-
attr_reader :secondary_object_type_ids
|
9
|
-
attr_accessor :name
|
10
|
-
attr_reader :description
|
11
|
-
attr_reader :created_by
|
12
|
-
attr_reader :creation_date
|
13
|
-
attr_reader :last_modified_by
|
14
|
-
attr_reader :last_modification_date
|
15
|
-
attr_accessor :change_token
|
16
|
-
attr_accessor :properties
|
17
|
-
|
18
|
-
def object_id
|
19
|
-
warn "[DEPRECATION] using `object_id` for CMIS objects is deprecated. Please use `cmis_object_id` instead."
|
20
|
-
cmis_object_id
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(repository_id, raw={})
|
24
|
-
@repository_id = repository_id
|
25
|
-
@properties = get_properties_map(raw)
|
26
|
-
|
27
|
-
@cmis_object_id = @properties[:'cmis:objectId']
|
28
|
-
@base_type_id = @properties[:'cmis:baseTypeId']
|
29
|
-
@object_type_id = @properties[:'cmis:objectTypeId']
|
30
|
-
@secondary_object_type_ids = @properties[:'cmis:secondaryObjectTypeIds']
|
31
|
-
@name = @properties[:'cmis:name']
|
32
|
-
@description = @properties[:'cmis:description']
|
33
|
-
@created_by = @properties[:'cmis:createdBy']
|
34
|
-
@creation_date = @properties[:'cmis:creationDate']
|
35
|
-
@last_modified_by = @properties[:'cmis:lastModifiedBy']
|
36
|
-
@last_modification_date = @properties[:'cmis:lastModificationDate']
|
37
|
-
@change_token = @properties[:'cmis:changeToken']
|
38
|
-
end
|
39
|
-
|
40
|
-
def repository
|
41
|
-
Server.repository(repository_id)
|
42
|
-
end
|
43
|
-
|
44
|
-
def object_type
|
45
|
-
repository.type(object_type_id)
|
46
|
-
end
|
47
|
-
|
48
|
-
def delete
|
49
|
-
Services.delete_object(repository_id, cmis_object_id, true)
|
50
|
-
end
|
51
|
-
|
52
|
-
def update_properties(properties)
|
53
|
-
r = Services.update_properties(repository_id, cmis_object_id, change_token, properties)
|
54
|
-
update_change_token(r)
|
55
|
-
end
|
56
|
-
|
57
|
-
def parents
|
58
|
-
Services.get_object_parents(repository_id, cmis_object_id, nil, nil, nil, nil, nil).map do |o|
|
59
|
-
ObjectFactory.create(repository_id, o[:object])
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def allowable_actions
|
64
|
-
Services.get_allowable_actions(repository_id, cmis_object_id)
|
65
|
-
end
|
66
|
-
|
67
|
-
def relationships(direction=:either)
|
68
|
-
result = Services.get_object_relationships(repository_id, cmis_object_id, nil, direction, nil, nil, false, nil, nil)
|
69
|
-
result[:objects].map { |r| Relationship.new(repository_id, r) }
|
70
|
-
end
|
71
|
-
|
72
|
-
def policies
|
73
|
-
Services.get_applied_policies(repository_id, cmis_object_id, nil).map do |policy|
|
74
|
-
Policy.new(repository_id, policy)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# remove from all folders
|
79
|
-
def unfile
|
80
|
-
Services.remove_object_from_folder(repository_id, cmis_object_id, nil)
|
81
|
-
end
|
82
|
-
|
83
|
-
def move(target_folder)
|
84
|
-
object_parents = parents
|
85
|
-
if object_parents.size == 1
|
86
|
-
Services.move_object(repository_id, cmis_object_id, target_folder.cmis_object_id, object_parents.first.cmis_object_id)
|
87
|
-
else
|
88
|
-
# raise?
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def acls
|
93
|
-
Services.get_acl(repository_id, cmis_object_id, nil)
|
94
|
-
end
|
95
|
-
|
96
|
-
def add_aces(aces)
|
97
|
-
Services.apply_acl(repository_id, cmis_object_id, aces, nil, nil)
|
98
|
-
end
|
99
|
-
|
100
|
-
def remove_aces(aces)
|
101
|
-
Services.apply_acl(repository_id, cmis_object_id, nil, aces, nil)
|
102
|
-
end
|
103
|
-
|
104
|
-
def create_properties
|
105
|
-
{'cmis:name' => name, 'cmis:objectTypeId' => object_type_id}.merge(properties)
|
106
|
-
end
|
107
|
-
|
108
|
-
def detached?
|
109
|
-
cmis_object_id.nil?
|
110
|
-
end
|
111
|
-
|
112
|
-
# utility
|
113
|
-
|
114
|
-
def can_be_deleted?
|
115
|
-
allowable_actions[:canDeleteObject]
|
116
|
-
end
|
117
|
-
|
118
|
-
def can_get_parents?
|
119
|
-
allowable_actions[:canGetObjectParents]
|
120
|
-
end
|
121
|
-
|
122
|
-
def can_update_properties
|
123
|
-
allowable_actions[:canUpdateProperties]
|
124
|
-
end
|
125
|
-
|
126
|
-
def method_missing(method_sym, *arguments, &block)
|
127
|
-
@properties[method_sym] ? @properties[method_sym] : super
|
128
|
-
end
|
129
|
-
|
130
|
-
def update_change_token(r)
|
131
|
-
@change_token = if r[:properties]
|
132
|
-
r[:properties][:'cmis:changeToken'][:value]
|
133
|
-
elsif r[:succinctProperties]
|
134
|
-
r[:succinctProperties][:'cmis:changeToken']
|
135
|
-
else
|
136
|
-
raise "Unexpected response: #{r}"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
private
|
141
|
-
|
142
|
-
def get_properties_map(raw)
|
143
|
-
if raw[:succinctProperties]
|
144
|
-
result = raw[:succinctProperties]
|
145
|
-
elsif raw[:properties]
|
146
|
-
result = raw[:properties].reduce({}) do |h, (k, v)|
|
147
|
-
val = v[:value]
|
148
|
-
val = v[:value].first if v[:value].is_a?(Array) and v[:type] == 'datetime'
|
149
|
-
val = Time.at(val / 1000) if val and v[:type] == 'datetime'
|
150
|
-
h.merge(k => val)
|
151
|
-
end
|
152
|
-
else
|
153
|
-
result = {}
|
154
|
-
end
|
155
|
-
result
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module YACCL
|
2
|
-
module Model
|
3
|
-
class ObjectFactory
|
4
|
-
def self.create(repository_id, raw)
|
5
|
-
base_type_id = if raw[:properties]
|
6
|
-
raw[:properties][:'cmis:baseTypeId'][:value]
|
7
|
-
elsif raw[:succinctProperties]
|
8
|
-
raw[:succinctProperties][:'cmis:baseTypeId']
|
9
|
-
else
|
10
|
-
raise "Unexpected raw: #{raw}"
|
11
|
-
end
|
12
|
-
|
13
|
-
case base_type_id
|
14
|
-
when 'cmis:folder' then Folder.new(repository_id, raw)
|
15
|
-
when 'cmis:document' then Document.new(repository_id, raw)
|
16
|
-
when 'cmis:relationship' then Relationship.new(repository_id, raw)
|
17
|
-
when 'cmis:policy' then Policy.new(repository_id, raw)
|
18
|
-
when 'cmis:item' then Item.new(repository_id, raw)
|
19
|
-
else raise "Unexpected baseTypeId: #{base_type_id}."
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/yaccl/model/policy.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module YACCL
|
2
|
-
module Model
|
3
|
-
class Policy < Object
|
4
|
-
attr_reader :policy_text
|
5
|
-
|
6
|
-
def initialize(repository_id, raw={})
|
7
|
-
super
|
8
|
-
@policy_text = @properties[:'cmis:policyText']
|
9
|
-
end
|
10
|
-
|
11
|
-
def apply_to(object)
|
12
|
-
Services.apply_policy(repository_id, cmis_object_id, object.cmis_object_id)
|
13
|
-
end
|
14
|
-
|
15
|
-
def remove_from(object)
|
16
|
-
Services.remove_policy(repository_id, cmis_object_id, object.cmis_object_id)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module YACCL
|
2
|
-
module Model
|
3
|
-
class PropertyDefinition
|
4
|
-
|
5
|
-
attr_accessor :id, :local_name, :query_name,
|
6
|
-
:description, :inherited, :open_choice,
|
7
|
-
:orderable, :property_type, :updatability,
|
8
|
-
:display_name, :required, :cardinality, :queryable, :other
|
9
|
-
|
10
|
-
def initialize(hash={})
|
11
|
-
@id = hash.delete(:id)
|
12
|
-
@local_name = hash.delete(:localName)
|
13
|
-
@query_name = hash.delete(:queryName)
|
14
|
-
@description = hash.delete(:description)
|
15
|
-
@inherited = hash.delete(:inherited)
|
16
|
-
@open_choice = hash.delete(:openChoice)
|
17
|
-
@orderable = hash.delete(:orderable)
|
18
|
-
@property_type = hash.delete(:propertyType)
|
19
|
-
@updatability = hash.delete(:updatability)
|
20
|
-
@display_name = hash.delete(:displayName)
|
21
|
-
@required = hash.delete(:required)
|
22
|
-
@cardinality = hash.delete(:cardinality)
|
23
|
-
@queryable = hash.delete(:queryable)
|
24
|
-
@other = hash
|
25
|
-
end
|
26
|
-
|
27
|
-
def readonly?
|
28
|
-
updatability == 'readonly'
|
29
|
-
end
|
30
|
-
|
31
|
-
def oncreate?
|
32
|
-
updatability == 'oncreate'
|
33
|
-
end
|
34
|
-
|
35
|
-
def readwrite?
|
36
|
-
updatability == 'readwrite'
|
37
|
-
end
|
38
|
-
|
39
|
-
def method_missing(m, *args, &block)
|
40
|
-
if @other.has_key?(m)
|
41
|
-
@other[m]
|
42
|
-
else
|
43
|
-
super
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def to_hash
|
48
|
-
hash = {}
|
49
|
-
hash[:id] = id
|
50
|
-
hash[:localName] = local_name
|
51
|
-
hash[:queryName] = query_name
|
52
|
-
hash[:description] = description
|
53
|
-
hash[:inherited] = inherited
|
54
|
-
hash[:openChoice] = open_choice
|
55
|
-
hash[:orderable] = orderable
|
56
|
-
hash[:propertyType] = property_type
|
57
|
-
hash[:updatability] = updatability
|
58
|
-
hash[:displayName] = display_name
|
59
|
-
hash[:required] = required
|
60
|
-
hash[:cardinality] = cardinality
|
61
|
-
hash[:queryable] = queryable
|
62
|
-
hash.merge(other)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module YACCL
|
2
|
-
module Model
|
3
|
-
class Relationship < Object
|
4
|
-
attr_reader :source_id
|
5
|
-
attr_reader :target_id
|
6
|
-
|
7
|
-
def initialize(repository_id, raw={})
|
8
|
-
super
|
9
|
-
@source_id = @properties[:'cmis:sourceId']
|
10
|
-
@target_id = @properties[:'cmis:targetId']
|
11
|
-
end
|
12
|
-
|
13
|
-
def source
|
14
|
-
ObjectFactory.create(repository_id, Services.get_object(repository_id, source_id, nil, false, nil, nil, false, false))
|
15
|
-
end
|
16
|
-
|
17
|
-
def target
|
18
|
-
ObjectFactory.create(repository_id, Services.get_object(repository_id, target_id, nil, false, nil, nil, false, false))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|