diff --git a/README.md b/README.md index 19a76d4..44ba971 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ in the Context Configuration: | REST_WD | The working directory to be set for every request | | REST_ADAPTERPGM | The adapter, typically RestBCAdapter.bbj | | REST_ADAPTERTERM | The terminal to set, e.g. IO or Tx | -| REST_TIMEOUT | The timeout after which idle background workers terminate. Default: 60 seconds. | +| REST_SERVLET_TIMEOUT | The timeout after which idle background workers terminate. Default: 60 seconds. | | REST_TRACE | The path of a directory to write a SETTRACE of the servlet and the BC Adapter. The directory must exist and be writable. Else the parameter will be ignored | | REST_SERVLET_TIMEOUT | Timeout after which a timeout is sent as response if the worker did not return in this moment. | | REST_KILL_WORKER_AT_TIMEOUT | If set to 1 the worker will be killed when the servlet observes a timeout. If not set or 0, the worker will continue to run, potentially for a long time if the request was bad and leads to long code execution. | diff --git a/RestBCAdapter.bbj b/RestBCAdapter.bbj index 0c3a9da..e97ede7 100644 --- a/RestBCAdapter.bbj +++ b/RestBCAdapter.bbj @@ -94,8 +94,8 @@ done_login: REST_TIMEOUT=60 -if servletParams!.containsKey("REST_TIMEOUT") then - REST_TIMEOUT=num(servletParams!.get("REST_TIMEOUT").toString(),err=*next) +if servletParams!.containsKey("REST_SERVLET_TIMEOUT") then + REST_TIMEOUT=num(servletParams!.get("REST_SERVLET_TIMEOUT").toString(),err=*next) endif diff --git a/RestBridge.bbj b/RestBridge.bbj index 1f6470d..5189be6 100644 --- a/RestBridge.bbj +++ b/RestBridge.bbj @@ -1206,7 +1206,7 @@ class public RestBridge rem *
  • REST_WD
  • rem *
  • REST_ADAPTERPGM
  • rem *
  • REST_ADAPTERTERM
  • - rem *
  • REST_TIMEOUT
  • + rem *
  • REST_SERVLET_TIMEOUT
  • rem *
  • REST_AUTHPGM
  • rem *
  • REST_REQUESTLOG
  • rem *
  • USE_GET_ALLOWED_FILTER
  • @@ -1236,7 +1236,6 @@ class public RestBridge parameterNames!.add("REST_WD") parameterNames!.add("REST_ADAPTERPGM") parameterNames!.add("REST_ADAPTERTERM") - parameterNames!.add("REST_TIMEOUT") parameterNames!.add("REST_SERVLET_TIMEOUT") parameterNames!.add("REST_KILL_WORKER_AT_TIMEOUT") parameterNames!.add("REST_MAX_WORKER_RECYCLECOUNT") diff --git a/cfg/RestBridgeConfigurationWindow.bbj b/cfg/RestBridgeConfigurationWindow.bbj index 2196790..aea9ff7 100644 --- a/cfg/RestBridgeConfigurationWindow.bbj +++ b/cfg/RestBridgeConfigurationWindow.bbj @@ -336,7 +336,7 @@ class public RestBridgeConfigurationWindow servlet! = #reciveBridgeInformation() if (servlet! <> null()) then - error = 1; #setTimeout(num(servlet!.getParameter("REST_TIMEOUT")),err=*next); error = 0 + error = 1; #setTimeout(num(servlet!.getParameter("REST_SERVLET_TIMEOUT")),err=*next); error = 0 if error = 1 then #setTimeout(0) #setMapping(servlet!.getMapping()) @@ -402,7 +402,7 @@ class public RestBridgeConfigurationWindow endif params! = new HashMap() - params!.put("REST_TIMEOUT", str(#getTimeout())) + params!.put("REST_SERVLET_TIMEOUT", str(#getTimeout())) params!.put("REST_WD", #getWorkingDirectoryPath()) params!.put("REST_AUTHPGM", #getAuthProgramPath()) params!.put("REST_PGM_PREFIX", #getProgramPrefix()) @@ -507,7 +507,7 @@ class public RestBridgeConfigurationWindow auth! = bbjHome!.getAbsolutePath().replaceAll("\\|\/", java.io.File.separator,err=*next) params! = new HashMap() - params!.put("REST_TIMEOUT","1000") + params!.put("REST_SERVLET_TIMEOUT","1000") params!.put("REST_WD", "") params!.put("REST_AUTHPGM",auth!) params!.put("REST_PGM_PREFIX","") @@ -737,7 +737,7 @@ class public RestBridgeConfigurationWindow builder!.append("REM Here you can add Parameter to your Birdge."+$0A$) builder!.append("bridgeConf!.addParameter(""REST_ADAPTERPGM"", adapterProgram!.getAbsolutePath())"+$0A$) builder!.append("bridgeConf!.addParameter(""REST_ADAPTERTERM"", ""IO"")"+$0A$) - builder!.append("bridgeConf!.addParameter(""REST_TIMEOUT"",timeOut!)"+$0A$) + builder!.append("bridgeConf!.addParameter(""REST_SERVLET_TIMEOUT"",timeOut!)"+$0A$) builder!.append("bridgeConf!.addParameter(""REST_WD"",workingDirectory!)"+$0A$) builder!.append("bridgeConf!.addParameter(""REST_AUTHPGM"",authpgm!)"+$0A$) builder!.append("bridgeConf!.addParameter(""REST_PGM_PREFIX"",preffix!)"+$0A$) diff --git a/test/CreateTestRestBridge.bbj b/test/CreateTestRestBridge.bbj index da0d35f..8808a05 100644 --- a/test/CreateTestRestBridge.bbj +++ b/test/CreateTestRestBridge.bbj @@ -12,7 +12,7 @@ directory! = new File(path!).getParent() bcDir! = new File(directory!, "test/example-bcs/") config! = context!.addBBxServlet("/rest_test/*", path!, "RestBridge", "service") -config!.addParameter("REST_TIMEOUT", "100") +config!.addParameter("REST_SERVLET_TIMEOUT", "100") config!.addParameter("REST_AUTHPGM", new File(directory!, "authenticate.bbj").getAbsolutePath()) config!.addParameter("REST_WD", bcDir!.getAbsolutePath()) config!.addParameter("REST_PGM_SUFFIX", ".bbj") diff --git a/test/RestBridgeTestConfigurator.bbj b/test/RestBridgeTestConfigurator.bbj index 742c597..a7422b3 100644 --- a/test/RestBridgeTestConfigurator.bbj +++ b/test/RestBridgeTestConfigurator.bbj @@ -49,7 +49,7 @@ class public RestBridgeTestConfigurator #mapping! = "/rest" + str(System.currentTimeMillis()) + "/" config! = context!.addBBxServlet(#mapping! + "*", path!, "RestBridge", "service") - config!.addParameter("REST_TIMEOUT", "100") + config!.addParameter("REST_SERVLET_TIMEOUT", "100") config!.addParameter("REST_AUTHPGM", new File(directory!, "authenticate.bbj").getAbsolutePath()) config!.addParameter("REST_WD", bcDir!.getAbsolutePath()) config!.addParameter("REST_PGM_SUFFIX", ".bbj") diff --git a/test/TestRestBridge.bbjt b/test/TestRestBridge.bbjt index 3f0c5d7..96720c6 100644 --- a/test/TestRestBridge.bbjt +++ b/test/TestRestBridge.bbjt @@ -62,7 +62,7 @@ class public RestBridgeTest #mapping! = "/rest" + str(System.currentTimeMillis()) + "/" config! = context!.addBBxServlet(#mapping! + "*", path!, "RestBridge", "service") - config!.addParameter("REST_TIMEOUT", "100") + config!.addParameter("REST_SERVLET_TIMEOUT", "100") config!.addParameter("REST_AUTHPGM", new File(directory!, "authenticate.bbj").getAbsolutePath()) config!.addParameter("REST_WD", bcDir!.getAbsolutePath()) config!.addParameter("REST_PGM_SUFFIX", ".bbj") diff --git a/test/request-types/TestPOST.bbjt b/test/request-types/TestPOST.bbjt index c5d5e91..40df212 100644 --- a/test/request-types/TestPOST.bbjt +++ b/test/request-types/TestPOST.bbjt @@ -13,6 +13,7 @@ use org.apache.http.client.methods.HttpPost use org.apache.http.client.entity.EntityBuilder use org.apache.http.HttpEntity +use org.apache.http.entity.ContentType class public TestPOST @@ -101,6 +102,45 @@ class public TestPOST rem comparing the JSON Strings Assert.Equals(actualRow!.toJson(0), #insertRow!.toJson(0)) methodend + + rem @Test + method public void testCreateRecordWithSpecialCharactersInBody() + special_param$ = "ÄÖÜßÉÁäöüßéá" + + #uriBuilder!.setPath(#configurator!.getRestBridgeMapping() + "ChileCustomer") + + declare HttpPost request! + request! = #configurator!.getRequestPOST(#uriBuilder!) + request!.setHeader("Accept", "application/json") + request!.setHeader("Content-Type", "application/json; charset=UTF-8") + request!.setHeader("ExecuteBCMethod", "customMethodWithParameter") + + rs! = new ResultSet() + row! = new DataRow() + row!.setFieldValue("param", special_param$) + rs!.add(row!) + + entity! = EntityBuilder.create().setText(rs!.toJson()).setContentType(ContentType.create("application/json", "UTF-8")).build() + request!.setEntity(entity!) + + declare HttpResponse response! + response! = #client!.execute(request!) + + + wasExecuted = BBjAPI().getGlobalNamespace().getKeys().contains("customMethodWithParameter", err=*next) + param! = BBjAPI().getGlobalNamespace().getValue("customMethodWithParameter", err=*next) + BBjAPI().getGlobalNamespace().removeValue("customMethodWithParameter", err=*next) + + if !wasExecuted then + Assert.Fail("The customMethodWithParameter was not executed") + endif + + if param! <> special_param$ then + Assert.Fail("The custom method was executed but the parameter was not processed correctly") + endif + + Assert.Equals(param!, special_param$) + methodend rem @Test method public void testUpdateRecordDataRowBody()