1030 lines
38 KiB
Plaintext
1030 lines
38 KiB
Plaintext
CREATE OR REPLACE PACKAGE BODY amfr_message_handler
|
|
/**
|
|
#############################################################################
|
|
# #
|
|
# Package: amfr_message_handler #
|
|
# #
|
|
# Application System: General #
|
|
# #
|
|
# Creation Date: 01/03/2006 #
|
|
# #
|
|
# Author: Oracle Team, Advantica Ltd #
|
|
# #
|
|
# Purpose: A flexible interface mechanism #
|
|
# #
|
|
# Dependancies: Access Manager Installation #
|
|
# #
|
|
# Revision: $Revision: 4 $ #
|
|
# #
|
|
# Advantica Ltd, 2006 #
|
|
#############################################################################
|
|
*/
|
|
IS
|
|
--
|
|
-- Internal Variables
|
|
--
|
|
--
|
|
--
|
|
-- Internal Constants
|
|
--
|
|
c_failure CONSTANT VARCHAR2(7) := 'failure';
|
|
c_success CONSTANT VARCHAR2(7) := 'success';
|
|
c_service_request_status CONSTANT VARCHAR2(100) := 'service_request_status';
|
|
c_service_request_status_rsn CONSTANT VARCHAR2(100) := 'service_request_status_reason';
|
|
c_xml_validation_failure_rsn CONSTANT VARCHAR2(100) := 'xml_validation_failure_reason';
|
|
c_xml_parsing_failure_rsn CONSTANT VARCHAR2(100) := 'xml_parsing_failure_reason';
|
|
c_msg_start CONSTANT VARCHAR2(100) := '<response>';
|
|
c_msg_end CONSTANT VARCHAR2(100) := '</response>';
|
|
--
|
|
c_service_status CONSTANT VARCHAR2(14) := 'service_status';
|
|
c_service_status_reason CONSTANT VARCHAR2(21) := 'service_status_reason';
|
|
c_error_code CONSTANT VARCHAR2(100) := 'error_code';
|
|
c_execution_failure CONSTANT VARCHAR2(100) := 'An unexpected error occured whilst invoking the legacy interface.';
|
|
--
|
|
-- Private Declaration
|
|
--
|
|
FUNCTION get_array_value(p_name_array IN owa.vc_arr,
|
|
p_value_array IN clob_arr,
|
|
p_scan_name IN VARCHAR2) RETURN VARCHAR2 IS
|
|
--
|
|
l_return VARCHAR2(32767);
|
|
l_idx NUMBER;
|
|
--
|
|
BEGIN
|
|
--
|
|
-- We know that the array is not sparse at the moment; however, that may not always be so
|
|
--
|
|
l_idx := p_name_array.FIRST;
|
|
--
|
|
FOR i IN 1 .. p_name_array.COUNT LOOP
|
|
--
|
|
-- If the scan name equals the current array element
|
|
--
|
|
IF p_name_array(l_idx) = p_scan_name THEN
|
|
--
|
|
-- Set the return variable
|
|
--
|
|
l_return := p_value_array(l_idx);
|
|
--
|
|
-- Exit the loop
|
|
--
|
|
EXIT;
|
|
--
|
|
END IF;
|
|
--
|
|
l_idx := p_name_array.NEXT(l_idx);
|
|
--
|
|
END LOOP;
|
|
--
|
|
caco_debug.putline('get_array_value: looking for ' || p_scan_name ||
|
|
' found ' || nvl(substr(l_return,1,3000),
|
|
'nothing'));
|
|
--
|
|
-- Return l_return which will be NULL if we haven't found anything
|
|
--
|
|
RETURN l_return;
|
|
--
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
caco_debug.putline(SQLCODE||' - '||SQLERRM);
|
|
|
|
END get_array_value;
|
|
--
|
|
FUNCTION get_array_value_clob(p_name_array IN owa.vc_arr,
|
|
p_value_array IN clob_arr,
|
|
p_scan_name IN VARCHAR2) RETURN CLOB IS
|
|
--
|
|
l_return CLOB;
|
|
l_idx NUMBER;
|
|
--
|
|
BEGIN
|
|
--
|
|
-- We know that the array is not sparse at the moment; however, that may not always be so
|
|
--
|
|
l_idx := p_name_array.FIRST;
|
|
--
|
|
FOR i IN 1 .. p_name_array.COUNT LOOP
|
|
--
|
|
-- If the scan name equals the current array element
|
|
--
|
|
IF p_name_array(l_idx) = p_scan_name THEN
|
|
--
|
|
-- Set the return variable
|
|
--
|
|
l_return := p_value_array(l_idx);
|
|
--
|
|
-- Exit the loop
|
|
--
|
|
EXIT;
|
|
--
|
|
END IF;
|
|
--
|
|
l_idx := p_name_array.NEXT(l_idx);
|
|
--
|
|
END LOOP;
|
|
--
|
|
caco_debug.putline('get_array_value: looking for ' || p_scan_name ||
|
|
' found ' || nvl(substr(l_return,1,3000),
|
|
'nothing'));
|
|
--
|
|
-- Return l_return which will be NULL if we haven't found anything
|
|
--
|
|
RETURN l_return;
|
|
--
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
caco_debug.putline(SQLCODE||' - '||SQLERRM);
|
|
|
|
END get_array_value_clob;
|
|
--
|
|
PROCEDURE add_array_value(p_name_array IN OUT owa.vc_arr,
|
|
p_value_array IN OUT clob_arr,
|
|
p_name IN VARCHAR2,
|
|
p_value IN VARCHAR2) IS
|
|
--
|
|
l_idx NUMBER;
|
|
--
|
|
BEGIN
|
|
--
|
|
-- We know that the array is not sparse at the moment; however, that may not always be so
|
|
--
|
|
l_idx := nvl(p_name_array.LAST,
|
|
0) + 1;
|
|
--
|
|
p_name_array(l_idx) := p_name;
|
|
p_value_array(l_idx) := p_value;
|
|
--
|
|
END add_array_value;
|
|
--
|
|
FUNCTION get_error_code(p_error_message IN VARCHAR2) RETURN NUMBER IS
|
|
--
|
|
CURSOR c_mtxt(c_error_message VARCHAR2) IS
|
|
SELECT text_number
|
|
FROM module_text
|
|
WHERE lower(text) = lower(c_error_message);
|
|
--
|
|
CURSOR c_exme IS
|
|
SELECT exme.exception_number
|
|
FROM exception_messages exme
|
|
WHERE lower(message) = lower(substr(p_error_message,8));
|
|
--
|
|
l_return NUMBER;
|
|
--
|
|
BEGIN
|
|
--
|
|
OPEN c_mtxt(p_error_message);
|
|
FETCH c_mtxt INTO l_return;
|
|
CLOSE c_mtxt;
|
|
--
|
|
IF l_return IS NULL THEN
|
|
-- see if the error code can be found by removing all of the text after and including semi colon
|
|
-- from the error message
|
|
IF instr(p_error_message,':') > 0 THEN
|
|
OPEN c_mtxt(substr(p_error_message,1,instr(p_error_message,':')-1));
|
|
FETCH c_mtxt INTO l_return;
|
|
CLOSE c_mtxt;
|
|
END IF;
|
|
END IF;
|
|
--
|
|
IF l_return IS NULL THEN
|
|
OPEN c_exme;
|
|
FETCH c_exme INTO l_return;
|
|
CLOSE c_exme;
|
|
END IF;
|
|
--
|
|
RETURN nvl(l_return,0);
|
|
--
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
caco_debug.putline(SQLCODE||' - '||SQLERRM);
|
|
|
|
END get_error_code;
|
|
--
|
|
/* FUNCTION translate(p_text IN VARCHAR2) RETURN VARCHAR2 IS
|
|
--
|
|
CURSOR c_mtxt(c_text_number NUMBER) IS
|
|
SELECT text
|
|
FROM module_text
|
|
WHERE text_number = c_text_number
|
|
AND language = 'HU';
|
|
--
|
|
l_return module_text.text%TYPE;
|
|
--
|
|
BEGIN
|
|
--
|
|
IF g_lang = 'HU' THEN
|
|
--
|
|
OPEN c_mtxt(get_error_code(p_text));
|
|
FETCH c_mtxt INTO l_return;
|
|
CLOSE c_mtxt;
|
|
--
|
|
END IF;
|
|
--
|
|
RETURN nvl(l_return,p_text);
|
|
--
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
caco_debug.putline(SQLCODE||' - '||SQLERRM);
|
|
|
|
END translate;*/
|
|
--
|
|
PROCEDURE validate_service_request(p_name_array IN OUT owa.vc_arr,
|
|
p_value_array IN OUT clob_arr,
|
|
p_sere_id OUT service_reqs.sere_id%TYPE) IS
|
|
--
|
|
--
|
|
-- Local Variables
|
|
--
|
|
l_req_id service_reqs.request_id%TYPE;
|
|
l_dummy VARCHAR2(10);
|
|
l_xml_data_clob CLOB;
|
|
l_serx_id service_req_xml.serx_id%TYPE;
|
|
--
|
|
-- Constants
|
|
--
|
|
c_inv_miss_error CONSTANT VARCHAR2(100) := caco_utilities.get_module_text(3940);-- Invalid or missing request_id
|
|
c_inv_param_error CONSTANT VARCHAR2(100) := caco_utilities.get_module_text(3941);-- Parameter list does not match request_id
|
|
c_xml_parsing_error CONSTANT VARCHAR2(100) := 'XML parsing error';
|
|
c_param_name_req_id CONSTANT VARCHAR2(100) := 'request_id';
|
|
--
|
|
-- Local procedural logic
|
|
--
|
|
l_login_success BOOLEAN;
|
|
l_login_message VARCHAR2(2000);
|
|
--
|
|
--
|
|
FUNCTION get_srpa(p_sere_id IN service_reqs.sere_id%TYPE,
|
|
p_param_name IN service_req_params.param_name%TYPE)
|
|
RETURN service_req_params.param_value%TYPE IS
|
|
--
|
|
l_return service_req_params.param_value%TYPE;
|
|
--
|
|
BEGIN
|
|
--
|
|
BEGIN
|
|
--
|
|
SELECT srpa.param_value
|
|
INTO l_return
|
|
FROM service_req_params srpa
|
|
WHERE srpa.param_name = p_param_name
|
|
AND srpa.sere_id = p_sere_id;
|
|
--
|
|
EXCEPTION
|
|
WHEN no_data_found THEN
|
|
l_return := NULL;
|
|
END;
|
|
--
|
|
RETURN l_return;
|
|
--
|
|
END get_srpa;
|
|
--
|
|
PROCEDURE add_svc_req_stat(p_svc_stat_rsn IN VARCHAR2) IS
|
|
--
|
|
--
|
|
BEGIN
|
|
--
|
|
-- Add the service status flag
|
|
--
|
|
add_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_name => c_service_request_status,
|
|
p_value => c_failure);
|
|
--
|
|
-- Add message
|
|
--
|
|
add_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_name => c_service_request_status_rsn,
|
|
p_value => p_svc_stat_rsn);
|
|
--
|
|
END add_svc_req_stat;
|
|
--
|
|
BEGIN
|
|
--
|
|
caco_debug.putline('Validating service request');
|
|
--
|
|
IF upper(owa_util.get_cgi_env('REQUEST_PROTOCOL')) <> 'HTTPS' AND
|
|
nvl(cout_system_configuration.get_configuration_item('AMFR_INT_HTTP_ALLOWED'),
|
|
'N') = 'N' THEN
|
|
--
|
|
-- Supposed to be a HTTPS request, therfore ignore it
|
|
--
|
|
caco_debug.putline('Error Point 0');
|
|
--
|
|
NULL;
|
|
--
|
|
ELSE
|
|
--
|
|
caco_debug.putline('Continue');
|
|
-- Either HTTPS or HTTP override, continue
|
|
--
|
|
IF p_name_array.COUNT = 0 OR p_value_array.COUNT = 0 THEN
|
|
--
|
|
caco_debug.putline('case1');
|
|
-- Either no parameter names have been passed or no values for those parameters, either way its an error
|
|
--
|
|
add_svc_req_stat(c_inv_miss_error);
|
|
--
|
|
caco_debug.putline('Error Point 1');
|
|
--
|
|
ELSIF p_name_array.COUNT <> p_value_array.COUNT THEN
|
|
--
|
|
caco_debug.putline('case2');
|
|
-- Array is not balanced - not a condition that should occur
|
|
--
|
|
add_svc_req_stat(c_inv_miss_error);
|
|
--
|
|
caco_debug.putline('Error Point 2');
|
|
--
|
|
ELSE
|
|
caco_debug.putline('case3');
|
|
--
|
|
-- Input passes basic validation, log the request
|
|
caco_debug.putline('Insert service request');
|
|
caco_debug.putline(owa_util.get_cgi_env('REMOTE_ADDR'));
|
|
caco_debug.putline(owa_util.get_cgi_env('HTTP_USER_AGENT'));
|
|
caco_debug.putline(owa_util.get_cgi_env('REQUEST_PROTOCOL'));
|
|
--
|
|
INSERT INTO service_reqs
|
|
(request_timestamp,
|
|
status,
|
|
address,
|
|
AGENT,
|
|
protocol)
|
|
VALUES
|
|
(SYSDATE,
|
|
'U',
|
|
owa_util.get_cgi_env('REMOTE_ADDR'),
|
|
substr(owa_util.get_cgi_env('HTTP_USER_AGENT'),
|
|
1,
|
|
99),
|
|
owa_util.get_cgi_env('REQUEST_PROTOCOL'))
|
|
RETURNING sere_id INTO p_sere_id;
|
|
--
|
|
caco_debug.putline('Inserted the service request');
|
|
-- Now insert the passed parameters
|
|
--
|
|
FOR x IN p_name_array.first .. p_name_array.last
|
|
LOOP
|
|
--
|
|
--
|
|
-- below code added by smore on 12-Jan-2009
|
|
-- to remove additional spaces in the message. As max allowd length of the message was exceeding
|
|
-- This has to be done in the original array value otherwise it will fail giving error as
|
|
-- ORA-01461: can bind a LONG value only for insert into a LONG columnneeds. while converting from CLOB to XML
|
|
---------------------------------------------------------------------------------------------------
|
|
WHILE (instr(p_value_array(x),' <',1) >0) LOOP
|
|
p_value_array(x) := substr(p_value_array(x),1,instr(p_value_array(x),' <',1)-1)||
|
|
substr(p_value_array(x),instr(p_value_array(x),' <')+1);
|
|
|
|
END LOOP;
|
|
---------------------------------------------------------------------------------------------------
|
|
|
|
INSERT INTO service_req_params
|
|
(sere_id,
|
|
param_value,
|
|
param_name)
|
|
VALUES
|
|
(p_sere_id,
|
|
p_value_array(x),
|
|
lower(p_name_array(x)));
|
|
--
|
|
END LOOP;
|
|
--
|
|
-- Look for a request identifier
|
|
--
|
|
l_req_id := get_srpa(p_sere_id => p_sere_id,
|
|
p_param_name => c_param_name_req_id);
|
|
--
|
|
IF l_req_id IS NULL THEN
|
|
--
|
|
-- No request ID supplied, do not continue
|
|
--
|
|
add_svc_req_stat(c_inv_miss_error);
|
|
--
|
|
caco_debug.putline('Error Point 4');
|
|
--
|
|
ELSE
|
|
--
|
|
-- Check against interface request
|
|
--
|
|
BEGIN
|
|
--
|
|
SELECT NULL
|
|
INTO l_dummy
|
|
FROM interface_reqs inre
|
|
WHERE inre.request_identifier = l_req_id;
|
|
--
|
|
-- If no exception has been raised, we know about this request
|
|
--
|
|
UPDATE service_reqs sere
|
|
SET sere.request_id = l_req_id
|
|
WHERE sere.sere_id = p_sere_id;
|
|
--
|
|
-- Verify the parameters are known and are valid
|
|
--
|
|
BEGIN
|
|
--
|
|
SELECT param_name
|
|
INTO l_dummy
|
|
FROM ((SELECT srpa.param_name
|
|
FROM service_req_params srpa
|
|
WHERE srpa.sere_id = p_sere_id
|
|
MINUS
|
|
SELECT irpa.param_name
|
|
FROM interface_req_params irpa,
|
|
interface_reqs inre
|
|
WHERE inre.inre_id = irpa.inre_id
|
|
AND inre.request_identifier = l_req_id) UNION
|
|
(SELECT irpa.param_name
|
|
FROM interface_req_params irpa,
|
|
interface_reqs inre
|
|
WHERE inre.inre_id = irpa.inre_id
|
|
AND inre.request_identifier = l_req_id
|
|
AND irpa.param_mandatory = 'Y'
|
|
MINUS
|
|
SELECT srpa.param_name
|
|
FROM service_req_params srpa
|
|
WHERE srpa.sere_id = p_sere_id) UNION ALL
|
|
(SELECT irpa.param_name
|
|
FROM interface_req_params irpa,
|
|
interface_reqs inre
|
|
WHERE inre.inre_id = irpa.inre_id
|
|
AND inre.request_identifier = l_req_id
|
|
AND irpa.value_mandatory = 'Y'
|
|
MINUS
|
|
SELECT srpa.param_name
|
|
FROM service_req_params srpa
|
|
WHERE srpa.sere_id = p_sere_id
|
|
AND srpa.param_value IS NOT NULL));
|
|
--
|
|
-- If no_data_found HAS NOT been raised, an error has occured - set the details up
|
|
--
|
|
add_svc_req_stat(c_inv_param_error);
|
|
--
|
|
caco_debug.putline('Error Point 6');
|
|
--
|
|
EXCEPTION
|
|
WHEN no_data_found THEN
|
|
--
|
|
-- Conversely, if I'm here, everything is OK
|
|
--
|
|
NULL;
|
|
--
|
|
WHEN too_many_rows THEN
|
|
--
|
|
-- If I'm here, I've found more than one row, a great cause for concern...
|
|
--
|
|
add_svc_req_stat(c_inv_param_error);
|
|
--
|
|
caco_debug.putline('Error Point 6');
|
|
--
|
|
END;
|
|
--
|
|
EXCEPTION
|
|
--
|
|
WHEN no_data_found THEN
|
|
--
|
|
add_svc_req_stat(c_inv_miss_error);
|
|
--
|
|
caco_debug.putline('Error Point 5');
|
|
--
|
|
END;
|
|
--
|
|
-- EFT wants us to check login before any XML errors are spat out by the insert into service_req_xml
|
|
--
|
|
-- Call the security package to process the logon
|
|
caco_security.process_interface_logon(p_username => get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => 'user'),
|
|
p_password => get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => 'password'),
|
|
p_success => l_login_success,
|
|
p_message => l_login_message);
|
|
--
|
|
IF l_login_success THEN
|
|
caco_debug.putline('Before converting');
|
|
/* convert from CLOB to XML and insert */
|
|
l_xml_data_clob := get_array_value_clob(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => 'xmldata');
|
|
caco_debug.putline('SP001');
|
|
caco_debug.putline('length: '||length(l_xml_data_clob));
|
|
SELECT serx_seq.NEXTVAL
|
|
INTO l_serx_id
|
|
FROM dual;
|
|
|
|
caco_debug.putline('Inserting the service xml');
|
|
BEGIN
|
|
--
|
|
INSERT INTO service_req_xml
|
|
(serx_id,
|
|
sere_id,
|
|
xml_data)
|
|
VALUES
|
|
(l_serx_id,
|
|
p_sere_id,
|
|
sys.xmltype.createxml(l_xml_data_clob));
|
|
--
|
|
caco_debug.putline('SP002');
|
|
--
|
|
EXCEPTION
|
|
WHEN OTHERS THEN
|
|
add_svc_req_stat(c_xml_parsing_error);
|
|
--
|
|
caco_debug.putline('SP003');
|
|
caco_debug.putline(c_xml_parsing_error||' '||SQLCODE||' - '||SQLERRM);
|
|
add_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_name => c_xml_parsing_failure_rsn,
|
|
p_value => SQLCODE||' - '||SQLERRM);
|
|
END;
|
|
caco_debug.putline('SP004');
|
|
--
|
|
ELSE
|
|
-- Login not successful for some reason
|
|
add_svc_req_stat(l_login_message);
|
|
--
|
|
END IF;
|
|
--
|
|
END IF;
|
|
--
|
|
END IF;
|
|
--
|
|
END IF;
|
|
--
|
|
END validate_service_request;
|
|
--
|
|
-- Invoke the specified legacy interface component
|
|
--
|
|
PROCEDURE invoke_legacy_interface(p_name_array IN OUT owa.vc_arr,
|
|
p_value_array IN OUT clob_arr,
|
|
p_sere_id IN service_reqs.sere_id%TYPE DEFAULT g_sere_id) IS
|
|
|
|
--
|
|
-- Local variables
|
|
--
|
|
l_interface_id interface_reqs.request_identifier%TYPE;
|
|
|
|
--
|
|
BEGIN
|
|
|
|
BEGIN
|
|
--
|
|
SELECT inre.request_identifier
|
|
INTO l_interface_id
|
|
FROM service_reqs sere,
|
|
interface_reqs inre
|
|
WHERE sere.request_id = inre.request_identifier
|
|
AND sere.sere_id = p_sere_id;
|
|
--
|
|
EXCEPTION
|
|
WHEN OTHERS
|
|
THEN
|
|
l_interface_id := NULL;
|
|
|
|
END;
|
|
--
|
|
IF l_interface_id = 60 -- nominations interface
|
|
THEN
|
|
caco_debug.putline('before calling the cust nom interface');
|
|
--
|
|
-- Set up the global arrays ready for invoking the interface
|
|
--
|
|
efno_xml_interface.g_name_array := p_name_array;
|
|
efno_xml_interface.g_value_array := p_value_array;
|
|
efno_xml_interface.g_sere_id := p_sere_id;
|
|
--
|
|
-- Call the interface
|
|
--
|
|
BEGIN
|
|
caco_debug.putline('before call to efno_xml_interface.process_xml_message');
|
|
efno_xml_interface.process_xml_message;
|
|
caco_debug.putline('after call to efno_xml_interface.process_xml_message');
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
|
|
caco_debug.putline('error - '||sqlcode||' - '||SQLERRM);
|
|
--
|
|
-- Add the service status flag
|
|
--
|
|
add_array_value(p_name_array => efno_xml_interface.g_name_array,
|
|
p_value_array => efno_xml_interface.g_value_array,
|
|
p_name => c_service_request_status,
|
|
p_value => c_failure);
|
|
--
|
|
add_array_value(p_name_array => efno_xml_interface.g_name_array,
|
|
p_value_array => efno_xml_interface.g_value_array,
|
|
p_name => c_service_request_status_rsn,
|
|
p_value => c_execution_failure || ': ' ||
|
|
SQLERRM);
|
|
--
|
|
caco_debug.putline(g_package_name || ' ' || 'ERROR - ' ||
|
|
SQLERRM);
|
|
--
|
|
END;
|
|
|
|
--
|
|
-- Reset passed in parameters
|
|
--
|
|
p_name_array := efno_xml_interface.g_name_array;
|
|
p_value_array := efno_xml_interface.g_value_array;
|
|
--
|
|
-- Finished processing, tidy up arrays
|
|
--
|
|
efno_xml_interface.g_name_array.DELETE;
|
|
efno_xml_interface.g_value_array.DELETE;
|
|
--
|
|
END IF;
|
|
--
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
|
|
caco_debug.putline('error - '||sqlcode||' - '||SQLERRM);
|
|
|
|
cout_err.report_and_stop(p_exception_number => SQLCODE
|
|
,p_exception_message => SQLERRM
|
|
);
|
|
|
|
END invoke_legacy_interface;
|
|
--
|
|
-- Construct a response in the require format to the HTTP stream
|
|
--
|
|
PROCEDURE produce_service_response(p_name_array IN OUT owa.vc_arr,
|
|
p_value_array IN OUT clob_arr,
|
|
p_sere_id IN service_reqs.sere_id%TYPE DEFAULT g_sere_id) IS
|
|
--
|
|
l_xmldata service_req_params.param_value%TYPE;
|
|
l_service_request_status_rsn VARCHAR2(1000);
|
|
l_xml_validation_failure_rsn VARCHAR2(1000);
|
|
l_xml_parsing_failure_rsn VARCHAR2(1000);
|
|
l_error_code NUMBER;
|
|
--
|
|
PROCEDURE insert_srre(p_sere_id IN service_req_resps.sere_id%TYPE DEFAULT g_sere_id,
|
|
p_param_name IN service_req_resps.param_name%TYPE,
|
|
p_param_value IN service_req_resps.param_value%TYPE) IS
|
|
BEGIN
|
|
--
|
|
INSERT INTO service_req_resps
|
|
(sere_id,
|
|
param_name,
|
|
param_value)
|
|
VALUES
|
|
(p_sere_id,
|
|
p_param_name,
|
|
p_param_value);
|
|
--
|
|
END insert_srre;
|
|
--
|
|
BEGIN
|
|
caco_debug.putline('Produce Response');
|
|
--
|
|
-- Only log the response if the request has been recorded
|
|
--
|
|
IF p_sere_id IS NOT NULL THEN
|
|
--
|
|
-- Check to see if the service_request_status has been included, if not, include it.
|
|
--
|
|
IF get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => c_service_request_status) IS NULL THEN
|
|
--
|
|
-- Not included, therefore add it an assume success
|
|
--
|
|
caco_debug.putline('Add statuses');
|
|
add_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_name => c_service_request_status,
|
|
p_value => c_success);
|
|
add_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_name => c_service_request_status_rsn,
|
|
p_value => '');
|
|
--
|
|
END IF;
|
|
-- insert service request status and reason into service_req_resps
|
|
insert_srre(p_param_name => c_service_status,
|
|
p_param_value => get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => c_service_request_status));
|
|
--
|
|
insert_srre(p_param_name => c_service_status_reason,
|
|
p_param_value => get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => c_service_request_status_rsn));
|
|
--
|
|
-- If a validation failure occured, build failure response
|
|
--
|
|
IF nvl(get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => c_service_request_status),
|
|
'x') = c_failure THEN
|
|
--
|
|
l_service_request_status_rsn := get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => c_service_request_status_rsn);
|
|
--
|
|
-- get the error code
|
|
--
|
|
l_error_code := (get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => c_error_code));
|
|
IF l_error_code IS NULL THEN
|
|
--
|
|
l_error_code := get_error_code(l_service_request_status_rsn);
|
|
--
|
|
END IF;
|
|
--
|
|
IF l_service_request_status_rsn = 'XML validation failed' THEN
|
|
l_xml_validation_failure_rsn := get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => c_xml_validation_failure_rsn);
|
|
--
|
|
l_service_request_status_rsn := caco_utilities.get_module_text(3937,g_lang)||': '||l_xml_validation_failure_rsn;
|
|
--
|
|
ELSIF l_service_request_status_rsn = 'XML parsing error' THEN
|
|
l_xml_parsing_failure_rsn := get_array_value(p_name_array => p_name_array,
|
|
p_value_array => p_value_array,
|
|
p_scan_name => c_xml_parsing_failure_rsn);
|
|
--
|
|
l_service_request_status_rsn := caco_utilities.get_module_text(3942,g_lang)||': '||replace(replace(l_xml_parsing_failure_rsn,'<','<'),'>','>');
|
|
--
|
|
ELSE
|
|
--
|
|
l_service_request_status_rsn := l_service_request_status_rsn;
|
|
--
|
|
END IF;
|
|
--
|
|
htp.p('<?xml version="1.0" encoding="utf-8"?>');
|
|
htp.p(c_msg_start);
|
|
htp.p('<error>'||
|
|
l_service_request_status_rsn||
|
|
'</error>');
|
|
htp.p('<error_code>'||
|
|
l_error_code||
|
|
'</error_code>');
|
|
htp.p(c_msg_end);
|
|
--
|
|
ELSE
|
|
-- output original xml with status, reason and reason_code tags aswell
|
|
FOR i IN (SELECT srpa.param_value
|
|
FROM service_req_params srpa
|
|
WHERE srpa.sere_id = p_sere_id
|
|
AND srpa.param_name = 'xmldata') LOOP
|
|
--
|
|
-- determine if we need to output an xml header
|
|
--
|
|
IF instr(i.param_value,'<?xml') = 0 THEN
|
|
htp.p('<?xml version="1.0" encoding="utf-8"?>');
|
|
END IF;
|
|
--
|
|
l_xmldata := replace(i.param_value,'</language>','</language><status>valid</status><reason></reason><reason_code></reason_code>');
|
|
l_xmldata := replace(l_xmldata,'</value>','</value><reason></reason><reason_code></reason_code>');
|
|
caco_debug.putline('---------------SP outputting xmldata to screen');
|
|
caco_debug.putline('xmldata length: '||length(l_xmldata));
|
|
IF length(l_xmldata) > 32000 THEN
|
|
-- insert Nomination successfully created (Nomination body too long to be displayed) message into reason tag
|
|
l_xmldata := replace(l_xmldata,'<reason></reason>','<reason>'||caco_utilities.get_module_text(3960)||'</reason>');
|
|
-- remove the nomination body
|
|
l_xmldata := substr(l_xmldata,1,instr(l_xmldata,'<nomination_body>')-1);
|
|
l_xmldata := l_xmldata||'<nomination_body></nomination_body></nomination>';
|
|
END IF;
|
|
htp.p(l_xmldata);
|
|
--
|
|
END LOOP;
|
|
--
|
|
END IF;
|
|
--
|
|
ELSE
|
|
--
|
|
-- I've not recorded anything, return the error messages
|
|
--
|
|
htp.p(c_msg_start || '=' || chr(10));
|
|
--
|
|
FOR x IN 1 .. p_name_array.COUNT LOOP
|
|
--
|
|
htp.p(p_name_array(x) || '=' || p_value_array(x) || chr(10));
|
|
--
|
|
END LOOP;
|
|
--
|
|
htp.p(c_msg_end || '=' || chr(10));
|
|
--
|
|
END IF;
|
|
--
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
|
|
caco_debug.putline('error - '||sqlcode||' - '||SQLERRM);
|
|
|
|
cout_err.report_and_stop(p_exception_number => SQLCODE
|
|
,p_exception_message => SQLERRM
|
|
);
|
|
|
|
END produce_service_response;
|
|
--
|
|
-- Public Procedural Logic
|
|
--
|
|
PROCEDURE service_request(name_array IN owa.vc_arr DEFAULT g_vc_arr,
|
|
value_array IN owa.vc_arr DEFAULT g_vc_arr) IS
|
|
--
|
|
l_clob_arr clob_arr;
|
|
--
|
|
BEGIN
|
|
--
|
|
--
|
|
--
|
|
FOR i IN 1..value_array.COUNT LOOP
|
|
--
|
|
l_clob_arr(i) := value_array(i);
|
|
--
|
|
END LOOP;
|
|
--
|
|
service_request_clob( name_array
|
|
, l_clob_arr);
|
|
--
|
|
g_clob_arr := l_clob_arr;
|
|
--
|
|
END service_request;
|
|
|
|
PROCEDURE service_request_clob(name_array IN owa.vc_arr DEFAULT g_vc_arr,
|
|
value_array IN clob_arr DEFAULT g_clob_arr) IS
|
|
--
|
|
-- Variables
|
|
--
|
|
l_name_array owa.vc_arr;
|
|
l_value_array clob_arr;
|
|
--
|
|
BEGIN
|
|
caco_debug.putline('Service request');
|
|
--
|
|
-- Set up local copies of the passed in variables
|
|
--
|
|
l_name_array := name_array;
|
|
l_value_array := value_array;
|
|
--
|
|
-- Call the validation routine
|
|
--
|
|
validate_service_request(p_name_array => l_name_array,
|
|
p_value_array => l_value_array,
|
|
p_sere_id => g_sere_id);
|
|
--
|
|
-- If a validation failure didn't occur, call the legacy interface
|
|
--
|
|
IF nvl(get_array_value(p_name_array => l_name_array,
|
|
p_value_array => l_value_array,
|
|
p_scan_name => c_service_request_status),
|
|
'x') <> c_failure THEN
|
|
--
|
|
-- If the request has validated OK
|
|
--
|
|
invoke_legacy_interface(p_name_array => l_name_array,
|
|
p_value_array => l_value_array);
|
|
--
|
|
END IF;
|
|
--
|
|
-- Now produce a servire response, regardless of whether the legacy interface has been contacted.
|
|
--
|
|
caco_debug.putline('End invoke legacy interface, responding');
|
|
--
|
|
produce_service_response(p_name_array => l_name_array,
|
|
p_value_array => l_value_array);
|
|
--
|
|
caco_debug.putline('Produced response ok');
|
|
--
|
|
-- Finished processing, tidy up
|
|
--
|
|
l_name_array.DELETE;
|
|
l_value_array.DELETE;
|
|
--
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
cout_err.report_and_go(p_exception_number => SQLCODE
|
|
,p_exception_message => SQLERRM
|
|
);
|
|
|
|
END service_request_clob;
|
|
--
|
|
-- Test interface procedure
|
|
--
|
|
PROCEDURE test_interface IS
|
|
--
|
|
l_script_path VARCHAR2(1000) := lower(owa_util.get_cgi_env('REQUEST_PROTOCOL') ||
|
|
'://' ||
|
|
owa_util.get_cgi_env('HTTP_HOST') ||
|
|
owa_util.get_cgi_env('SCRIPT_NAME') || '/');
|
|
--
|
|
BEGIN
|
|
--
|
|
IF NOT
|
|
caco_security.security_check(p_package_name => 'amfr_message_handler.test_interface') THEN
|
|
--
|
|
RETURN;
|
|
--
|
|
END IF;
|
|
--
|
|
htp.htmlopen;
|
|
htp.headopen;
|
|
htp.title('Test EFT Interface');
|
|
htp.style(cstyle => 'body,td,div,.p,a{font-family:arial,sans-serif; color:#F21C0A; font-size:10pt;} h1 {font-size:1.4em;padding:0px;margin:0px;}');
|
|
htp.headclose;
|
|
htp.bodyopen;
|
|
--
|
|
htp.header(nsize => 1,
|
|
cheader => 'Test EFT Interface');
|
|
--
|
|
htp.para;
|
|
htp.italic('This page is for internal use for GL only.','style="color:black"');
|
|
htp.para;
|
|
--
|
|
FOR i IN (SELECT inre.NAME,
|
|
inre.request_identifier,
|
|
inre.inre_id
|
|
FROM interface_reqs inre
|
|
) LOOP
|
|
--
|
|
--
|
|
--
|
|
htp.header(nsize => 2,
|
|
cheader => i.NAME);
|
|
--
|
|
htp.formopen(curl => l_script_path ||
|
|
'!amfr_message_handler.service_request',
|
|
cmethod => 'POST',
|
|
cattributes => 'NAME=form' || i.request_identifier);
|
|
htp.tableopen;
|
|
--
|
|
FOR j IN (SELECT irpa.param_name || decode(irpa.param_mandatory,
|
|
'Y',
|
|
'(*)',
|
|
NULL) AS label,
|
|
irpa.param_name,
|
|
irpa.value_clob,
|
|
decode(irpa.param_name,
|
|
'request_id',
|
|
i.request_identifier,
|
|
NULL) AS def_val
|
|
FROM interface_req_params irpa
|
|
WHERE irpa.inre_id = i.inre_id) LOOP
|
|
--
|
|
--
|
|
--
|
|
htp.tablerowopen;
|
|
htp.tabledata(htf.bold(j.label,'style="color:black"'));
|
|
IF j.value_clob = 'Y' THEN
|
|
htp.tabledata(htf.formtextarea(cname => j.param_name,
|
|
nrows => 8,
|
|
ncolumns => 40));
|
|
ELSE
|
|
htp.tabledata(htf.formtext(cname => j.param_name,
|
|
cvalue => j.def_val));
|
|
END IF;
|
|
htp.tablerowclose;
|
|
--
|
|
END LOOP;
|
|
--
|
|
htp.tableclose;
|
|
--
|
|
htp.anchor(curl => 'javascript:document.form' ||
|
|
i.request_identifier || '.submit();',
|
|
ctext => 'Test');
|
|
--
|
|
htp.formclose;
|
|
--
|
|
END LOOP;
|
|
--
|
|
htp.formclose;
|
|
--
|
|
htp.bodyclose;
|
|
htp.htmlclose;
|
|
--
|
|
END test_interface;
|
|
--
|
|
FUNCTION about RETURN VARCHAR2 IS
|
|
--
|
|
--
|
|
BEGIN
|
|
--
|
|
--
|
|
--
|
|
RETURN(g_package_name || chr(10) || g_revision || chr(10) || g_header);
|
|
--
|
|
END about;
|
|
--
|
|
BEGIN
|
|
--
|
|
-- Package Initialisation
|
|
--
|
|
NULL;
|
|
--
|
|
END amfr_message_handler;
|
|
/
|