diff --git a/APPL/API/api_gen_import.asp b/APPL/API/api_gen_import.asp index da07f6fc0b..d553f8fdbd 100644 --- a/APPL/API/api_gen_import.asp +++ b/APPL/API/api_gen_import.asp @@ -41,7 +41,16 @@ } "Error 'Operation not Allowed' op de volgende regel betekent meestal dat de upload te groot is"; - var xmlResp = api_gen_import(API, Request.BinaryRead(bytes)); + var result = api_gen_import(API, Request.BinaryRead(bytes)); + xmlResp = result.xmldom; + + if (API.apidata.errorhandling == 1) + { + if (result.anyError) // een 'E' in imp_log + { + Response.Status = '400 Bad Request'; + } + } Response.ContentType = "text/xml"; if (API.apidata.stylesheet_out) @@ -52,5 +61,6 @@ else Response.Write(xmlResp.xml); + ASPPAGE_END(); %> diff --git a/APPL/API/api_gen_import.inc b/APPL/API/api_gen_import.inc index 4f0ebf7e09..a3525e2c87 100644 --- a/APPL/API/api_gen_import.inc +++ b/APPL/API/api_gen_import.inc @@ -11,6 +11,7 @@ Context: Ook vanuit APPL\MARX\API_mareon_opdracht.asp */ +// result: { xmldom: object, anyError: boolean } function api_gen_import(API, data, charset) // { var fileStream = Server.CreateObject("ADODB.Stream"); @@ -72,7 +73,7 @@ function api_gen_import(API, data, charset) // if (import_key > 0) { - var anyError = 0; // hoeveel errors? + var errorCount = 0; // hoeveel errors? var elementDetails = xmlResp.createElement("details"); var sql = "SELECT imp_log_status," + " imp_log_omschrijving," @@ -106,7 +107,7 @@ function api_gen_import(API, data, charset) // if (oRs("imp_log_status").Value != null ) { if (oRs("imp_log_status").Value == 'E' || oRs("imp_log_status").Value == 'F') - anyError ++ + errorCount ++ var elementStatus = xmlResp.createElement("status"); var elementStatusText = xmlResp.createTextNode(oRs("imp_log_status").Value); elementStatus.appendChild(elementStatusText); @@ -143,6 +144,6 @@ function api_gen_import(API, data, charset) // } xmlResp.appendChild(FCLTElement); - return xmlResp; + return { xmldom: xmlResp, anyError: errorCount > 0 }; } %> diff --git a/APPL/FAC/fac_edit_api.asp b/APPL/FAC/fac_edit_api.asp index 9c238e63c5..464c87f182 100644 --- a/APPL/FAC/fac_edit_api.asp +++ b/APPL/FAC/fac_edit_api.asp @@ -12,6 +12,7 @@ + <% FCLTHeader.Requires({ plugins:["jQuery"] }) @@ -25,10 +26,10 @@ var api_omschrijving; var api_apikey; var api_filepath; var api_loglevel; +var api_errorhandling; var usrrap_key; var api_viewmapping_json; var api_stylesheet; -var import_app_key; var api_options_json; var api_xmlnode; @@ -56,14 +57,18 @@ if (api_key > 0) var api_omschrijving = oRs("fac_api_omschrijving").Value; var api_filepath = oRs("fac_api_filepath").Value; var api_loglevel = oRs("fac_api_loglevel").Value; + var api_errorhandling = oRs("fac_api_errorhandling").Value; var usrrap_key = oRs("fac_usrrap_key").Value; var api_viewmapping_json = prettyJson(oRs("fac_api_viewmapping_json").Value); var api_stylesheet = oRs("fac_api_stylesheet").Value; var api_stylesheet_out = oRs("fac_api_stylesheet_out").Value; - var import_app_key = oRs("fac_import_app_key").Value; var api_options_json = prettyJson(oRs("fac_api_options_json").Value); oRs.Close(); } +else +{ + var api_errorhandling = 1; // default 400 on error +} %> @@ -119,6 +124,12 @@ if (api_key > 0) RWFIELDTR("fac_api_omschrijving", "fld", L("lcl_fac_api_omschrijving"), api_omschrijving, {maxlength: 60}); RWFIELDTR("fac_api_filepath", "fld required", L("lcl_fac_api_filepath") , api_filepath, {maxlength: 64}); RWFIELDTR("fac_api_loglevel", "fld", L("lcl_fac_api_loglevel") , api_loglevel); + var sql = " SELECT 0, " + safe.qL("lcl_fac_api_errorhandling0") + " FROM DUAL" + + " UNION ALL SELECT 1, " + safe.qL("lcl_fac_api_errorhandling1") + " FROM DUAL"; + FCLTselector("fac_api_errorhandling", sql, + { initKey: api_errorhandling, + label: L("lcl_fac_api_errorhandling") + }); FCLTrapportselector("fac_usrrap_key" ,"sgRapport" ,{ label: L("lcl_fac_api_usrrap") @@ -128,7 +139,6 @@ if (api_key > 0) RWTEXTAREATR("fac_api_viewmapping_json", "fldtxt", L("lcl_fac_api_viewmapping") , api_viewmapping_json, {maxlength: 4000, no_bb_codes: true}); RWFIELDTR("fac_api_stylesheet", "fld", L("lcl_fac_api_stylesheet") , api_stylesheet, {maxlength: 64}); RWFIELDTR("fac_api_stylesheet_out", "fld", L("lcl_fac_api_stylesheet_out"), api_stylesheet_out, {maxlength: 64}); - RWFIELDTR("fac_import_app_key", "fld", L("lcl_fac_import_app") , import_app_key); RWTEXTAREATR("fac_api_options_json", "fldtxt", L("lcl_fac_api_options") , api_options_json, {maxlength: 4000, no_bb_codes: true}); BLOCK_END(); IFACE.FORM_END(); diff --git a/APPL/FAC/fac_edit_api_save.asp b/APPL/FAC/fac_edit_api_save.asp index 594f1891d8..b266fad58a 100644 --- a/APPL/FAC/fac_edit_api_save.asp +++ b/APPL/FAC/fac_edit_api_save.asp @@ -53,11 +53,11 @@ if (viewjson) var fields = [ { dbs: "fac_api_name", typ: "varchar", frm: "fac_api_name" }, { dbs: "fac_api_filepath", typ: "varchar", frm: "fac_api_filepath" }, { dbs: "fac_api_loglevel", typ: "number", frm: "fac_api_loglevel" }, + { dbs: "fac_api_errorhandling", typ: "number", frm: "fac_api_errorhandling" }, { dbs: "fac_usrrap_key", typ: "key", frm: "fac_usrrap_key" }, { dbs: "fac_api_viewmapping_json", typ: "varchar", val: viewjson, len: 4000}, { dbs: "fac_api_stylesheet", typ: "varchar", frm: "fac_api_stylesheet"}, { dbs: "fac_api_stylesheet_out", typ: "varchar", frm: "fac_api_stylesheet_out"}, - { dbs: "fac_import_app_key", typ: "key", frm: "fac_import_app_key"}, { dbs: "fac_api_options_json", typ: "varchar", val: viewoptions, len: 4000}, { dbs: "fac_api_omschrijving", typ: "varchar", frm: "fac_api_omschrijving", len: 60}]; diff --git a/APPL/FAC/fac_show_api.asp b/APPL/FAC/fac_show_api.asp index 97b0d5d83f..58f7385f0f 100644 --- a/APPL/FAC/fac_show_api.asp +++ b/APPL/FAC/fac_show_api.asp @@ -11,6 +11,7 @@ + <% FCLTHeader.Requires({ plugins:["jQuery"] }) @@ -90,11 +91,19 @@ if (oRs.Eof) }; BLOCK_START("apiSample", L("lcl_fac_api"), { "icon": "fa-network-wired" }); - ROFIELDTR("fld", L("lcl_key") , oRs("fac_api_key").Value); - ROFIELDTR("fld", L("lcl_fac_api_name") , oRs("fac_api_name").Value); - ROFIELDTR("fld", L("lcl_fac_api_omschrijving"), oRs("fac_api_omschrijving").value); - ROFIELDTR("fld", L("lcl_fac_api_filepath") , oRs("fac_api_filepath").Value); - ROFIELDTR("fld", L("lcl_fac_api_loglevel") , oRs("fac_api_loglevel").Value); + ROFIELDTR("fld", L("lcl_key") , oRs("fac_api_key").Value); + ROFIELDTR("fld", L("lcl_fac_api_name") , oRs("fac_api_name").Value); + ROFIELDTR("fld", L("lcl_fac_api_omschrijving") , oRs("fac_api_omschrijving").value); + ROFIELDTR("fld", L("lcl_fac_api_filepath") , oRs("fac_api_filepath").Value); + ROFIELDTR("fld", L("lcl_fac_api_loglevel") , oRs("fac_api_loglevel").Value); + var sql = " SELECT 0, " + safe.qL("lcl_fac_api_errorhandling0") + " FROM DUAL" + + " UNION ALL SELECT 1, " + safe.qL("lcl_fac_api_errorhandling1") + " FROM DUAL"; + FCLTselector("fac_api_errorhandling", sql, + { initKey: oRs("fac_api_errorhandling").Value, + label: L("lcl_fac_api_errorhandling"), + readonly: true + }); + FCLTrapportselector("fac_usrrap_key" ,"sgRapport" ,{ label: L("lcl_fac_api_usrrap") @@ -104,21 +113,8 @@ if (oRs.Eof) ROTEXTAREATR("fldtxt", L("lcl_fac_api_viewmapping") , prettyJson(oRs("fac_api_viewmapping_json").Value)); ROFIELDTR("fld", L("lcl_fac_api_stylesheet") , oRs("fac_api_stylesheet").Value); ROFIELDTR("fld", L("lcl_fac_api_stylesheet_out") , oRs("fac_api_stylesheet_out").Value); - ROFIELDTR("fld", L("lcl_fac_import_app") , oRs("fac_import_app_key").Value); ROTEXTAREATR("fldtxt", L("lcl_fac_api_options") , prettyJson(oRs("fac_api_options_json").Value)); BLOCK_END(); -if (0) // We weten niet welke user te gebruiken? -{ - BLOCK_START("apiSample", L("lcl_fac_api")+" "+L("lcl_fac_api_sample"), { "icon": "fa-eye" }); - var proto = (Request.ServerVariables("SERVER_PORT") == "443")? "https" : "http"; - var sitenoroot = proto + "://" + Request.ServerVariables("SERVER_NAME"); - var site = sitenoroot + rooturl; - var deep = site + "/?API="+oRs("fac_api_name").Value+"&APIKEY="+oRs("fac_api_apikey").Value; - ROFIELDTR("fldtxt",L("lcl_fac_api_sample"), deep); - var deep = site + "/?fac_id="+customerId+"&API="+oRs("fac_api_name").Value+"&APIKEY="+oRs("fac_api_apikey").Value; - ROFIELDTR("fldtxt",L("lcl_fac_api_of"), deep); - BLOCK_END(); -} SUBFRAME_END(); %> diff --git a/APPL/MARX/API_mareon_opdracht.asp b/APPL/MARX/API_mareon_opdracht.asp index 8dfc7b8d3d..c3eefb7347 100644 --- a/APPL/MARX/API_mareon_opdracht.asp +++ b/APPL/MARX/API_mareon_opdracht.asp @@ -368,9 +368,17 @@ if (v_API) var API_imp = new API_func(v_API); // utf-8 moet als parameter mee, b.v. een €-teken in een omschrijving van de XML zorgt ervoor dat de XML ongeldig wordt... - var result = api_gen_import(API_imp, xmlReq.xml, "utf-8"); - - + var resultdata = api_gen_import(API_imp, xmlReq.xml, "utf-8"); + var result = resultdata.xmldom; + + if (API.apidata.errorhandling == 1) + { + if (result.anyError) // een 'E' in imp_log + { + Response.Status = '400 Bad Request'; + } + } + __Log("result:" + result.xml); if (result) { diff --git a/APPL/MARX/api_bct_factuur_import.asp b/APPL/MARX/api_bct_factuur_import.asp index 5f27286190..325a564daf 100644 --- a/APPL/MARX/api_bct_factuur_import.asp +++ b/APPL/MARX/api_bct_factuur_import.asp @@ -67,7 +67,7 @@ var bytes = Request.TotalBytes; if (bytes == 0) { - __DoLog("api_gen_import empty body posted", "#ffff00"); + __DoLog("api_bct_factuur_import empty body posted", "#ffff00"); Response.Write("Error: no data posted for API import"); Response.End; // Grof maar anders AiAi, dat is nog erger }