Using Custom Business Logic before/event handlers is it possible to open up a network connection with an outside source? If not, is such a feature planned on the roadmap? It’s a feature many people would want for CBL to integrate with external systems, REST APIs etc.
Following the OrderManagement tutorial I implemented the following code but get a SocketPermission error after deploying it to the production environment trying to pull the HTML contents from http://edition.cnn.com.
Code:
@Override
public void beforeCreate( RunnerContext context, Order order ) throws Exception
{
// add your code here
String openURL = "http://edition.cnn.com/index.html";
System.out.println( "opening URL: " + openURL);
URL u;
InputStream is = null;
DataInputStream dis;
String s;
u = new URL(openURL);
is = u.openStream();
dis = new DataInputStream(new BufferedInputStream(is));
while ((s = dis.readLine()) != null) {
System.out.println(s);
}
is.close();
}
Error after running curl client:
$ curl -H application-id:XXXXX -H secret-key:XXXXX -H Content-Type:application/json -X POST -d "{\"customername\":\"foobar corp\"}" -v https://api.backendless.com/v1/data/Order
* Adding handle: conn: 0x7f9b1480cc00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f9b1480cc00) send_pipe: 1, recv_pipe: 0
* About to connect() to api.backendless.com port 443 (#0)
* Trying 54.208.108.141...
* Connected to api.backendless.com (54.208.108.141) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
* Server certificate: *.backendless.com
* Server certificate: Starfield Secure Certification Authority
* Server certificate: Starfield Class 2 Certification Authority
> POST /v1/data/Order HTTP/1.1
> User-Agent: curl/7.30.0
> Host: api.backendless.com
> Accept: */*
> application-id:XXXXX
> secret-key:XXXXXX
> Content-Type:application/json
> Content-Length: 30
>
* upload completely sent off: 30 out of 30 bytes
< HTTP/1.1 400 Bad Request
* Server nginx/1.4.2 is not blacklisted
< Server: nginx/1.4.2
< Date: Fri, 13 Jun 2014 08:56:05 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 111
< Connection: keep-alive
< Access-Control-Allow-Headers: origin, application-id, application-type, content-type, secret-key, request, user-token
< Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
< Access-Control-Allow-Origin: *
<
* Connection #0 to host api.backendless.com left intact
{"message":"access denied (\"java.net.SocketPermission\" \"edition.cnn.com:80\" \"connect,resolve\")","code":0}