yaccl 0.1.5 → 1.0.pre.alpha
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/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
@@ -0,0 +1,15 @@
|
|
1
|
+
module YACCL
|
2
|
+
class QueryResult
|
3
|
+
|
4
|
+
attr_reader :results
|
5
|
+
attr_reader :num_items
|
6
|
+
attr_reader :has_more_items
|
7
|
+
|
8
|
+
def initialize(results, num_items, has_more_items)
|
9
|
+
@results = results
|
10
|
+
@num_items = num_items
|
11
|
+
@has_more_items = has_more_items
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module YACCL
|
2
|
+
class Relationship < Object
|
3
|
+
|
4
|
+
def initialize(raw, repository)
|
5
|
+
super
|
6
|
+
cmis_properties %w( cmis:sourceId cmis:targetId )
|
7
|
+
end
|
8
|
+
|
9
|
+
def source
|
10
|
+
repository.object(source_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def target
|
14
|
+
repository.object(target_id)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module YACCL
|
2
|
+
class Repository
|
3
|
+
|
4
|
+
attr_reader :connection
|
5
|
+
|
6
|
+
def initialize(raw, connection)
|
7
|
+
raw.each do |key, value|
|
8
|
+
class_eval "def #{key.underscore};'#{value}';end"
|
9
|
+
class_eval "def #{key.gsub('repository', '').underscore};'#{value}';end"
|
10
|
+
end
|
11
|
+
|
12
|
+
@connection = connection
|
13
|
+
end
|
14
|
+
|
15
|
+
def new_document
|
16
|
+
Document.new({}, self)
|
17
|
+
end
|
18
|
+
|
19
|
+
def new_folder
|
20
|
+
Folder.new({}, self)
|
21
|
+
end
|
22
|
+
|
23
|
+
def new_relationship
|
24
|
+
Relationship.new({}, self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def new_item
|
28
|
+
Item.new({}, self)
|
29
|
+
end
|
30
|
+
|
31
|
+
def new_policy
|
32
|
+
Policy.new({}, self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def root
|
36
|
+
result = connection.execute!({ cmisselector: 'object',
|
37
|
+
repositoryId: id,
|
38
|
+
objectId: root_folder_id })
|
39
|
+
|
40
|
+
ObjectFactory.create(result, self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def object(cmis_object_id)
|
44
|
+
result = connection.execute!({ cmisselector: 'object',
|
45
|
+
repositoryId: id,
|
46
|
+
objectId: cmis_object_id })
|
47
|
+
|
48
|
+
ObjectFactory.create(result, self)
|
49
|
+
end
|
50
|
+
|
51
|
+
def types
|
52
|
+
result = connection.execute!({ cmisselector: 'typeDescendants',
|
53
|
+
repositoryId: id,
|
54
|
+
includePropertyDefinitions: true })
|
55
|
+
|
56
|
+
construct_types(result)
|
57
|
+
end
|
58
|
+
|
59
|
+
def type(type_id)
|
60
|
+
result = connection.execute!({ cmisselector: 'typeDefinition',
|
61
|
+
repositoryId: id,
|
62
|
+
typeId: type_id })
|
63
|
+
|
64
|
+
Type.new(result, self)
|
65
|
+
end
|
66
|
+
|
67
|
+
def create_type(type)
|
68
|
+
result = connection.execute!({ cmisaction: 'createType',
|
69
|
+
repositoryId: id,
|
70
|
+
type: MultiJson.dump(type.to_hash) })
|
71
|
+
|
72
|
+
Type.new(result, self)
|
73
|
+
end
|
74
|
+
|
75
|
+
def create_relationship(object)
|
76
|
+
raise 'Object is not a Relationship' unless object.is_a?(Relationship)
|
77
|
+
|
78
|
+
result = connection.execute!({ cmisaction: 'createRelationship',
|
79
|
+
repositoryId: id,
|
80
|
+
properties: object.properties })
|
81
|
+
|
82
|
+
ObjectFactory.create(result, self)
|
83
|
+
end
|
84
|
+
|
85
|
+
def content_changes(change_log_token)
|
86
|
+
connection.execute!({ cmisselector: 'contentChanges',
|
87
|
+
repositoryId: id,
|
88
|
+
changeLogToken: change_log_token })
|
89
|
+
end
|
90
|
+
|
91
|
+
def query(statement, options = {})
|
92
|
+
Query.new(self, statement, options)
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def construct_types(a)
|
99
|
+
types = []
|
100
|
+
a.each do |t|
|
101
|
+
types << Type.new(t['type'], self)
|
102
|
+
types << construct_types(t['children']) if t.has_key?('children')
|
103
|
+
end
|
104
|
+
types.flatten
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
data/lib/yaccl/server.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
2
|
+
|
3
|
+
module YACCL
|
4
|
+
class Server
|
5
|
+
|
6
|
+
attr_reader :connection
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
options.stringify_keys!
|
10
|
+
|
11
|
+
service_url = options['service_url'] || ENV['CMIS_BROWSER_URL']
|
12
|
+
username = options['username'] || ENV['CMIS_USER']
|
13
|
+
password = options['password'] || ENV['CMIS_PASSWORD']
|
14
|
+
headers = options['headers']
|
15
|
+
|
16
|
+
raise "'service_url' must be set" unless service_url
|
17
|
+
|
18
|
+
@connection = Connection.new(service_url, username, password, headers)
|
19
|
+
end
|
20
|
+
|
21
|
+
def repositories
|
22
|
+
result = connection.execute!
|
23
|
+
|
24
|
+
result.values.map do |r|
|
25
|
+
Repository.new(r, connection)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def repository(repository_id)
|
30
|
+
result = connection.execute!({ cmisselector: 'repositoryInfo',
|
31
|
+
repositoryId: repository_id })
|
32
|
+
|
33
|
+
Repository.new(result[repository_id], connection)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/yaccl/type.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
|
3
|
+
module YACCL
|
4
|
+
class Type
|
5
|
+
|
6
|
+
attr_accessor :connection
|
7
|
+
attr_accessor :repository
|
8
|
+
|
9
|
+
def initialize(hash = {}, repository = nil)
|
10
|
+
@repository = repository
|
11
|
+
@connection = repository.connection if repository
|
12
|
+
|
13
|
+
@hash = hash.with_indifferent_access
|
14
|
+
|
15
|
+
properties = %w( id localName localNamespace queryName displayName baseId
|
16
|
+
parentId description creatable fileable queryable
|
17
|
+
controllablePolicy controllableACL fulltextIndexed
|
18
|
+
includedInSupertypeQuery propertyDefinitions versionable
|
19
|
+
contentStreamAllowed allowedSourceTypes allowedTargetTypes )
|
20
|
+
|
21
|
+
properties.each do |key|
|
22
|
+
class_eval "def #{key.underscore};@hash['#{key}'];end"
|
23
|
+
class_eval "def #{key.underscore}=(value);@hash['#{key}']=value;end"
|
24
|
+
end
|
25
|
+
|
26
|
+
@hash['propertyDefinitions'] ||= ActiveSupport::HashWithIndifferentAccess.new
|
27
|
+
@hash['propertyDefinitions'].each do |key, value|
|
28
|
+
@hash['propertyDefinitions'][key] = PropertyDefinition.new(value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_property_definition(property)
|
33
|
+
property_definitions[property[:id]] = property
|
34
|
+
end
|
35
|
+
|
36
|
+
def create
|
37
|
+
repository.create_type(self)
|
38
|
+
end
|
39
|
+
|
40
|
+
def update(changed_property_defs)
|
41
|
+
new_defs = changed_property_defs.map(&:to_hash).inject({}) do |result, element|
|
42
|
+
result[element[:id]] = element
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
hash = to_hash
|
47
|
+
hash['propertyDefinitions'] = new_defs
|
48
|
+
|
49
|
+
result = connection.execute! ({ cmisaction: 'updateType',
|
50
|
+
repositoryId: repository.id,
|
51
|
+
type: MultiJson.dump(hash) })
|
52
|
+
|
53
|
+
Type.new(result, repository)
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete
|
57
|
+
connection.execute!({ cmisaction: 'deleteType',
|
58
|
+
repositoryId: repository.id,
|
59
|
+
typeId: id })
|
60
|
+
end
|
61
|
+
|
62
|
+
def document_type?
|
63
|
+
base_id == 'cmis:document'
|
64
|
+
end
|
65
|
+
|
66
|
+
def folder_type?
|
67
|
+
base_id == 'cmis:folder'
|
68
|
+
end
|
69
|
+
|
70
|
+
def relationship_type?
|
71
|
+
base_id == 'cmis:relationship'
|
72
|
+
end
|
73
|
+
|
74
|
+
def policy_type?
|
75
|
+
base_id == 'cmis:policy'
|
76
|
+
end
|
77
|
+
|
78
|
+
def item_type?
|
79
|
+
base_id == 'cmis:item'
|
80
|
+
end
|
81
|
+
|
82
|
+
def new_object
|
83
|
+
object = case base_id
|
84
|
+
when 'cmis:document'
|
85
|
+
Document.new({}, repository)
|
86
|
+
when 'cmis:folder'
|
87
|
+
Folder.new({}, repository)
|
88
|
+
when 'cmis:relationship'
|
89
|
+
Relationship.new({}, repository)
|
90
|
+
when 'cmis:policy'
|
91
|
+
Policy.new({}, repository)
|
92
|
+
when 'cmis:item'
|
93
|
+
Item.new({}, repository)
|
94
|
+
else
|
95
|
+
raise "Unsupported base type: #{base_id}"
|
96
|
+
end
|
97
|
+
object.object_type_id = id
|
98
|
+
object
|
99
|
+
end
|
100
|
+
|
101
|
+
def to_hash
|
102
|
+
@hash
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
data/lib/yaccl/version.rb
CHANGED
data/lib/yaccl.rb
CHANGED
@@ -1,11 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
require 'yaccl/
|
11
|
-
|
1
|
+
|
2
|
+
require 'yaccl/connection'
|
3
|
+
require 'yaccl/server'
|
4
|
+
|
5
|
+
require 'yaccl/helpers'
|
6
|
+
require 'yaccl/query_result'
|
7
|
+
require 'yaccl/query'
|
8
|
+
require 'yaccl/children'
|
9
|
+
|
10
|
+
require 'yaccl/repository'
|
11
|
+
|
12
|
+
require 'yaccl/object'
|
13
|
+
require 'yaccl/object_factory'
|
14
|
+
require 'yaccl/document'
|
15
|
+
require 'yaccl/folder'
|
16
|
+
require 'yaccl/item'
|
17
|
+
require 'yaccl/policy'
|
18
|
+
require 'yaccl/relationship'
|
19
|
+
|
20
|
+
require 'yaccl/type'
|
21
|
+
require 'yaccl/property_definition'
|
data/readme.md
CHANGED
@@ -11,10 +11,7 @@ Running the tests requires a running CMIS server.
|
|
11
11
|
## TODO
|
12
12
|
|
13
13
|
* caching
|
14
|
-
* complete model( (update) properties)
|
15
14
|
* (type) check service input
|
16
|
-
* config object (basic auth, succint property…)
|
17
|
-
* expand tests to services
|
18
15
|
|
19
16
|
## Contributing
|
20
17
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative './helper'
|
2
2
|
|
3
|
-
describe YACCL::
|
3
|
+
describe YACCL::Document do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@repo = create_repository('test')
|
@@ -15,7 +15,7 @@ describe YACCL::Model::Document do
|
|
15
15
|
new_object.name = 'doc1'
|
16
16
|
new_object.object_type_id = 'cmis:document'
|
17
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.
|
18
|
+
doc = new_object.create_in_folder(@repo.root)
|
19
19
|
doc.name.should eq 'doc1'
|
20
20
|
doc.content_stream_mime_type.should eq 'text/plain'
|
21
21
|
doc.content_stream_file_name.should eq 'doc1.txt'
|
@@ -27,7 +27,7 @@ describe YACCL::Model::Document do
|
|
27
27
|
new_object = @repo.new_document
|
28
28
|
new_object.name = 'doc2'
|
29
29
|
new_object.object_type_id = 'cmis:document'
|
30
|
-
doc = new_object.create_in_folder(@repo.
|
30
|
+
doc = new_object.create_in_folder(@repo.root)
|
31
31
|
doc.name.should eq 'doc2'
|
32
32
|
doc.content.should be nil
|
33
33
|
doc.delete
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative './helper'
|
2
2
|
|
3
|
-
describe YACCL::
|
3
|
+
describe YACCL::Folder do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@repo = create_repository('test')
|
@@ -29,7 +29,7 @@ describe YACCL::Model::Folder do
|
|
29
29
|
new_object.object_type_id = 'cmis:document'
|
30
30
|
new_object.set_content(StringIO.new('apple is a fruit'), 'text/plain', 'apple.txt')
|
31
31
|
object = @repo.root.create(new_object)
|
32
|
-
object.should be_a_kind_of YACCL::
|
32
|
+
object.should be_a_kind_of YACCL::Document
|
33
33
|
object.name.should eq 'doc1'
|
34
34
|
object.content_stream_mime_type.should eq 'text/plain'
|
35
35
|
object.content_stream_file_name.should eq 'apple.txt'
|
@@ -42,7 +42,7 @@ describe YACCL::Model::Folder do
|
|
42
42
|
new_object.name = 'folder1'
|
43
43
|
new_object.object_type_id = 'cmis:folder'
|
44
44
|
object = @repo.root.create(new_object)
|
45
|
-
object.should be_a_kind_of YACCL::
|
45
|
+
object.should be_a_kind_of YACCL::Folder
|
46
46
|
object.name.should eq 'folder1'
|
47
47
|
object.delete
|
48
48
|
end
|
@@ -60,14 +60,14 @@ describe YACCL::Model::Folder do
|
|
60
60
|
new_object.name = 'item1'
|
61
61
|
new_object.object_type_id = 'cmis:item'
|
62
62
|
object = @repo.root.create(new_object)
|
63
|
-
object.should be_a_kind_of YACCL::
|
63
|
+
object.should be_a_kind_of YACCL::Item
|
64
64
|
object.name.should eq 'item1'
|
65
65
|
object.delete
|
66
66
|
end unless @repo.cmis_version_supported < '1.1'
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'create object' do
|
70
|
-
new_object = YACCL::
|
70
|
+
new_object = YACCL::Object.new({}, @repo)
|
71
71
|
new_object.name = 'object1'
|
72
72
|
new_object.object_type_id = 'cmis:folder'
|
73
73
|
lambda { @repo.root.create(new_object) }.should raise_exception
|
data/spec/helper.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
require 'yaccl'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
-
YACCL.
|
4
|
+
META = YACCL::Server.new.repository('meta')
|
5
5
|
|
6
6
|
def create_repository(id)
|
7
|
-
|
7
|
+
delete_repository(id)
|
8
8
|
|
9
|
-
repo_type =
|
9
|
+
repo_type = META.type('repository')
|
10
10
|
property_definitions = repo_type.property_definitions.keys
|
11
11
|
|
12
|
-
f =
|
12
|
+
f = repo_type.new_object
|
13
13
|
f.name = id
|
14
14
|
f.properties[:id] = id
|
15
|
-
f.
|
16
|
-
f.properties[:
|
17
|
-
f.properties[:
|
18
|
-
f.properties[:
|
19
|
-
|
20
|
-
meta.root.create(f)
|
15
|
+
f.properties[:supportsRelationships] = true if property_definitions.include?('supportsRelationships')
|
16
|
+
f.properties[:supportsPolicies] = true if property_definitions.include?('supportsPolicies')
|
17
|
+
f.properties[:supportsItems] = true if property_definitions.include?('supportsItems')
|
18
|
+
f.properties[:realtime] = true if property_definitions.include?('realtime')
|
19
|
+
META.root.create(f)
|
21
20
|
|
22
|
-
YACCL::
|
21
|
+
YACCL::Server.new.repository(id)
|
23
22
|
end
|
24
23
|
|
25
24
|
def delete_repository(id)
|
26
|
-
|
25
|
+
META.object(id).delete
|
26
|
+
rescue YACCL::CMISRequestError => ex
|
27
27
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative './helper'
|
2
2
|
|
3
|
-
describe YACCL::
|
3
|
+
describe YACCL::Object do
|
4
4
|
|
5
5
|
before :all do
|
6
6
|
@repo = create_repository('test')
|
@@ -12,14 +12,14 @@ describe YACCL::Model::Object do
|
|
12
12
|
|
13
13
|
it 'repository' do
|
14
14
|
doc = create_document
|
15
|
-
doc.repository.should be_a_kind_of YACCL::
|
15
|
+
doc.repository.should be_a_kind_of YACCL::Repository
|
16
16
|
doc.repository.id.should eq 'test'
|
17
17
|
doc.delete
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'object_type' do
|
21
21
|
doc = create_document
|
22
|
-
doc.object_type.should be_a_kind_of YACCL::
|
22
|
+
doc.object_type.should be_a_kind_of YACCL::Type
|
23
23
|
doc.object_type.id.should eq 'cmis:document'
|
24
24
|
doc.delete
|
25
25
|
end
|
@@ -44,7 +44,7 @@ describe YACCL::Model::Object do
|
|
44
44
|
rels = doc.relationships
|
45
45
|
rels.should_not be_nil
|
46
46
|
rels.each do |r|
|
47
|
-
r.should be_a_kind_of YACCL::
|
47
|
+
r.should be_a_kind_of YACCL::Relationship
|
48
48
|
end
|
49
49
|
doc.delete
|
50
50
|
end
|
@@ -54,7 +54,7 @@ describe YACCL::Model::Object do
|
|
54
54
|
pols = doc.policies
|
55
55
|
pols.should_not be_nil
|
56
56
|
pols.each do |p|
|
57
|
-
p.should be_a_kind_of YACCL::
|
57
|
+
p.should be_a_kind_of YACCL::Policy
|
58
58
|
end
|
59
59
|
doc.delete
|
60
60
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative './helper'
|
2
|
+
|
3
|
+
describe YACCL::Relationship do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@dummy = YACCL::Server.new.repository('meta')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should make properties accessible through method' do
|
10
|
+
new_object = YACCL::Relationship.new({ succinctProperties: { myProp: 'myValue' } }, @dummy)
|
11
|
+
new_object.properties['myProp'].should eq 'myValue'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should raise methodmissing for unknown property' do
|
15
|
+
new_object = YACCL::Relationship.new({ succinctProperties: { 'myProp' => 'myValue' } }, @dummy)
|
16
|
+
expect { new_object.myOtherProp }.to raise_error(NoMethodError, /undefined method `myOtherProp'/)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require_relative './helper'
|
2
|
+
|
3
|
+
describe YACCL::Repository do
|
4
|
+
|
5
|
+
context 'generic' do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@id = 'meta'
|
9
|
+
@repo = YACCL::Server.new.repository(@id)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'id' do
|
13
|
+
@repo.id.should.eql? @id
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'fields' do
|
17
|
+
@repo.id.should_not be_nil
|
18
|
+
@repo.name.should_not be_nil
|
19
|
+
@repo.product_version.should_not be_nil
|
20
|
+
@repo.description.should_not be_nil
|
21
|
+
@repo.root_folder_id.should_not be_nil
|
22
|
+
@repo.capabilities.should_not be_nil
|
23
|
+
@repo.url.should_not be_nil
|
24
|
+
@repo.changes_on_type.should_not be_nil
|
25
|
+
@repo.root_folder_url.should_not be_nil
|
26
|
+
@repo.product_name.should_not be_nil
|
27
|
+
@repo.product_version.should_not be_nil
|
28
|
+
|
29
|
+
%w(1.0 1.1).should include @repo.cmis_version_supported
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'new object' do
|
33
|
+
@repo.new_folder.should be_a_kind_of YACCL::Folder
|
34
|
+
@repo.new_document.should be_a_kind_of YACCL::Document
|
35
|
+
@repo.new_relationship.should be_a_kind_of YACCL::Relationship
|
36
|
+
@repo.new_policy.should be_a_kind_of YACCL::Policy
|
37
|
+
@repo.new_item.should be_a_kind_of YACCL::Item
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'repositories' do
|
41
|
+
YACCL::Server.new.repositories
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'repository' do
|
45
|
+
r = YACCL::Server.new.repository('generali')
|
46
|
+
r.name.should eq 'generali'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'root' do
|
50
|
+
root = @repo.root
|
51
|
+
root.should be_a_kind_of YACCL::Folder
|
52
|
+
root.cmis_object_id.should eq @repo.root_folder_id
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'object' do
|
56
|
+
id = @repo.root_folder_id
|
57
|
+
object = @repo.object(id)
|
58
|
+
object.should be_a_kind_of YACCL::Folder
|
59
|
+
object.cmis_object_id.should eq id
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'type - document' do
|
63
|
+
document = @repo.type('cmis:document')
|
64
|
+
document.should be_a_kind_of YACCL::Type
|
65
|
+
document.id.should eq 'cmis:document'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'type - folder' do
|
69
|
+
folder = @repo.type('cmis:folder')
|
70
|
+
folder.should be_a_kind_of YACCL::Type
|
71
|
+
folder.id.should eq 'cmis:folder'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'upn' do
|
76
|
+
|
77
|
+
before :all do
|
78
|
+
@repo = create_repository('testrepository')
|
79
|
+
end
|
80
|
+
|
81
|
+
after :all do
|
82
|
+
delete_repository('testrepository')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'type - relationship' do
|
86
|
+
relationship = @repo.type('cmis:relationship')
|
87
|
+
relationship.should be_a_kind_of YACCL::Type
|
88
|
+
relationship.id.should eq 'cmis:relationship'
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'type - policy' do
|
92
|
+
policy = @repo.type('cmis:policy')
|
93
|
+
policy.should be_a_kind_of YACCL::Type
|
94
|
+
policy.id.should eq 'cmis:policy'
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'type - item' do
|
98
|
+
begin
|
99
|
+
item = @repo.type('cmis:item')
|
100
|
+
item.should be_a_kind_of YACCL::Type
|
101
|
+
item.id.should eq 'cmis:item'
|
102
|
+
end unless @repo.cmis_version_supported < '1.1'
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'create, get, delete type - document' do
|
106
|
+
type_id = 'apple'
|
107
|
+
|
108
|
+
type = YACCL::Type.new
|
109
|
+
type.id = type_id
|
110
|
+
type.local_name = 'apple'
|
111
|
+
type.query_name = 'apple'
|
112
|
+
type.display_name = 'apple'
|
113
|
+
type.parent_id = 'cmis:document'
|
114
|
+
type.base_id = 'cmis:document'
|
115
|
+
type.description = 'appel'
|
116
|
+
type.creatable = true
|
117
|
+
type.fileable = true
|
118
|
+
type.queryable = true
|
119
|
+
type.controllable_policy = true
|
120
|
+
type.controllable_acl = true
|
121
|
+
type.fulltext_indexed = true
|
122
|
+
type.included_in_supertype_query = true
|
123
|
+
type.content_stream_allowed = 'allowed'
|
124
|
+
type.versionable = false
|
125
|
+
|
126
|
+
type.add_property_definition(id: 'color',
|
127
|
+
localName: 'color',
|
128
|
+
queryName: 'color',
|
129
|
+
displayName: 'color',
|
130
|
+
description: 'color',
|
131
|
+
propertyType: 'string',
|
132
|
+
cardinality: 'single',
|
133
|
+
updatability: 'readwrite',
|
134
|
+
inherited: false,
|
135
|
+
required: false,
|
136
|
+
queryable: true,
|
137
|
+
orderable: true)
|
138
|
+
|
139
|
+
@repo.create_type(type)
|
140
|
+
|
141
|
+
@repo.type(type_id).tap do |t|
|
142
|
+
t.should be_a_kind_of YACCL::Type
|
143
|
+
t.id.should eq type_id
|
144
|
+
end
|
145
|
+
|
146
|
+
@repo.type(type_id).delete
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative './helper'
|
2
|
+
|
3
|
+
describe YACCL::Server do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@server = YACCL::Server.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'repositories' do
|
10
|
+
@server.repositories.each do |repo|
|
11
|
+
repo.should be_a_kind_of YACCL::Repository
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'repository' do
|
16
|
+
id = 'meta'
|
17
|
+
repo = @server.repository(id)
|
18
|
+
repo.should be_a_kind_of YACCL::Repository
|
19
|
+
repo.id.should eq id
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|