Class: ActiveCMIS::Repository
- Inherits:
-
Object
- Object
- ActiveCMIS::Repository
- Defined in:
- lib/active_cmis/repository.rb
Instance Attribute Summary collapse
-
#logger ⇒ Logger
readonly
A logger to which debug output and so on is sent.
-
#server ⇒ ActiveCMIS::Server
readonly
The server from which the repository was requested.
Instance Method Summary collapse
-
#acls_readable? ⇒ Boolean
returns true if ACLs can at least be viewed.
-
#anonymous_user ⇒ String
You should probably not use this directly, use :anonymous instead where a user name is required.
-
#authenticate(*authentication_info) ⇒ Repository
Use authentication to access the CMIS repository This returns a new Repository object, the existing repository will still use the previous authentication info.
-
#base_types ⇒ Collection<Class>
A collection containing the CMIS base types supported by this repository.
-
#capabilities ⇒ Hash{String => String,Boolean}
Describes the capabilities of the repository.
-
#changes(options = {}) ⇒ Collection
Returns a collection with the changes since the given changeLogToken.
-
#cmis_version ⇒ String
The version of the CMIS standard supported by this repository.
-
#conn ⇒ Internal::Connection
Returns an Internal::Connection object, normally you should not use this directly.
-
#description ⇒ String
A description of the repository.
-
#initialize(server, connection, logger, initial_data, authentication_info) ⇒ Repository
constructor
A new instance of Repository.
- #inspect ⇒ String
-
#key ⇒ String
The identifier of the repository.
-
#latest_changelog_token ⇒ String
Changelog token representing the most recent change to this repository (will represent the most recent change at the time that this ActiveCMIS::Repository was created.
-
#name ⇒ String
The name of the repository, meant for display purposes.
-
#object_by_id(id, parameters = {"renditionFilter" => "*", "includeAllowableActions" => "true", "includeACL" => true}) ⇒ Object
Finds the object with a given ID in the repository.
- #object_by_id_url(parameters) ⇒ Object
-
#product_name ⇒ String
The name of the product behind this Repository.
-
#product_version ⇒ String
The version of the product behind this Repository.
-
#pwc_updatable? ⇒ Boolean
Responds with true if Private Working Copies are updateable, false otherwise (if false the PWC object can only be updated during the checkin).
-
#query(query_string, options = {}) ⇒ Collection
Returns a collection with the results of a query (if supported by the repository).
-
#root_folder(reload = false) ⇒ Folder
The root folder of the repository (as defined in the CMIS standard).
-
#thin_client_uri ⇒ URI?
A URI that points to a web service for this repository.
-
#type_by_id(id) ⇒ Class
Finds the type with a given ID in the repository.
-
#types ⇒ <Class>
An array containing all the types used by this repository.
-
#vendor ⇒ String
The name of the vendor of this Repository.
-
#version_specific_filing? ⇒ Boolean
Responds with true if different versions of the same document can be filed in different folders.
-
#world_user ⇒ String
You should probably not use this directly, use :world instead where a user name is required.
Constructor Details
#initialize(server, connection, logger, initial_data, authentication_info) ⇒ Repository
Returns a new instance of Repository.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/active_cmis/repository.rb', line 11 def initialize(server, connection, logger, initial_data, authentication_info) #:nodoc: @server = server @conn = connection @data = initial_data @logger = logger method, *params = authentication_info if method conn.authenticate(method, *params) end end |
Instance Attribute Details
#logger ⇒ Logger (readonly)
Returns A logger to which debug output and so on is sent.
4 5 6 |
# File 'lib/active_cmis/repository.rb', line 4 def logger @logger end |
#server ⇒ ActiveCMIS::Server (readonly)
Returns The server from which the repository was requested.
8 9 10 |
# File 'lib/active_cmis/repository.rb', line 8 def server @server end |
Instance Method Details
#acls_readable? ⇒ Boolean
returns true if ACLs can at least be viewed
279 280 281 |
# File 'lib/active_cmis/repository.rb', line 279 def acls_readable? ["manage", "discover"].include? capabilities["ACL"] end |
#anonymous_user ⇒ String
You should probably not use this directly, use :anonymous instead where a user name is required
285 286 287 288 289 |
# File 'lib/active_cmis/repository.rb', line 285 def anonymous_user if acls_readable? data.xpath('cra:repositoryInfo/c:principalAnonymous', NS::COMBINED).text end end |
#authenticate(*authentication_info) ⇒ Repository
Use authentication to access the CMIS repository This returns a new Repository object, the existing repository will still use the previous authentication info. If the used authentication info (method, username, password) is the same as for the current Repository object, then self will be returned (unless the server repository cache is cleared first)
e.g.: authenticated = repo.authenticate(:basic, “username”, “password”)
34 35 36 |
# File 'lib/active_cmis/repository.rb', line 34 def authenticate(*authentication_info) server.repository(key, authentication_info) end |
#base_types ⇒ Collection<Class>
A collection containing the CMIS base types supported by this repository
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/active_cmis/repository.rb', line 156 def base_types @base_types ||= begin query = "app:collection[cra:collectionType[child::text() = 'types']]/@href" href = data.xpath(query, NS::COMBINED) if href.first url = href.first.text Collection.new(self, url) do |entry| id = entry.xpath("cra:type/c:id", NS::COMBINED).text type_by_id id end else raise "Repository has no types collection, this is strange and wrong" end end end |
#capabilities ⇒ Hash{String => String,Boolean}
Describes the capabilities of the repository
251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/active_cmis/repository.rb', line 251 def capabilities @capabilities ||= begin capa = {} data.xpath("cra:repositoryInfo/c:capabilities/*", NS::COMBINED).map do |node| # FIXME: conversion should be based on knowledge about data model + transforming bool code should not be duplicated capa[node.name.sub("capability", "")] = case t = node.text when "true", "1"; true when "false", "0"; false else t end end capa end end |
#changes(options = {}) ⇒ Collection
Returns a collection with the changes since the given changeLogToken.
Completely uncached so use with care
192 193 194 195 196 197 198 199 |
# File 'lib/active_cmis/repository.rb', line 192 def changes( = {}) query = "at:link[@rel = '#{Rel[cmis_version][:changes]}']/@href" link = data.xpath(query, NS::COMBINED) if link = link.first link = Internal::Utils.append_parameters(link.to_s, ) Collection.new(self, link) end end |
#cmis_version ⇒ String
The version of the CMIS standard supported by this repository
51 52 53 54 55 56 57 |
# File 'lib/active_cmis/repository.rb', line 51 def cmis_version # NOTE: we might want to "version" our xml namespaces depending on the CMIS version # If we do that we need to make this method capable of not using the predefined namespaces # # On the other hand breaking the XML namespace is probably going to break other applications too so the might not change them even when the spec is updated @cmis_version ||= data.xpath("cra:repositoryInfo/c:cmisVersionSupported", NS::COMBINED).text end |
#conn ⇒ Internal::Connection
Returns an Internal::Connection object, normally you should not use this directly
245 246 247 |
# File 'lib/active_cmis/repository.rb', line 245 def conn @conn ||= Internal::Connection.new end |
#description ⇒ String
A description of the repository
67 68 69 |
# File 'lib/active_cmis/repository.rb', line 67 def description @name ||= data.xpath("cra:repositoryInfo/c:repositoryDescription", NS::COMBINED).text end |
#inspect ⇒ String
45 46 47 |
# File 'lib/active_cmis/repository.rb', line 45 def inspect "<#ActiveCMIS::Repository #{key}>" end |
#key ⇒ String
The identifier of the repository
40 41 42 |
# File 'lib/active_cmis/repository.rb', line 40 def key @key ||= data.xpath('cra:repositoryInfo/c:repositoryId', NS::COMBINED).text end |
#latest_changelog_token ⇒ String
Changelog token representing the most recent change to this repository (will represent the most recent change at the time that this ActiveCMIS::Repository was created
93 94 95 |
# File 'lib/active_cmis/repository.rb', line 93 def latest_changelog_token @changelog_token ||= data.xpath("cra:repositoryInfo/c:latestChangeLogToken", NS::COMBINED).text end |
#name ⇒ String
The name of the repository, meant for display purposes
61 62 63 |
# File 'lib/active_cmis/repository.rb', line 61 def name @name ||= data.xpath("cra:repositoryInfo/c:repositoryName", NS::COMBINED).text end |
#object_by_id(id, parameters = {"renditionFilter" => "*", "includeAllowableActions" => "true", "includeACL" => true}) ⇒ Object
Finds the object with a given ID in the repository
111 112 113 |
# File 'lib/active_cmis/repository.rb', line 111 def object_by_id(id, parameters = {"renditionFilter" => "*", "includeAllowableActions" => "true", "includeACL" => true}) ActiveCMIS::Object.from_parameters(self, parameters.merge("id" => id)) end |
#object_by_id_url(parameters) ⇒ Object
116 117 118 119 120 |
# File 'lib/active_cmis/repository.rb', line 116 def object_by_id_url(parameters) template = pick_template("objectbyid") raise "Repository does not define required URI-template 'objectbyid'" unless template url = fill_in_template(template, parameters) end |
#product_name ⇒ String
The name of the product behind this Repository
79 80 81 |
# File 'lib/active_cmis/repository.rb', line 79 def product_name @product_name ||= data.xpath("cra:repositoryInfo/c:productName", NS::COMBINED).text end |
#product_version ⇒ String
The version of the product behind this Repository
85 86 87 |
# File 'lib/active_cmis/repository.rb', line 85 def product_version @product_version ||= data.xpath("cra:repositoryInfo/c:productVersion", NS::COMBINED).text end |
#pwc_updatable? ⇒ Boolean
Responds with true if Private Working Copies are updateable, false otherwise (if false the PWC object can only be updated during the checkin)
268 269 270 |
# File 'lib/active_cmis/repository.rb', line 268 def pwc_updatable? capabilities["PWCUpdatable"] end |
#query(query_string, options = {}) ⇒ Collection
Returns a collection with the results of a query (if supported by the repository)
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/active_cmis/repository.rb', line 212 def query(query_string, = {}) raise "This repository does not support queries" if capabilities["Query"] == "none" # For the moment we make no difference between metadataonly,fulltextonly,bothseparate and bothcombined # Nor do we look at capabilities["Join"] (none, inneronly, innerandouter) # For searchAllVersions need to check capabilities["AllVersionsSearchable"] # includeRelationships, includeAllowableActions and renditionFilter only work if SELECT only contains attributes from 1 object valid_params = ["searchAllVersions", "includeAllowableActions", "includeRelationships", "renditionFilter", "maxItems", "skipCount"] invalid_params = .keys - valid_params unless invalid_params.empty? raise "Invalid parameters for query: #{invalid_params.join ', '}" end # FIXME: options are not respected yet by pick_template url = pick_template("query", :mimetype => "application/atom+xml", :type => "feed") url = fill_in_template(url, .merge("q" => query_string)) Collection.new(self, url) do |entry| QueryResult.new(entry) end end |
#root_folder(reload = false) ⇒ Folder
The root folder of the repository (as defined in the CMIS standard)
235 236 237 238 239 240 241 |
# File 'lib/active_cmis/repository.rb', line 235 def root_folder(reload = false) if reload @root_folder = object_by_id(data.xpath("cra:repositoryInfo/c:rootFolderId", NS::COMBINED).text) else @root_folder ||= object_by_id(data.xpath("cra:repositoryInfo/c:rootFolderId", NS::COMBINED).text) end end |
#thin_client_uri ⇒ URI?
A URI that points to a web service for this repository. May not be present
99 100 101 102 103 104 |
# File 'lib/active_cmis/repository.rb', line 99 def thin_client_uri @thin_client_uri ||= begin string = data.xpath("cra:repositoryInfo/c:thinClientURI", NS::COMBINED).text URI.parse(string) if string && string != "" end end |
#type_by_id(id) ⇒ Class
Finds the type with a given ID in the repository
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/active_cmis/repository.rb', line 124 def type_by_id(id) @type_by_id ||= {} if result = @type_by_id[id] result else template = pick_template("typebyid") raise "Repository does not define required URI-template 'typebyid'" unless template url = fill_in_template(template, "id" => id) @type_by_id[id] = Type.create(conn, self, conn.get_atom_entry(url)) end end |
#types ⇒ <Class>
An array containing all the types used by this repository
174 175 176 177 178 |
# File 'lib/active_cmis/repository.rb', line 174 def types @types ||= base_types.map do |t| t.all_subtypes end.flatten end |
#vendor ⇒ String
The name of the vendor of this Repository
73 74 75 |
# File 'lib/active_cmis/repository.rb', line 73 def vendor @vendor ||= data.xpath("cra:repositoryInfo/c:vendorName", NS::COMBINED).text end |
#version_specific_filing? ⇒ Boolean
Responds with true if different versions of the same document can be filed in different folders
274 275 276 |
# File 'lib/active_cmis/repository.rb', line 274 def version_specific_filing? capabilities["VersionSpecificFiling"] end |