示例#1
0
 /**
  * Process the $expand and $select option and update the request description.
  * 
  * @return void
  * 
  * @throws ODataException Throws bad request error in the following cases
  *                          (1) If $expand or select cannot be applied to the
  *                              requested resource.
  *                          (2) If projection is disabled by the developer
  *                          (3) If some error occurs while parsing the options
  */
 private function _processExpandAndSelect()
 {
     $expand = $this->_dataService->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_EXPAND);
     if (!is_null($expand)) {
         $this->_checkExpandOrSelectApplicable(ODataConstants::HTTPQUERY_STRING_EXPAND);
     }
     $select = $this->_dataService->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_SELECT);
     if (!is_null($select)) {
         if (!$this->_dataService->getServiceConfiguration()->getAcceptProjectionRequests()) {
             ODataException::createBadRequestError(Messages::dataServiceConfigurationProjectionsNotAccepted());
         }
         $this->_checkExpandOrSelectApplicable(ODataConstants::HTTPQUERY_STRING_SELECT);
     }
     // We will generate RootProjectionNode in case of $link request also, but
     // expand and select in this case must be null (we are ensuring this above)
     // 'RootProjectionNode' is required while generating next page Link
     if ($this->_expandSelectApplicable || $this->_requestDescription->isLinkUri()) {
         try {
             $rootProjectionNode = ExpandProjectionParser::parseExpandAndSelectClause($this->_requestDescription->getTargetResourceSetWrapper(), $this->_requestDescription->getTargetResourceType(), $this->_requestDescription->getInternalOrderByInfo(), $this->_requestDescription->getSkipCount(), $this->_requestDescription->getTopCount(), $expand, $select, $this->_dataService->getMetadataQueryProviderWrapper());
             if ($rootProjectionNode->isSelectionSpecified()) {
                 $this->_requestDescription->raiseMinimumVersionRequirement(2, 0, $this->_dataService);
             }
             if ($rootProjectionNode->hasPagedExpandedResult()) {
                 $this->_requestDescription->raiseResponseVersion(2, 0, $this->_dataService);
             }
             $this->_requestDescription->setRootProjectionNode($rootProjectionNode);
         } catch (ODataException $odataException) {
             throw $odataException;
         }
     }
 }