Commit a7afe22b by Adi Amir

support v2 ap(s)

parent b45ffe8e
{
"config": {
"metaDataConfig": "logic.adapter.HttpAdapter.model.HttpAdapterConfig",
"configHttpRequestParams": {
"baseUrl": "ie-parking.run.aws-usw02-pr.ice.predix.io/",
"basePath": "v1/",
"headers": [{
"name": "predix-zone-id",
"value": "c54e3e63-8dc6-425e-a533-64e061f64023"
}]
},
"authentication": {
"type": "oauth2",
"credential": {
"uaa": "9deacc64-7c53-4790-9a6c-c9de0fdebcdf.predix-uaa.run.aws-usw02-pr.ice.predix.io/oauth/token",
"clientId": "ipgallery",
"clientSecret": "1PGall3ry"
}
}
},
"flows": [{
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "GetAllParkingSpots",
"httpMethod": "GET",
"path": "locations/search",
"queryParams": [{
"name": "bbox",
"value": "32.123:-117,32.723179:-117.172655"
}, {
"name": "q",
"value": "location-type:PARKING_SPOT"
}, {
"name": "size",
"value": "30"
}],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": [
{
"metaDataActionClass": "logic.adapter.action.ExtractValueAction",
"params": {
"path": "/_embedded/locations",
"valueType": "ARRAY-NODE"
}
}, {
"metaDataActionClass": "logic.adapter.action.JsonConvertAction",
"params": {
"intermediateOperations": [{
"metaDataOperationClass": "logic.adapter.HttpAdapter.model.MapStringToJsonOperation",
"operationParams": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"variables": {
"id": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/_links/self/href",
"valueType": "STRING"
},
"subString": {
"from": {
"str": "/",
"location": "LAST",
"index": null
},
"to": null
}
}
}},
"id": "getLocationDetails",
"httpMethod": "GET",
"path": "locations/$id",
"queryParams": null,
"headers": [],
"content": null
}
}
}
}, {
"metaDataOperationClass": "logic.adapter.HttpAdapter.model.MapJsonToJsonOperation",
"operationParams": {
"action": {
"metaDataActionClass": "logic.adapter.action.JsonPatchAction",
"params": {
"variables": {
"mdeKey": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/_embedded/assets/0/_links/self/href",
"valueType": "STRING"
},
"subString": {
"from": {
"str": "/",
"location": "LAST",
"index": null
},
"to": null
}
}
}
},
"fileInput": null,
"filePatch": "parkingSpotJsonPatch.json"
}
}
}
}],
"terminateOperation": null
}
}]
},
"onError": null
}
}, {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "getLocationDetails",
"httpMethod": "GET",
"path": "locations/$id",
"queryParams": [],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": []
},
"onError": {
"actionsInput": "CONTENT",
"actions": []
}
}
}, {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "subscribe",
"httpMethod": "GET",
"path": "assets/$mdeKey/live-events",
"queryParams": [{
"name": "event-types",
"value": "PKIN,PKOUT"
}],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": [{
"metaDataActionClass": "logic.adapter.HttpAdapter.action.WebSocketAction",
"params": {
"variables": {
"webSocket": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/url",
"valueType": "STRING"
},
"subString": {
"from": null,
"to": null
}
}
}
},
"headers": [{
"name": "predix-zone-id",
"value": "c54e3e63-8dc6-425e-a533-64e061f64023"
}],
"webSocket": "$webSocket",
"mdeKey": "$mdeKey",
"uid": "$uid"
}
}]
},
"onError": {
"actionsInput": "CONTENT",
"actions": []
}
}
}
]
}
\ No newline at end of file
{
"config": {
"metaDataConfig": "logic.adapter.HttpAdapter.model.HttpAdapterConfig",
"configHttpRequestParams": {
"baseUrl": "ie-pedestrian.run.aws-usw02-pr.ice.predix.io/",
"basePath": "v1/",
"headers": [{
"name": "predix-zone-id",
"value": "c1e012d3-653f-4f71-b03d-76810db8d48e"
}]
},
"authentication": {
"type": "oauth2",
"credential": {
"uaa": "9deacc64-7c53-4790-9a6c-c9de0fdebcdf.predix-uaa.run.aws-usw02-pr.ice.predix.io/oauth/token",
"clientId": "ipgallery",
"clientSecret": "1PGall3ry"
}
}
},
"flows": [
{
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "GetAllCrosswalks",
"httpMethod": "GET",
"path": "locations/search",
"queryParams": [{
"name": "bbox",
"value": "32.123:-117,32.723179:-117.172655"
}, {
"name": "q",
"value": "location-type:CROSSWALK"
}, {
"name": "size",
"value": "30"
}],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": [{
"metaDataActionClass": "logic.adapter.action.ExtractValueAction",
"params": {
"path": "/_embedded/locations",
"valueType": "ARRAY-NODE"
}
}, {
"metaDataActionClass": "logic.adapter.action.JsonConvertAction",
"params": {
"intermediateOperations": [{
"metaDataOperationClass": "logic.adapter.HttpAdapter.model.MapStringToJsonOperation",
"operationParams": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"variables": {
"id": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/_links/self/href",
"valueType": "STRING"
},
"subString": {
"from": {
"str": "/",
"location": "LAST",
"index": null
},
"to": null
}
}
}},
"id": "getLocationDetails",
"httpMethod": "GET",
"path": "locations/$id",
"queryParams": null,
"headers": [],
"content": null
}
}
}
},
{
"metaDataOperationClass": "logic.adapter.HttpAdapter.model.MapJsonToJsonOperation",
"operationParams": {
"action": {
"metaDataActionClass": "logic.adapter.action.JsonPatchAction",
"params": {
"variables": {
"mdeKey": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/_embedded/assets/0/_links/self/href",
"valueType": "STRING"
},
"subString": {
"from": {
"str": "/",
"location": "LAST",
"index": null
},
"to": null
}
}
}
},
"fileInput": null,
"filePatch": "crosswalkJsonPatch.json"
}
}
}
}],
"terminateOperation": null
}
}]
},
"onError": null
}
}, {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "getLocationDetails",
"httpMethod": "GET",
"path": "locations/$id",
"queryParams": [],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": []
},
"onError": {
"actionsInput": "CONTENT",
"actions": []
}
}
},
{
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "subscribe",
"httpMethod": "GET",
"path": "assets/$mdeKey/live-events",
"queryParams": [
{
"name": "event-types",
"value": "SFIN,SFOUT"
}
],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": [
{
"metaDataActionClass": "logic.adapter.HttpAdapter.action.WebSocketAction",
"params": {
"variables": {
"webSocket": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/url",
"valueType": "STRING"
},
"subString": {
"from": null,
"to": null
}
}
}
},
"headers": [
{
"name": "predix-zone-id",
"value": "c1e012d3-653f-4f71-b03d-76810db8d48e"
}
],
"webSocket": "$webSocket",
"mdeKey": "$mdeKey",
"uid": "$uid"
}
}
]
},
"onError": {
"actionsInput": "CONTENT",
"actions": []
}
}
}
]
}
\ No newline at end of file
{
"config": {
"metaDataConfig": "logic.adapter.HttpAdapter.model.HttpAdapterConfig",
"configHttpRequestParams": {
"baseUrl": "ie-traffic.run.aws-usw02-pr.ice.predix.io/",
"basePath": "v1/",
"headers": [{
"name": "predix-zone-id",
"value": "b6fc22b6-ad71-423e-867b-a1b197f6cfc2"
}]
},
"authentication": {
"type": "oauth2",
"credential": {
"uaa": "9deacc64-7c53-4790-9a6c-c9de0fdebcdf.predix-uaa.run.aws-usw02-pr.ice.predix.io/oauth/token",
"clientId": "ipgallery",
"clientSecret": "1PGall3ry"
}
}
},
"flows": [
{
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "GetAllTrafficLanes",
"httpMethod": "GET",
"path": "locations/search",
"queryParams": [{
"name": "bbox",
"value": "32.123:-117,32.723179:-117.172655"
}, {
"name": "q",
"value": "location-type:TRAFFIC_LANE"
}, {
"name": "size",
"value": "30"
}],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": [{
"metaDataActionClass": "logic.adapter.action.ExtractValueAction",
"params": {
"path": "/_embedded/locations",
"valueType": "ARRAY-NODE"
}
}, {
"metaDataActionClass": "logic.adapter.action.JsonConvertAction",
"params": {
"intermediateOperations": [{
"metaDataOperationClass": "logic.adapter.HttpAdapter.model.MapStringToJsonOperation",
"operationParams": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"variables": {
"id": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/_links/self/href",
"valueType": "STRING"
},
"subString": {
"from": {
"str": "/",
"location": "LAST",
"index": null
},
"to": null
}
}
}},
"id": "getLocationDetails",
"httpMethod": "GET",
"path": "locations/$id",
"queryParams": null,
"headers": [],
"content": null
}
}
}
},
{
"metaDataOperationClass": "logic.adapter.HttpAdapter.model.MapJsonToJsonOperation",
"operationParams": {
"action": {
"metaDataActionClass": "logic.adapter.action.JsonPatchAction",
"params": {
"variables": {
"mdeKey": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/_embedded/assets/0/_links/self/href",
"valueType": "STRING"
},
"subString": {
"from": {
"str": "/",
"location": "LAST",
"index": null
},
"to": null
}
}
}
},
"fileInput": null,
"filePatch": "trafficLaneJsonPatch.json"
}
}
}
}],
"terminateOperation": null
}
}]
},
"onError": null
}
}, {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "getLocationDetails",
"httpMethod": "GET",
"path": "locations/$id",
"queryParams": [],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": []
},
"onError": {
"actionsInput": "CONTENT",
"actions": []
}
}
},
{
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.SimpleHttpAction",
"params": {
"id": "subscribe",
"httpMethod": "GET",
"path": "assets/$mdeKey/live-events",
"queryParams": [
{
"name": "event-types",
"value": "TFEVT"
}
],
"headers": [],
"content": null
}
},
"onResponse": {
"onSuccess": {
"actionsInput": "CONTENT",
"actions": [
{
"metaDataActionClass": "logic.adapter.HttpAdapter.action.WebSocketAction",
"params": {
"variables": {
"webSocket": {
"action": {
"metaDataActionClass": "logic.adapter.HttpAdapter.action.ExtractSubStringAction",
"extract": {
"path": "/url",
"valueType": "STRING"
},
"subString": {
"from": null,
"to": null
}
}
}
},
"headers": [
{
"name": "predix-zone-id",
"value": "c54e3e63-8dc6-425e-a533-64e061f64023"
}
],
"webSocket": "$webSocket",
"mdeKey": "$mdeKey",
"uid": "$uid"
}
}
]
},
"onError": {
"actionsInput": "CONTENT",
"actions": []
}
}
}
]
}
\ No newline at end of file
{
"adapters": [{
"id": "adapter.ge.parking",
"type": "HttpAdapter"
},
{
"id": "adapter.ge.traffic",
"type": "HttpAdapter"
},
{
"id": "adapter.ge.pedestrian",
"type": "HttpAdapter"
}]
"id": "adapter.v1.ge.parking",
"type": "HttpAdapter"
}, {
"id": "adapter.v1.ge.traffic",
"type": "HttpAdapter"
}, {
"id": "adapter.v1.ge.pedestrian",
"type": "HttpAdapter"
}, {
"id": "adapter.v2.ge.parking",
"type": "HttpAdapter"
}, {
"id": "adapter.v2.ge.traffic",
"type": "HttpAdapter"
}, {
"id": "adapter.v2.ge.pedestrian",
"type": "HttpAdapter"
}]
}
\ No newline at end of file
......@@ -3,21 +3,21 @@
{
"apiIn": "routes",
"actions": [{
"adapterId": "adapter.chicago.transportation",
"adapterId": "adapter.v1.chicago.transportation",
"apiOut": "getroutes"
}]
},
{
"apiIn": "directions",
"actions": [{
"adapterId": "adapter.chicago.transportation",
"adapterId": "adapter.v1.chicago.transportation",
"apiOut": "directions"
}]
},
{
"apiIn": "reports",
"actions": [{
"adapterId": "adapter.chicago.public-safety",
"adapterId": "adapter.v1.chicago.public-safety",
"apiOut": "getReports"
}]
}]
......
......@@ -4,7 +4,7 @@
"apiIn": { "name": "spots", "paramsTypes": null},
"method": "GET",
"actions": [{
"adapterId": "adapter.ge.parking",
"adapterId": "adapter.v1.ge.parking",
"apiOut": "GetAllParkingSpots"
}]
},
......@@ -12,7 +12,7 @@
"apiIn": {"name": "resources/devices/$id", "paramsTypes": ["DIGITS"]},
"method": "GET",
"actions": [{
"adapterId": "adapter.ge.parking",
"adapterId": "adapter.v1.ge.parking",
"apiOut": "getLastEventDetails"
}]
},
......@@ -20,7 +20,7 @@
"apiIn": {"name": "subscribe/$mdeKey/$uid", "paramsTypes": ["DIGITS","NO_CHECK"]},
"method": "POST",
"actions": [{
"adapterId": "adapter.ge.parking",
"adapterId": "adapter.v1.ge.parking",
"apiOut": "subscribe"
}]
}
......
......@@ -4,7 +4,7 @@
"apiIn": { "name": "cross-walks", "paramsTypes": null},
"method": "GET",
"actions": [{
"adapterId": "adapter.ge.pedestrian",
"adapterId": "adapter.v1.ge.pedestrian",
"apiOut": "GetAllCrosswalks"
}]
},
......@@ -12,7 +12,7 @@
"apiIn": {"name": "resources/devices/$id", "paramsTypes": ["DIGITS"]},
"method": "GET",
"actions": [{
"adapterId": "adapter.ge.pedestrian",
"adapterId": "adapter.v1.ge.pedestrian",
"apiOut": "getLastEventDetails"
}]
},
......@@ -20,7 +20,7 @@
"apiIn": {"name": "subscribe/$mdeKey/$uid", "paramsTypes": ["DIGITS","NO_CHECK"]},
"method": "POST",
"actions": [{
"adapterId": "adapter.ge.pedestrian",
"adapterId": "adapter.v1.ge.pedestrian",
"apiOut": "subscribe"
}]
}
......
......@@ -4,7 +4,7 @@
"apiIn": {"name": "subscribe/$mdeKey/$uid", "paramsTypes": ["DIGITS","NO_CHECK"]},
"method": "POST",
"actions": [{
"adapterId": "adapter.ge.traffic",
"adapterId": "adapter.v1.ge.traffic",
"apiOut": "subscribe"
}]
},
......@@ -12,7 +12,7 @@
"apiIn": { "name": "traffic-lanes", "paramsTypes": null},
"method": "GET",
"actions": [{
"adapterId": "adapter.ge.traffic",
"adapterId": "adapter.v1.ge.traffic",
"apiOut": "GetAllTrafficLanes"
}]
}
......
{
"apiList": [
{
"apiIn": { "name": "spots", "paramsTypes": null},
"method": "GET",
"actions": [{
"adapterId": "adapter.v2.ge.parking",
"apiOut": "GetAllParkingSpots"
}]
},
{
"apiIn": {"name": "resources/devices/$id", "paramsTypes": ["DIGITS"]},
"method": "GET",
"actions": [{
"adapterId": "adapter.v2.ge.parking",
"apiOut": "getLastEventDetails"
}]
},
{
"apiIn": {"name": "subscribe/$mdeKey/$uid", "paramsTypes": ["DIGITS","NO_CHECK"]},
"method": "POST",
"actions": [{
"adapterId": "adapter.v2.ge.parking",
"apiOut": "subscribe"
}]
}
]
}
{
"apiList": [
{
"apiIn": { "name": "cross-walks", "paramsTypes": null},
"method": "GET",
"actions": [{
"adapterId": "adapter.v2.ge.pedestrian",
"apiOut": "GetAllCrosswalks"
}]
},
{
"apiIn": {"name": "resources/devices/$id", "paramsTypes": ["DIGITS"]},
"method": "GET",
"actions": [{
"adapterId": "adapter.v2.ge.pedestrian",
"apiOut": "getLastEventDetails"
}]
},
{
"apiIn": {"name": "subscribe/$mdeKey/$uid", "paramsTypes": ["DIGITS","NO_CHECK"]},
"method": "POST",
"actions": [{
"adapterId": "adapter.v2.ge.pedestrian",
"apiOut": "subscribe"
}]
}
]
}
{
"apiList": [
{
"apiIn": {"name": "subscribe/$mdeKey/$uid", "paramsTypes": ["DIGITS","NO_CHECK"]},
"method": "POST",
"actions": [{
"adapterId": "adapter.v2.ge.traffic",
"apiOut": "subscribe"
}]
},
{
"apiIn": { "name": "traffic-lanes", "paramsTypes": null},
"method": "GET",
"actions": [{
"adapterId": "adapter.v2.ge.traffic",
"apiOut": "GetAllTrafficLanes"
}]
}
]
}
{
"services": [ { "id": "ge.parking" } , { "id": "ge.traffic" } , { "id": "ge.pedestrian" }]
"services": [{
"id": "v1.ge.parking"
}, {
"id": "v1.ge.traffic"
}, {
"id": "v1.ge.pedestrian"
}, {
"id": "v2.ge.parking"
}, {
"id": "v2.ge.traffic"
}, {
"id": "v2.ge.pedestrian"
}]
}
\ No newline at end of file
......@@ -96,7 +96,7 @@ public class MdeHandler extends BaseHandler {
private BaseRestResponse validityCheck(RequestContext requestContext) {
String[] params=requestContext.params;
if (params.length>=3)
if (params.length>=4)
return new BaseRestResponse(true,null);
else{
return new BaseRestResponse(false,"missing url parameters. after base url at least "+params.length+ " parameters must be populated");
......
package logic;
import com.fasterxml.jackson.databind.JsonNode;
import http.simpleHttpClient.SimpleHttpResponse;
import logic.adapter.BaseAdapter;
import logic.adapter.HttpAdapter.HttpAdapter;
import logic.adapter.HttpAdapter.RequestParams;
import logic.service.model.Action;
import logic.service.model.Api;
import microservice.RequestContext;
import microservice.types.BaseRestResponse;
import java.util.List;
/**
* Created by adi on 01/03/17.
*/
public class GEManager {
public BaseRestResponse executeRequest(String serviceId, String[] apiIdAsParams, RequestContext requestContext, JsonNode content, boolean isMaintenanceRequest) {
return null;
}
}
......@@ -35,6 +35,8 @@ public class MdeManager {
private AdaptersRepository adaptersRepository;
private ServicesRepository servicesRepository;
private GEManager geManager = new GEManager();
public MdeManager(ILogger logger) throws Exception {
try{
......@@ -66,14 +68,18 @@ public class MdeManager {
boolean isMaintenanceRequest=false;
int offset=0;
if (requestContext.params[0].equals("maintenance")) {
isMaintenanceRequest=true;
isMaintenanceRequest = true;
//to skip first param("maintenance")
offset=1;
offset = 1;
}
serviceId=getServiceId(requestContext, offset);
serviceId = getServiceId(requestContext, offset);
String[] apiIdAsParams = getApiIdAsParams(requestContext,offset);
brr = executeRequest(serviceId,apiIdAsParams,requestContext,null,isMaintenanceRequest);
String ver = serviceId.split("\\.")[0];
if (ver.equals("v2"))
brr = geManager.executeRequest(serviceId,apiIdAsParams,requestContext,null, isMaintenanceRequest);
else
brr = executeRequest(serviceId,apiIdAsParams,requestContext,null,isMaintenanceRequest);
return brr;
}
......@@ -94,10 +100,13 @@ public class MdeManager {
serviceId = getServiceId(requestContext,offset);
String[] apiIdAsParams = getApiIdAsParams(requestContext, offset);
brr = executeRequest(serviceId,apiIdAsParams,requestContext,content, isMaintenanceRequest);
return brr;
String ver = serviceId.split("\\.")[0];
if (ver.equals("v2"))
brr = geManager.executeRequest(serviceId,apiIdAsParams,requestContext,content, isMaintenanceRequest);
else
brr = executeRequest(serviceId,apiIdAsParams,requestContext,content, isMaintenanceRequest);
return brr;
}
private BaseRestResponse executeRequest(String serviceId, String[] apiIdAsParams, RequestContext requestContext, JsonNode content, boolean isMaintenanceRequest) {
......@@ -130,16 +139,29 @@ public class MdeManager {
}
private String getServiceId(RequestContext requestContext, int offset) {
return requestContext.params[offset]+"."+requestContext.params[offset+1];
StringBuilder sb = new StringBuilder();
sb.append(requestContext.params[offset]).append(".") // vX
.append(requestContext.params[offset+1]).append(".") // tenantId
.append(requestContext.params[offset+2]); // serviceId
String serviceId = sb.toString();
return serviceId;
}
private String[] getApiIdAsParams(RequestContext requestContext, int offset) {
String[] params = null;
int size = requestContext.params.length;
if (size-offset>2){
params = new String[size-offset-2];
System.arraycopy(requestContext.params, 2+offset, params,0, size-offset-2);
// int size = requestContext.params.length;
//
// if (size-offset>3){
// params = new String[size-offset-3];
// System.arraycopy(requestContext.params, 3+offset, params,0, size-offset-3);
// }
int apiStart = offset + 3;
String[] params = new String[requestContext.params.length - apiStart];
int k = 0;
for (int i = apiStart; i < requestContext.params.length; i++) {
params[k] = requestContext.params[i];
k++;
}
return params;
}
......
......@@ -15,7 +15,6 @@ import util.zjsonpatch.ZJsonPatch;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -368,7 +367,7 @@ public class WebSocketEventListener implements WebSocketListener {
try {
JsonNode newJsonPatch = Utils.getJsonNodeFromString(jsonPatchStr);
jsonEvent = ZJsonPatch.apply(newJsonPatch, jsonEvent);
this.sendHttpPost(details.getCallBackUrl(), jsonEvent);
this.sendHttpCallback(details.getCallBackUrl(), jsonEvent);
} catch (IOException e) {
logging(connectionId+ " #1 sendEvent failed to send event error: "+e, eTraceLevel.eERROR, false);
}
......@@ -381,11 +380,9 @@ public class WebSocketEventListener implements WebSocketListener {
catch (Exception e) {
logging(connectionId+ " #3 sendEvent failed to send event error: "+e, eTraceLevel.eERROR, false);
}
}
private void sendHttpPost(String callBackUrl, JsonNode jsonEvent) {
private void sendHttpCallback(String callBackUrl, JsonNode jsonEvent) {
SimpleHttpRequest request = new SimpleHttpRequest();
request.setMethod(SimpleHttpRequest.Method.POST);
request.setProtocol("http");
......@@ -393,12 +390,15 @@ public class WebSocketEventListener implements WebSocketListener {
request.setContent(jsonEvent.toString());
try {
SimpleHttpResponse resp = httpClient.processRequest(request);
} catch (UnsupportedEncodingException e) {
if (resp.getStatusCode() == 200)
logging(connectionId + " callback activated succesfully: " + callBackUrl, eTraceLevel.eDEBUG, false);
else
logging(connectionId + " failed to activate callback: " + callBackUrl + ". resp: " + resp.getContent(), eTraceLevel.eERROR, false);
} catch (Exception e) {
e.printStackTrace();
logging(connectionId+ " sendHttpPost failed to send event with error: "+e, eTraceLevel.eERROR, false);
logging(connectionId + " failed to activate callback: " + callBackUrl + " e: " + e, eTraceLevel.eERROR, false);
return;
}
logging(connectionId+ " sendHttpPost event was send successfuly to: "+callBackUrl, eTraceLevel.eDEBUG, false);
}
/**
......
......@@ -32,7 +32,7 @@ public class App {
.withMetrics()
.withMonitoring()
.withPubSub(new IPubSubMQTTImpl("tcp://localhost",0,null,0))
.addHandler("/mde/api/v1", new MdeHandler())
.addHandler("/mde/api", new MdeHandler())
//.addMicroserviceClient(new MicroserviceClient(MicroserviceClient.EnumRestClientType.E_HTTP,clientParams))
.addRestServer(new IRestServerUndertowImpl(new RestServerParams(SERVER_PORT.intValue(), SERVER_HOST, workerThreadsNum.intValue())))
.build()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment