Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
4 changes: 2 additions & 2 deletions RestBCAdapter.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 1 addition & 2 deletions RestBridge.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ class public RestBridge
rem * <li>REST_WD</li>
rem * <li>REST_ADAPTERPGM</li>
rem * <li>REST_ADAPTERTERM</li>
rem * <li>REST_TIMEOUT</li>
rem * <li>REST_SERVLET_TIMEOUT</li>
rem * <li>REST_AUTHPGM</li>
rem * <li>REST_REQUESTLOG</li>
rem * <li>USE_GET_ALLOWED_FILTER</li>
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions cfg/RestBridgeConfigurationWindow.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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","")
Expand Down Expand Up @@ -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$)
Expand Down
2 changes: 1 addition & 1 deletion test/CreateTestRestBridge.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test/RestBridgeTestConfigurator.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test/TestRestBridge.bbjt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
40 changes: 40 additions & 0 deletions test/request-types/TestPOST.bbjt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down