/* ****************************************************************************
*
* postSubscribeContextAvailability - 
*/
std::string postSubscribeContextAvailability(ConnectionInfo* ciP, int components, std::vector<std::string> compV, ParseData* parseDataP)
{
  SubscribeContextAvailabilityResponse  scar;
  std::string                           answer;

  // FIXME P6: at the moment, we assume that notifications are sent in the same format that the one
  // used to do the subscription, so we are passing ciP->inFormat. This is just an heuristic, the client could want
  // for example to use XML in the subscription message but wants notifications in JSON. We need a more
  // flexible approach, to be implemented
  ciP->httpStatusCode = mongoSubscribeContextAvailability(&parseDataP->scar.res, &scar, ciP->inFormat);
  answer = scar.render(SubscribeContextAvailability, ciP->outFormat, "");

  return answer;
}
/* ****************************************************************************
*
* SubscribeContextAvailabilityRequest::check - 
*/
std::string SubscribeContextAvailabilityRequest::check(RequestType requestType, Format format, const std::string& indent, const std::string& predetectedError, int counter)
{
  SubscribeContextAvailabilityResponse response;
  std::string                          res;

  if (predetectedError != "")
  {
    response.errorCode.fill(SccBadRequest, predetectedError);
  }
  else if (((res = entityIdVector.check(SubscribeContextAvailability, format, indent, predetectedError, counter))   != "OK") ||
           ((res = attributeList.check(SubscribeContextAvailability, format, indent, predetectedError, counter))    != "OK") ||
           ((res = reference.check(SubscribeContextAvailability, format, indent, predetectedError, counter))        != "OK") ||
           ((res = duration.check(SubscribeContextAvailability, format, indent, predetectedError, counter))         != "OK") ||
           ((res = restriction.check(SubscribeContextAvailability, format, indent, predetectedError, restrictions)) != "OK"))
  {
    response.errorCode.fill(SccBadRequest, res);
  }
  else
    return "OK";

  return response.render(SubscribeContextAvailability, format, indent);
}