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.
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(method, *params) ⇒ void
Use authentication to access the CMIS repository.
-
#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.
-
#initialize(connection, logger, initial_data) ⇒ Repository
constructor
A new instance of Repository.
- #inspect ⇒ String
-
#key ⇒ String
The identifier of the repository.
-
#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
-
#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 ⇒ Folder
The root folder of the repository (as defined in the CMIS standard).
-
#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.
-
#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(connection, logger, initial_data) ⇒ Repository
Returns a new instance of Repository.
7 8 9 10 11 |
# File 'lib/active_cmis/repository.rb', line 7 def initialize(connection, logger, initial_data) #:nodoc: @conn = connection @data = initial_data @logger = logger 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 |
Instance Method Details
#acls_readable? ⇒ Boolean
returns true if ACLs can at least be viewed
210 211 212 |
# File 'lib/active_cmis/repository.rb', line 210 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
216 217 218 219 220 |
# File 'lib/active_cmis/repository.rb', line 216 def anonymous_user if acls_readable? data.xpath('cra:repositoryInfo/c:principalAnonymous', NS::COMBINED).text end end |
#authenticate(method, *params) ⇒ void
This method returns an undefined value.
Use authentication to access the CMIS repository
e.g.: repo.authenticate(:basic, “username”, “password”)
17 18 19 20 |
# File 'lib/active_cmis/repository.rb', line 17 def authenticate(method, *params) conn.authenticate(method, *params) nil end |
#base_types ⇒ Collection<Class>
A collection containing the CMIS base types supported by this repository
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/active_cmis/repository.rb', line 93 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
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/active_cmis/repository.rb', line 182 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
129 130 131 132 133 134 135 136 |
# File 'lib/active_cmis/repository.rb', line 129 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
35 36 37 38 39 40 41 |
# File 'lib/active_cmis/repository.rb', line 35 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
176 177 178 |
# File 'lib/active_cmis/repository.rb', line 176 def conn @conn ||= Internal::Connection.new end |
#inspect ⇒ String
29 30 31 |
# File 'lib/active_cmis/repository.rb', line 29 def inspect "<#ActiveCMIS::Repository #{key}>" end |
#key ⇒ String
The identifier of the repository
24 25 26 |
# File 'lib/active_cmis/repository.rb', line 24 def key @key ||= data.xpath('cra:repositoryInfo/c:repositoryId', 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
48 49 50 |
# File 'lib/active_cmis/repository.rb', line 48 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
53 54 55 56 57 |
# File 'lib/active_cmis/repository.rb', line 53 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 |
#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)
199 200 201 |
# File 'lib/active_cmis/repository.rb', line 199 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)
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/active_cmis/repository.rb', line 149 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) end |
#root_folder ⇒ Folder
The root folder of the repository (as defined in the CMIS standard)
170 171 172 |
# File 'lib/active_cmis/repository.rb', line 170 def root_folder @root_folder ||= object_by_id(data.xpath("cra:repositoryInfo/c:rootFolderId", NS::COMBINED).text) end |
#type_by_id(id) ⇒ Class
Finds the type with a given ID in the repository
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/active_cmis/repository.rb', line 61 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
111 112 113 114 115 |
# File 'lib/active_cmis/repository.rb', line 111 def types @types ||= base_types.map do |t| t.all_subtypes end.flatten end |
#version_specific_filing? ⇒ Boolean
Responds with true if different versions of the same document can be filed in different folders
205 206 207 |
# File 'lib/active_cmis/repository.rb', line 205 def version_specific_filing? capabilities["VersionSpecificFiling"] end |