diff --git a/EtsiServerGen/conanfile.txt b/EtsiServerGen/conanfile.txt index 23ea16b7bd222bd3dabd169df59216c3b250034e..f69afee308c93c008d891f59bdf32dfdf0f4190e 100644 --- a/EtsiServerGen/conanfile.txt +++ b/EtsiServerGen/conanfile.txt @@ -1,5 +1,5 @@ [requires] -boost/1.78.0 +boost/1.84.0 restbed/4.8 [generators] diff --git a/EtsiServerGen/patches/applyPatches.sh b/EtsiServerGen/patches/applyPatches.sh index 7bb60bb4ef7553bf6ef124a309ef199e6c59fb2c..f806052ae3e6dafe973abf5f9bfa33f96355b7cd 100755 --- a/EtsiServerGen/patches/applyPatches.sh +++ b/EtsiServerGen/patches/applyPatches.sh @@ -1,15 +1,9 @@ #!/bin/bash patch -u ../api/DefaultApi.h -i fixHeaderModelIssue.patch patch -u ../api/DefaultApi.cpp -i fixCppModelIssue.patch -patch -u ../api/TrackablesApi.cpp -i fixCppTrackable.patch +patch -u ../api/RelocalizationInformationApi.cpp -i fixCppRelocalizationInformation.patch patch -u ../api/WorldAnchorsApi.cpp -i fixCppWorldAnchors.patch +patch -u ../model/WorldAnchor.cpp -i fixCppWorldAnchorModel.patch patch -u ../api/WorldLinksApi.cpp -i fixCppWorldLinks.patch -patch -u ../api/RelocalizationInformationApi.cpp -i fixCppRelocalizationInformation.patch patch -u ../model/WorldLink.cpp -i fixCppWorldLinksModel.patch -patch -u ../model/WorldAnchor.cpp -i fixCppWorldAnchorModel.patch -patch -u ../model/Trackable.cpp -i fixCppTrackableModel.patch -patch -u ../model/helpers.h -i fixHelperHeader.patch -patch -u ../model/RelocalizationInformation.cpp -i fixCppRelocalizationInformationModel.patch -patch -u ../model/RelocalizationInformationParam.cpp -i fixCppRelocalizationInformationParamModel.patch -patch -u ../model/GetRelocalizationInformation_200_response.cpp -i fixCppGetRelocResponse.patch -patch -u ../model/Capability.cpp -i fixCppCapabilityModel.patch + diff --git a/EtsiServerGen/patches/fixCppRelocalizationInformation.patch b/EtsiServerGen/patches/fixCppRelocalizationInformation.patch index d70dfd0faf2f9e01415912215f5ec923d8cd761a..f1f79fc1ff43e3ba7f3628d76ae5793a610718bd 100644 --- a/EtsiServerGen/patches/fixCppRelocalizationInformation.patch +++ b/EtsiServerGen/patches/fixCppRelocalizationInformation.patch @@ -1,78 +1,17 @@ -diff --git a/EtsiServerGen/api/RelocalizationInformationApi.cpp b/../../world-storage-cpp-server/EtsiServerGen/api/RelocalizationInformationApi.cpp -index f332ad2..6ba51b8 100644 ---- a/EtsiServerGen/api/RelocalizationInformationApi.cpp -+++ b/../../world-storage-cpp-server/EtsiServerGen/api/RelocalizationInformationApi.cpp -@@ -22,7 +22,7 @@ - #include <boost/algorithm/string.hpp> - - #include "RelocalizationInformationApi.h" -- -+#include <iostream> - namespace org { - namespace openapitools { - namespace server { -@@ -155,21 +155,28 @@ void RelocalizationInformationResource::defaultSessionClose(const std::shared_pt - - void RelocalizationInformationResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session) - { -+ - const auto request = session->get_request(); - // Getting the query params -- std::string uuids_raw = request->get_query_parameter("uuids"); -+ std::multimap<std::string, std::string> uuids_raw = request->get_query_parameters("uuids"); - std::vector<RelocalizationInformationParam> uuids; -- std::vector<std::string> uuids_temp; -- boost::split(uuids_temp, uuids_raw, boost::is_any_of(",")); -- std::transform(uuids_temp.begin(), uuids_temp.end(), std::back_inserter(uuids), [](const auto& i){ RelocalizationInformationParam ret; ret.fromString(i); return ret;}); -- std::string capabilities_raw = request->get_query_parameter("capabilities"); -+ for (auto it = uuids_raw.begin(); it != uuids_raw.end(); it++) -+ { -+ RelocalizationInformationParam relocInformationParam; -+ relocInformationParam.fromJsonString(it->second); -+ uuids.push_back(relocInformationParam); -+ } -+ std::multimap<std::string, std::string> capabilities_raw = request->get_query_parameters("capabilities"); +--- RelocalizationInformationApi.cpp 2024-08-30 10:10:07.846664769 +0200 ++++ RelocalizationInformationApi_corrected.cpp 2024-08-30 10:05:55.896662600 +0200 +@@ -161,12 +161,12 @@ + std::vector<GetRelocalizationInformation_uuids_parameter_inner> uuids; + std::vector<std::string> uuids_temp; + boost::split(uuids_temp, uuids_raw, boost::is_any_of(",")); +- std::transform(uuids_temp.begin(), uuids_temp.end(), std::back_inserter(uuids), [](const auto& i){ GetRelocalizationInformation_uuids_parameter_inner ret; ret.fromString(i); return ret;}); ++ std::transform(uuids_temp.begin(), uuids_temp.end(), std::back_inserter(uuids), [](const auto& i){ GetRelocalizationInformation_uuids_parameter_inner ret; ret.setUuid(i); return ret;}); + std::string capabilities_raw = request->get_query_parameter("capabilities"); std::vector<Capability> capabilities; -- std::vector<std::string> capabilities_temp; -- boost::split(capabilities_temp, capabilities_raw, boost::is_any_of(",")); + std::vector<std::string> capabilities_temp; + boost::split(capabilities_temp, capabilities_raw, boost::is_any_of(",")); - std::transform(capabilities_temp.begin(), capabilities_temp.end(), std::back_inserter(capabilities), [](const auto& i){ Capability ret; ret.fromString(i); return ret;}); -+ for (auto it = capabilities_raw.begin(); it != capabilities_raw.end(); it++) -+ { -+ Capability capability; -+ capability.fromJsonString(it->second); -+ capabilities.push_back(capability); -+ } ++ std::transform(capabilities_temp.begin(), capabilities_temp.end(), std::back_inserter(capabilities), [](const auto& i){ Capability ret; ret.fromJsonString(i); return ret;}); // Getting the headers std::string token = request->get_header("token", ""); -- -+ - int status_code = 500; - GetRelocalizationInformation_200_response resultObject = GetRelocalizationInformation_200_response{}; - std::string result = ""; -@@ -202,22 +209,22 @@ void RelocalizationInformationResource::handler_GET_internal(const std::shared_p - } - result = resultObject.toJsonString(); -- returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders); -+ returnResponse(session, 200, result.empty() ? "empty" : result, responseHeaders); - return; - } - if (status_code == 400) { - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Invalid UUID supplied."; - -- result = resultObject; -+ result = resultObject.toJsonString(); - returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders); - return; - } - if (status_code == 404) { - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); -- result = "Not found, could not find UUID in database."; -+ result = "Not found, could not find UUID or Supported content in database."; - -- result = resultObject; -+ - returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders); - return; - } diff --git a/EtsiServerGen/patches/fixCppTrackableModel.patch b/EtsiServerGen/patches/fixCppTrackableModel.patch index a867fc9f99f00e03c8b4fc568ac0f66fb95011f6..def0e935e4c918562e3a74647205504b6bd7d2a3 100644 --- a/EtsiServerGen/patches/fixCppTrackableModel.patch +++ b/EtsiServerGen/patches/fixCppTrackableModel.patch @@ -1,16 +1,6 @@ -diff --git a/EtsiServerGen/model/Trackable.cpp b/../../world-storage-cpp-server/EtsiServerGen/model/Trackable.cpp -index de65bd0..26bc26d 100644 ---- a/EtsiServerGen/model/Trackable.cpp -+++ b/../../world-storage-cpp-server/EtsiServerGen/model/Trackable.cpp -@@ -41,6 +41,7 @@ Trackable::Trackable(boost::property_tree::ptree const& pt) - } - - -+ - std::string Trackable::toJsonString(bool prettyJson /* = false */) const - { - std::stringstream ss; -@@ -48,9 +49,12 @@ std::string Trackable::toJsonString(bool prettyJson /* = false */) const +--- Trackable.cpp 2024-08-30 11:59:56.122059845 +0200 ++++ Trackable_corrected.cpp 2024-08-30 15:24:54.948427783 +0200 +@@ -48,6 +48,8 @@ // workaround inspired by: https://stackoverflow.com/a/56395440 std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\""); std::string result = std::regex_replace(ss.str(), reg, "$1"); @@ -19,22 +9,7 @@ index de65bd0..26bc26d 100644 return result; } -+ - void Trackable::fromJsonString(std::string const& jsonString) - { - std::stringstream ss(jsonString); -@@ -65,7 +69,10 @@ ptree Trackable::toPropertyTree() const - ptree tmp_node; - pt.put("UUID", m_UUID); - pt.put("name", m_Name); -+ pt.put("trackablePayload", "|" + m_TrackablePayload + "|" ); - pt.put("creatorUUID", m_CreatorUUID); -+ pt.put("trackableType", m_TrackableType.getEnumValue()); -+ pt.put("unit", m_Unit.getEnumValue()); - pt.add_child("trackableEncodingInformation", m_TrackableEncodingInformation.toPropertyTree()); - // generate tree for LocalCRS - tmp_node.clear(); -@@ -83,9 +90,22 @@ ptree Trackable::toPropertyTree() const +@@ -85,8 +87,19 @@ } // generate tree for KeyvalueTags if (!m_KeyvalueTags.empty()) { @@ -54,27 +29,14 @@ index de65bd0..26bc26d 100644 + } + pt.add_child("keyvalueTags", keyvalueTags); } -+ -+ tmp_node.clear(); pt.put("confidence", m_Confidence); - return pt; -@@ -96,6 +116,8 @@ void Trackable::fromPropertyTree(ptree const &pt) - ptree tmp_node; - m_UUID = pt.get("UUID", ""); - m_Name = pt.get("name", ""); -+ m_TrackableType.setEnumValue(pt.get("trackableType","")); -+ m_Unit.setEnumValue(pt.get("unit","")); - m_CreatorUUID = pt.get("creatorUUID", ""); - if (pt.get_child_optional("trackableEncodingInformation")) { - m_TrackableEncodingInformation = fromPt<EncodingInformationStructure>(pt.get_child("trackableEncodingInformation")); -@@ -111,6 +133,9 @@ void Trackable::fromPropertyTree(ptree const &pt) +@@ -115,6 +128,8 @@ if (pt.get_child_optional("keyvalueTags")) { m_KeyvalueTags = fromPt<std::map<std::string, std::vector<std::string>>>(pt.get_child("keyvalueTags")); } + if (pt.get_child_optional("trackablePayload")) { + m_TrackablePayload = fromPt<std::string>(pt.get_child("trackablePayload")); -+ } m_Confidence = pt.get("confidence", 0.0); } diff --git a/EtsiServerGen/patches/fixCppWorldAnchorModel.patch b/EtsiServerGen/patches/fixCppWorldAnchorModel.patch index ea5e25cecc30a95ed16442484a0ec5a4702a390a..325d8f92463926a24d737e201c82c31646a6460c 100644 --- a/EtsiServerGen/patches/fixCppWorldAnchorModel.patch +++ b/EtsiServerGen/patches/fixCppWorldAnchorModel.patch @@ -1,25 +1,6 @@ -diff --git a/EtsiServerGen/model/WorldAnchor.cpp b/../../world-storage-cpp-server/EtsiServerGen/model/WorldAnchor.cpp -index a26966d..9bf2ac1 100644 ---- a/EtsiServerGen/model/WorldAnchor.cpp -+++ b/../../world-storage-cpp-server/EtsiServerGen/model/WorldAnchor.cpp -@@ -48,6 +48,8 @@ std::string WorldAnchor::toJsonString(bool prettyJson /* = false */) const - // workaround inspired by: https://stackoverflow.com/a/56395440 - std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\""); - std::string result = std::regex_replace(ss.str(), reg, "$1"); -+ result.erase(std::remove(result.begin(), result.end(), '|'), result.end()); -+ - return result; - } - -@@ -66,6 +68,7 @@ ptree WorldAnchor::toPropertyTree() const - pt.put("UUID", m_UUID); - pt.put("name", m_Name); - pt.put("creatorUUID", m_CreatorUUID); -+ pt.put("unit", m_Unit.getEnumValue()); - // generate tree for LocalCRS - tmp_node.clear(); - if (!m_LocalCRS.empty()) { -@@ -82,8 +85,19 @@ ptree WorldAnchor::toPropertyTree() const +--- WorldAnchor.cpp 2024-08-30 16:07:36.273085120 +0200 ++++ WorldAnchor_corrected.cpp 2024-08-30 16:10:28.143238251 +0200 +@@ -83,8 +83,20 @@ } // generate tree for KeyvalueTags if (!m_KeyvalueTags.empty()) { @@ -37,15 +18,8 @@ index a26966d..9bf2ac1 100644 + keyvalueTags.add_child(kv.first,tag_node); + + } -+ pt.add_child("keyvalueTags", keyvalueTags); ++ pt.add_child("keyvalueTags", keyvalueTags); ++ } tmp_node.clear(); return pt; -@@ -95,6 +109,7 @@ void WorldAnchor::fromPropertyTree(ptree const &pt) - m_UUID = pt.get("UUID", ""); - m_Name = pt.get("name", ""); - m_CreatorUUID = pt.get("creatorUUID", ""); -+ m_Unit.setEnumValue(pt.get("unit","")); - // push all items of LocalCRS into member - if (pt.get_child_optional("localCRS")) { - m_LocalCRS = fromPt<std::vector<float>>(pt.get_child("localCRS")); diff --git a/EtsiServerGen/patches/fixCppWorldAnchors.patch b/EtsiServerGen/patches/fixCppWorldAnchors.patch index 51b0dca11d5ac4410e04794f4a9ff035408e375e..c8962f00f167bd5077ab205ee377daeaf537d1cb 100644 --- a/EtsiServerGen/patches/fixCppWorldAnchors.patch +++ b/EtsiServerGen/patches/fixCppWorldAnchors.patch @@ -1,17 +1,14 @@ -diff --git a/EtsiServerGen/api/WorldAnchorsApi.cpp b/../../world-storage-cpp-server/EtsiServerGen/api/WorldAnchorsApi.cpp -index 4d56ab8..36119b5 100644 ---- a/EtsiServerGen/api/WorldAnchorsApi.cpp -+++ b/../../world-storage-cpp-server/EtsiServerGen/api/WorldAnchorsApi.cpp -@@ -20,7 +20,7 @@ - #include <boost/property_tree/json_parser.hpp> +--- WorldAnchorsApi.cpp 2024-08-30 11:59:56.242044753 +0200 ++++ WorldAnchorsApi_corrected.cpp 2024-08-30 15:32:20.829988554 +0200 +@@ -21,6 +21,7 @@ #include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> -- + +#include <iostream> #include "WorldAnchorsApi.h" namespace org { -@@ -159,11 +159,27 @@ void WorldAnchorsResource::defaultSessionClose(const std::shared_ptr<restbed::Se +@@ -159,11 +160,26 @@ session->close(status, result, { {"Connection", "close"} }); } @@ -33,138 +30,39 @@ index 4d56ab8..36119b5 100644 { const auto request = session->get_request(); + int content_length = request->get_header("Content-Length", 0); -+ // body params or form params here from the body content string - std::string bodyContent = extractBodyContent(session); -+ extractBodyContentAsync(session, content_length, [this, session,request](const std::string& bodyContent) { ++ extractBodyContentAsync(session, content_length, [this, session,request](const std::string& bodyContent) { auto worldAnchor = extractJsonModelBodyParam<WorldAnchor>(bodyContent); // Getting the headers std::string token = request->get_header("token", ""); -@@ -234,13 +250,12 @@ void WorldAnchorsResource::handler_POST_internal(const std::shared_ptr<restbed:: - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Unexpected error."; - -- result = resultObject.toJsonString(); -+ result = resultObject; - returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders); +@@ -239,7 +255,7 @@ return; } defaultSessionClose(session, status_code, result); - -- -+ }); ++ }); + } - // x-extension -@@ -280,7 +295,17 @@ void WorldAnchorsResource::handler_GET_internal(const std::shared_ptr<restbed::S - responseHeaders.insert(std::make_pair("Accept", acceptTypes)); - } - -- returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders); -+ std::string rep = "[\n"; -+ for (const WorldAnchor& item : resultObject) { -+ rep += item.toJsonString() + ",\n"; -+ } -+ -+ if (!resultObject.empty()) { -+ -+ rep = rep.substr(0, rep.size() - 2); -+ } -+ rep += "\n]"; -+ returnResponse(session, 200, rep, responseHeaders); - return; - } - if (status_code == 201) { -@@ -289,16 +314,19 @@ void WorldAnchorsResource::handler_GET_internal(const std::shared_ptr<restbed::S - responseHeaders.insert(std::make_pair("Accept", acceptTypes)); - } - -- result = resultObject; -- returnResponse(session, 201, result.empty() ? "{}" : result, responseHeaders); -+ std::string rep; -+ for (const WorldAnchor& item : resultObject) { -+ rep += item.toJsonString() + ",\n"; -+ } -+ -+ returnResponse(session, 201, rep, responseHeaders); - return; - } - if (status_code == 0) { - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Unexpected error."; - -- result = resultObject.toJsonString(); -- returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders); -+ returnResponse(session, 0, result, responseHeaders); - return; - } - defaultSessionClose(session, status_code, result); -@@ -308,8 +336,10 @@ void WorldAnchorsResource::handler_GET_internal(const std::shared_ptr<restbed::S +@@ -309,8 +325,9 @@ // x-extension void WorldAnchorsResource::handler_PUT_internal(const std::shared_ptr<restbed::Session> session) { const auto request = session->get_request(); + int content_length = request->get_header("Content-Length", 0); -+ // body params or form params here from the body content string - std::string bodyContent = extractBodyContent(session); -+ extractBodyContentAsync(session, content_length, [this, session,request](const std::string& bodyContent) { ++ extractBodyContentAsync(session, content_length, [this, session,request](const std::string& bodyContent) { auto worldAnchor = extractJsonModelBodyParam<WorldAnchor>(bodyContent); // Getting the headers std::string token = request->get_header("token", ""); -@@ -370,13 +400,11 @@ void WorldAnchorsResource::handler_PUT_internal(const std::shared_ptr<restbed::S - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Unexpected error."; - -- result = resultObject.toJsonString(); -- returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders); -+ returnResponse(session, 0, result, responseHeaders); +@@ -386,8 +403,7 @@ return; } defaultSessionClose(session, status_code, result); - - -+ }); ++ }); } - std::pair<int, std::string> WorldAnchorsResource::handler_POST( -@@ -507,7 +535,6 @@ void WorldAnchorsWorldAnchorUUIDResource::handler_DELETE_internal(const std::sha - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Invalid UUID supplied."; - -- result = resultObject; - returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders); - return; - } -@@ -515,7 +542,6 @@ void WorldAnchorsWorldAnchorUUIDResource::handler_DELETE_internal(const std::sha - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Not found, could not find UUID in database."; - -- result = resultObject; - returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders); - return; - } -@@ -571,7 +597,6 @@ void WorldAnchorsWorldAnchorUUIDResource::handler_GET_internal(const std::shared - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Invalid UUID supplied."; - -- result = resultObject; - returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders); - return; - } -@@ -579,7 +604,7 @@ void WorldAnchorsWorldAnchorUUIDResource::handler_GET_internal(const std::shared - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Not found, could not find UUID in database."; - -- result = resultObject; -+ - returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders); - return; - } -@@ -600,6 +625,7 @@ std::pair<int, WorldAnchor> WorldAnchorsWorldAnchorUUIDResource::handler_GET( - return handler_GET_func(worldAnchorUUID, token); - } - -+ - std::string WorldAnchorsWorldAnchorUUIDResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) { - const auto request = session->get_request(); - int content_length = request->get_header("Content-Length", 0); + std::pair<int, Error> WorldAnchorsResource::handler_POST( diff --git a/EtsiServerGen/patches/fixCppWorldLinks.patch b/EtsiServerGen/patches/fixCppWorldLinks.patch index 24b4d61a34b4a491d3dd24b25f382194855b70c8..c74b39621832383a3573ad241b1c6b8d04ab1be3 100644 --- a/EtsiServerGen/patches/fixCppWorldLinks.patch +++ b/EtsiServerGen/patches/fixCppWorldLinks.patch @@ -1,8 +1,6 @@ -diff --git a/EtsiServerGen/api/WorldLinksApi.cpp b/../../world-storage-cpp-server/EtsiServerGen/api/WorldLinksApi.cpp -index 543a4ba..589cd28 100644 ---- a/EtsiServerGen/api/WorldLinksApi.cpp -+++ b/../../world-storage-cpp-server/EtsiServerGen/api/WorldLinksApi.cpp -@@ -159,11 +159,27 @@ void WorldLinksResource::defaultSessionClose(const std::shared_ptr<restbed::Sess +--- WorldLinksApi.cpp 2024-08-30 15:39:14.710928653 +0200 ++++ WorldLinksApi_corrected.cpp 2024-08-30 15:39:10.800920831 +0200 +@@ -159,11 +159,26 @@ session->close(status, result, { {"Connection", "close"} }); } @@ -24,20 +22,13 @@ index 543a4ba..589cd28 100644 { const auto request = session->get_request(); + int content_length = request->get_header("Content-Length", 0); -+ // body params or form params here from the body content string - std::string bodyContent = extractBodyContent(session); + extractBodyContentAsync(session, content_length, [this, session,request](const std::string& bodyContent) { auto worldLink = extractJsonModelBodyParam<WorldLink>(bodyContent); // Getting the headers std::string token = request->get_header("token", ""); -@@ -234,13 +250,11 @@ void WorldLinksResource::handler_POST_internal(const std::shared_ptr<restbed::Se - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Unexpected error."; - -- result = resultObject.toJsonString(); -- returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders); -+ returnResponse(session, 0, result, responseHeaders); +@@ -239,8 +254,7 @@ return; } defaultSessionClose(session, status_code, result); @@ -47,95 +38,24 @@ index 543a4ba..589cd28 100644 } // x-extension -@@ -280,7 +294,16 @@ void WorldLinksResource::handler_GET_internal(const std::shared_ptr<restbed::Ses - responseHeaders.insert(std::make_pair("Accept", acceptTypes)); - } - -- returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders); -+ std::string rep = "[\n"; -+ for (const WorldLink& item : resultObject) { -+ rep += item.toJsonString() + ",\n"; -+ } -+ if (!resultObject.empty()) { -+ -+ rep = rep.substr(0, rep.size() - 2); -+ } -+ rep += "\n]"; -+ returnResponse(session, 200, rep, responseHeaders); - return; - } - if (status_code == 201) { -@@ -289,16 +312,19 @@ void WorldLinksResource::handler_GET_internal(const std::shared_ptr<restbed::Ses - responseHeaders.insert(std::make_pair("Accept", acceptTypes)); - } - -- result = resultObject; -- returnResponse(session, 201, result.empty() ? "{}" : result, responseHeaders); -+ std::string rep; -+ for (const WorldLink& item : resultObject) { -+ rep += item.toJsonString() + ",\n"; -+ } -+ -+ returnResponse(session, 201, rep, responseHeaders); - return; - } - if (status_code == 0) { - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Unexpected error."; - -- result = resultObject.toJsonString(); -- returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders); -+ returnResponse(session, 0, result, responseHeaders); - return; - } - defaultSessionClose(session, status_code, result); -@@ -308,8 +334,10 @@ void WorldLinksResource::handler_GET_internal(const std::shared_ptr<restbed::Ses +@@ -309,8 +323,9 @@ // x-extension void WorldLinksResource::handler_PUT_internal(const std::shared_ptr<restbed::Session> session) { const auto request = session->get_request(); + int content_length = request->get_header("Content-Length", 0); -+ // body params or form params here from the body content string - std::string bodyContent = extractBodyContent(session); -+ extractBodyContentAsync(session, content_length, [this, session,request](const std::string& bodyContent) { ++ extractBodyContentAsync(session, content_length, [this, session,request](const std::string& bodyContent) { auto worldLink = extractJsonModelBodyParam<WorldLink>(bodyContent); // Getting the headers std::string token = request->get_header("token", ""); -@@ -370,13 +398,11 @@ void WorldLinksResource::handler_PUT_internal(const std::shared_ptr<restbed::Ses - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Unexpected error."; - -- result = resultObject.toJsonString(); -- returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders); -+ returnResponse(session, 0, result, responseHeaders); +@@ -386,8 +401,7 @@ return; } defaultSessionClose(session, status_code, result); - - -+ }); ++ }); } - std::pair<int, std::string> WorldLinksResource::handler_POST( -@@ -570,17 +596,15 @@ void WorldLinksWorldLinkUUIDResource::handler_GET_internal(const std::shared_ptr - if (status_code == 400) { - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Invalid UUID supplied."; -- -- result = resultObject; -- returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders); -+ -+ returnResponse(session, 400, result, responseHeaders); - return; - } - if (status_code == 404) { - responseHeaders.insert(std::make_pair("Content-Type", "text/plain")); - result = "Not found, could not find UUID in database."; -- -- result = resultObject; -- returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders); -+ -+ returnResponse(session, 404, result, responseHeaders); - return; - } - defaultSessionClose(session, status_code, result); + std::pair<int, Error> WorldLinksResource::handler_POST( diff --git a/EtsiServerGen/patches/fixCppWorldLinksModel.patch b/EtsiServerGen/patches/fixCppWorldLinksModel.patch index f699a2e9878a71b15a7c710043f051c065a58182..f9d2599ba0c5baef7e6322d72c1b5cb1e720e113 100644 --- a/EtsiServerGen/patches/fixCppWorldLinksModel.patch +++ b/EtsiServerGen/patches/fixCppWorldLinksModel.patch @@ -1,35 +1,7 @@ -diff --git a/EtsiServerGen/model/WorldLink.cpp b/../../world-storage-cpp-server/EtsiServerGen/model/WorldLink.cpp -index fd113d9..cefd41e 100644 ---- a/EtsiServerGen/model/WorldLink.cpp -+++ b/../../world-storage-cpp-server/EtsiServerGen/model/WorldLink.cpp -@@ -48,6 +48,9 @@ std::string WorldLink::toJsonString(bool prettyJson /* = false */) const - // workaround inspired by: https://stackoverflow.com/a/56395440 - std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\""); - std::string result = std::regex_replace(ss.str(), reg, "$1"); -+ -+ result.erase(std::remove(result.begin(), result.end(), '|'), result.end()); -+ - return result; - } - -@@ -64,9 +67,12 @@ ptree WorldLink::toPropertyTree() const - ptree pt; - ptree tmp_node; - pt.put("UUID", m_UUID); -+ pt.put("unit", m_Unit.getEnumValue()); - pt.put("creatorUUID", m_CreatorUUID); - pt.put("UUIDFrom", m_UUIDFrom); - pt.put("UUIDTo", m_UUIDTo); -+ pt.put("typeFrom", m_TypeFrom.getEnumValue()); -+ pt.put("typeTo", m_TypeTo.getEnumValue()); - // generate tree for Transform - tmp_node.clear(); - if (!m_Transform.empty()) { -@@ -74,10 +80,22 @@ ptree WorldLink::toPropertyTree() const - pt.add_child("transform", tmp_node); - tmp_node.clear(); - } -+ +--- WorldLink.cpp 2024-08-30 15:49:02.321890614 +0200 ++++ WorldLink_corrected.cpp 2024-08-30 15:50:43.262030987 +0200 +@@ -79,8 +79,19 @@ + pt.put("unit", m_Unit); // generate tree for KeyvalueTags if (!m_KeyvalueTags.empty()) { - tmp_node = toPt(m_KeyvalueTags); @@ -50,17 +22,3 @@ index fd113d9..cefd41e 100644 } tmp_node.clear(); return pt; -@@ -87,9 +105,13 @@ void WorldLink::fromPropertyTree(ptree const &pt) - { - ptree tmp_node; - m_UUID = pt.get("UUID", ""); -+ m_Unit.setEnumValue(pt.get("unit","")); - m_CreatorUUID = pt.get("creatorUUID", ""); - m_UUIDFrom = pt.get("UUIDFrom", ""); - m_UUIDTo = pt.get("UUIDTo", ""); -+ m_Unit.setEnumValue(pt.get("unit","")); -+ m_TypeFrom.setEnumValue(pt.get("typeFrom", "")); -+ m_TypeTo.setEnumValue(pt.get("typeTo", "")); - // push all items of Transform into member - if (pt.get_child_optional("transform")) { - m_Transform = fromPt<std::vector<float>>(pt.get_child("transform")); diff --git a/arf005 b/arf005 index 61f9f881fd6e4df80767f35107ae36750b307395..8be02781f334915d2fa0efabc0f924d97f10922c 160000 --- a/arf005 +++ b/arf005 @@ -1 +1 @@ -Subproject commit 61f9f881fd6e4df80767f35107ae36750b307395 +Subproject commit 8be02781f334915d2fa0efabc0f924d97f10922c diff --git a/package-lock.json b/package-lock.json index 81b1d41b8de15d58884b0e24828f66dedd1632a5..d743d0725449acd75f796a312b4c44abab01984c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "worldstorageserver", - "version": "0.0.1", + "version": "2.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "worldstorageserver", - "version": "0.0.1", + "version": "2.1.0", "devDependencies": { "@openapitools/openapi-generator-cli": "^2.7.0" } @@ -21,14 +21,13 @@ } }, "node_modules/@nestjs/axios": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.1.tgz", - "integrity": "sha512-VlOZhAGDmOoFdsmewn8AyClAdGpKXQQaY1+3PGB+g6ceurGIdTxZgRX3VXc1T6Zs60PedWjg3A82TDOB05mrzQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.2.tgz", + "integrity": "sha512-Z6GuOUdNQjP7FX+OuV2Ybyamse+/e0BFdTWBX5JxpBDKA+YkdLynDgG6HTF04zy6e9zPa19UX0WA2VDoehwhXQ==", "dev": true, "peerDependencies": { "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0", "axios": "^1.3.1", - "reflect-metadata": "^0.1.12", "rxjs": "^6.0.0 || ^7.0.0" } }, @@ -118,17 +117,17 @@ } }, "node_modules/@openapitools/openapi-generator-cli": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.13.1.tgz", - "integrity": "sha512-WJB6MsFXlA69mpKCuR3hBsdFr7MptNhoIGlyvoYEorBQEg3cd6n1gACHx0fz20B3e03/imvorQlNMsrHTIeU9w==", + "version": "2.13.5", + "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.13.5.tgz", + "integrity": "sha512-9VgeKOTiiatKSwZDKKB3C86cW8tN9eDcFohotD4eisdK38UQswk/4Ysoq9KChRCbymjoMp6AIDHPtK1DQ2fTgw==", "dev": true, "hasInstallScript": true, "dependencies": { - "@nestjs/axios": "3.0.1", + "@nestjs/axios": "3.0.2", "@nestjs/common": "10.3.0", "@nestjs/core": "10.3.0", "@nuxtjs/opencollective": "0.3.2", - "axios": "1.6.5", + "axios": "1.7.4", "chalk": "4.1.2", "commander": "8.3.0", "compare-versions": "4.1.4", @@ -136,6 +135,7 @@ "console.table": "0.10.0", "fs-extra": "10.1.0", "glob": "7.2.3", + "https-proxy-agent": "7.0.4", "inquirer": "8.2.6", "lodash": "4.17.21", "reflect-metadata": "0.1.13", @@ -153,6 +153,18 @@ "url": "https://opencollective.com/openapi_generator" } }, + "node_modules/agent-base": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", + "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -199,12 +211,12 @@ "dev": true }, "node_modules/axios": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", - "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", "dev": true, "dependencies": { - "follow-redirects": "^1.15.4", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -492,6 +504,23 @@ "url": "https://opencollective.com/date-fns" } }, + "node_modules/debug": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/defaults": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", @@ -676,6 +705,19 @@ "node": ">=8" } }, + "node_modules/https-proxy-agent": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz", + "integrity": "sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==", + "dev": true, + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -879,6 +921,12 @@ "node": "*" } }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -1298,9 +1346,9 @@ "dev": true }, "@nestjs/axios": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.1.tgz", - "integrity": "sha512-VlOZhAGDmOoFdsmewn8AyClAdGpKXQQaY1+3PGB+g6ceurGIdTxZgRX3VXc1T6Zs60PedWjg3A82TDOB05mrzQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.2.tgz", + "integrity": "sha512-Z6GuOUdNQjP7FX+OuV2Ybyamse+/e0BFdTWBX5JxpBDKA+YkdLynDgG6HTF04zy6e9zPa19UX0WA2VDoehwhXQ==", "dev": true, "requires": {} }, @@ -1341,16 +1389,16 @@ } }, "@openapitools/openapi-generator-cli": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.13.1.tgz", - "integrity": "sha512-WJB6MsFXlA69mpKCuR3hBsdFr7MptNhoIGlyvoYEorBQEg3cd6n1gACHx0fz20B3e03/imvorQlNMsrHTIeU9w==", + "version": "2.13.5", + "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.13.5.tgz", + "integrity": "sha512-9VgeKOTiiatKSwZDKKB3C86cW8tN9eDcFohotD4eisdK38UQswk/4Ysoq9KChRCbymjoMp6AIDHPtK1DQ2fTgw==", "dev": true, "requires": { - "@nestjs/axios": "3.0.1", + "@nestjs/axios": "3.0.2", "@nestjs/common": "10.3.0", "@nestjs/core": "10.3.0", "@nuxtjs/opencollective": "0.3.2", - "axios": "1.6.5", + "axios": "1.7.4", "chalk": "4.1.2", "commander": "8.3.0", "compare-versions": "4.1.4", @@ -1358,6 +1406,7 @@ "console.table": "0.10.0", "fs-extra": "10.1.0", "glob": "7.2.3", + "https-proxy-agent": "7.0.4", "inquirer": "8.2.6", "lodash": "4.17.21", "reflect-metadata": "0.1.13", @@ -1365,6 +1414,15 @@ "tslib": "2.6.2" } }, + "agent-base": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", + "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", + "dev": true, + "requires": { + "debug": "^4.3.4" + } + }, "ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -1396,12 +1454,12 @@ "dev": true }, "axios": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", - "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", "dev": true, "requires": { - "follow-redirects": "^1.15.4", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -1608,6 +1666,15 @@ "integrity": "sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw==", "dev": true }, + "debug": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, "defaults": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", @@ -1742,6 +1809,16 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, + "https-proxy-agent": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz", + "integrity": "sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==", + "dev": true, + "requires": { + "agent-base": "^7.0.2", + "debug": "4" + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -1889,6 +1966,12 @@ "brace-expansion": "^1.1.7" } }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", diff --git a/package.json b/package.json index 35d7b47d0cd451709b68283e6fc67ea73bf99d91..ac8901556f5b6fbfcc8322a632e4096f9cc5d439 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "description": "ISG ARF World Storage Cpp Server", "main": "index.js", "scripts": { - "generate": "cd EtsiServerGen && ./patches/applyYamlPatch.sh && java -jar /usr/local/lib/node_modules/@openapitools/openapi-generator-cli/versions/7.5.0.jar generate -i ../arf005/API/worldstorage/worldstorageopenapiPatched.yaml --skip-validate-spec -g cpp-restbed-server -o . && cd patches && ./applyPatches.sh && sudo rm ../../arf005/API/worldstorage/worldstorageopenapiPatched.yaml", + "generate": "cd EtsiServerGen && java -jar /usr/local/lib/node_modules/@openapitools/openapi-generator-cli/versions/7.5.0.jar generate -i ../arf005/API/worldstorage/worldstorageopenapi.yaml --skip-validate-spec -g cpp-restbed-server -o . && cd patches && ./applyPatches.sh", "build": "cd EtsiServerGen && conan install . --build=missing && cd build && cmake .. --preset conan-release && cd Release && cmake --build . && sudo make install" }, "devDependencies": {