Commit 5b7d84bb authored by Yann Garcia's avatar Yann Garcia

Big fixed on MEC-013 Codec

parent 4b41b857
......@@ -105,8 +105,8 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
loggers::get_instance().log("json_codec::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str());
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
if (it->second.find("\"UserList\"") != std::string::npos) { // Be careful to the order
// TODO To be refined, find("\"userList\"") is not optimal
if (it->second.find("\"userList\"") != std::string::npos) { // Be careful to the order
// TODO To be refined, find("\"userList\"") is not optimal
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
......@@ -120,14 +120,30 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
access_point_list.decode(LocationAPI__TypesAndValues::AccessPointList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.accessPointList() = access_point_list;
} else if (it->second.find("\"userTrackingSubscription\"") != std::string::npos) {
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
LocationAPI__TypesAndValues::UserTrackingSubscription user_tracking_subscription;
user_tracking_subscription.decode(LocationAPI__TypesAndValues::UserTrackingSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.userTrackingSubscription() = user_tracking_subscription;
} else if (it->second.find("\"userInfo\"") != std::string::npos) {
} else if (it->second.find("\"periodicTrackingSubscription\"") != std::string::npos) {
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
LocationAPI__TypesAndValues::PeriodicTrackingSubscription periodic_tracking_subscription;
periodic_tracking_subscription.decode(LocationAPI__TypesAndValues::PeriodicTrackingSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.periodicTrackingSubscription() = periodic_tracking_subscription;
} else if (it->second.find("\"accessPointId\"") != std::string::npos) {
LocationAPI__TypesAndValues::UserInfo user_info;
user_info.decode(LocationAPI__TypesAndValues::UserInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.userInfo() = user_info;
} else if (it->second.find("\"terminalDistance\"") != std::string::npos) {
int idx_begin = it->second.find(":");
int idx_end = it->second.rfind("}") - 1; // Remove the last '}'
str = it->second.substr(idx_begin + 1, idx_end - idx_begin);
TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
LocationAPI__TypesAndValues::TerminalDistance terminal_distance;
terminal_distance.decode(LocationAPI__TypesAndValues::TerminalDistance_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
msg.terminalDistance() = terminal_distance;
......
......@@ -73,13 +73,12 @@ module AtsMec_LocationAPI_TestCases {
mw_http_response(
mw_http_response_ok(
mw_http_message_body_json(
mw_body_json_user_list(
mw_user_list(
{
*,
mw_user_info(PX_USER, PX_ACCESS_POINT_ID, PX_ZONE_ID, PX_RESOURCE_URL),
*
}
mw_body_json_user_info(
mw_user_info(
PX_USER,
PX_ACCESS_POINT_ID,
PX_ZONE_ID,
PX_RESOURCE_URL
)))))) {
tc_ac.stop;
......@@ -493,11 +492,11 @@ module AtsMec_LocationAPI_TestCases {
mw_http_response(
mw_http_response_201_created(
mw_http_message_body_json(
mw_body_json_user_tracking_subscription(
mw_user_tracking_subscription(
PX_CLIENT_ID,
PX_CALLBACK_REF_URL,
PX_USER
mw_body_json_periodic_tracking_subscription(
mw_periodic_tracking_subscription(
PX_CLIENT_ID,
PX_CALLBACK_REF_URL,
PX_USER
)))))) {
tc_ac.stop;
......@@ -952,7 +951,7 @@ module AtsMec_LocationAPI_TestCases {
httpPort.send(
m_http_request(
m_http_request_post(
"/" & PICS_ROOT_API & "invilad/" & PX_ME_APP_Q_USERS_INF_SUB_URI,
"/" & PICS_ROOT_API & "/invilad/" & PX_ME_APP_Q_USERS_INF_SUB_URI,
v_headers,
m_http_message_body_json(
m_body_json_zonal_traffic_subscription(
......
......@@ -69,7 +69,7 @@ module AtsMec_RadioNodeLocationAPI_TestCases {
httpPort.send(
m_http_request(
m_http_request_get(
PX_ME_APP_Q_ZONE_ID_URI & "/" & oct2char(unichar2oct(PX_ZONE_ID, "UTF-8")) & "/accessPoints",
"/" & PICS_ROOT_API & PX_ME_APP_Q_ZONE_ID_URI & "/" & oct2char(unichar2oct(PX_ZONE_ID, "UTF-8")) & "/accessPoints",
v_headers
)
)
......@@ -562,7 +562,7 @@ module AtsMec_RadioNodeLocationAPI_TestCases {
httpPort.send(
m_http_request(
m_http_request_post(
"/" & PICS_ROOT_API & oct2char(unichar2oct(PX_UE_DIST_SUB_URI, "UTF-8")),
"/" & PICS_ROOT_API & PX_ME_APP_Q_DIST_URI,
v_headers,
m_http_message_body_json(
m_body_json_distance_notification_subscription(
......@@ -646,7 +646,7 @@ module AtsMec_RadioNodeLocationAPI_TestCases {
httpPort.send(
m_http_request(
m_http_request_post(
"/" & PICS_ROOT_API & oct2char(unichar2oct(PX_UE_DIST_SUB_URI, "UTF-8")),
"/" & PICS_ROOT_API & PX_ME_APP_Q_DIST_URI,
v_headers,
m_http_message_body_json(
m_body_json_distance_notification_subscription(
......@@ -712,7 +712,7 @@ module AtsMec_RadioNodeLocationAPI_TestCases {
httpPort.send(
m_http_request(
m_http_request_delete(
"/" & PICS_ROOT_API & oct2char(unichar2oct(PX_UE_DIST_SUB_URI, "UTF-8")) & oct2char(unichar2oct(PX_SUBSCRIPTION_ID, "UTF-8")),
"/" & PICS_ROOT_API & PX_ME_APP_Q_DIST_URI & "/" & oct2char(unichar2oct(PX_SUBSCRIPTION_ID, "UTF-8")),
v_headers
)
)
......@@ -766,7 +766,7 @@ module AtsMec_RadioNodeLocationAPI_TestCases {
httpPort.send(
m_http_request(
m_http_request_delete(
"/" & PICS_ROOT_API & oct2char(unichar2oct(PX_UE_DIST_SUB_URI, "UTF-8")) & oct2char(unichar2oct(PX_NON_EXISTENT_SUBSCRIPTION_ID, "UTF-8")),
"/" & PICS_ROOT_API & PX_ME_APP_Q_DIST_URI & "/" & oct2char(unichar2oct(PX_NON_EXISTENT_SUBSCRIPTION_ID, "UTF-8")),
v_headers
)
)
......@@ -827,7 +827,7 @@ module AtsMec_RadioNodeLocationAPI_TestCases {
httpPort.send(
m_http_request(
m_http_request_get(
"/" & PICS_ROOT_API & oct2char(unichar2oct(PX_UE_LOC_USERS_URI)) & "?address=" & oct2char(unichar2oct(PX_ACR_SOME_IP, "UTF-8")),
"/" & PICS_ROOT_API & PX_ME_APP_Q_USERS_LIST_URI,
v_headers
)
)
......
......@@ -37,13 +37,13 @@ module LocationAPI_Pixits {
modulepar CallbackReference PX_CALLBACK_REF_URL := { "http://clientApp.example.com/location_notifications/123456" };
modulepar CallbackReference PX_UE_PERIODIC_SUB_CALLBACK_URI := { "" };
modulepar CallbackReference PX_UE_PERIODIC_SUB_CALLBACK_URI := { "http://clientApp.example.com/location_notifications/123456" };
modulepar Address PX_IP_ADDRESS := "acr:10.0.0.3";
modulepar CallbackReference PX_AREA_SUB_CALLBACK_URI := { "" };
modulepar CallbackReference PX_AREA_SUB_CALLBACK_URI := { "http://clientApp.example.com/location_notifications/123456" };
modulepar CallbackReference PX_UE_DIST_SUB_CALLBACK_URI := { "" };
modulepar CallbackReference PX_UE_DIST_SUB_CALLBACK_URI := { "http://clientApp.example.com/location_notifications/123456" };
modulepar Address PX_UE_MONITORED_IP_ADDRESS := "acr:10.0.0.1";
......
......@@ -174,6 +174,36 @@ module LocationAPI_Templates {
resourceURL := p_resourceURL
} // End of template mw_user_tracking_subscription
template (value) PeriodicTrackingSubscription m_periodic_tracking_subscription(
in ClientCorrelator p_clientCorrelator,
in CallbackReference p_callbackReference,
in Address p_address := PX_USER,
in JSON.Number p_frequency := 10.0,
in JSON.Number p_requestedAccuracy := 10.0
) := {
clientCorrelator := p_clientCorrelator,
callbackReference := p_callbackReference,
address_ := p_address,
frequency := p_frequency,
requestedAccuracy := p_requestedAccuracy,
resourceURL := omit
} // End of template m_periodic_tracking_subscription
template (present) PeriodicTrackingSubscription mw_periodic_tracking_subscription(
template (present) ClientCorrelator p_clientCorrelator := ?,
template (present) CallbackReference p_callbackReference := ?,
template (present) Address p_address := PX_USER,
template (present) JSON.Number p_frequency := ?,
template (present) JSON.Number p_requestedAccuracy := ?
) := {
clientCorrelator := p_clientCorrelator,
callbackReference := p_callbackReference,
address_ := p_address,
frequency := p_frequency,
requestedAccuracy := p_requestedAccuracy,
resourceURL := *
} // End of template mw_periodic_tracking_subscription
template (value) ZonalTrafficSubscription m_zonal_traffic_subscription(
in ClientCorrelator p_client_correlator,
in CallbackReference p_callback_reference,
......
......@@ -367,6 +367,21 @@ REST_NetAPI_Common].
variant (address_) "name as 'address'";
}
/**
* @desc A type containing periodic tracking subscription.
* @member
*/
type record PeriodicTrackingSubscription {
ClientCorrelator clientCorrelator optional,
CallbackReference callbackReference,
Address address_,
JSON.Number frequency,
JSON.Number requestedAccuracy,
ResourceURL resourceURL optional
} with {
variant (address_) "name as 'address'";
}
/**
* @desc A type containing zonal presence notification
* @member
......@@ -501,6 +516,7 @@ REST_NetAPI_Common].
type record NotificationSubscriptionList {
ZonalTrafficSubscription zonalTrafficSubscription optional,
UserTrackingSubscription userTrackingSubscription optional,
PeriodicTrackingSubscription periodicTrackingSubscription optional,
ZoneStatusSubscription zoneStatusSubscription optional,
CircleNotificationSubscription circleNotificationSubscription optional,
PeriodicNotificationSubscription periodicNotificationSubscription optional,
......
......@@ -40,6 +40,7 @@ module LibItsHttp_JsonMessageBodyTypes {
ZoneInfo zoneInfo,
AccessPointList accessPointList,
UserTrackingSubscription userTrackingSubscription,
PeriodicTrackingSubscription periodicTrackingSubscription,
ZonalTrafficSubscription zonalTrafficSubscription,
CircleNotificationSubscription circleNotificationSubscription,
TerminalDistance terminalDistance,
......
......@@ -458,6 +458,18 @@ group ams_api {
userTrackingSubscription := p_user_tracking_subscription
} // End of template mw_body_json_user_rtracking_subscription
template (value) JsonBody m_body_json_periodic_tracking_subscription(
in template (value) PeriodicTrackingSubscription p_periodic_tracking_subscription
) := {
periodicTrackingSubscription := p_periodic_tracking_subscription
} // End of template m_body_json_periodic_tracking_subscription
template (present) JsonBody mw_body_json_periodic_tracking_subscription(
template (present) PeriodicTrackingSubscription p_periodic_tracking_subscription := ?
) := {
periodicTrackingSubscription := p_periodic_tracking_subscription
} // End of template mw_body_json_periodic_rtracking_subscription
template (value) JsonBody m_body_json_zonal_traffic_subscription(
in template (value) ZonalTrafficSubscription p_zonal_traffic_subscription
) := {
......
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 to comment