yaccl 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ module YACCL
2
+ module PolicyServices
3
+ def apply_policy(repository_id, policy_id, object_id, extension={})
4
+ required = {cmisaction: 'applyPolicy',
5
+ repositoryId: repository_id,
6
+ policyId: policy_id,
7
+ objectId: object_id}
8
+ perform_request(required)
9
+ end
10
+
11
+ def remove_policy(repository_id, policy_id, object_id, extension={})
12
+ required = {cmisaction: 'removePolicy',
13
+ repositoryId: repository_id,
14
+ policyId: policy_id,
15
+ objectId: object_id}
16
+ perform_request(required)
17
+ end
18
+
19
+ def get_applied_policies(repository_id, object_id, filter, extension={})
20
+ required = {cmisselector: 'policies',
21
+ repositoryId: repository_id,
22
+ objectId: object_id}
23
+ optional = {filter: filter}
24
+ perform_request(required, optional)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ module YACCL
2
+ module RelationshipServices
3
+ def get_object_relationships(repository_id, object_id, include_sub_relationship_types, relationship_direction, type_id, filter, include_allowable_actions, max_items, skip_count, extension={})
4
+ required = {cmisselector: 'relationships',
5
+ repositoryId: repository_id,
6
+ objectId: object_id}
7
+ optional = {includeSubRelationshipTypes: include_sub_relationship_types,
8
+ relationshipDirection: relationship_direction,
9
+ typeId: type_id,
10
+ filter: filter,
11
+ includeAllowableActions: include_allowable_actions,
12
+ maxItems: max_items,
13
+ skipCount: skip_count}
14
+ perform_request(required, optional)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,60 @@
1
+ module YACCL
2
+ module RepositoryServices
3
+ def get_repositories(extension={})
4
+ perform_request
5
+ end
6
+
7
+ def get_repository_info(repository_id, extension={})
8
+ required = {cmisselector: 'repositoryInfo',
9
+ repositoryId: repository_id}
10
+ perform_request(required)
11
+ end
12
+
13
+ def get_type_children(repository_id, type_id, include_property_definitions, max_items, skip_count, extension={})
14
+ required = {cmisselector: 'typeChildren',
15
+ repositoryId: repository_id}
16
+ optional = {typeId: type_id,
17
+ includePropertyDefinitions: include_property_definitions,
18
+ maxItems: max_items,
19
+ skipCount: skip_count}
20
+ perform_request(required, optional)
21
+ end
22
+
23
+ def get_type_descendants(repository_id, type_id, depth, include_property_definitions, extension={})
24
+ required = {cmisselector: 'typeDescendants',
25
+ repositoryId: repository_id}
26
+ optional = {typeId: type_id,
27
+ depth: depth,
28
+ includePropertyDefinitions: include_property_definitions}
29
+ perform_request(required, optional)
30
+ end
31
+
32
+ def get_type_definition(repository_id, type_id, extension={})
33
+ required = {cmisselector: 'typeDefinition',
34
+ repositoryId: repository_id,
35
+ typeId: type_id}
36
+ perform_request(required)
37
+ end
38
+
39
+ def create_type(repository_id, type, extension={})
40
+ required = {cmisaction: 'createType',
41
+ repositoryId: repository_id,
42
+ type: MultiJson.dump(type)}
43
+ perform_request(required)
44
+ end
45
+
46
+ def update_type(type, extension={})
47
+ required = {cmisaction: 'updateType',
48
+ repositoryId: repository_id,
49
+ type: MultiJson.dump(type)}
50
+ perform_request(required)
51
+ end
52
+
53
+ def delete_type(repository_id, type_id, extension={})
54
+ required = {cmisaction: 'deleteType',
55
+ repositoryId: repository_id,
56
+ typeId: type_id}
57
+ perform_request(required)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,21 @@
1
+ module YACCL
2
+ module VersioningServices
3
+ def check_out(repository_id, object_id, content_copied, extension={})
4
+ end
5
+
6
+ def cancel_check_out(repository_id, object_id, extension={})
7
+ end
8
+
9
+ def check_in(repository_id, object_id, major, properties, content_stream, checkin_comment, policies, add_aces, remove_aces, extension={})
10
+ end
11
+
12
+ def get_object_of_latest_version(repository_id, object_id, version_series_id, major, filter, include_allowable_actions, include_relationships, rendition_filter, include_policy_ids, include_acl, extension={})
13
+ end
14
+
15
+ def get_properties_of_latest_version(repository_id, object_id, version_series_id, major, filter, extension={})
16
+ end
17
+
18
+ def get_all_versions(repository_id, object_id, version_series_id, filter, include_allowable_actions, extension={})
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # YACCL
2
+
3
+ **YACCL** (pronounced _jackal_) stands for **Yet Another CMIS Client Library** and is a [CMIS](http://chemistry.apache.org/project/cmis.html) client library on top of the CMIS browser binding ([CMIS 1.1](http://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html)), written in Ruby.
4
+
5
+ ## Running Test
6
+
7
+ Running the tests requires a running CMIS server.
8
+
9
+ rake
10
+
11
+ ## TODO
12
+
13
+ * caching
14
+ * complete model( (update) properties)
15
+ * (type) check service input
16
+ * config object (basic auth, succint property…)
17
+ * expand tests to services
18
+
19
+ ## Contributing
20
+
21
+ Write some code. Run the tests. Open a pull request.
@@ -0,0 +1,19 @@
1
+ require 'yaccl'
2
+
3
+ YACCL.init('http://localhost:8080/upncmis/browser')
4
+
5
+ def create_repository(id)
6
+ meta = YACCL::Model::Server.repository('meta')
7
+ f = meta.new_folder
8
+ f.name = id
9
+ f.object_type_id = 'repository'
10
+ f.properties['supportsRelationships'] = true
11
+ f.properties['supportsPolicies'] = true
12
+ f.properties['supportsItem'] = true
13
+ meta.root.create(f)
14
+ YACCL::Model::Server.repository(id)
15
+ end
16
+
17
+ def delete_repository(id)
18
+ YACCL::Model::Server.repository('meta').object(id).delete
19
+ end
@@ -0,0 +1,44 @@
1
+ require_relative '../helper'
2
+
3
+ describe YACCL::Model::Document do
4
+
5
+ before :all do
6
+ @repo = create_repository('test_document')
7
+ end
8
+
9
+ after :all do
10
+ delete_repository('test_document')
11
+ end
12
+
13
+ it 'create_in_folder with content' do
14
+ new_object = @repo.new_document
15
+ new_object.name = 'doc1'
16
+ new_object.object_type_id = 'cmis:document'
17
+ new_object.set_content(StringIO.new('content1'), 'text/plain', 'doc1.txt') # set content on detached doc
18
+ doc = new_object.create_in_folder(@repo.root_folder_id)
19
+ doc.name.should eq 'doc1'
20
+ doc.content_stream_mime_type.should eq 'text/plain'
21
+ doc.content_stream_file_name.should eq 'doc1.txt'
22
+ doc.content.should eq 'content1'
23
+ doc.delete
24
+ end
25
+
26
+ it 'create_in_folder without content' do
27
+ new_object = @repo.new_document
28
+ new_object.name = 'doc2'
29
+ new_object.object_type_id = 'cmis:document'
30
+ doc = new_object.create_in_folder(@repo.root_folder_id)
31
+ doc.name.should eq 'doc2'
32
+ doc.delete
33
+ end
34
+
35
+ #it 'set content - attached' do
36
+ # new_object = @repo.new_document
37
+ # new_object.name = 'doc3'
38
+ # new_object.object_type_id = 'cmis:document'
39
+ # doc = @repo.root.create(new_object)
40
+ # doc.set_content(StringIO.new('content3'), 'text/plain', 'doc3.txt') # set content on attached doc
41
+ # doc.content.should eq 'content3'
42
+ # doc.delete
43
+ #end
44
+ end
@@ -0,0 +1,73 @@
1
+ require_relative '../helper'
2
+
3
+ describe YACCL::Model::Folder do
4
+
5
+ before :all do
6
+ @repo = create_repository('test_folder')
7
+ end
8
+
9
+ after :all do
10
+ delete_repository('test_folder')
11
+ end
12
+
13
+ it 'parent - root' do
14
+ @repo.root.parent.should be_nil
15
+ end
16
+
17
+ it 'parent - root child' do
18
+ new_object = @repo.new_folder
19
+ new_object.name = 'folder1'
20
+ new_object.object_type_id = 'cmis:folder'
21
+ folder = @repo.root.create(new_object)
22
+ folder.parent.object_id.should eq @repo.root_folder_id
23
+ folder.delete
24
+ end
25
+
26
+ it 'create document' do
27
+ new_object = @repo.new_document
28
+ new_object.name = 'doc1'
29
+ new_object.object_type_id = 'cmis:document'
30
+ new_object.set_content(StringIO.new('apple is a fruit'), 'text/plain', 'apple.txt')
31
+ object = @repo.root.create(new_object)
32
+ object.should be_a_kind_of YACCL::Model::Document
33
+ object.name.should eq 'doc1'
34
+ object.content_stream_mime_type.should eq 'text/plain'
35
+ object.content_stream_file_name.should eq 'apple.txt'
36
+ object.content.should eq 'apple is a fruit'
37
+ object.delete
38
+ end
39
+
40
+ it 'create folder' do
41
+ new_object = @repo.new_folder
42
+ new_object.name = 'folder1'
43
+ new_object.object_type_id = 'cmis:folder'
44
+ object = @repo.root.create(new_object)
45
+ object.should be_a_kind_of YACCL::Model::Folder
46
+ object.name.should eq 'folder1'
47
+ object.delete
48
+ end
49
+
50
+ it 'create relationship' do
51
+ new_object = @repo.new_relationship
52
+ new_object.name = 'rel1'
53
+ new_object.object_type_id = 'cmis:relationship'
54
+ lambda { @repo.root.create(new_object) }.should raise_exception
55
+ end
56
+
57
+ it 'create item' do
58
+ new_object = @repo.new_item
59
+ new_object.name = 'item1'
60
+ new_object.object_type_id = 'cmis:item'
61
+ object = @repo.root.create(new_object)
62
+ object.should be_a_kind_of YACCL::Model::Item
63
+ object.name.should eq 'item1'
64
+ object.delete
65
+ end
66
+
67
+ it 'create object' do
68
+ new_object = YACCL::Model::Object.new @repo.id
69
+ new_object.name = 'object1'
70
+ new_object.object_type_id = 'cmis:folder'
71
+ lambda { @repo.root.create(new_object) }.should raise_exception
72
+ end
73
+ end
@@ -0,0 +1,103 @@
1
+ require_relative '../helper'
2
+
3
+ describe YACCL::Model::Object do
4
+
5
+ before :all do
6
+ @repo = create_repository('test_object')
7
+ end
8
+
9
+ after :all do
10
+ delete_repository('test_object')
11
+ end
12
+
13
+ it 'repository' do
14
+ doc = create_document
15
+ doc.repository.should be_a_kind_of YACCL::Model::Repository
16
+ doc.repository.id.should eq 'test_object'
17
+ doc.delete
18
+ end
19
+
20
+ it 'object_type' do
21
+ doc = create_document
22
+ doc.object_type.should be_a_kind_of YACCL::Model::Type
23
+ doc.object_type.id.should eq 'cmis:document'
24
+ doc.delete
25
+ end
26
+
27
+ it 'delete' do
28
+ doc = create_document
29
+ doc.delete
30
+ #TODO check
31
+ end
32
+
33
+ it 'allowable actions' do
34
+ doc = create_document
35
+ actions = doc.allowable_actions
36
+ actions.should_not be_nil
37
+ actions.should_not be_empty
38
+ actions.values.each { |v| [true, false].should include v }
39
+ doc.delete
40
+ end
41
+
42
+ it 'relationships' do
43
+ doc = create_document
44
+ rels = doc.relationships
45
+ rels.should_not be_nil
46
+ rels.should have_key :objects
47
+ rels.should have_key :hasMoreItems
48
+ rels.should have_key :numItems
49
+ rels[:objects].each do |r|
50
+ r.should be_a_kind_of YACCL::Model::Relationship
51
+ end
52
+ doc.delete
53
+ end
54
+
55
+ it 'policies' do
56
+ doc = create_document
57
+ pols = doc.policies
58
+ pols.should_not be_nil
59
+ pols.each do |p|
60
+ p.should be_a_kind_of YACCL::Model::Policy
61
+ end
62
+ doc.delete
63
+ end
64
+
65
+ it 'unfile' do
66
+ doc = create_document
67
+ doc.unfile
68
+ #TODO check
69
+ doc.delete
70
+ end
71
+
72
+ it 'acls' do
73
+ doc = create_document
74
+ acls = doc.acls
75
+ acls.should_not be_nil
76
+ acls.should_not be_empty
77
+ acls.should have_key :aces
78
+ acls.should have_key :isExact
79
+ [true, false].should include acls[:isExact]
80
+ doc.delete
81
+ end
82
+
83
+ it 'add aces' do
84
+ doc = create_document
85
+ doc.add_aces({})
86
+ #TODO check
87
+ doc.delete
88
+ end
89
+
90
+ it 'remove aces' do
91
+ doc = create_document
92
+ doc.remove_aces({})
93
+ #TODO check
94
+ doc.delete
95
+ end
96
+
97
+ def create_document
98
+ new_object = @repo.new_document
99
+ new_object.name = 'doc'
100
+ new_object.object_type_id = 'cmis:document'
101
+ @repo.root.create(new_object)
102
+ end
103
+ end
@@ -0,0 +1,134 @@
1
+ require_relative '../helper'
2
+
3
+ describe YACCL::Model::Repository do
4
+
5
+ context 'generic' do
6
+ before do
7
+ @id = 'meta'
8
+ @repo = YACCL::Model::Server.repository(@id)
9
+ end
10
+
11
+ it 'id' do
12
+ @repo.id.should.eql? @id
13
+ end
14
+
15
+ it 'fields' do
16
+ @repo.id.should_not be_nil
17
+ @repo.name.should_not be_nil
18
+ @repo.product_version.should_not be_nil
19
+ @repo.description.should_not be_nil
20
+ @repo.root_folder_id.should_not be_nil
21
+ @repo.capabilities.should_not be_nil
22
+ @repo.url.should_not be_nil
23
+ @repo.changes_on_type.should_not be_nil
24
+ @repo.root_folder_url.should_not be_nil
25
+ @repo.product_name.should_not be_nil
26
+ @repo.product_version.should_not be_nil
27
+
28
+ %w(1.0 1.1).should include @repo.cmis_version_supported
29
+ end
30
+
31
+ it 'new object' do
32
+ @repo.new_folder.should be_a_kind_of YACCL::Model::Folder
33
+ @repo.new_document.should be_a_kind_of YACCL::Model::Document
34
+ @repo.new_relationship.should be_a_kind_of YACCL::Model::Relationship
35
+ @repo.new_policy.should be_a_kind_of YACCL::Model::Policy
36
+ @repo.new_item.should be_a_kind_of YACCL::Model::Item
37
+ end
38
+
39
+ it 'root' do
40
+ root = @repo.root
41
+ root.should be_a_kind_of YACCL::Model::Folder
42
+ root.object_id.should eq @repo.root_folder_id
43
+ end
44
+
45
+ it 'object' do
46
+ id = @repo.root_folder_id
47
+ object = @repo.object(id)
48
+ object.should be_a_kind_of YACCL::Model::Folder
49
+ object.object_id.should eq id
50
+ end
51
+
52
+ it 'type - document' do
53
+ document = @repo.type('cmis:document')
54
+ document.should be_a_kind_of YACCL::Model::Type
55
+ document.id.should eq 'cmis:document'
56
+ end
57
+
58
+ it 'type - folder' do
59
+ folder = @repo.type('cmis:folder')
60
+ folder.should be_a_kind_of YACCL::Model::Type
61
+ folder.id.should eq 'cmis:folder'
62
+ end
63
+ end
64
+
65
+ context 'upn' do
66
+ before :all do
67
+ @repo = create_repository('test_repository')
68
+ end
69
+
70
+ after :all do
71
+ delete_repository('test_repository')
72
+ end
73
+
74
+ it 'type - relationship' do
75
+ relationship = @repo.type('cmis:relationship')
76
+ relationship.should be_a_kind_of YACCL::Model::Type
77
+ relationship.id.should eq 'cmis:relationship'
78
+ end
79
+
80
+ it 'type - policy' do
81
+ policy = @repo.type('cmis:policy')
82
+ policy.should be_a_kind_of YACCL::Model::Type
83
+ policy.id.should eq 'cmis:policy'
84
+ end
85
+
86
+ it 'type - item' do
87
+ item = @repo.type('cmis:item')
88
+ item.should be_a_kind_of YACCL::Model::Type
89
+ item.id.should eq 'cmis:item'
90
+ end
91
+
92
+ it 'create, get, delete type - document' do
93
+ type_id = 'apple'
94
+
95
+ type = YACCL::Model::Type.new
96
+ type.id = type_id
97
+ type.local_name = 'apple'
98
+ type.query_name = 'apple'
99
+ type.display_name = 'apple'
100
+ type.parent_id = 'cmis:document'
101
+ type.base_id = 'cmis:document'
102
+ type.description = 'appel'
103
+ type.creatable = true
104
+ type.fileable = true
105
+ type.queryable = true
106
+ type.controllable_policy = true
107
+ type.controllable_acl = true
108
+ type.fulltext_indexed = true
109
+ type.included_in_supertype_query = true
110
+ type.content_stream_allowed = 'allowed'
111
+ type.versionable = false
112
+
113
+ type.add_property_definition(id: 'color',
114
+ localName: 'color',
115
+ queryName: 'color',
116
+ displayName: 'color',
117
+ description: 'color',
118
+ propertyType: 'string',
119
+ cardinality: 'single',
120
+ updatability: 'readwrite',
121
+ inherited: false,
122
+ required: false,
123
+ queryable: true,
124
+ orderable: true)
125
+
126
+ @repo.create_type(type)
127
+ @repo.type(type_id).tap do |t|
128
+ t.should be_a_kind_of YACCL::Model::Type
129
+ t.id.should eq type_id
130
+ end
131
+ @repo.delete_type(type_id)
132
+ end
133
+ end
134
+ end