[Content] Add deprecation to some not frequently used members
[platform/core/api/webapi-plugins.git] / src / content / content_filter.cc
index 130b0d5..e17ce5b 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "common/converter.h"
 #include "common/logger.h"
+#include "common/tools.h"
 
 using common::AttributeMatchFlag;
 using common::CompositeFilterType;
@@ -45,9 +46,12 @@ std::map<std::string, std::string> const attributeNameMap = {
     {"createdDate", "MEDIA_ADDED_TIME"},
     {"releaseDate", "MEDIA_DATETAKEN"},
     {"modifiedDate", "MEDIA_MODIFIED_TIME"},
-    {"geolocation.latitude", "MEDIA_LATITUDE"},
-    {"geolocation.longitude", "MEDIA_LONGITUDE"},
-    {"duration", "MEDIA_DURATION"},
+    {"geolocation.latitude",
+     "MEDIA_LATITUDE"},  // Deprecated since 9.0 //TODO remove after 2 versions
+    {"geolocation.longitude",
+     "MEDIA_LONGITUDE"},  // Deprecated since 9.0 //TODO remove after 2 versions
+    {"duration",
+     "MEDIA_DURATION"},  // Deprecated since 9.0 //TODO remove after 2 versions
     {"album", "MEDIA_ALBUM"},
     {"artists", "MEDIA_ARTIST"},
     {"width", "MEDIA_WIDTH"},
@@ -57,7 +61,7 @@ std::map<std::string, std::string> const attributeNameMap = {
 };
 
 std::string escapeValueString(const std::string& data) {
-  LoggerD("Enter");
+  ScopeLogger();
   std::string out;
   // If string won't be resized, then it will be faster
   out.reserve(data.size());
@@ -81,9 +85,15 @@ std::string escapeValueString(const std::string& data) {
 }  // namespace
 
 PlatformResult ContentFilter::MapField(const std::string& name, std::string* result) {
-  LoggerD("Enter");
+  ScopeLogger();
   auto it = attributeNameMap.find(name);
   if (it != attributeNameMap.end()) {
+    if (name == "rating" || name == "description" ||
+        name == "geolocation.latitude" || name == "geolocation.longitude" ||
+        name == "duration") {
+      std::string warning = "Filtering by attribute '" + name + "'";
+      common::tools::PrintDeprecationWarningFor(warning.c_str());
+    }
     *result = it->second;
   } else {
     return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR);
@@ -93,13 +103,13 @@ PlatformResult ContentFilter::MapField(const std::string& name, std::string* res
 
 PlatformResult ContentFilter::BuildQuery(const picojson::object& jsFilter,
                                          std::string* queryToCall) {
-  LoggerD("Enter");
+  ScopeLogger();
   std::vector<std::vector<std::string>> partialqueries;
   partialqueries.push_back(std::vector<std::string>());
 
   visitor.SetOnAttributeFilter([&](const std::string& name, AttributeMatchFlag match_flag,
                                    const picojson::value& match_value) {
-    LoggerD("entered OnAttributeFilter");
+    ScopeLogger("Entered into asynchronous function, visitor.SetOnAttributeFilter's argument");
 
     std::string query;
     std::string matchValue;
@@ -162,13 +172,13 @@ PlatformResult ContentFilter::BuildQuery(const picojson::object& jsFilter,
   });
 
   visitor.SetOnCompositeFilterBegin([&](CompositeFilterType type) {
-    LoggerD("entered OnCompositeFilterBegin");
+    ScopeLogger("Entered into asynchronous function, visitor.SetOnCompositeFilterBegin's argument");
     partialqueries.push_back(std::vector<std::string>());
     return PlatformResult(ErrorCode::NO_ERROR);
   });
 
   visitor.SetOnCompositeFilterEnd([&](CompositeFilterType calType) {
-    LoggerD("entered OnCompositeFilterEnd");
+    ScopeLogger("Entered into asynchronous function, visitor.SetOnCompositeFilterEnd's argument");
     std::string finalQuery;
     std::string separator;
 
@@ -200,7 +210,7 @@ PlatformResult ContentFilter::BuildQuery(const picojson::object& jsFilter,
   visitor.SetOnAttributeRangeFilter([&](const std::string& name,
                                         const picojson::value& initial_value,
                                         const picojson::value& end_value) {
-    LoggerD("entered OnAttributeFilter");
+    ScopeLogger("Entered into asynchronous function, visitor.SetOnAttributeRangeFilter's argument");
 
     std::string query = "";
     std::string paramName;