diff --git a/ccsrc/Protocols/Json/json_codec.cc b/ccsrc/Protocols/Json/json_codec.cc index 38054913b81b1a8f91e37aeaa90c18023ab10ed8..6c57224136dcb85fff625c1a08521a0f0b52e887 100644 --- a/ccsrc/Protocols/Json/json_codec.cc +++ b/ccsrc/Protocols/Json/json_codec.cc @@ -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; diff --git a/ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn b/ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn index b152929a8da91f69cb366751c82b3d5addd823c4..b68d530a27b0c8700e4db702a7667f2561f9cd48 100644 --- a/ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn +++ b/ttcn/AtsMec/AtsMec_LocationAPI_TestCases.ttcn @@ -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( diff --git a/ttcn/AtsMec/AtsMec_RadioNodeLocationAPI_TestCases.ttcn b/ttcn/AtsMec/AtsMec_RadioNodeLocationAPI_TestCases.ttcn index 0a11d382cd2e2a9c5f77179cf2951a1e9ca86c2b..d829b548dc708f42901d505d8703a9b0ba9c58c7 100644 --- a/ttcn/AtsMec/AtsMec_RadioNodeLocationAPI_TestCases.ttcn +++ b/ttcn/AtsMec/AtsMec_RadioNodeLocationAPI_TestCases.ttcn @@ -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 ) ) diff --git a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Pixits.ttcn b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Pixits.ttcn index faea124c0eee7150f246dade2b5e685263121149..9b3c7169a0ffa335f06ca53ac7292bd9cf6a231f 100644 --- a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Pixits.ttcn +++ b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Pixits.ttcn @@ -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"; diff --git a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Templates.ttcn b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Templates.ttcn index 2cda43789afd02eeb8b40d21b040eb8bb36917aa..7f86a783dbe70e96d129c402648d9524c5623519 100644 --- a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Templates.ttcn +++ b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_Templates.ttcn @@ -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, diff --git a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_TypesAndValues.ttcn b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_TypesAndValues.ttcn index 9135ea8a9827a54dbaf1d670c4c843a284feb3de..bd158438100ccc95d646b27d33c1ac14479f9881 100644 --- a/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_TypesAndValues.ttcn +++ b/ttcn/LibMec/LocationAPI/ttcn/LocationAPI_TypesAndValues.ttcn @@ -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, diff --git a/ttcn/patch_lib_http/LibItsHttp_JsonMessageBodyTypes.ttcn b/ttcn/patch_lib_http/LibItsHttp_JsonMessageBodyTypes.ttcn index 186b991ca31cd4cd87d8ff3d3f343970a4848337..97d375e1c4b34ea52cd3db624b8c7a4d8d07b248 100644 --- a/ttcn/patch_lib_http/LibItsHttp_JsonMessageBodyTypes.ttcn +++ b/ttcn/patch_lib_http/LibItsHttp_JsonMessageBodyTypes.ttcn @@ -40,6 +40,7 @@ module LibItsHttp_JsonMessageBodyTypes { ZoneInfo zoneInfo, AccessPointList accessPointList, UserTrackingSubscription userTrackingSubscription, + PeriodicTrackingSubscription periodicTrackingSubscription, ZonalTrafficSubscription zonalTrafficSubscription, CircleNotificationSubscription circleNotificationSubscription, TerminalDistance terminalDistance, diff --git a/ttcn/patch_lib_http/LibItsHttp_JsonTemplates.ttcn b/ttcn/patch_lib_http/LibItsHttp_JsonTemplates.ttcn index dc5881da1d8735dc212e52d6a6f92bf943d28d45..2ae706fa1f8e1998c83d00ace96436cc88587915 100644 --- a/ttcn/patch_lib_http/LibItsHttp_JsonTemplates.ttcn +++ b/ttcn/patch_lib_http/LibItsHttp_JsonTemplates.ttcn @@ -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 ) := {