| Class | OpenWFE::OldRestWorklistServlet |
| In: |
lib/openwfe/worklist/oldrest.rb
|
| Parent: | OldRestServlet |
This webrick servlet provides a REST interface for an old style OpenWFE worklist.
# File lib/openwfe/worklist/oldrest.rb, line 53
53: def initialize (server, params)
54: super
55: @worklist = params[:Worklist]
56: end
Returns the flow expression ids of the workitems with a given workflow instance id in a store.
# File lib/openwfe/worklist/oldrest.rb, line 159
159: def do__findflowinstance (req, res)
160:
161: store_name = get_store_name req
162:
163: wfid = req.query['id']
164: raise "404 'id' not specified" unless wfid
165:
166: wis = @worklist.list_workitems(
167: req.attributes['username'], store_name, wfid)
168:
169: e = REXML::Element.new 'stores'
170:
171: wis.each do |wi|
172: e << OpenWFE::XmlCodec::encode(wi.fei)
173: end
174:
175: reply_with_xml res, 200, e
176: end
Forwards the workitem (makes the worklist reply to the engine with the modified workitem)
# File lib/openwfe/worklist/oldrest.rb, line 198
198: def do__forwardworkitem (req, res)
199:
200: execute_wi_post :forward, req, res
201: end
Retrieves a workitem from the worklist, locks it and returns it
# File lib/openwfe/worklist/oldrest.rb, line 150
150: def do__getandlockworkitem (req, res)
151:
152: execute_wi_get :get_and_lock, req, res
153: end
This implementation simply encodes the workitem, no transformation into headers at all.
# File lib/openwfe/worklist/oldrest.rb, line 93
93: def do__getheaders (req, res)
94:
95: limit = req.query['limit']
96: limit = limit.to_s.to_i if limit
97: limit = nil if limit and limit < 1
98:
99: hs = @worklist.get_headers(
100: req.attributes['username'],
101: get_store_name(req),
102: limit)
103:
104: # TODO raise "404 no store named '#{store_name}'" unless store
105: # TODO raise "403 forbidden"
106:
107: e = REXML::Element.new 'headers'
108:
109: hs.each do |h|
110:
111: workitem, locked = h
112:
113: e << OpenWFE::XmlCodec::encode_workitem_as_header(
114: workitem, locked)
115: end
116:
117: reply_with_xml res, 200, e
118: end
Lists the stores in the worklist
# File lib/openwfe/worklist/oldrest.rb, line 68
68: def do__getstorenames (req, res)
69:
70: e = REXML::Element.new 'stores'
71:
72: @worklist.each_store do |regex, store_name, store|
73:
74: perms = @worklist.get_permissions(
75: req.attributes['username'], store_name)
76:
77: es = REXML::Element.new 'store'
78: es.add_attribute 'name', store_name
79: es.add_attribute 'workitem-count', store.size
80: es.add_attribute 'permissions', perms
81: e << es
82: end
83:
84: reply_with_xml res, 200, e
85: end
Retrieves a workitem from the worklist
# File lib/openwfe/worklist/oldrest.rb, line 142
142: def do__getworkitem (req, res)
143:
144: execute_wi_get :get, req, res
145: end
Launches a new process instance.
# File lib/openwfe/worklist/oldrest.rb, line 123
123: def do__launchflow (req, res)
124:
125: engine_name = req.query['engineid']
126: engine_name = "__nil__" unless engine_name
127:
128: launch_item = OpenWFE::XmlCodec::decode req.body
129:
130: r = @worklist.launch_flow engine_name, launch_item
131:
132: e = REXML::Element.new 'ok'
133:
134: e.add_attribute 'flow-id', r.to_s
135:
136: reply_with_xml res, 200, e
137: end
Releases a workitem (unlocks it).
# File lib/openwfe/worklist/oldrest.rb, line 181
181: def do__releaseworkitem (req, res)
182:
183: execute_wi_post :release, req, res
184: end
Simply saves the workitem and the modifications done to it.
# File lib/openwfe/worklist/oldrest.rb, line 189
189: def do__saveworkitem (req, res)
190:
191: execute_wi_post :save, req, res
192: end
The realm for HTTP authentication.
# File lib/openwfe/worklist/oldrest.rb, line 61
61: def get_realm_name
62: "worklist"
63: end
# File lib/openwfe/worklist/oldrest.rb, line 218
218: def execute_wi_get (method, req, res)
219:
220: store_name = get_store_name req
221: fei = OpenWFE::XmlCodec::decode req.body
222:
223: wi = @worklist.send(
224: method, req.attributes['username'], store_name, fei)
225:
226: raise "404 no workitem found for #{fei.to_s}" unless wi
227:
228: reply_with_wi res, wi
229: end
# File lib/openwfe/worklist/oldrest.rb, line 205
205: def execute_wi_post (method, req, res)
206:
207: store_name = get_store_name req
208:
209: wi = OpenWFE::XmlCodec::decode req.body
210:
211: @worklist.send(
212: method,
213: req.attributes['username'],
214: store_name,
215: wi)
216: end
# File lib/openwfe/worklist/oldrest.rb, line 236
236: def get_store_name (req)
237:
238: ss = req.path.split("/")
239: raise "404 'store' not specified" if ss.length != 3
240: ss[-1]
241: end