Class: ActiveCMIS::Server
- Inherits:
-
Object
- Object
- ActiveCMIS::Server
- Includes:
- Internal::Caching
- Defined in:
- lib/active_cmis/server.rb
Overview
This class is used to manage different CMIS servers.
Instance Attribute Summary collapse
-
#endpoint ⇒ URI
readonly
The location of the server.
-
#logger ⇒ Logger
readonly
A default logger for derived repositories.
Class Method Summary collapse
-
.endpoints ⇒ {(URI, Logger) => Server}
The cache of known Servers.
-
.new(endpoint, logger = nil) ⇒ Server
Cached by endpoint and logger.
Instance Method Summary collapse
- #authenticate(method, *params) ⇒ void
-
#initialize(endpoint, logger) ⇒ Server
constructor
A connection needs the URL to a CMIS REST endpoint.
- #inspect ⇒ String
-
#repositories ⇒ <{:id, :name} => String>
Lists all the available repositories.
-
#repository(repository_id) ⇒ Repository
Returns the _Repository identified by the ID.
- #to_s ⇒ String
Methods included from Internal::Caching
Constructor Details
#initialize(endpoint, logger) ⇒ Server
A connection needs the URL to a CMIS REST endpoint.
It’s used to manage all communication with the CMIS Server
36 37 38 39 |
# File 'lib/active_cmis/server.rb', line 36 def initialize(endpoint, logger) @endpoint = endpoint @logger = logger end |
Instance Attribute Details
#endpoint ⇒ URI (readonly)
Returns The location of the server.
6 7 8 |
# File 'lib/active_cmis/server.rb', line 6 def endpoint @endpoint end |
#logger ⇒ Logger (readonly)
Returns A default logger for derived repositories.
8 9 10 |
# File 'lib/active_cmis/server.rb', line 8 def logger @logger end |
Class Method Details
.endpoints ⇒ {(URI, Logger) => Server}
Returns The cache of known Servers.
20 21 22 |
# File 'lib/active_cmis/server.rb', line 20 def self.endpoints @endpoints ||= {} end |
.new(endpoint, logger = nil) ⇒ Server
Returns Cached by endpoint and logger.
11 12 13 14 15 16 17 |
# File 'lib/active_cmis/server.rb', line 11 def self.new(endpoint, logger = nil) endpoint = case endpoint when URI; endpoint else URI(endpoint.to_s) end endpoints[[endpoint, logger]] ||= super(endpoint, logger || ActiveCMIS.default_logger) end |
Instance Method Details
#authenticate(method, *params) ⇒ void
This method returns an undefined value.
44 45 46 |
# File 'lib/active_cmis/server.rb', line 44 def authenticate(method, *params) conn.authenticate(method, *params) end |
#inspect ⇒ String
25 26 27 |
# File 'lib/active_cmis/server.rb', line 25 def inspect "Server #{@endpoint}" end |
#repositories ⇒ <{:id, :name} => String>
Lists all the available repositories
68 69 70 71 72 |
# File 'lib/active_cmis/server.rb', line 68 def repositories repositories = repository_info.xpath("/app:service/app:workspace/cra:repositoryInfo", NS::COMBINED) repositories.map {|ri| next {:id => ri.xpath("ns:repositoryId", "ns" => NS::CMIS_CORE).text, :name => ri.xpath("ns:repositoryName", "ns" => NS::CMIS_CORE).text }} end |
#repository(repository_id) ⇒ Repository
Returns the _Repository identified by the ID
Cached by the repository_id, no way to reset cache yet
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/active_cmis/server.rb', line 53 def repository(repository_id) cached_repositories[repository_id] ||= begin repository_data = repository_info. xpath("/app:service/app:workspace[cra:repositoryInfo/c:repositoryId[child::text() = '#{repository_id}']]", NS::COMBINED) if repository_data.empty? raise Error::ObjectNotFound.new("The repository #{repository_id} doesn't exist") else Repository.new(conn.dup, logger.dup, repository_data) end end end |
#to_s ⇒ String
29 30 31 |
# File 'lib/active_cmis/server.rb', line 29 def to_s "Server " + @endpoint.to_s + " : " + repositories.map {|h| h[:name] + "(#{h[:id]})"}.join(", ") end |