Class TaskJuggler::ProjectBrokerIface
In: lib/taskjuggler/daemon/ProjectBroker.rb
Parent: Object

This class is the DRb interface for ProjectBroker. We only want to expose these methods for remote access.

Methods

apiVersion   command   new   trap   updateState  

Public Class methods

[Source]

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 504
    def initialize(broker)
      @broker = broker
    end

Public Instance methods

Check the authentication key and the client/server version match. The following return values can be generated: 0 : authKey does not match 1 : client and server versions match -1 : client and server versions don‘t match

[Source]

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 513
    def apiVersion(authKey, version)
      return 0 unless @broker.checkKey(authKey, 'apiVersion')

      version == 1 ? 1 : -1
    end

[Source]

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 533
    def command(authKey, cmd, args)
      return false unless @broker.checkKey(authKey, cmd)

      trap do
        case cmd
        when :status
          @broker.status
        when :stop
          @broker.stop
        when :addProject
          # To pass the DRbObject as separate arguments we need to convert it
          # into a real Array again.
          @broker.addProject(*Array.new(args))
        when :removeProject
          @broker.removeProject(args)
        when :getProject
          @broker.getProject(args)
        when :update
          @broker.update
        else
          LogFile.instance.fatal('Unknown command #{cmd} called')
        end
      end
    end

This function catches all unhandled exceptions in the passed block.

[Source]

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 520
    def trap
      log = LogFile.instance

      begin
        yield
      rescue
        $stderr.print $!.to_s
        $stderr.print $!.backtrace.join("\n")
        log.debug($!.backtrace.join("\n"))
        log.fatal("Unexpected exception: #{$!}")
      end
    end

[Source]

# File lib/taskjuggler/daemon/ProjectBroker.rb, line 558
    def updateState(authKey, projectKey, id, status, modified)
      return false unless @broker.checkKey(authKey, 'updateState')

      trap { @broker.updateState(projectKey, id, status, modified) }
    end

[Validate]