arpadboda commented on a change in pull request #488: MINIFICPP-739: Resolve 
json checks for c2 responses
URL: https://github.com/apache/nifi-minifi-cpp/pull/488#discussion_r258220703
 
 

 ##########
 File path: libminifi/src/c2/protocols/RESTProtocol.cpp
 ##########
 @@ -43,23 +46,33 @@ const C2Payload RESTProtocol::parseJsonResponse(const 
C2Payload &payload, const
       std::string requested_operation = getOperation(payload);
 
       std::string identifier;
+
       if (root.HasMember("operationid")) {
         identifier = root["operationid"].GetString();
       } else if (root.HasMember("operationId")) {
         identifier = root["operationId"].GetString();
       } else if (root.HasMember("identifier")) {
         identifier = root["identifier"].GetString();
       }
-      if (root["requested_operations"].Size() == 0 && 
root["requestedOperations"].Size() == 0)
+
 
 Review comment:
   Ouch. It's pretty painful that both can occur.
   
   I my opinion the following way is a bit more straight forward to deal with 
this, but I don't adhert to it:
   ```
   std::array<std::string, 2> ops = {""requested_operations"", 
"requestedOperations"};
   auto it = ops.begin();
   for(; it != ops.end() ; ++it) {
     if(root.HasMember(*it)) break;
   }
   if(it == ops.end()) //not found 
     return C2Payload(payload.getOperation(), 
state::UpdateState::READ_COMPLETE, true);
   
   //no need to bother with size as it's surely found
   for (const rapidjson::Value& request : root[*it].GetArray()) {
   ...
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to