Class: Confluence::RPC

Inherits:
Object
  • Object
show all
Defined in:
lib/confluence/confluence_rpc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_url, proxy = "confluence1") ⇒ RPC

Returns a new instance of RPC.



20
21
22
23
24
25
26
27
28
# File 'lib/confluence/confluence_rpc.rb', line 20

def initialize(server_url, proxy = "confluence1")
  server_url += "/rpc/xmlrpc" unless server_url[-11..-1] == "/rpc/xmlrpc"
  @server_url = server_url
  server = XMLRPC::Client.new2(server_url)
  @conf = server.proxy(proxy)
  @token = "12345"
  
  @log = Logger.new($stdout)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/confluence/confluence_rpc.rb', line 37

def method_missing(method_name, *args)
  log.info "Calling #{method_name}(#{args.inspect})."
  begin
    @conf.send(method_name, *([@token] + args))
  rescue XMLRPC::FaultException => e
    log.error "#{e}: #{e.message}"
    if (e.faultString.include?("InvalidSessionException"))
      
      retry
    else
      raise RemoteException, e.respond_to?(:message) ? e.message : e
    end
  rescue
    log.error "#{$!}"
    raise $!
  end
end

Instance Attribute Details

#logObject

Returns the value of attribute log.



18
19
20
# File 'lib/confluence/confluence_rpc.rb', line 18

def log
  @log
end

Instance Method Details

#login(username, password) ⇒ Object



30
31
32
33
34
35
# File 'lib/confluence/confluence_rpc.rb', line 30

def (username, password)
  log.info "Logging in as '#{username}'."
  @user = username
  @pass = password
  ()
end