RT notifier: parse templates without header correctly
[openxpki.git] / trunk / clients / perl / OpenXPKI-Client-HTML-Mason / htdocs / lib / process_response.mhtml
blob972bd95fc4fee1c602ec3f4fbcadf3f6af25d7f5
1 %# This component checks if the client is in the correct state to read
2 %# a response from the server ('can_receive'). If this is the case,
3 %# it fetches the server response, analyzes the output and dispatches
4 %# the response to the most specific rendering component available.
5 %#
6 <%perl>
7   if ($session_context->{client}->get_communication_state() 
8       eq 'can_receive') {
9       my $response = $session_context->{client}->collect();
10       my $service_msg = $response->{SERVICE_MSG};
12       my $command;
13       my $comp_path;
14       if ($service_msg eq 'COMMAND') {
15           # offload this to a COMMAND renderer
16           $comp_path = '/Renderer/Command';
17           $command = $response->{COMMAND};
18       } else {
19           # process service message response
20           $comp_path = '/Renderer/Service',
21           $command = $service_msg;
22       }
24       eval {
25           $m->comp("$comp_path/$command.mhtml",
26               response => $response);
27       };
28       if ($EVAL_ERROR) {
29           $context{debug}("Eval error: $EVAL_ERROR");
30           $m->comp("$comp_path/default.mhtml",
31               response => $response);
32       }
33   }
34 </%perl>
35 <%once>
36   use Data::Dumper;
37 </%once>
38 <%init>
39   my $session_context = $m->comp('/lib/getsession.mhtml', %ARGS);
40 </%init>