Class: OpenWFE::OldRestServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/openwfe/orest/oldrestservlet.rb

Overview

A common parent class for the worklist and the engine old-style (2002) REST interface.

Direct Known Subclasses

OldRestWorklistServlet

Constant Summary collapse

MUTEX =
Mutex.new
CT =
"Content-Type"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, params) ⇒ OldRestServlet

Returns a new instance of OldRestServlet.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/openwfe/orest/oldrestservlet.rb', line 58

def initialize (server, params)

    super

    @auth_system = params[:AuthSystem] || {}

    @realm_name = get_realm_name

    @last_given_session_id = -1
    @sessions = {}
end

Class Method Details

.get_instance(server, *options) ⇒ Object

Returns always the same servlet instance.



122
123
124
125
126
127
# File 'lib/openwfe/orest/oldrestservlet.rb', line 122

def self.get_instance (server, *options)
    MUTEX.synchronize do
        return @__instance__ if @__instance__
        @__instance__ = self.new(server, *options)
    end
end

Instance Method Details

#get_realm_nameObject

this default implementation returns “no_realm”.



73
74
75
# File 'lib/openwfe/orest/oldrestservlet.rb', line 73

def get_realm_name
    "no_realm"
end

#service(req, res) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/openwfe/orest/oldrestservlet.rb', line 77

def service req, res

    if req.request_method == 'POST'
        class << req
            def parse_query
                @query = WEBrick::HTTPUtils::parse_query(@query_string)
            end
        end
    end

    username = authenticate req, res

    if req.query_string == nil

        get_new_session username, req, res
        return
    end

    req.attributes['username'] = username

    action = req.query["action"]
    action = action.downcase if action

    if action == "endworksession"
        end_work_session req, res
        return
    end

    action_method = "do__#{action}".intern

    unless self.respond_to?(action_method)
        action_not_implemented action, res
        return
    end

    begin
        self.send action_method, req, res
    rescue Exception => e
        reply_with_exception res, e
    end
end