active_cmis2 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c812acdd307582351bcc4125c5daf00fd9f432f3ac95f94698e496299bd0ce7f
4
+ data.tar.gz: e6366fb72cbb02ec9dfb6ce10f5fd25867f75d5a692e0abeaaff318220c04ea9
5
+ SHA512:
6
+ metadata.gz: f4e94cb9319621ec547e5fcea245f1cdb1afca2afd139e10072996e746e399dc24922001ea68592f1695687707358062036310fa8a196e08fca79ad965e3f8d8
7
+ data.tar.gz: fb6e90a4175d2b44c39d4eb30a588560501bfd978843473eea2ae37d15e6b222dbcd8925bf019f25a4ff51542bb62def74f921038ef25b6620450ce4714c272c
data/AUTHORS ADDED
@@ -0,0 +1,10 @@
1
+ Joeri Samson
2
+ Michel Benevento
3
+ Tim Felgentreff
4
+ Stijn Van Vreckem
5
+ linzhixing
6
+ Jean-Denis Vauguet
7
+ Kenneth Geerts
8
+ Ryan Murphy
9
+ Guillaume Hain
10
+ Linagora
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2010 XAOP bvba
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+
6
+ files (the "Software"), to deal in the Software without
7
+ restriction, including without limitation the rights to use,
8
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the
10
+
11
+ Software is furnished to do so, subject to the following
12
+ conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+
24
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # ActiveCMIS Release 0.3.4 #
2
+ **Git**: <http://github.com/xaop/activecmis>
3
+ **Documentation**: <http://rdoc.info/github/xaop/activecmis/master/frames>
4
+ **Author**: XAOP bvba
5
+ **Copyright**: 2011
6
+ **License**: MIT License
7
+ ## Synopsis ##
8
+ ActiveCMIS is Ruby library aimed at easing the interaction with various CMIS providers. It creates Ruby objects for CMIS objects, and creates Ruby classes that correspond to CMIS types.
9
+ ## Features ##
10
+ - Read support for all CMIS object types
11
+ - Write support and the ability to create new objects.
12
+ - Support for paging
13
+
14
+ ## Changes since 0.3.5 ##
15
+ - implement the possibility to set the timeout to be used by the Net::HTTP object (thanks to zedtux)
16
+
17
+ ## Changes since 0.3.4 ##
18
+ - Fix a bug with checkin
19
+
20
+ ## Changes since 0.3.3 ##
21
+ - added #set_versioning_state for documents (thanks to @zedtux)
22
+ - improve checking method to make more parameters optional (and use set_versioning_state when possible)
23
+
24
+ ## Changes since 0.3.2 ##
25
+ - Fix for header of PUT request (thanks to @linzhixing)
26
+ - Improvement for integer conversion (thanks to @kennethgeerts)
27
+ - Correctly set the default namespace (reported by @brunospy)
28
+
29
+ ## Changes since 0.3.1 ##
30
+ - Does not require ntlm-http unless needed for authentication
31
+ - Fix some issues with authentication (thanks to @beno)
32
+ - Follow redirects for renditions (thanks to @timfel)
33
+
34
+
35
+ ## Changes since 0.2.6 ##
36
+ The way authentication works has changed. If you previously used ActiveCMIS.connect then you're fine, otherwise the authentication changes will affect you: the authenticate methods on ActiveCMIS::Server and ActiveCMIS::Repository now return a new object, and don't change the authentication on the object itself. You can also specify optional authentication when connecting to a Server, or when calling the repository method.
37
+
38
+ ## Installation ##
39
+ If you haven't installed Nokogiri yet it will be installed automatically, you will need a C compiler and the development files for libxml2.
40
+
41
+ > gem install active_cmis
42
+
43
+ ActiveCMIS also depends on ntlm-http for ntlm authentication, unfortunately ntlm-http is broken on ruby 1.9.x
44
+ This isn't a problem as long as you don't actually try to connect with NTLM authentication.
45
+ If you actually need NTLM authentication you can use https://github.com/xaop/ntlm-http (or any other fixed version of the library), although you may need to use bundler for this to work.
46
+
47
+ ## Usage ##
48
+ require 'active_cmis'
49
+ repository = ActiveCMIS.load_config('configuration', 'optional_filename_for_config')
50
+ f = repository.root_folder
51
+ p f.items.map do |i| i.cmis.name end
52
+
53
+ And so on ...
54
+
55
+ Full documentation of the API can be found at [rdoc.info](http://rdoc.info/projects/xaop/activecmis)
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+
3
+ begin
4
+ require 'yard'
5
+
6
+ YARD::Rake::YardocTask.new do |t|
7
+ t.files = ['lib/**/*.rb', '-', 'TODO'] # optional
8
+ t.options = ["--default-return", "::Object", "--query", "!@private", "--hide-void-return"]
9
+ end
10
+ rescue LoadError
11
+ puts "Yard, or a dependency, not available. Install it with gem install yard"
12
+ end
13
+
14
+ begin
15
+ require 'jeweler'
16
+ Jeweler::Tasks.new do |gemspec|
17
+ gemspec.name = "active_cmis"
18
+ gemspec.summary = "A library to interact with CMIS repositories through the AtomPub/REST binding"
19
+ gemspec.description = "A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS."
20
+ gemspec.email = "joeri@xaop.com"
21
+ gemspec.homepage = "http://xaop.com/labs/activecmis/"
22
+ gemspec.authors = ["Joeri Samson"]
23
+
24
+ gemspec.add_runtime_dependency 'nokogiri', '>= 1.4.1'
25
+ gemspec.add_runtime_dependency 'ntlm-http', '~> 0.1', '>= 0.1.1'
26
+ gemspec.add_runtime_dependency 'require_relative', '~> 1.0', '>= 1.0.2'
27
+
28
+ gemspec.required_ruby_version = '>= 1.8.6'
29
+ gemspec.files.exclude '.gitignore'
30
+ end
31
+ Jeweler::GemcutterTasks.new
32
+ rescue LoadError
33
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
34
+ end
data/TODO ADDED
@@ -0,0 +1,7 @@
1
+ - For {ActiveCMIS::Rendition#get_file Rendition#get_file}:
2
+ * filename should be optional, a temporary file should be created (e.g. in /tmp) if no filename is given
3
+ - For {ActiveCMIS::Type::ClassMethods#attributes Type::ClassMethods#attributes}: inherited parameter is misleading (+ default is wrong, some other code depends on it being true by default if it would work)
4
+ - improve use of correct Exceptions:
5
+ * don't throw RuntimeError anymore (except perhaps where the library code is the only code that could cause the exception)
6
+ * try to use correct exceptions when receiving errors from server (may need some wrapper with repository specific code)
7
+ - improve support for queries (i.e. allow interface such as the with_ATTR_NAME way of ActiveDCTM, allow select to return only a few attributes, ...)
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 3
4
+ :patch: 6
5
+ :build:
@@ -0,0 +1,79 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: active_cmis 0.3.6 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "active_cmis2"
9
+ s.version = "0.3.8"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Joeri Samson","Linagora"]
14
+ s.date = "2021-01-21"
15
+ s.description = "A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS."
16
+ s.email = "joeri@xaop.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.md",
20
+ "TODO"
21
+ ]
22
+ s.files = [
23
+ "AUTHORS",
24
+ "LICENSE",
25
+ "README.md",
26
+ "Rakefile",
27
+ "TODO",
28
+ "VERSION.yml",
29
+ "active_cmis.gemspec",
30
+ "lib/active_cmis.rb",
31
+ "lib/active_cmis/acl.rb",
32
+ "lib/active_cmis/acl_entry.rb",
33
+ "lib/active_cmis/active_cmis.rb",
34
+ "lib/active_cmis/atomic_types.rb",
35
+ "lib/active_cmis/attribute_prefix.rb",
36
+ "lib/active_cmis/collection.rb",
37
+ "lib/active_cmis/document.rb",
38
+ "lib/active_cmis/exceptions.rb",
39
+ "lib/active_cmis/folder.rb",
40
+ "lib/active_cmis/internal/caching.rb",
41
+ "lib/active_cmis/internal/connection.rb",
42
+ "lib/active_cmis/internal/utils.rb",
43
+ "lib/active_cmis/ns.rb",
44
+ "lib/active_cmis/object.rb",
45
+ "lib/active_cmis/policy.rb",
46
+ "lib/active_cmis/property_definition.rb",
47
+ "lib/active_cmis/query_result.rb",
48
+ "lib/active_cmis/rel.rb",
49
+ "lib/active_cmis/relationship.rb",
50
+ "lib/active_cmis/rendition.rb",
51
+ "lib/active_cmis/repository.rb",
52
+ "lib/active_cmis/server.rb",
53
+ "lib/active_cmis/type.rb",
54
+ "lib/active_cmis/version.rb"
55
+ ]
56
+ s.homepage = "https://github.com/linagora/activecmis"
57
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
58
+ s.rubygems_version = "2.4.5"
59
+ s.summary = "A library to interact with CMIS repositories through the AtomPub/REST binding"
60
+
61
+ if s.respond_to? :specification_version then
62
+ s.specification_version = 4
63
+
64
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
65
+ s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.1"])
66
+ s.add_runtime_dependency(%q<ntlm-http>, [">= 0.1.1", "~> 0.1"])
67
+ s.add_runtime_dependency(%q<require_relative>, [">= 1.0.2", "~> 1.0"])
68
+ else
69
+ s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
70
+ s.add_dependency(%q<ntlm-http>, [">= 0.1.1", "~> 0.1"])
71
+ s.add_dependency(%q<require_relative>, [">= 1.0.2", "~> 1.0"])
72
+ end
73
+ else
74
+ s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
75
+ s.add_dependency(%q<ntlm-http>, [">= 0.1.1", "~> 0.1"])
76
+ s.add_dependency(%q<require_relative>, [">= 1.0.2", "~> 1.0"])
77
+ end
78
+ end
79
+
@@ -0,0 +1,30 @@
1
+ require 'nokogiri'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require 'yaml'
5
+ require 'logger'
6
+ require 'require_relative'
7
+ require_relative 'active_cmis/version'
8
+ require_relative 'active_cmis/internal/caching'
9
+ require_relative 'active_cmis/internal/connection'
10
+ require_relative 'active_cmis/exceptions'
11
+ require_relative 'active_cmis/server'
12
+ require_relative 'active_cmis/repository'
13
+ require_relative 'active_cmis/object'
14
+ require_relative 'active_cmis/document'
15
+ require_relative 'active_cmis/folder'
16
+ require_relative 'active_cmis/policy'
17
+ require_relative 'active_cmis/relationship'
18
+ require_relative 'active_cmis/type'
19
+ require_relative 'active_cmis/atomic_types'
20
+ require_relative 'active_cmis/property_definition'
21
+ require_relative 'active_cmis/collection.rb'
22
+ require_relative 'active_cmis/rendition.rb'
23
+ require_relative 'active_cmis/acl.rb'
24
+ require_relative 'active_cmis/acl_entry.rb'
25
+ require_relative 'active_cmis/ns'
26
+ require_relative 'active_cmis/active_cmis'
27
+ require_relative 'active_cmis/internal/utils'
28
+ require_relative 'active_cmis/rel'
29
+ require_relative 'active_cmis/attribute_prefix'
30
+ require_relative 'active_cmis/query_result'
@@ -0,0 +1,181 @@
1
+ module ActiveCMIS
2
+ # ACLs belong to a document and have no identity of their own
3
+ #
4
+ # = Updating:
5
+ # The effect on documents other than the one this ACL belongs to depends
6
+ # on the repository.
7
+ #
8
+
9
+ class Acl
10
+ include Internal::Caching
11
+
12
+ # @return [Object] The document or object from which we got this ACL
13
+ attr_reader :document
14
+ # @return [Repository]
15
+ attr_reader :repository
16
+
17
+ # @private
18
+ def initialize(repository, document, link, _data = nil)
19
+ @repository = repository
20
+ @document = document
21
+ @self_link = case link
22
+ when URI; link
23
+ else URI(link)
24
+ end
25
+ @data = _data if _data
26
+ end
27
+
28
+ # Returns an array with all Acl entries.
29
+ # @return [Array<AclEntry>]
30
+ def permissions
31
+ data.xpath("c:permission", NS::COMBINED).map do |permit|
32
+ principal = nil
33
+ permissions = []
34
+ direct = false
35
+ permit.children.each do |child|
36
+ next unless child.namespace && child.namespace.href == NS::CMIS_CORE
37
+
38
+ case child.name
39
+ when "principal"
40
+ child.children.map do |n|
41
+ next unless n.namespace && n.namespace.href == NS::CMIS_CORE
42
+
43
+ if n.name == "principalId" && principal.nil?
44
+ principal = convert_principal(n.text)
45
+ end
46
+ end
47
+ when "permission"
48
+ permissions << child.text
49
+ when "direct"
50
+ direct = AtomicType::Boolean.xml_to_bool(child.text)
51
+ end
52
+ end
53
+ AclEntry.new(principal, permissions, direct)
54
+ end
55
+ end
56
+ cache :permissions
57
+
58
+ # An indicator that the ACL fully describes the permissions for this object.
59
+ # This means that there are no other security constraints.
60
+ def exact?
61
+ @exact ||= begin
62
+ value = data.xpath("c:exact", NS::COMBINED)
63
+ if value.empty?
64
+ false
65
+ elsif value.length == 1
66
+ AtomicType::Boolean.xml_to_bool(value.first.text)
67
+ else
68
+ raise "Unexpected multiplicity of exactness ACL"
69
+ end
70
+ end
71
+ end
72
+
73
+ # @param [String, :anonymous, :world] user Can be "cmis:user" to indicate the currently logged in user.
74
+ # For :anonymous and :world you can use both the the active_cmis symbol or the name used by the CMIS repository
75
+ # @param permissions (see ActiveCMIS::AclEntry#initialize)
76
+ # @return [void]
77
+ def grant_permission(user, *permissions)
78
+ principal = convert_principal(user)
79
+
80
+ relevant = self.permissions.select {|p| p.principal == principal && p.direct?}
81
+ if relevant = relevant.first
82
+ self.permissions.delete relevant
83
+ permissions.concat(relevant.permissions)
84
+ end
85
+
86
+ @updated = true
87
+ self.permissions << AclEntry.new(principal, permissions, true)
88
+ end
89
+
90
+ # @param (see ActiveCMIS::Acl#grant_permission)
91
+ # @return [void]
92
+ def revoke_permission(user, *permissions)
93
+ principal = convert_principal(user)
94
+
95
+ keep = self.permissions.reject {|p| p.principal == principal && p.permissions.any? {|t| permissions.include? t} }
96
+
97
+ relevant = self.permissions.select {|p| p.principal == principal && p.permissions.any? {|t| permissions.include? t} }
98
+ changed = relevant.map {|p| AclEntry.new(principal, p.permissions - permissions, p.direct?) }
99
+
100
+ @updated = true
101
+ @permissions = keep + changed
102
+ end
103
+
104
+ # @param user (see ActiveCMIS::Acl#grant_permission)
105
+ # @return [void]
106
+ def revoke_all_permissions(user)
107
+ principal = convert_principal(user)
108
+ @updated = true
109
+ permissions.reject! {|p| p.principal == principal}
110
+ end
111
+
112
+ # Needed to actually execute changes on the server, this method is also executed when you save an object with a modified ACL
113
+ # @return [void]
114
+ def apply
115
+ body = Nokogiri::XML::Builder.new do |xml|
116
+ xml.acl("xmlns" => NS::CMIS_CORE) do
117
+ permissions.each do |permission|
118
+ xml.permission do
119
+ xml.principal { xml.principalId { convert_principal(permission.principal) }}
120
+ xml.direct { permission.direct? }
121
+ permission.each do |permit|
122
+ xml.permission { permit }
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ conn.put(self_link("onlyBasicPermissions" => false), body)
129
+ reload
130
+ end
131
+
132
+ # True if there are local changes to the ACL
133
+ def updated?
134
+ @updated
135
+ end
136
+
137
+ # @return [void]
138
+ def reload
139
+ @updated = false
140
+ @exact = nil
141
+ __reload
142
+ end
143
+
144
+ private
145
+ def self_link(options = {})
146
+ Internal::Utils.append_parameters(@self_link, options)
147
+ end
148
+
149
+ def conn
150
+ repository.conn
151
+ end
152
+
153
+ def data
154
+ conn.get_xml(self_link).xpath("c:acl", NS::COMBINED)
155
+ end
156
+ cache :data
157
+
158
+ def anonymous_user
159
+ repository.anonymous_user
160
+ end
161
+ def world_user
162
+ repository.world_user
163
+ end
164
+
165
+ def convert_principal(principal)
166
+ case principal
167
+ when :anonymous
168
+ anonymous_user
169
+ when :world
170
+ world
171
+ when anonymous_user
172
+ :anonymous
173
+ when world_user
174
+ :world
175
+ else
176
+ principal
177
+ end
178
+ end
179
+
180
+ end
181
+ end