/** * This method verfiy the client provided url query parameters and check whether * any of the odata query option specified more than once or check any of the * non-odata query parameter start will $ symbol or check any of the odata query * option specified with out value. If any of the above check fails throws * ODataException, else set _queryOptions memeber variable * * @return void * * @throws ODataException */ public function validateQueryParameters() { $queryOptions =& $this->_operationContext->incomingRequest()->getQueryParameters(); reset($queryOptions); // Check whether user specified $format query option while ($queryOption = current($queryOptions)) { $optionName = key($queryOption); $optionValue = current($queryOption); if (!empty($optionName) && $optionName === ODataConstants::HTTPQUERY_STRING_FORMAT) { //$optionValue is the format if (!is_null($optionValue)) { if ($optionValue === ODataConstants::FORMAT_ATOM) { $this->setRequestAccept(ODataConstants::MIME_APPLICATION_ATOM . ';q=1.0'); } else { if ($optionValue === ODataConstants::FORMAT_JSON) { $this->setRequestAccept(ODataConstants::MIME_APPLICATION_JSON . ';q=1.0'); } else { // Invalid format value, this error should not be // serialized in atom or json format since we don't // know which format client can understand, so error // will be in plain text. header(ODataConstants::HTTPRESPONSE_HEADER_CONTENTTYPE . ':' . ODataConstants::MIME_TEXTPLAIN); header(ODataConstants::HTTPRESPONSE_HEADER_STATUS . ':' . HttpStatus::CODE_BAD_REQUEST . ' ' . 'Bad Request'); echo Messages::queryProcessorInvalidValueForFormat(); exit; } } } break; } next($queryOptions); } reset($queryOptions); $namesFound = array(); while ($queryOption = current($queryOptions)) { $optionName = key($queryOption); $optionValue = current($queryOption); if (empty($optionName)) { if (!empty($optionValue)) { if ($optionValue[0] == '$') { if ($this->_isODataQueryOption($optionValue)) { ODataException::createBadRequestError(Messages::dataServiceHostODataQueryOptionFoundWithoutValue($optionValue)); } else { ODataException::createBadRequestError(Messages::dataServiceHostNonODataOptionBeginsWithSystemCharacter($optionValue)); } } } } else { if ($optionName[0] == '$') { if (!$this->_isODataQueryOption($optionName)) { ODataException::createBadRequestError(Messages::dataServiceHostNonODataOptionBeginsWithSystemCharacter($optionName)); } if (array_search($optionName, $namesFound) !== false) { ODataException::createBadRequestError(Messages::dataServiceHostODataQueryOptionCannotBeSpecifiedMoreThanOnce($optionName)); } if (empty($optionValue)) { ODataException::createBadRequestError(Messages::dataServiceHostODataQueryOptionFoundWithoutValue($optionName)); } $namesFound[] = $optionName; } } next($queryOptions); } $this->_queryOptions = $queryOptions; }