yaccl 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +176 -0
- data/lib/yaccl.rb +1 -1
- data/lib/yaccl/model/document.rb +5 -1
- data/lib/yaccl/model/folder.rb +2 -2
- data/lib/yaccl/model/object.rb +17 -4
- data/lib/yaccl/model/repository.rb +15 -2
- data/lib/yaccl/services/navigation_services.rb +2 -2
- data/lib/yaccl/services/object_services.rb +3 -2
- data/spec/helper.rb +1 -0
- data/spec/model/document_spec.rb +3 -2
- data/spec/model/folder_spec.rb +2 -2
- data/spec/model/object_spec.rb +4 -7
- data/spec/model/repository_spec.rb +2 -2
- data/spec/services/navigation_services_spec.rb +64 -0
- data/spec/services/object_services_spec.rb +44 -0
- data/spec/services/repository_services_spec.rb +35 -0
- metadata +9 -2
data/LICENSE
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
data/lib/yaccl.rb
CHANGED
data/lib/yaccl/model/document.rb
CHANGED
@@ -42,7 +42,11 @@ module YACCL
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def content
|
45
|
-
|
45
|
+
begin
|
46
|
+
Services.get_content_stream(repository_id, object_id, nil, nil, nil)
|
47
|
+
rescue Services::CMISRequestError
|
48
|
+
nil
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
52
|
def set_content(stream, mime_type, filename)
|
data/lib/yaccl/model/folder.rb
CHANGED
@@ -24,8 +24,8 @@ module YACCL
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def children
|
27
|
-
Services.
|
28
|
-
ObjectFactory.create(repository_id, o)
|
27
|
+
Services.get_children(repository_id, object_id, nil, nil, nil, nil, nil, nil, nil, nil)[:objects].map do |o|
|
28
|
+
ObjectFactory.create(repository_id, o[:object])
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
data/lib/yaccl/model/object.rb
CHANGED
@@ -13,11 +13,15 @@ module YACCL
|
|
13
13
|
attr_reader :last_modified_by
|
14
14
|
attr_reader :last_modification_date
|
15
15
|
attr_reader :change_token
|
16
|
-
|
16
|
+
attr_accessor :properties
|
17
17
|
|
18
18
|
def initialize(repository_id, raw={})
|
19
19
|
@repository_id = repository_id
|
20
20
|
@properties = get_properties_map(raw)
|
21
|
+
|
22
|
+
@properties[:'cmis:creationDate'] = Time.at(@properties[:'cmis:creationDate'] / 1000) unless @properties[:'cmis:creationDate'].nil?
|
23
|
+
@properties[:'cmis:lastModificationDate'] = Time.at(@properties[:'cmis:lastModificationDate'] / 1000) unless @properties[:'cmis:lastModificationDate'].nil?
|
24
|
+
|
21
25
|
@object_id = @properties[:'cmis:objectId']
|
22
26
|
@base_type_id = @properties[:'cmis:baseTypeId']
|
23
27
|
@object_type_id = @properties[:'cmis:objectTypeId']
|
@@ -43,14 +47,23 @@ module YACCL
|
|
43
47
|
Services.delete_object(repository_id, object_id, true)
|
44
48
|
end
|
45
49
|
|
50
|
+
def update_properties(properties)
|
51
|
+
Services.update_properties(repository_id, object_id, nil, properties)
|
52
|
+
end
|
53
|
+
|
54
|
+
def parents
|
55
|
+
Services.get_object_parents(repository_id, object_id, nil, nil, nil, nil, nil).map do |o|
|
56
|
+
ObjectFactory.create(repository_id, o[:object])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
46
60
|
def allowable_actions
|
47
61
|
Services.get_allowable_actions(repository_id, object_id)
|
48
62
|
end
|
49
63
|
|
50
|
-
def relationships(direction
|
64
|
+
def relationships(direction=:either)
|
51
65
|
result = Services.get_object_relationships(repository_id, object_id, nil, direction, nil, nil, false, nil, nil)
|
52
|
-
result[:objects]
|
53
|
-
result
|
66
|
+
result[:objects].map { |r| Relationship.create(repository_id, r) }
|
54
67
|
end
|
55
68
|
|
56
69
|
def policies
|
@@ -75,9 +75,11 @@ module YACCL
|
|
75
75
|
Type.create(Services.get_type_definition(id, type_id))
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
78
|
+
def types
|
79
|
+
_types(Services.get_type_descendants(id, nil, nil, nil))
|
79
80
|
end
|
80
81
|
|
82
|
+
|
81
83
|
def create_type(type)
|
82
84
|
Type.create(Services.create_type(id, type.to_hash))
|
83
85
|
end
|
@@ -93,7 +95,7 @@ module YACCL
|
|
93
95
|
# discovery
|
94
96
|
|
95
97
|
def query(statement)
|
96
|
-
Services.query(id, statement, false, nil, nil, nil, nil, nil).map do |o|
|
98
|
+
Services.query(id, statement, false, nil, nil, nil, nil, nil)[:results].map do |o|
|
97
99
|
ObjectFactory.create(id, o)
|
98
100
|
end
|
99
101
|
end
|
@@ -101,6 +103,17 @@ module YACCL
|
|
101
103
|
def content_changes(change_log_token)
|
102
104
|
Services.get_content_changes(id, change_log_token, nil, nil, nil, nil)
|
103
105
|
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def _types(arr)
|
110
|
+
types = []
|
111
|
+
arr.each do |t|
|
112
|
+
types << Type.create(t[:type])
|
113
|
+
types << _types(t[:children]) if t.has_key?(:children)
|
114
|
+
end
|
115
|
+
types.flatten
|
116
|
+
end
|
104
117
|
end
|
105
118
|
end
|
106
119
|
end
|
@@ -45,7 +45,7 @@ module YACCL
|
|
45
45
|
required = {cmisselector: 'parent',
|
46
46
|
repositoryId: repository_id,
|
47
47
|
objectId: folder_id}
|
48
|
-
optional = {filter:filter}
|
48
|
+
optional = {filter: filter}
|
49
49
|
perform_request(required, optional)
|
50
50
|
end
|
51
51
|
|
@@ -57,7 +57,7 @@ module YACCL
|
|
57
57
|
includeAllowableActions: include_allowable_actions,
|
58
58
|
includeRelationships: include_relationships,
|
59
59
|
renditionFilter: rendition_filter,
|
60
|
-
|
60
|
+
includeRelativePathSegment: include_relative_path_segment}
|
61
61
|
perform_request(required, optional)
|
62
62
|
end
|
63
63
|
|
@@ -24,8 +24,9 @@ module YACCL
|
|
24
24
|
def create_document(repository_id, properties, folder_id, content, versioning_state, policies, add_aces, remove_aces, extension={})
|
25
25
|
required = {cmisaction: 'createDocument',
|
26
26
|
repositoryId: repository_id,
|
27
|
-
properties: properties
|
28
|
-
|
27
|
+
properties: properties,
|
28
|
+
objectId: folder_id}
|
29
|
+
optional = {folderId: folder_id,
|
29
30
|
content: content,
|
30
31
|
versioningState: versioning_state,
|
31
32
|
policies: policies,
|
data/spec/helper.rb
CHANGED
data/spec/model/document_spec.rb
CHANGED
@@ -3,11 +3,11 @@ require_relative '../helper'
|
|
3
3
|
describe YACCL::Model::Document do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@repo = create_repository('
|
6
|
+
@repo = create_repository('test')
|
7
7
|
end
|
8
8
|
|
9
9
|
after :all do
|
10
|
-
delete_repository('
|
10
|
+
delete_repository('test')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'create_in_folder with content' do
|
@@ -29,6 +29,7 @@ describe YACCL::Model::Document do
|
|
29
29
|
new_object.object_type_id = 'cmis:document'
|
30
30
|
doc = new_object.create_in_folder(@repo.root_folder_id)
|
31
31
|
doc.name.should eq 'doc2'
|
32
|
+
doc.content.should be nil
|
32
33
|
doc.delete
|
33
34
|
end
|
34
35
|
|
data/spec/model/folder_spec.rb
CHANGED
@@ -3,11 +3,11 @@ require_relative '../helper'
|
|
3
3
|
describe YACCL::Model::Folder do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@repo = create_repository('
|
6
|
+
@repo = create_repository('test')
|
7
7
|
end
|
8
8
|
|
9
9
|
after :all do
|
10
|
-
delete_repository('
|
10
|
+
delete_repository('test')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'parent - root' do
|
data/spec/model/object_spec.rb
CHANGED
@@ -3,17 +3,17 @@ require_relative '../helper'
|
|
3
3
|
describe YACCL::Model::Object do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@repo = create_repository('
|
6
|
+
@repo = create_repository('test')
|
7
7
|
end
|
8
8
|
|
9
9
|
after :all do
|
10
|
-
delete_repository('
|
10
|
+
delete_repository('test')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'repository' do
|
14
14
|
doc = create_document
|
15
15
|
doc.repository.should be_a_kind_of YACCL::Model::Repository
|
16
|
-
doc.repository.id.should eq '
|
16
|
+
doc.repository.id.should eq 'test'
|
17
17
|
doc.delete
|
18
18
|
end
|
19
19
|
|
@@ -43,10 +43,7 @@ describe YACCL::Model::Object do
|
|
43
43
|
doc = create_document
|
44
44
|
rels = doc.relationships
|
45
45
|
rels.should_not be_nil
|
46
|
-
rels.
|
47
|
-
rels.should have_key :hasMoreItems
|
48
|
-
rels.should have_key :numItems
|
49
|
-
rels[:objects].each do |r|
|
46
|
+
rels.each do |r|
|
50
47
|
r.should be_a_kind_of YACCL::Model::Relationship
|
51
48
|
end
|
52
49
|
doc.delete
|
@@ -64,11 +64,11 @@ describe YACCL::Model::Repository do
|
|
64
64
|
|
65
65
|
context 'upn' do
|
66
66
|
before :all do
|
67
|
-
@repo = create_repository('
|
67
|
+
@repo = create_repository('testrepository')
|
68
68
|
end
|
69
69
|
|
70
70
|
after :all do
|
71
|
-
delete_repository('
|
71
|
+
delete_repository('testrepository')
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'type - relationship' do
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
|
3
|
+
describe YACCL::NavigationServices do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@repo = create_repository('testrepo')
|
7
|
+
end
|
8
|
+
|
9
|
+
after :all do
|
10
|
+
delete_repository('testrepo')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'get children' do
|
14
|
+
root = @repo.root
|
15
|
+
f1 = create_folder(root)
|
16
|
+
|
17
|
+
root_children = YACCL::Services.get_children('testrepo', root.object_id, nil, nil, nil, nil, nil, nil, nil, nil)
|
18
|
+
root_children[:objects].length.should be 1
|
19
|
+
root_children[:objects].first[:object][:properties][:'cmis:objectId'][:value].should eq f1.object_id
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'folder in folder - get parents' do
|
23
|
+
root = @repo.root
|
24
|
+
|
25
|
+
f1 = create_folder(root)
|
26
|
+
f1_parents = YACCL::Services.get_object_parents('testrepo', f1.object_id, nil, nil, nil, nil, nil)
|
27
|
+
f1_parents.length.should eq 1
|
28
|
+
f1_parents.first[:object][:properties][:'cmis:objectId'][:value].should eq root.object_id
|
29
|
+
|
30
|
+
f2 = create_folder(f1)
|
31
|
+
f2_parents = YACCL::Services.get_object_parents('testrepo', f2.object_id, nil, nil, nil, nil, nil)
|
32
|
+
f2_parents.length.should eq 1
|
33
|
+
f2_parents.first[:object][:properties][:'cmis:objectId'][:value].should eq f1.object_id
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'document in folder - get parents' do
|
37
|
+
root = @repo.root
|
38
|
+
|
39
|
+
f1 = create_folder(root)
|
40
|
+
f1_parents = YACCL::Services.get_object_parents('testrepo', f1.object_id, nil, nil, nil, nil, nil)
|
41
|
+
f1_parents.length.should eq 1
|
42
|
+
f1_parents.first[:object][:properties][:'cmis:objectId'][:value].should eq root.object_id
|
43
|
+
|
44
|
+
doc = create_document(f1)
|
45
|
+
doc_parents = YACCL::Services.get_object_parents('testrepo', doc.object_id, nil, nil, nil, nil, nil)
|
46
|
+
doc_parents.length.should eq 1
|
47
|
+
doc_parents.first[:object][:properties][:'cmis:objectId'][:value].should eq f1.object_id
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_folder(folder)
|
51
|
+
new_object = @repo.new_folder
|
52
|
+
new_object.name = 'folder'
|
53
|
+
new_object.object_type_id = 'cmis:folder'
|
54
|
+
folder.create(new_object)
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_document(folder)
|
58
|
+
new_object = @repo.new_document
|
59
|
+
new_object.name = 'document'
|
60
|
+
new_object.object_type_id = 'cmis:document'
|
61
|
+
folder.create(new_object)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
|
3
|
+
describe YACCL::NavigationServices do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@repo = create_repository('testrepo')
|
7
|
+
end
|
8
|
+
|
9
|
+
after :all do
|
10
|
+
delete_repository('testrepo')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'create_document' do
|
14
|
+
root = @repo.root
|
15
|
+
|
16
|
+
properties = {'cmis:objectTypeId' => 'cmis:document', 'cmis:name' => 'document'}
|
17
|
+
YACCL::Services.create_document('testrepo', properties, root.object_id, nil, nil, nil, nil, nil)
|
18
|
+
|
19
|
+
root_children = YACCL::Services.get_children('testrepo', root.object_id, nil, nil, nil, nil, nil, nil, nil, nil)
|
20
|
+
root_children[:objects].length.should be 1
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'get content stream' do
|
24
|
+
root = @repo.root
|
25
|
+
|
26
|
+
properties = {'cmis:objectTypeId' => 'cmis:document', 'cmis:name' => 'document'}
|
27
|
+
content = { stream: StringIO.new('Apples are green.'), mime_type: 'text/plain', filename: 'apples.txt' }
|
28
|
+
doc = YACCL::Services.create_document('testrepo', properties, root.object_id, content, nil, nil, nil, nil)
|
29
|
+
doc_id = doc[:properties][:'cmis:objectId'][:value]
|
30
|
+
|
31
|
+
YACCL::Services.get_content_stream('testrepo', doc_id, nil, nil, nil).should eq 'Apples are green.'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'get content stream when not set' do
|
35
|
+
root = @repo.root
|
36
|
+
|
37
|
+
properties = {'cmis:objectTypeId' => 'cmis:document', 'cmis:name' => 'document'}
|
38
|
+
doc = YACCL::Services.create_document('testrepo', properties, root.object_id, nil, nil, nil, nil, nil)
|
39
|
+
doc_id = doc[:properties][:'cmis:objectId'][:value]
|
40
|
+
|
41
|
+
lambda { YACCL::Services.get_content_stream('testrepo', doc_id, nil, nil, nil) }.should raise_exception
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
|
3
|
+
describe YACCL::RepositoryServices do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@repo = create_repository('testrepo')
|
7
|
+
end
|
8
|
+
|
9
|
+
after :all do
|
10
|
+
delete_repository('testrepo')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'get repositories' do
|
14
|
+
repos = YACCL::Services.get_repositories
|
15
|
+
repos.keys.should include :testrepo
|
16
|
+
repo = repos[:testrepo]
|
17
|
+
repo[:repositoryId].should eq 'testrepo'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'get repository info' do
|
21
|
+
repos = YACCL::Services.get_repository_info('testrepo')
|
22
|
+
repos.keys.should eq [:testrepo]
|
23
|
+
repo = repos[:testrepo]
|
24
|
+
repo[:repositoryId].should eq 'testrepo'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'get meta repo type descendants' do
|
28
|
+
descendants = YACCL::Services.get_type_descendants('meta', nil, nil, nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'get type descendants' do
|
32
|
+
descendants = YACCL::Services.get_type_descendants('testrepo', nil, nil, nil)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-02-
|
13
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -69,6 +69,7 @@ extra_rdoc_files: []
|
|
69
69
|
files:
|
70
70
|
- .gitignore
|
71
71
|
- Gemfile
|
72
|
+
- LICENSE
|
72
73
|
- Rakefile
|
73
74
|
- examples/create_type_manual.rb
|
74
75
|
- lib/yaccl.rb
|
@@ -101,6 +102,9 @@ files:
|
|
101
102
|
- spec/model/object_spec.rb
|
102
103
|
- spec/model/repository_spec.rb
|
103
104
|
- spec/model/server_spec.rb
|
105
|
+
- spec/services/navigation_services_spec.rb
|
106
|
+
- spec/services/object_services_spec.rb
|
107
|
+
- spec/services/repository_services_spec.rb
|
104
108
|
- yaccl.gemspec
|
105
109
|
homepage: http://www.up-nxt.com
|
106
110
|
licenses: []
|
@@ -133,4 +137,7 @@ test_files:
|
|
133
137
|
- spec/model/object_spec.rb
|
134
138
|
- spec/model/repository_spec.rb
|
135
139
|
- spec/model/server_spec.rb
|
140
|
+
- spec/services/navigation_services_spec.rb
|
141
|
+
- spec/services/object_services_spec.rb
|
142
|
+
- spec/services/repository_services_spec.rb
|
136
143
|
has_rdoc:
|