#!/usr/bin/perl
package RVL::Task::ExecuteAjaxAction;
##LICENSE##
use strict;
use warnings;
use base qw(RVL::ProcessRequest);
use base qw(RVL::DecorateProcess);
use Class::Std::Utils;
{
sub process {
my ($this, $input, $output) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($req) = ${$input}->getRequest();
my ($moduleName) = ${$req}->getModuleName();
my ($method) = ${$req}->getActionName();
my ($managerName) = ${$req}->getManagerName();
RVL::logMessage("Call Module: $moduleName, Manager: $managerName, Action: $method", __CONSTANT__::RVL_LOG_DEBUG);
my ($providerFile) = __CONSTANT__::RVL_MOD_DIR . '/' . $moduleName . '/classes/AjaxMgr/' . ucfirst($managerName) . 'AjaxMgr.pm';
my ($providerClass);
if (-e $providerFile) {
$providerClass = ucfirst($managerName) . 'AjaxMgr';
} else {
$providerFile = __CONSTANT__::RVL_MOD_DIR . '/' . $moduleName . '/classes/AjaxMgr/' . ucfirst($moduleName) . 'AjaxMgr.pm';
$providerClass = ucfirst($moduleName) . 'AjaxMgr';
}
my ($mgr);
eval {
require $providerFile;
$mgr = $providerClass->new();
};
if ($@) {
RVL::logMessage("Error : $@", __CONSTANT__::RVL_LOG_DEBUG);
${$output}->{responseFormat} = __CONSTANT__::RVL_RESPONSEFORMAT_JSON;
${$output}->{data}->{ON_ERROR} = 'true';
${$output}->{data}->{ERROR} = $@;
} else {
eval {
$mgr->validate(${$req}, $input);
};
${$input}->aggregate($output);
if ($mgr->isValid()) {
$mgr->{actionPrefix} = '_ajax_';
RVL::logMessage('BEGIN: Process', __CONSTANT__::RVL_LOG_DEBUG);
my ($ok) = $mgr->process($input, $output);
RVL::logMessage('END: Process' . " $mgr->{responseFormat}" , __CONSTANT__::RVL_LOG_DEBUG);
${$output}->{responseFormat} = defined($mgr->{responseFormat})
? $mgr->{responseFormat}
: __CONSTANT__::RVL_RESPONSEFORMAT_JSON;
RVL::logMessage('END: ExecuteAjaxAction' . ", set responseFormat: ${$output}->{responseFormat}", __CONSTANT__::RVL_LOG_DEBUG);
} else {
my ($error) = RVL::Error::singleton()->pop();
${$output}->{responseFormat} = __CONSTANT__::RVL_RESPONSEFORMAT_JSON;
${$output}->{data}->{ON_ERROR} = 'true';
${$output}->{data}->{ERROR} = $error->{message};
}
}
$this->SUPER::process($input, $output);
}
}
1;
Copyright 2K16 - 2K18 Indonesian Hacker Rulez