public function handleRequest() { $this->createProviders(); $this->getHost()->validateQueryParameters(); $requestMethod = $this->getOperationContext()->incomingRequest()->getMethod(); if ($requestMethod != HTTPRequestMethod::GET()) { throw ODataException::createNotImplementedError(Messages::onlyReadSupport($requestMethod)); } return UriProcessor::process($this); }
/** * Top-level handler invoked by Dispatcher against any request to this * service. This method will hand over request processing task to other * functions which process the request, set required headers and Response * stream (if any in Atom/Json format) in * WebOperationContext::Current()::OutgoingWebResponseContext. * Once this function returns, dispatcher uses global WebOperationContext * to write out the request response to client. * This function will perform the following operations: * (1) Check whether the top level service class implements * IServiceProvider which means the service is a custom service, in * this case make sure the top level service class implements * IMetaDataProvider and IQueryProvider. * These are the minimal interfaces that a custom service to be * implemented in order to expose its data as OData. Save reference to * These interface implementations. * NOTE: Here we will ensure only providers for IDSQP and IDSMP. The * IDSSP will be ensured only when there is an GET request on MLE/Named * stream. * * (2). Invoke 'Initialize' method of top level service for * collecting the configuration rules set by the developer for this * service. * * (3). Invoke the Uri processor to process the request URI. The uri * processor will do the following: * (a). Validate the request uri syntax using OData uri rules * (b). Validate the request using metadata of this service * (c). Parse the request uri and using, IQueryProvider * implementation, fetches the resources pointed by the uri * if required * (d). Build a RequestDescription which encapsulate everything * related to request uri (e.g. type of resource, result * etc...) * (3). Invoke handleRequest2 for further processing * * @return void */ public function handleRequest() { try { $this->createProviders(); $this->_serviceHost->validateQueryParameters(); $requestMethod = $this->getOperationContext()->incomingRequest()->getMethod(); if ($requestMethod != HTTPRequestMethod::GET()) { throw ODataException::createNotImplementedError(Messages::onlyReadSupport($requestMethod)); } $uriProcessor = UriProcessor::process($this); $request = $uriProcessor->getRequest(); $this->serializeResult($request, $uriProcessor); } catch (\Exception $exception) { ErrorHandler::handleException($exception, $this); // Return to dispatcher for writing serialized exception return; } }
public function testProcessRequestForCollectionWithInlineCountProviderHandlesPaging() { $requestURI = new Url('http://host.com/data.svc/Collection/?$inlinecount=allpages'); Phockito::when($this->mockServiceHost->getAbsoluteRequestUri())->return($requestURI); //mock inline count as all pages Phockito::when($this->mockServiceHost->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_INLINECOUNT))->return("allpages"); $this->fakeServiceConfig->setAcceptCountRequests(true); $this->fakeServiceConfig->setMaxDataServiceVersion(ProtocolVersion::V2()); $uriProcessor = UriProcessor::process($this->mockService); $fakeQueryResult = new QueryResult(); $fakeQueryResult->results = array(1, 2, 3); $fakeQueryResult->count = 10; Phockito::when($this->mockProvidersWrapper->getResourceSet(QueryType::ENTITIES_WITH_COUNT(), $this->mockCollectionResourceSetWrapper, null, null, null, null))->return($fakeQueryResult); //indicate that the Provider performs the paging (thus it will use the count in the QueryResult) Phockito::when($this->mockProvidersWrapper->handlesOrderedPaging())->return(true); $uriProcessor->execute(); $request = $uriProcessor->getRequest(); $actual = $request->getTargetResult(); $this->assertEquals(array(1, 2, 3), $actual); $this->assertEquals(10, $request->getCountValue()); }
public function handleRequest() { $this->createProviders(); $this->getHost()->validateQueryParameters(); return UriProcessor::process($this); }
/** * Top-level handler invoked by Dispatcher against any request to this * service. This method will hand over request processing task to other * functions which process the request, set required headers and Response * stream (if any in Atom/Json format) in * WebOperationContext::Current()::OutgoingWebResponseContext. * Once this function returns, dispatcher uses global WebOperationContext * to write out the request response to client. * This function will perform the following operations: * (1) Check whether the top level service class implements * IServiceProvider which means the service is a custom service, in * this case make sure the top level service class implements * IMetaDataProvider and IQueryProvider. * These are the minimal interfaces that a custom service to be * implemented in order to expose its data as OData. Save reference to * These interface implementations. * NOTE: Here we will ensure only providers for IDSQP and IDSMP. The * IDSSP will be ensured only when there is an GET request on MLE/Named * stream. * * (2). Invoke 'Initialize' method of top level service for * collecting the configuration rules set by the developer for this * service. * * (3). Invoke the Uri processor to process the request URI. The uri * processor will do the following: * (a). Validate the request uri syntax using OData uri rules * (b). Validate the request using metadata of this service * (c). Parse the request uri and using, IQueryProvider * implementation, fetches the resources pointed by the uri * if required * (d). Build a RequestDescription which encapsulate everything * related to request uri (e.g. type of resource, result * etc...) * (3). Invoke handleRequest2 for further processing * * @return void */ public function handleRequest() { try { $this->createProviders(); $this->_serviceHost->validateQueryParameters(); $requestMethod = $this->getOperationContext()->incomingRequest()->getMethod(); // Lion: accept OPTIONS request if ($requestMethod == HTTPRequestMethod::OPTIONS()) { header('Allow: GET,PATCH,POST,PUT'); http_response_code(200); return; } // ---- // if ($requestMethod != HTTPRequestMethod::GET()) { // throw ODataException::createNotImplementedError(Messages::onlyReadSupport($requestMethod)); // } $uriProcessor = UriProcessor::process($this); $request = $uriProcessor->getRequest(); $this->serializeResult($request, $uriProcessor); } catch (\Exception $exception) { ErrorHandler::handleException($exception, $this); // Return to dispatcher for writing serialized exception return; } }