Sha256: 6bd6a5f1d35d266fcc1f401564cc0b254784bf4efc9357b503377f0d2f276977

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

module CMIS
  class Server
    def initialize(options = {})
      @options = options.symbolize_keys
    end

    def execute!(params = {}, options = {})
      params.symbolize_keys!

      options.symbolize_keys!
      query = options.fetch(:query, {})
      headers = options.fetch(:headers, {})

      response = connection.do_request(params, query, headers)
      response.body
    end

    def repositories(opts = {})
      result = execute!({}, opts)

      result.values.map do |r|
        Repository.new(r, self)
      end
    end

    def repository(repository_id, opts = {})
      result = execute!({ cmisselector: 'repositoryInfo',
                          repositoryId: repository_id }, opts)

      Repository.new(result[repository_id], self)
    end

    def repository?(repository_id)
      repository(repository_id)
      true
    rescue Exceptions::ObjectNotFound
      false
    end

    private

    def connection
      @connection ||= Connection.new(@options)
    end

    def marshal_dump
      @options
    end

    def marshal_load(options)
      @options = options
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cmis-ruby-0.5.2 lib/cmis/server.rb
cmis-ruby-0.5.1 lib/cmis/server.rb
cmis-ruby-0.5 lib/cmis/server.rb
cmis-ruby-0.4.11 lib/cmis/server.rb
cmis-ruby-0.4.10 lib/cmis/server.rb
cmis-ruby-0.4.9 lib/cmis/server.rb