コード例 #1
0
/* ****************************************************************************
*
* patchSubscription -
*
* PATCH /v2/subscriptions/{entityId}
*
* Payload In:  None
* Payload Out: None
*
* URI parameters:
*   -
*/
std::string patchSubscription
(
  ConnectionInfo*            ciP,
  int                        components,
  std::vector<std::string>&  compV,
  ParseData*                 parseDataP
)
{
  std::string                        answer;
  std::string                        subscriptionId =  compV[2];
  UpdateContextSubscriptionResponse  ucsr;


  // 'Fill In' UpdateContextSubscriptionRequest
  parseDataP->ucsr.res.subscriptionId.set(subscriptionId);

  TIMED_MONGO(ciP->httpStatusCode = mongoUpdateContextSubscription(&parseDataP->ucsr.res,
                                                                   &ucsr,
                                                                   ciP->outFormat,
                                                                   ciP->tenant,
                                                                   ciP->httpHeaders.xauthToken,
                                                                   ciP->servicePathV,
                                                                   ciP->apiVersion));

  if (ciP->httpStatusCode != SccOk)
  {
    OrionError oe(ciP->httpStatusCode);

    TIMED_RENDER(answer = oe.render(ciP, ""));

    return answer;
  }
  else if (ucsr.subscribeError.errorCode.code != SccNone)
  {
    OrionError oe(ucsr.subscribeError.errorCode.code);

    ciP->httpStatusCode = ucsr.subscribeError.errorCode.code;

    oe.reasonPhrase = ucsr.subscribeError.errorCode.reasonPhrase;

    if (ucsr.subscribeError.errorCode.code == SccContextElementNotFound)
    {
      oe.details = "The requested subscription has not been found. Check id";
    }

    TIMED_RENDER(answer = oe.render(ciP, ""));

    return answer;
  }

  ciP->httpStatusCode = SccNoContent;

  return "";
}
コード例 #2
0
/* ****************************************************************************
*
* postUpdateContextSubscription - 
*/
std::string postUpdateContextSubscription(ConnectionInfo* ciP, int components, std::vector<std::string> compV, ParseData* parseDataP)
{
  UpdateContextSubscriptionResponse  ucsr;
  std::string                        answer;

  ucsr.subscribeError.subscriptionId = parseDataP->ucsr.res.subscriptionId;

  // FIXME P6: by the moment, we are assuming that notification will be sent in the same format than the one
  // used to do the subscription, so we are passing ciP->inFomat. 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 = mongoUpdateContextSubscription(&parseDataP->ucsr.res, &ucsr, ciP->inFormat);
  answer = ucsr.render(UpdateContextSubscription, ciP->outFormat, "");
  return answer;
}
コード例 #3
0
/* ****************************************************************************
*
* postUpdateContextSubscription - 
*/
std::string postUpdateContextSubscription
(
  ConnectionInfo*            ciP,
  int                        components,
  std::vector<std::string>&  compV,
  ParseData*                 parseDataP
)
{
  UpdateContextSubscriptionResponse  ucsr;
  std::string                        answer;

  ucsr.subscribeError.subscriptionId = parseDataP->ucsr.res.subscriptionId;  

  TIMED_MONGO(ciP->httpStatusCode = mongoUpdateContextSubscription(&parseDataP->ucsr.res,
                                                                   &ucsr,                                                                   
                                                                   ciP->tenant,
                                                                   ciP->httpHeaders.xauthToken,
                                                                   ciP->servicePathV));

  TIMED_RENDER(answer = ucsr.render(UpdateContextSubscription, ""));

  return answer;
}