@@ -678,6 +678,7 @@ |
||
| 678 | 678 | * @param boolean &$needToSerializeResponse On return, this will contain |
| 679 | 679 | * True if response needs to be |
| 680 | 680 | * serialized, False otherwise. |
| 681 | + * @param boolean $needToSerializeResponse |
|
| 681 | 682 | * |
| 682 | 683 | * @return string|null The ETag for the entry object if it has eTag properties |
| 683 | 684 | * NULL otherwise. |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | - //TODO: shouldn't we hide this from the interface..if we need it at all. |
|
| 102 | + //TODO: shouldn't we hide this from the interface..if we need it at all. |
|
| 103 | 103 | /** |
| 104 | 104 | * Get the wrapper over developer's IQueryProvider and IMetadataProvider implementation. |
| 105 | 105 | * |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function getProvidersWrapper() |
| 109 | 109 | { |
| 110 | - return $this->providersWrapper; |
|
| 110 | + return $this->providersWrapper; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -230,33 +230,33 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * @return IQueryProvider |
|
| 235 | - */ |
|
| 236 | - public abstract function getQueryProvider(); |
|
| 233 | + /** |
|
| 234 | + * @return IQueryProvider |
|
| 235 | + */ |
|
| 236 | + public abstract function getQueryProvider(); |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * @return IMetadataProvider |
|
| 240 | - */ |
|
| 241 | - public abstract function getMetadataProvider(); |
|
| 238 | + /** |
|
| 239 | + * @return IMetadataProvider |
|
| 240 | + */ |
|
| 241 | + public abstract function getMetadataProvider(); |
|
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * @return \POData\Providers\Stream\IStreamProvider |
|
| 245 | - */ |
|
| 246 | - public abstract function getStreamProviderX(); |
|
| 243 | + /** |
|
| 244 | + * @return \POData\Providers\Stream\IStreamProvider |
|
| 245 | + */ |
|
| 246 | + public abstract function getStreamProviderX(); |
|
| 247 | 247 | |
| 248 | 248 | |
| 249 | - /** @var ODataWriterRegistry */ |
|
| 250 | - private $writerRegistry; |
|
| 249 | + /** @var ODataWriterRegistry */ |
|
| 250 | + private $writerRegistry; |
|
| 251 | 251 | |
| 252 | - /** |
|
| 253 | - * Returns the ODataWriterRegistry to use when writing the response to a service document or resource request |
|
| 254 | - * @return ODataWriterRegistry |
|
| 255 | - */ |
|
| 256 | - public function getODataWriterRegistry() |
|
| 257 | - { |
|
| 258 | - return $this->writerRegistry; |
|
| 259 | - } |
|
| 252 | + /** |
|
| 253 | + * Returns the ODataWriterRegistry to use when writing the response to a service document or resource request |
|
| 254 | + * @return ODataWriterRegistry |
|
| 255 | + */ |
|
| 256 | + public function getODataWriterRegistry() |
|
| 257 | + { |
|
| 258 | + return $this->writerRegistry; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -302,32 +302,32 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $this->initialize($this->config); |
| 304 | 304 | |
| 305 | - //TODO: this seems like a bad spot to do this |
|
| 306 | - $this->writerRegistry = new ODataWriterRegistry(); |
|
| 307 | - $this->registerWriters(); |
|
| 305 | + //TODO: this seems like a bad spot to do this |
|
| 306 | + $this->writerRegistry = new ODataWriterRegistry(); |
|
| 307 | + $this->registerWriters(); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - //TODO: i don't want this to be public..but it's the only way to test it right now... |
|
| 311 | - public function registerWriters() |
|
| 312 | - { |
|
| 313 | - $registry = $this->getODataWriterRegistry(); |
|
| 314 | - $serviceVersion = $this->getConfiguration()->getMaxDataServiceVersion(); |
|
| 315 | - $serviceURI = $this->getHost()->getAbsoluteServiceUri()->getUrlAsString(); |
|
| 310 | + //TODO: i don't want this to be public..but it's the only way to test it right now... |
|
| 311 | + public function registerWriters() |
|
| 312 | + { |
|
| 313 | + $registry = $this->getODataWriterRegistry(); |
|
| 314 | + $serviceVersion = $this->getConfiguration()->getMaxDataServiceVersion(); |
|
| 315 | + $serviceURI = $this->getHost()->getAbsoluteServiceUri()->getUrlAsString(); |
|
| 316 | 316 | |
| 317 | - //We always register the v1 stuff |
|
| 318 | - $registry->register(new JsonODataV1Writer()); |
|
| 319 | - $registry->register(new AtomODataWriter($serviceURI)); |
|
| 317 | + //We always register the v1 stuff |
|
| 318 | + $registry->register(new JsonODataV1Writer()); |
|
| 319 | + $registry->register(new AtomODataWriter($serviceURI)); |
|
| 320 | 320 | |
| 321 | - if($serviceVersion->compare(Version::v2()) > -1){ |
|
| 322 | - $registry->register(new JsonODataV2Writer()); |
|
| 323 | - } |
|
| 321 | + if($serviceVersion->compare(Version::v2()) > -1){ |
|
| 322 | + $registry->register(new JsonODataV2Writer()); |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - if($serviceVersion->compare(Version::v3()) > -1){ |
|
| 326 | - $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI)); |
|
| 327 | - $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI)); |
|
| 328 | - $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI)); |
|
| 329 | - } |
|
| 330 | - } |
|
| 325 | + if($serviceVersion->compare(Version::v3()) > -1){ |
|
| 326 | + $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI)); |
|
| 327 | + $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI)); |
|
| 328 | + $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI)); |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | 333 | * Serialize the requested resource. |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | $responseContentType = self::getResponseContentType($request, $uriProcessor, $this); |
| 353 | 353 | |
| 354 | - if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) { |
|
| 355 | - //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type |
|
| 356 | - throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
| 357 | - } |
|
| 354 | + if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) { |
|
| 355 | + //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type |
|
| 356 | + throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - $odataModelInstance = null; |
|
| 359 | + $odataModelInstance = null; |
|
| 360 | 360 | $hasResponseBody = true; |
| 361 | 361 | // Execution required at this point if request target to any resource other than |
| 362 | 362 | // |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | // In the query 'Orders(1245)/$links/Customer', the targeted |
| 408 | 408 | // Customer might be null |
| 409 | 409 | if (is_null($result)) { |
| 410 | - throw ODataException::createResourceNotFoundError( |
|
| 410 | + throw ODataException::createResourceNotFoundError( |
|
| 411 | 411 | $request->getIdentifier() |
| 412 | 412 | ); |
| 413 | 413 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | if (!is_null($this->_serviceHost->getRequestIfMatch()) |
| 418 | 418 | && !is_null($this->_serviceHost->getRequestIfNoneMatch()) |
| 419 | 419 | ) { |
| 420 | - throw ODataException::createBadRequestError( |
|
| 420 | + throw ODataException::createBadRequestError( |
|
| 421 | 421 | Messages::bothIfMatchAndIfNoneMatchHeaderSpecified() |
| 422 | 422 | ); |
| 423 | 423 | } |
@@ -453,22 +453,22 @@ discard block |
||
| 453 | 453 | } |
| 454 | 454 | } else if ($requestTargetKind == TargetKind::COMPLEX_OBJECT()) { |
| 455 | 455 | |
| 456 | - $odataModelInstance = $objectModelSerializer->writeTopLevelComplexObject( |
|
| 456 | + $odataModelInstance = $objectModelSerializer->writeTopLevelComplexObject( |
|
| 457 | 457 | $result, |
| 458 | 458 | $request->getProjectedProperty()->getName(), |
| 459 | - $request->getTargetResourceType() |
|
| 460 | - ); |
|
| 459 | + $request->getTargetResourceType() |
|
| 460 | + ); |
|
| 461 | 461 | } else if ($requestTargetKind == TargetKind::BAG()) { |
| 462 | 462 | $odataModelInstance = $objectModelSerializer->writeTopLevelBagObject( |
| 463 | 463 | $result, |
| 464 | 464 | $request->getProjectedProperty()->getName(), |
| 465 | - $request->getTargetResourceType(), |
|
| 465 | + $request->getTargetResourceType(), |
|
| 466 | 466 | $odataModelInstance |
| 467 | 467 | ); |
| 468 | 468 | } else if ($requestTargetKind == TargetKind::PRIMITIVE()) { |
| 469 | 469 | $odataModelInstance = $objectModelSerializer->writeTopLevelPrimitive( |
| 470 | 470 | $result, |
| 471 | - $request->getProjectedProperty(), |
|
| 471 | + $request->getProjectedProperty(), |
|
| 472 | 472 | $odataModelInstance |
| 473 | 473 | ); |
| 474 | 474 | } else if ($requestTargetKind == TargetKind::PRIMITIVE_VALUE()) { |
@@ -486,10 +486,10 @@ discard block |
||
| 486 | 486 | //Note: Response content type can be null for named stream |
| 487 | 487 | if ($hasResponseBody && !is_null($responseContentType)) { |
| 488 | 488 | if ($request->getTargetKind() != TargetKind::MEDIA_RESOURCE() && $responseContentType != MimeTypes::MIME_APPLICATION_OCTETSTREAM) { |
| 489 | - //append charset for everything except: |
|
| 490 | - //stream resources as they have their own content type |
|
| 491 | - //binary properties (they content type will be App Octet for those...is this a good way? we could also decide based upon the projected property |
|
| 492 | - // |
|
| 489 | + //append charset for everything except: |
|
| 490 | + //stream resources as they have their own content type |
|
| 491 | + //binary properties (they content type will be App Octet for those...is this a good way? we could also decide based upon the projected property |
|
| 492 | + // |
|
| 493 | 493 | $responseContentType .= ';charset=utf-8'; |
| 494 | 494 | } |
| 495 | 495 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | * @throws ODataException, HttpHeaderFailure |
| 518 | 518 | */ |
| 519 | 519 | public static function getResponseContentType( |
| 520 | - RequestDescription $request, |
|
| 520 | + RequestDescription $request, |
|
| 521 | 521 | UriProcessor $uriProcessor, |
| 522 | 522 | IService $service |
| 523 | 523 | ) { |
@@ -525,12 +525,12 @@ discard block |
||
| 525 | 525 | // The Accept request-header field specifies media types which are acceptable for the response |
| 526 | 526 | |
| 527 | 527 | $host = $service->getHost(); |
| 528 | - $requestAcceptText = $host->getRequestAccept(); |
|
| 528 | + $requestAcceptText = $host->getRequestAccept(); |
|
| 529 | 529 | $requestVersion = $request->getResponseVersion(); |
| 530 | 530 | |
| 531 | - //if the $format header is present it overrides the accepts header |
|
| 532 | - $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT); |
|
| 533 | - if(!is_null($format)){ |
|
| 531 | + //if the $format header is present it overrides the accepts header |
|
| 532 | + $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT); |
|
| 533 | + if(!is_null($format)){ |
|
| 534 | 534 | |
| 535 | 535 | //There's a strange edge case..if application/json is supplied and it's V3 |
| 536 | 536 | if($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()){ |
@@ -539,128 +539,128 @@ discard block |
||
| 539 | 539 | $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META; |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format); |
|
| 543 | - } |
|
| 542 | + $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format); |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | 545 | |
| 546 | 546 | |
| 547 | 547 | |
| 548 | - //The response format can be dictated by the target resource kind. IE a $value will be different then expected |
|
| 549 | - //getTargetKind doesn't deal with link resources directly and this can change things |
|
| 550 | - $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind(); |
|
| 548 | + //The response format can be dictated by the target resource kind. IE a $value will be different then expected |
|
| 549 | + //getTargetKind doesn't deal with link resources directly and this can change things |
|
| 550 | + $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind(); |
|
| 551 | 551 | |
| 552 | - switch($targetKind){ |
|
| 553 | - case TargetKind::METADATA(): |
|
| 554 | - return HttpProcessUtility::selectMimeType( |
|
| 555 | - $requestAcceptText, |
|
| 556 | - array(MimeTypes::MIME_APPLICATION_XML) |
|
| 557 | - ); |
|
| 552 | + switch($targetKind){ |
|
| 553 | + case TargetKind::METADATA(): |
|
| 554 | + return HttpProcessUtility::selectMimeType( |
|
| 555 | + $requestAcceptText, |
|
| 556 | + array(MimeTypes::MIME_APPLICATION_XML) |
|
| 557 | + ); |
|
| 558 | 558 | |
| 559 | - case TargetKind::SERVICE_DIRECTORY(): |
|
| 560 | - return HttpProcessUtility::selectMimeType( |
|
| 561 | - $requestAcceptText, |
|
| 562 | - array( |
|
| 563 | - MimeTypes::MIME_APPLICATION_XML, |
|
| 564 | - MimeTypes::MIME_APPLICATION_ATOMSERVICE, |
|
| 565 | - MimeTypes::MIME_APPLICATION_JSON, |
|
| 559 | + case TargetKind::SERVICE_DIRECTORY(): |
|
| 560 | + return HttpProcessUtility::selectMimeType( |
|
| 561 | + $requestAcceptText, |
|
| 562 | + array( |
|
| 563 | + MimeTypes::MIME_APPLICATION_XML, |
|
| 564 | + MimeTypes::MIME_APPLICATION_ATOMSERVICE, |
|
| 565 | + MimeTypes::MIME_APPLICATION_JSON, |
|
| 566 | 566 | MimeTypes::MIME_APPLICATION_JSON_FULL_META, |
| 567 | 567 | MimeTypes::MIME_APPLICATION_JSON_NO_META, |
| 568 | 568 | MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, |
| 569 | - MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
| 569 | + MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
| 570 | 570 | |
| 571 | 571 | ) |
| 572 | - ); |
|
| 573 | - |
|
| 574 | - case TargetKind::PRIMITIVE_VALUE(): |
|
| 575 | - $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN); |
|
| 576 | - |
|
| 577 | - if ($request->getIdentifier() != '$count') { |
|
| 578 | - $projectedProperty = $request->getProjectedProperty(); |
|
| 579 | - self::assert( |
|
| 580 | - !is_null($projectedProperty), |
|
| 581 | - '!is_null($projectedProperty)' |
|
| 582 | - ); |
|
| 583 | - $type = $projectedProperty->getInstanceType(); |
|
| 584 | - self::assert( |
|
| 585 | - !is_null($type) && $type instanceof IType, |
|
| 586 | - '!is_null($type) && $type instanceof IType' |
|
| 587 | - ); |
|
| 588 | - if ($type instanceof Binary) { |
|
| 589 | - $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM); |
|
| 590 | - } |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - return HttpProcessUtility::selectMimeType( |
|
| 594 | - $requestAcceptText, |
|
| 595 | - $supportedResponseMimeTypes |
|
| 596 | - ); |
|
| 597 | - |
|
| 598 | - case TargetKind::PRIMITIVE(): |
|
| 599 | - case TargetKind::COMPLEX_OBJECT(): |
|
| 600 | - case TargetKind::BAG(): |
|
| 601 | - case TargetKind::LINK(): |
|
| 602 | - return HttpProcessUtility::selectMimeType( |
|
| 603 | - $requestAcceptText, |
|
| 604 | - array( |
|
| 605 | - MimeTypes::MIME_APPLICATION_XML, |
|
| 606 | - MimeTypes::MIME_TEXTXML, |
|
| 607 | - MimeTypes::MIME_APPLICATION_JSON, |
|
| 572 | + ); |
|
| 573 | + |
|
| 574 | + case TargetKind::PRIMITIVE_VALUE(): |
|
| 575 | + $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN); |
|
| 576 | + |
|
| 577 | + if ($request->getIdentifier() != '$count') { |
|
| 578 | + $projectedProperty = $request->getProjectedProperty(); |
|
| 579 | + self::assert( |
|
| 580 | + !is_null($projectedProperty), |
|
| 581 | + '!is_null($projectedProperty)' |
|
| 582 | + ); |
|
| 583 | + $type = $projectedProperty->getInstanceType(); |
|
| 584 | + self::assert( |
|
| 585 | + !is_null($type) && $type instanceof IType, |
|
| 586 | + '!is_null($type) && $type instanceof IType' |
|
| 587 | + ); |
|
| 588 | + if ($type instanceof Binary) { |
|
| 589 | + $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM); |
|
| 590 | + } |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + return HttpProcessUtility::selectMimeType( |
|
| 594 | + $requestAcceptText, |
|
| 595 | + $supportedResponseMimeTypes |
|
| 596 | + ); |
|
| 597 | + |
|
| 598 | + case TargetKind::PRIMITIVE(): |
|
| 599 | + case TargetKind::COMPLEX_OBJECT(): |
|
| 600 | + case TargetKind::BAG(): |
|
| 601 | + case TargetKind::LINK(): |
|
| 602 | + return HttpProcessUtility::selectMimeType( |
|
| 603 | + $requestAcceptText, |
|
| 604 | + array( |
|
| 605 | + MimeTypes::MIME_APPLICATION_XML, |
|
| 606 | + MimeTypes::MIME_TEXTXML, |
|
| 607 | + MimeTypes::MIME_APPLICATION_JSON, |
|
| 608 | 608 | MimeTypes::MIME_APPLICATION_JSON_FULL_META, |
| 609 | 609 | MimeTypes::MIME_APPLICATION_JSON_NO_META, |
| 610 | 610 | MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, |
| 611 | - MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
| 612 | - ) |
|
| 613 | - ); |
|
| 611 | + MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
| 612 | + ) |
|
| 613 | + ); |
|
| 614 | 614 | |
| 615 | 615 | case TargetKind::BATCH(): |
| 616 | - case TargetKind::RESOURCE(): |
|
| 617 | - return HttpProcessUtility::selectMimeType( |
|
| 618 | - $requestAcceptText, |
|
| 619 | - array( |
|
| 620 | - MimeTypes::MIME_APPLICATION_ATOM, |
|
| 621 | - MimeTypes::MIME_APPLICATION_JSON, |
|
| 616 | + case TargetKind::RESOURCE(): |
|
| 617 | + return HttpProcessUtility::selectMimeType( |
|
| 618 | + $requestAcceptText, |
|
| 619 | + array( |
|
| 620 | + MimeTypes::MIME_APPLICATION_ATOM, |
|
| 621 | + MimeTypes::MIME_APPLICATION_JSON, |
|
| 622 | 622 | MimeTypes::MIME_APPLICATION_JSON_FULL_META, |
| 623 | 623 | MimeTypes::MIME_APPLICATION_JSON_NO_META, |
| 624 | 624 | MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, |
| 625 | - MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
| 626 | - ) |
|
| 627 | - ); |
|
| 628 | - |
|
| 629 | - case TargetKind::MEDIA_RESOURCE(): |
|
| 630 | - if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){ |
|
| 631 | - throw ODataException::createBadRequestError( |
|
| 632 | - Messages::badRequestInvalidUriForMediaResource( |
|
| 633 | - $host->getAbsoluteRequestUri()->getUrlAsString() |
|
| 634 | - ) |
|
| 635 | - ); |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - $uriProcessor->execute(); |
|
| 639 | - $request->setExecuted(); |
|
| 640 | - // DSSW::getStreamContentType can throw error in 2 cases |
|
| 641 | - // 1. If the required stream implementation not found |
|
| 642 | - // 2. If IDSSP::getStreamContentType returns NULL for MLE |
|
| 643 | - $responseContentType = $service->getStreamProviderWrapper() |
|
| 644 | - ->getStreamContentType( |
|
| 645 | - $request->getTargetResult(), |
|
| 646 | - $request->getResourceStreamInfo() |
|
| 647 | - ); |
|
| 648 | - |
|
| 649 | - |
|
| 650 | - // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not |
|
| 651 | - // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error |
|
| 652 | - if (!is_null($responseContentType)) { |
|
| 653 | - $responseContentType = HttpProcessUtility::selectMimeType( |
|
| 654 | - $requestAcceptText, |
|
| 655 | - array($responseContentType) |
|
| 656 | - ); |
|
| 657 | - } |
|
| 658 | - |
|
| 659 | - return $responseContentType; |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - |
|
| 663 | - //If we got here, we just don't know what it is... |
|
| 625 | + MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
| 626 | + ) |
|
| 627 | + ); |
|
| 628 | + |
|
| 629 | + case TargetKind::MEDIA_RESOURCE(): |
|
| 630 | + if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){ |
|
| 631 | + throw ODataException::createBadRequestError( |
|
| 632 | + Messages::badRequestInvalidUriForMediaResource( |
|
| 633 | + $host->getAbsoluteRequestUri()->getUrlAsString() |
|
| 634 | + ) |
|
| 635 | + ); |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + $uriProcessor->execute(); |
|
| 639 | + $request->setExecuted(); |
|
| 640 | + // DSSW::getStreamContentType can throw error in 2 cases |
|
| 641 | + // 1. If the required stream implementation not found |
|
| 642 | + // 2. If IDSSP::getStreamContentType returns NULL for MLE |
|
| 643 | + $responseContentType = $service->getStreamProviderWrapper() |
|
| 644 | + ->getStreamContentType( |
|
| 645 | + $request->getTargetResult(), |
|
| 646 | + $request->getResourceStreamInfo() |
|
| 647 | + ); |
|
| 648 | + |
|
| 649 | + |
|
| 650 | + // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not |
|
| 651 | + // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error |
|
| 652 | + if (!is_null($responseContentType)) { |
|
| 653 | + $responseContentType = HttpProcessUtility::selectMimeType( |
|
| 654 | + $requestAcceptText, |
|
| 655 | + array($responseContentType) |
|
| 656 | + ); |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + return $responseContentType; |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + |
|
| 663 | + //If we got here, we just don't know what it is... |
|
| 664 | 664 | throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
| 665 | 665 | |
| 666 | 666 | } |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | if ($this->config->getValidateETagHeader() && !$resourceType->hasETagProperties()) { |
| 703 | 703 | if (!is_null($ifMatch) || !is_null($ifNoneMatch)) { |
| 704 | 704 | // No eTag properties but request has eTag headers, bad request |
| 705 | - throw ODataException::createBadRequestError( |
|
| 705 | + throw ODataException::createBadRequestError( |
|
| 706 | 706 | Messages::noETagPropertiesForType() |
| 707 | 707 | ); |
| 708 | 708 | } |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | $value = null; |
| 790 | 790 | try { |
| 791 | 791 | |
| 792 | - //TODO #88...also this seems like dupe work |
|
| 792 | + //TODO #88...also this seems like dupe work |
|
| 793 | 793 | $reflectionProperty = new \ReflectionProperty($entryObject, $eTagProperty->getName() ); |
| 794 | 794 | $value = $reflectionProperty->getValue($entryObject); |
| 795 | 795 | } catch (\ReflectionException $reflectionException) { |
@@ -318,11 +318,11 @@ discard block |
||
| 318 | 318 | $registry->register(new JsonODataV1Writer()); |
| 319 | 319 | $registry->register(new AtomODataWriter($serviceURI)); |
| 320 | 320 | |
| 321 | - if($serviceVersion->compare(Version::v2()) > -1){ |
|
| 321 | + if ($serviceVersion->compare(Version::v2()) > -1) { |
|
| 322 | 322 | $registry->register(new JsonODataV2Writer()); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if($serviceVersion->compare(Version::v3()) > -1){ |
|
| 325 | + if ($serviceVersion->compare(Version::v3()) > -1) { |
|
| 326 | 326 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI)); |
| 327 | 327 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI)); |
| 328 | 328 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI)); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) { |
| 355 | 355 | //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type |
| 356 | - throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
| 356 | + throw new ODataException(Messages::unsupportedMediaType(), 415); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | $odataModelInstance = null; |
@@ -530,10 +530,10 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | //if the $format header is present it overrides the accepts header |
| 532 | 532 | $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT); |
| 533 | - if(!is_null($format)){ |
|
| 533 | + if (!is_null($format)) { |
|
| 534 | 534 | |
| 535 | 535 | //There's a strange edge case..if application/json is supplied and it's V3 |
| 536 | - if($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()){ |
|
| 536 | + if ($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()) { |
|
| 537 | 537 | //then it's actual minimalmetadata |
| 538 | 538 | //TODO: should this be done with the header text too? |
| 539 | 539 | $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META; |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | //getTargetKind doesn't deal with link resources directly and this can change things |
| 550 | 550 | $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind(); |
| 551 | 551 | |
| 552 | - switch($targetKind){ |
|
| 552 | + switch ($targetKind) { |
|
| 553 | 553 | case TargetKind::METADATA(): |
| 554 | 554 | return HttpProcessUtility::selectMimeType( |
| 555 | 555 | $requestAcceptText, |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | ); |
| 628 | 628 | |
| 629 | 629 | case TargetKind::MEDIA_RESOURCE(): |
| 630 | - if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){ |
|
| 630 | + if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()) { |
|
| 631 | 631 | throw ODataException::createBadRequestError( |
| 632 | 632 | Messages::badRequestInvalidUriForMediaResource( |
| 633 | 633 | $host->getAbsoluteRequestUri()->getUrlAsString() |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | |
| 663 | 663 | //If we got here, we just don't know what it is... |
| 664 | - throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
| 664 | + throw new ODataException(Messages::unsupportedMediaType(), 415); |
|
| 665 | 665 | |
| 666 | 666 | } |
| 667 | 667 | |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | * @return string|null The ETag for the entry object if it has eTag properties |
| 683 | 683 | * NULL otherwise. |
| 684 | 684 | */ |
| 685 | - protected function compareETag(&$entryObject, ResourceType &$resourceType, |
|
| 685 | + protected function compareETag(&$entryObject, ResourceType & $resourceType, |
|
| 686 | 686 | &$needToSerializeResponse |
| 687 | 687 | ) { |
| 688 | 688 | $needToSerializeResponse = true; |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | * for use in a URI) there are etag properties, NULL if |
| 776 | 776 | * there is no etag property. |
| 777 | 777 | */ |
| 778 | - protected function getETagForEntry(&$entryObject, ResourceType &$resourceType) |
|
| 778 | + protected function getETagForEntry(&$entryObject, ResourceType & $resourceType) |
|
| 779 | 779 | { |
| 780 | 780 | $eTag = null; |
| 781 | 781 | $comma = null; |
@@ -790,16 +790,16 @@ discard block |
||
| 790 | 790 | try { |
| 791 | 791 | |
| 792 | 792 | //TODO #88...also this seems like dupe work |
| 793 | - $reflectionProperty = new \ReflectionProperty($entryObject, $eTagProperty->getName() ); |
|
| 793 | + $reflectionProperty = new \ReflectionProperty($entryObject, $eTagProperty->getName()); |
|
| 794 | 794 | $value = $reflectionProperty->getValue($entryObject); |
| 795 | 795 | } catch (\ReflectionException $reflectionException) { |
| 796 | 796 | throw ODataException::createInternalServerError( |
| 797 | - Messages::failedToAccessProperty($eTagProperty->getName(), $resourceType->getName() ) |
|
| 797 | + Messages::failedToAccessProperty($eTagProperty->getName(), $resourceType->getName()) |
|
| 798 | 798 | ); |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | if (is_null($value)) { |
| 802 | - $eTag = $eTag . $comma. 'null'; |
|
| 802 | + $eTag = $eTag . $comma . 'null'; |
|
| 803 | 803 | } else { |
| 804 | 804 | $eTag = $eTag . $comma . $type->convertToOData($value); |
| 805 | 805 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * To check whether the given character is a HTTP token character |
| 464 | 464 | * or not. |
| 465 | 465 | * |
| 466 | - * @param char $char The character to inspect. |
|
| 466 | + * @param string $char The character to inspect. |
|
| 467 | 467 | * |
| 468 | 468 | * @return boolean True if the given character is a valid HTTP token |
| 469 | 469 | * character, False otherwise. |
@@ -606,6 +606,7 @@ discard block |
||
| 606 | 606 | * @param string $text Text to read qvalue from. |
| 607 | 607 | * @param int &$textIndex Index into text where the qvalue starts. |
| 608 | 608 | * @param int &$qualityValue After the method executes, the normalized qvalue. |
| 609 | + * @param integer $textIndex |
|
| 609 | 610 | * |
| 610 | 611 | * @throws HttpHeaderFailure If any error occured while reading and processing |
| 611 | 612 | * the quality factor. |
@@ -659,7 +660,7 @@ discard block |
||
| 659 | 660 | /** |
| 660 | 661 | * Converts the specified character from the ASCII range to a digit. |
| 661 | 662 | * |
| 662 | - * @param char $c Character to convert |
|
| 663 | + * @param string $c Character to convert |
|
| 663 | 664 | * |
| 664 | 665 | * @return int The Int32 value for $c, or -1 if it is an element separator. |
| 665 | 666 | * |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | //the rest look like QSPs..kinda so we can do this |
| 104 | 104 | parse_str(implode("&", $candidateParts), $candidateParts); |
| 105 | 105 | if(array_key_exists('odata', $candidateParts)){ |
| 106 | - $candidateODataValue = $candidateParts['odata']; |
|
| 106 | + $candidateODataValue = $candidateParts['odata']; |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | return $c == ',' || $c == ' ' || $c == '\t'; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - /** |
|
| 699 | + /** |
|
| 700 | 700 | * Get server key by header |
| 701 | 701 | * @param string $headerName Name of header |
| 702 | 702 | */ |
@@ -717,6 +717,6 @@ discard block |
||
| 717 | 717 | case 'MAXDATASERVICEVERSION': |
| 718 | 718 | return 'HTTP_' . $name; |
| 719 | 719 | } |
| 720 | - return $name; |
|
| 721 | - } |
|
| 720 | + return $name; |
|
| 721 | + } |
|
| 722 | 722 | } |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | * @param SegmentDescriptor[] $segmentDescriptors Description of segments in the resource path. |
| 239 | 239 | * @param Url $requestUri |
| 240 | 240 | * @param Version $serviceMaxVersion |
| 241 | - * @param $requestVersion |
|
| 242 | - * @param $maxRequestVersion |
|
| 241 | + * @param null|string $requestVersion |
|
| 242 | + * @param null|string $maxRequestVersion |
|
| 243 | 243 | * @param string $dataType |
| 244 | 244 | */ |
| 245 | 245 | public function __construct($segmentDescriptors, Url $requestUri, Version $serviceMaxVersion, $requestVersion, $maxRequestVersion, $dataType = null, IService $service = null) |
@@ -307,6 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | 309 | * Define request data from body |
| 310 | + * @param string $dataType |
|
| 310 | 311 | */ |
| 311 | 312 | private function _readData($dataType) { |
| 312 | 313 | $this->_data = null; |
@@ -12,7 +12,6 @@ discard block |
||
| 12 | 12 | use POData\Providers\Metadata\ResourceProperty; |
| 13 | 13 | use POData\Providers\Metadata\ResourceSetWrapper; |
| 14 | 14 | use POData\Providers\Metadata\ResourceStreamInfo; |
| 15 | -use POData\UriProcessor\QueryProcessor\QueryProcessor; |
|
| 16 | 15 | use POData\UriProcessor\UriProcessor; |
| 17 | 16 | use POData\UriProcessor\ResourcePathProcessor\SegmentParser\SegmentParser; |
| 18 | 17 | use POData\UriProcessor\ResourcePathProcessor\SegmentParser\TargetSource; |
@@ -24,7 +23,6 @@ discard block |
||
| 24 | 23 | use POData\UriProcessor\QueryProcessor\ExpandProjectionParser\RootProjectionNode; |
| 25 | 24 | use POData\Providers\Metadata\ResourceType; |
| 26 | 25 | use POData\Providers\Query\QueryType; |
| 27 | -use Verdant\XML2Array; |
|
| 28 | 26 | |
| 29 | 27 | |
| 30 | 28 | /** |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | private $requiredMinRequestVersion; |
| 80 | 80 | |
| 81 | - /** @var Version */ |
|
| 82 | - private $maxServiceVersion; |
|
| 81 | + /** @var Version */ |
|
| 82 | + private $maxServiceVersion; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Collection of known data service versions. |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | private $_containerName; |
| 118 | 118 | |
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * The count option specified in the request. |
|
| 122 | - * |
|
| 123 | - * @var QueryType |
|
| 124 | - */ |
|
| 125 | - public $queryType; |
|
| 120 | + /** |
|
| 121 | + * The count option specified in the request. |
|
| 122 | + * |
|
| 123 | + * @var QueryType |
|
| 124 | + */ |
|
| 125 | + public $queryType; |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * Number of segments. |
@@ -226,47 +226,47 @@ discard block |
||
| 226 | 226 | * Reference to the service |
| 227 | 227 | * @var IService |
| 228 | 228 | */ |
| 229 | - private $_service; |
|
| 229 | + private $_service; |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * The parts of a multipart request |
| 233 | 233 | * @var array |
| 234 | 234 | */ |
| 235 | - private $_parts; |
|
| 235 | + private $_parts; |
|
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * @param SegmentDescriptor[] $segmentDescriptors Description of segments in the resource path. |
|
| 239 | - * @param Url $requestUri |
|
| 240 | - * @param Version $serviceMaxVersion |
|
| 241 | - * @param $requestVersion |
|
| 242 | - * @param $maxRequestVersion |
|
| 237 | + /** |
|
| 238 | + * @param SegmentDescriptor[] $segmentDescriptors Description of segments in the resource path. |
|
| 239 | + * @param Url $requestUri |
|
| 240 | + * @param Version $serviceMaxVersion |
|
| 241 | + * @param $requestVersion |
|
| 242 | + * @param $maxRequestVersion |
|
| 243 | 243 | * @param string $dataType |
| 244 | - */ |
|
| 245 | - public function __construct($segmentDescriptors, Url $requestUri, Version $serviceMaxVersion, $requestVersion, $maxRequestVersion, $dataType = null, IService $service = null) |
|
| 244 | + */ |
|
| 245 | + public function __construct($segmentDescriptors, Url $requestUri, Version $serviceMaxVersion, $requestVersion, $maxRequestVersion, $dataType = null, IService $service = null) |
|
| 246 | 246 | { |
| 247 | 247 | $this->segments = $segmentDescriptors; |
| 248 | 248 | $this->_segmentCount = count($this->segments); |
| 249 | 249 | $this->requestUrl = $requestUri; |
| 250 | 250 | $this->lastSegment = $segmentDescriptors[$this->_segmentCount - 1]; |
| 251 | - $this->queryType = QueryType::ENTITIES(); |
|
| 251 | + $this->queryType = QueryType::ENTITIES(); |
|
| 252 | 252 | $this->_service = $service; |
| 253 | 253 | $this->_parts = array(); |
| 254 | 254 | |
| 255 | 255 | //we use this for validation checks down in validateVersions...but maybe we should check that outside of this object... |
| 256 | 256 | $this->maxServiceVersion = $serviceMaxVersion; |
| 257 | 257 | |
| 258 | - //Per OData 1 & 2 spec we must return the smallest size |
|
| 259 | - //We start at 1.0 and move it up as features are requested |
|
| 258 | + //Per OData 1 & 2 spec we must return the smallest size |
|
| 259 | + //We start at 1.0 and move it up as features are requested |
|
| 260 | 260 | $this->requiredMinResponseVersion = clone Version::v1(); |
| 261 | 261 | $this->requiredMinRequestVersion = clone Version::v1(); |
| 262 | 262 | |
| 263 | 263 | |
| 264 | - //see http://www.odata.org/documentation/odata-v2-documentation/overview/#ProtocolVersioning |
|
| 265 | - //if requestVersion isn't there, use Service Max Version |
|
| 266 | - $this->requestVersion = is_null($requestVersion) ? $serviceMaxVersion : self::parseVersionHeader($requestVersion, ODataConstants::ODATAVERSIONHEADER); |
|
| 264 | + //see http://www.odata.org/documentation/odata-v2-documentation/overview/#ProtocolVersioning |
|
| 265 | + //if requestVersion isn't there, use Service Max Version |
|
| 266 | + $this->requestVersion = is_null($requestVersion) ? $serviceMaxVersion : self::parseVersionHeader($requestVersion, ODataConstants::ODATAVERSIONHEADER); |
|
| 267 | 267 | |
| 268 | - //if max version isn't there, use the request version |
|
| 269 | - $this->requestMaxVersion = is_null($maxRequestVersion) ? $this->requestVersion : self::parseVersionHeader($maxRequestVersion, ODataConstants::ODATAMAXVERSIONHEADER); |
|
| 268 | + //if max version isn't there, use the request version |
|
| 269 | + $this->requestMaxVersion = is_null($maxRequestVersion) ? $this->requestVersion : self::parseVersionHeader($maxRequestVersion, ODataConstants::ODATAMAXVERSIONHEADER); |
|
| 270 | 270 | |
| 271 | 271 | //if it's OData v3..things change a bit |
| 272 | 272 | if($this->maxServiceVersion == Version::v3()){ |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | public function raiseMinVersionRequirement($major, $minor) { |
| 405 | 405 | if($this->requiredMinRequestVersion->raiseVersion($major, $minor)) |
| 406 | 406 | { |
| 407 | - $this->validateVersions(); |
|
| 407 | + $this->validateVersions(); |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | */ |
| 420 | 420 | public function raiseResponseVersion($major, $minor) { |
| 421 | 421 | if($this->requiredMinResponseVersion->raiseVersion($major, $minor)){ |
| 422 | - $this->validateVersions(); |
|
| 422 | + $this->validateVersions(); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | } |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | public function getResponseVersion() |
| 948 | 948 | { |
| 949 | 949 | |
| 950 | - return $this->requiredMinResponseVersion; |
|
| 950 | + return $this->requiredMinResponseVersion; |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | /** |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | { |
| 976 | 976 | if (is_null(self::$_knownDataServiceVersions)) { |
| 977 | 977 | self::$_knownDataServiceVersions = array( |
| 978 | - new Version(1, 0), |
|
| 978 | + new Version(1, 0), |
|
| 979 | 979 | new Version(2, 0), |
| 980 | 980 | new Version(3, 0) |
| 981 | 981 | ); |
@@ -1004,32 +1004,32 @@ discard block |
||
| 1004 | 1004 | */ |
| 1005 | 1005 | public function validateVersions() { |
| 1006 | 1006 | |
| 1007 | - //If the request version is below the minimum version required by supplied request arguments..throw an exception |
|
| 1007 | + //If the request version is below the minimum version required by supplied request arguments..throw an exception |
|
| 1008 | 1008 | if ($this->requestVersion->compare($this->requiredMinRequestVersion) < 0) { |
| 1009 | - throw ODataException::createBadRequestError( |
|
| 1009 | + throw ODataException::createBadRequestError( |
|
| 1010 | 1010 | Messages::requestVersionTooLow( |
| 1011 | - $this->requestVersion->toString(), |
|
| 1012 | - $this->requiredMinRequestVersion->toString() |
|
| 1011 | + $this->requestVersion->toString(), |
|
| 1012 | + $this->requiredMinRequestVersion->toString() |
|
| 1013 | 1013 | ) |
| 1014 | 1014 | ); |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | - //If the requested max version is below the version required to fulfill the response...throw an exception |
|
| 1017 | + //If the requested max version is below the version required to fulfill the response...throw an exception |
|
| 1018 | 1018 | if ($this->requestMaxVersion->compare($this->requiredMinResponseVersion) < 0) { |
| 1019 | - throw ODataException::createBadRequestError( |
|
| 1019 | + throw ODataException::createBadRequestError( |
|
| 1020 | 1020 | Messages::requestVersionTooLow( |
| 1021 | - $this->requestMaxVersion->toString(), |
|
| 1022 | - $this->requiredMinResponseVersion->toString() |
|
| 1021 | + $this->requestMaxVersion->toString(), |
|
| 1022 | + $this->requiredMinResponseVersion->toString() |
|
| 1023 | 1023 | ) |
| 1024 | 1024 | ); |
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | //If the max version supported by the service is below the version required to fulfill the response..throw an exception |
| 1028 | 1028 | if ($this->maxServiceVersion->compare($this->requiredMinResponseVersion) < 0) { |
| 1029 | - throw ODataException::createBadRequestError( |
|
| 1029 | + throw ODataException::createBadRequestError( |
|
| 1030 | 1030 | Messages::requestVersionIsBiggerThanProtocolVersion( |
| 1031 | - $this->requiredMinResponseVersion->toString(), |
|
| 1032 | - $this->maxServiceVersion->toString() |
|
| 1031 | + $this->requiredMinResponseVersion->toString(), |
|
| 1032 | + $this->maxServiceVersion->toString() |
|
| 1033 | 1033 | ) |
| 1034 | 1034 | ); |
| 1035 | 1035 | } |
@@ -1060,9 +1060,9 @@ discard block |
||
| 1060 | 1060 | for ($i = 0; $i < $libNameIndex; $i++) { |
| 1061 | 1061 | if ($versionHeader[$i] == '.') { |
| 1062 | 1062 | |
| 1063 | - //Throw an exception if we find more than 1 dot |
|
| 1064 | - if ($dotIndex != -1) { |
|
| 1065 | - throw ODataException::createBadRequestError( |
|
| 1063 | + //Throw an exception if we find more than 1 dot |
|
| 1064 | + if ($dotIndex != -1) { |
|
| 1065 | + throw ODataException::createBadRequestError( |
|
| 1066 | 1066 | Messages::requestDescriptionInvalidVersionHeader( |
| 1067 | 1067 | $versionHeader, |
| 1068 | 1068 | $headerName |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | |
| 1073 | 1073 | $dotIndex = $i; |
| 1074 | 1074 | } else if ($versionHeader[$i] < '0' || $versionHeader[$i] > '9') { |
| 1075 | - throw ODataException::createBadRequestError( |
|
| 1075 | + throw ODataException::createBadRequestError( |
|
| 1076 | 1076 | Messages::requestDescriptionInvalidVersionHeader( |
| 1077 | 1077 | $versionHeader, |
| 1078 | 1078 | $headerName |
@@ -1082,14 +1082,14 @@ discard block |
||
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | |
| 1085 | - $major = intval(substr($versionHeader, 0, $dotIndex)); |
|
| 1086 | - $minor = 0; |
|
| 1085 | + $major = intval(substr($versionHeader, 0, $dotIndex)); |
|
| 1086 | + $minor = 0; |
|
| 1087 | 1087 | |
| 1088 | - //Apparently the . is optional |
|
| 1088 | + //Apparently the . is optional |
|
| 1089 | 1089 | if ($dotIndex != -1) { |
| 1090 | 1090 | if ($dotIndex == 0) { |
| 1091 | - //If it starts with a ., throw an exception |
|
| 1092 | - throw ODataException::createBadRequestError( |
|
| 1091 | + //If it starts with a ., throw an exception |
|
| 1092 | + throw ODataException::createBadRequestError( |
|
| 1093 | 1093 | Messages::requestDescriptionInvalidVersionHeader( |
| 1094 | 1094 | $versionHeader, |
| 1095 | 1095 | $headerName |
@@ -1102,8 +1102,8 @@ discard block |
||
| 1102 | 1102 | |
| 1103 | 1103 | $version = new Version($major, $minor); |
| 1104 | 1104 | |
| 1105 | - //TODO: move this somewhere... |
|
| 1106 | - /* |
|
| 1105 | + //TODO: move this somewhere... |
|
| 1106 | + /* |
|
| 1107 | 1107 | $isSupportedVersion = false; |
| 1108 | 1108 | foreach (self::getKnownDataServiceVersions() as $version1) { |
| 1109 | 1109 | if ($version->compare($version1) == 0) { |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | $this->requestMaxVersion = is_null($maxRequestVersion) ? $this->requestVersion : self::parseVersionHeader($maxRequestVersion, ODataConstants::ODATAMAXVERSIONHEADER); |
| 270 | 270 | |
| 271 | 271 | //if it's OData v3..things change a bit |
| 272 | - if($this->maxServiceVersion == Version::v3()){ |
|
| 273 | - if(is_null($maxRequestVersion)) |
|
| 272 | + if ($this->maxServiceVersion == Version::v3()) { |
|
| 273 | + if (is_null($maxRequestVersion)) |
|
| 274 | 274 | { |
| 275 | 275 | //if max request version isn't specified we use the service max version instead of the request version |
| 276 | 276 | //thus we favour newer versions |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | * @throws ODataException If capability negotiation fails. |
| 403 | 403 | */ |
| 404 | 404 | public function raiseMinVersionRequirement($major, $minor) { |
| 405 | - if($this->requiredMinRequestVersion->raiseVersion($major, $minor)) |
|
| 405 | + if ($this->requiredMinRequestVersion->raiseVersion($major, $minor)) |
|
| 406 | 406 | { |
| 407 | 407 | $this->validateVersions(); |
| 408 | 408 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @throws ODataException If capability negotiation fails. |
| 419 | 419 | */ |
| 420 | 420 | public function raiseResponseVersion($major, $minor) { |
| 421 | - if($this->requiredMinResponseVersion->raiseVersion($major, $minor)){ |
|
| 421 | + if ($this->requiredMinResponseVersion->raiseVersion($major, $minor)) { |
|
| 422 | 422 | $this->validateVersions(); |
| 423 | 423 | } |
| 424 | 424 | |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | * |
| 753 | 753 | * @return void |
| 754 | 754 | */ |
| 755 | - public function setInternalOrderByInfo(InternalOrderByInfo &$internalOrderByInfo) |
|
| 755 | + public function setInternalOrderByInfo(InternalOrderByInfo & $internalOrderByInfo) |
|
| 756 | 756 | { |
| 757 | 757 | $this->internalOrderByInfo = $internalOrderByInfo; |
| 758 | 758 | } |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | * @return void |
| 777 | 777 | */ |
| 778 | 778 | public function setInternalSkipTokenInfo( |
| 779 | - InternalSkipTokenInfo &$internalSkipTokenInfo |
|
| 779 | + InternalSkipTokenInfo & $internalSkipTokenInfo |
|
| 780 | 780 | ) { |
| 781 | 781 | $this->_internalSkipTokenInfo = $internalSkipTokenInfo; |
| 782 | 782 | } |
@@ -808,9 +808,9 @@ discard block |
||
| 808 | 808 | * |
| 809 | 809 | * @return void |
| 810 | 810 | */ |
| 811 | - public function setRootProjectionNode(RootProjectionNode &$rootProjectionNode) |
|
| 811 | + public function setRootProjectionNode(RootProjectionNode & $rootProjectionNode) |
|
| 812 | 812 | { |
| 813 | - $this->_rootProjectionNode = $rootProjectionNode; |
|
| 813 | + $this->_rootProjectionNode = $rootProjectionNode; |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | /** |
@@ -321,12 +321,10 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | - } |
|
| 325 | - elseif ($dataType === MimeTypes::MIME_APPLICATION_JSON) { |
|
| 324 | + } elseif ($dataType === MimeTypes::MIME_APPLICATION_JSON) { |
|
| 326 | 325 | $data = json_decode($string, true); |
| 327 | 326 | $this->_data = $data; |
| 328 | - } |
|
| 329 | - elseif (explode(';', $dataType)[0] === MimeTypes::MIME_MULTIPART_MIXED) { |
|
| 327 | + } elseif (explode(';', $dataType)[0] === MimeTypes::MIME_MULTIPART_MIXED) { |
|
| 330 | 328 | preg_match('/boundary=(.*)$/', $dataType, $matches); |
| 331 | 329 | $boundary = $matches[1]; |
| 332 | 330 | |
@@ -337,20 +335,22 @@ discard block |
||
| 337 | 335 | // loop data blocks |
| 338 | 336 | foreach ($a_blocks as $id => $block) |
| 339 | 337 | { |
| 340 | - if (empty($block)) |
|
| 341 | - continue; |
|
| 338 | + if (empty($block)) { |
|
| 339 | + continue; |
|
| 340 | + } |
|
| 342 | 341 | |
| 343 | 342 | $contentType = null; |
| 344 | 343 | $requestMethod = null; |
| 345 | 344 | $requestUrl = null; |
| 346 | 345 | |
| 347 | 346 | foreach (explode("\n", $block) as $line) { |
| 348 | - if (empty($line)) continue; |
|
| 347 | + if (empty($line)) { |
|
| 348 | + continue; |
|
| 349 | + } |
|
| 349 | 350 | $m = array(); |
| 350 | 351 | if (preg_match('/Content-Type:\s*(.*?)\s*$/', $line, $m)) { |
| 351 | 352 | $contentType = trim($m[1]); |
| 352 | - } |
|
| 353 | - else if (preg_match('/^(GET|PUT|POST|PATCH|DELETE)\s+(.*?)(\s+HTTP\/\d\.\d)?\s*$/', $line, $m)) { |
|
| 353 | + } else if (preg_match('/^(GET|PUT|POST|PATCH|DELETE)\s+(.*?)(\s+HTTP\/\d\.\d)?\s*$/', $line, $m)) { |
|
| 354 | 354 | $requestMethod = trim($m[1]); |
| 355 | 355 | $requestUrl = new Url(trim($m[2]), false); |
| 356 | 356 | } |
@@ -10,116 +10,116 @@ |
||
| 10 | 10 | |
| 11 | 11 | class IncomingIlluminateRequest implements IHTTPRequest |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * The Illuminate request |
|
| 15 | - * |
|
| 16 | - * @var Request |
|
| 17 | - */ |
|
| 18 | - private $request; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * The request headers |
|
| 22 | - * |
|
| 23 | - * @var array |
|
| 24 | - */ |
|
| 25 | - private $_headers; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * The incoming url in raw format |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - private $_rawUrl = null; |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The request method (GET, POST, PUT, DELETE or MERGE) |
|
| 37 | - * |
|
| 38 | - * @var HTTPRequestMethod HttpVerb |
|
| 39 | - */ |
|
| 40 | - private $_method; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The query options as key value. |
|
| 44 | - * |
|
| 45 | - * @var array(string, string); |
|
| 46 | - */ |
|
| 47 | - private $_queryOptions; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * A collection that represents mapping between query |
|
| 51 | - * option and its count. |
|
| 52 | - * |
|
| 53 | - * @var array(string, int) |
|
| 54 | - */ |
|
| 55 | - private $_queryOptionsCount; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * IncomingIlluminateRequest constructor. |
|
| 59 | - * @param Request $request |
|
| 60 | - */ |
|
| 61 | - public function __construct(Request $request) |
|
| 62 | - { |
|
| 63 | - $this->request = $request; |
|
| 64 | - $this->_headers = null; |
|
| 65 | - $this->_queryOptions = null; |
|
| 66 | - $this->_queryOptionsCount = null; |
|
| 67 | - $this->_method = new HTTPRequestMethod($this->request->getMethod()); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return string RequestURI called by User with the value of QueryString |
|
| 72 | - */ |
|
| 73 | - public function getRawUrl() |
|
| 74 | - { |
|
| 75 | - $this->_rawUrl = $this->request->fullUrl(); |
|
| 76 | - |
|
| 77 | - return $this->_rawUrl; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @param string $key The header name |
|
| 82 | - * @return array|null|string |
|
| 83 | - */ |
|
| 84 | - public function getRequestHeader($key) |
|
| 85 | - { |
|
| 86 | - $result = $this->request->header($key); |
|
| 87 | - //Zend returns false for a missing header...POData needs a null |
|
| 88 | - if($result === false || $result === ''){ |
|
| 89 | - return null; |
|
| 90 | - } |
|
| 91 | - return $result; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Returns the Query String Parameters (QSPs) as an array of KEY-VALUE pairs. If a QSP appears twice |
|
| 96 | - * it will have two entries in this array |
|
| 97 | - * |
|
| 98 | - * @return array |
|
| 99 | - */ |
|
| 100 | - public function getQueryParameters() |
|
| 101 | - { |
|
| 102 | - //TODO: the contract is more specific than this, it requires the name and values to be decoded |
|
| 103 | - //not sure how to test that... |
|
| 104 | - //TODO: another issue. This may not be the right thing to return...since POData only really understands GET requests today |
|
| 105 | - //Have to convert to the stranger format known to POData that deals with multiple query strings. |
|
| 106 | - //this makes this request a bit non compliant as it doesn't expose duplicate keys, something POData will check for |
|
| 107 | - //instead whatever parameter was last in the query string is set. IE |
|
| 108 | - //odata.svc/?$format=xml&$format=json the format will be json |
|
| 109 | - $this->_queryOptions = []; |
|
| 110 | - $this->_queryOptionsCount = 0; |
|
| 111 | - foreach($this->request->all() as $key => $value){ |
|
| 112 | - $this->_queryOptions[] = [$key => $value]; |
|
| 113 | - $this->_queryOptionsCount++; |
|
| 114 | - } |
|
| 115 | - return $this->_queryOptions; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @return HTTPRequestMethod |
|
| 120 | - */ |
|
| 121 | - public function getMethod() |
|
| 122 | - { |
|
| 123 | - return $this->_method; |
|
| 124 | - } |
|
| 13 | + /** |
|
| 14 | + * The Illuminate request |
|
| 15 | + * |
|
| 16 | + * @var Request |
|
| 17 | + */ |
|
| 18 | + private $request; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * The request headers |
|
| 22 | + * |
|
| 23 | + * @var array |
|
| 24 | + */ |
|
| 25 | + private $_headers; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * The incoming url in raw format |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + private $_rawUrl = null; |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The request method (GET, POST, PUT, DELETE or MERGE) |
|
| 37 | + * |
|
| 38 | + * @var HTTPRequestMethod HttpVerb |
|
| 39 | + */ |
|
| 40 | + private $_method; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The query options as key value. |
|
| 44 | + * |
|
| 45 | + * @var array(string, string); |
|
| 46 | + */ |
|
| 47 | + private $_queryOptions; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * A collection that represents mapping between query |
|
| 51 | + * option and its count. |
|
| 52 | + * |
|
| 53 | + * @var array(string, int) |
|
| 54 | + */ |
|
| 55 | + private $_queryOptionsCount; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * IncomingIlluminateRequest constructor. |
|
| 59 | + * @param Request $request |
|
| 60 | + */ |
|
| 61 | + public function __construct(Request $request) |
|
| 62 | + { |
|
| 63 | + $this->request = $request; |
|
| 64 | + $this->_headers = null; |
|
| 65 | + $this->_queryOptions = null; |
|
| 66 | + $this->_queryOptionsCount = null; |
|
| 67 | + $this->_method = new HTTPRequestMethod($this->request->getMethod()); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return string RequestURI called by User with the value of QueryString |
|
| 72 | + */ |
|
| 73 | + public function getRawUrl() |
|
| 74 | + { |
|
| 75 | + $this->_rawUrl = $this->request->fullUrl(); |
|
| 76 | + |
|
| 77 | + return $this->_rawUrl; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @param string $key The header name |
|
| 82 | + * @return array|null|string |
|
| 83 | + */ |
|
| 84 | + public function getRequestHeader($key) |
|
| 85 | + { |
|
| 86 | + $result = $this->request->header($key); |
|
| 87 | + //Zend returns false for a missing header...POData needs a null |
|
| 88 | + if($result === false || $result === ''){ |
|
| 89 | + return null; |
|
| 90 | + } |
|
| 91 | + return $result; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Returns the Query String Parameters (QSPs) as an array of KEY-VALUE pairs. If a QSP appears twice |
|
| 96 | + * it will have two entries in this array |
|
| 97 | + * |
|
| 98 | + * @return array |
|
| 99 | + */ |
|
| 100 | + public function getQueryParameters() |
|
| 101 | + { |
|
| 102 | + //TODO: the contract is more specific than this, it requires the name and values to be decoded |
|
| 103 | + //not sure how to test that... |
|
| 104 | + //TODO: another issue. This may not be the right thing to return...since POData only really understands GET requests today |
|
| 105 | + //Have to convert to the stranger format known to POData that deals with multiple query strings. |
|
| 106 | + //this makes this request a bit non compliant as it doesn't expose duplicate keys, something POData will check for |
|
| 107 | + //instead whatever parameter was last in the query string is set. IE |
|
| 108 | + //odata.svc/?$format=xml&$format=json the format will be json |
|
| 109 | + $this->_queryOptions = []; |
|
| 110 | + $this->_queryOptionsCount = 0; |
|
| 111 | + foreach($this->request->all() as $key => $value){ |
|
| 112 | + $this->_queryOptions[] = [$key => $value]; |
|
| 113 | + $this->_queryOptionsCount++; |
|
| 114 | + } |
|
| 115 | + return $this->_queryOptions; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @return HTTPRequestMethod |
|
| 120 | + */ |
|
| 121 | + public function getMethod() |
|
| 122 | + { |
|
| 123 | + return $this->_method; |
|
| 124 | + } |
|
| 125 | 125 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param RequestDescription $request Description of the request submitted by client. |
| 66 | 66 | * @param IService $service Reference to the service implementation. |
| 67 | 67 | */ |
| 68 | - private function __construct(RequestDescription $request, IService $service ) { |
|
| 68 | + private function __construct(RequestDescription $request, IService $service) { |
|
| 69 | 69 | $this->request = $request; |
| 70 | 70 | $this->service = $service; |
| 71 | 71 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @throws ODataException |
| 104 | 104 | */ |
| 105 | - public static function process(RequestDescription $request, IService $service ) { |
|
| 105 | + public static function process(RequestDescription $request, IService $service) { |
|
| 106 | 106 | $queryProcessor = new QueryProcessor($request, $service); |
| 107 | 107 | if ($request->getTargetSource() == TargetSource::NONE) { |
| 108 | 108 | //A service directory, metadata or batch request |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | private function _processSkipAndTop() |
| 149 | 149 | { |
| 150 | 150 | $value = null; |
| 151 | - if ($this->_readSkipOrTopOption( ODataConstants::HTTPQUERY_STRING_SKIP, $value ) ) { |
|
| 151 | + if ($this->_readSkipOrTopOption(ODataConstants::HTTPQUERY_STRING_SKIP, $value)) { |
|
| 152 | 152 | $this->request->setSkipCount($value); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | ->getResourceSetPageSize(); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ($this->_readSkipOrTopOption(ODataConstants::HTTPQUERY_STRING_TOP, $value) ) { |
|
| 163 | + if ($this->_readSkipOrTopOption(ODataConstants::HTTPQUERY_STRING_TOP, $value)) { |
|
| 164 | 164 | $this->request->setTopOptionCount($value); |
| 165 | 165 | if ($isPagingRequired && $pageSize < $value) { |
| 166 | 166 | //If $top is greater than or equal to page size, |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | private function _processOrderBy() |
| 198 | 198 | { |
| 199 | - $orderBy = $this->service->getHost()->getQueryStringItem( ODataConstants::HTTPQUERY_STRING_ORDERBY ); |
|
| 199 | + $orderBy = $this->service->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_ORDERBY); |
|
| 200 | 200 | |
| 201 | 201 | if (!is_null($orderBy)) { |
| 202 | 202 | $this->_checkSetQueryApplicable(); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * RequestDescription::getTopCount will give non-null value. |
| 218 | 218 | * |
| 219 | 219 | */ |
| 220 | - if (!is_null($this->request->getSkipCount())|| !is_null($this->request->getTopCount())) { |
|
| 220 | + if (!is_null($this->request->getSkipCount()) || !is_null($this->request->getTopCount())) { |
|
| 221 | 221 | $orderBy = !is_null($orderBy) ? $orderBy . ', ' : null; |
| 222 | 222 | $keys = array_keys($targetResourceType->getKeyProperties()); |
| 223 | 223 | //assert(!empty($keys)) |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | private function _processFilter() |
| 262 | 262 | { |
| 263 | - $filter = $this->service->getHost()->getQueryStringItem( ODataConstants::HTTPQUERY_STRING_FILTER ); |
|
| 263 | + $filter = $this->service->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FILTER); |
|
| 264 | 264 | if (is_null($filter)) { |
| 265 | 265 | return; |
| 266 | 266 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $kind = $this->request->getTargetKind(); |
| 269 | 269 | if (!($kind == TargetKind::RESOURCE() |
| 270 | 270 | || $kind == TargetKind::COMPLEX_OBJECT() |
| 271 | - || $this->request->queryType == QueryType::COUNT() ) |
|
| 271 | + || $this->request->queryType == QueryType::COUNT()) |
|
| 272 | 272 | ) { |
| 273 | 273 | throw ODataException::createBadRequestError( |
| 274 | 274 | Messages::queryProcessorQueryFilterOptionNotApplicable() |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | $resourceType = $this->request->getTargetResourceType(); |
| 278 | 278 | $expressionProvider = $this->service->getProvidersWrapper()->getExpressionProvider(); |
| 279 | 279 | $filterInfo = ExpressionParser2::parseExpression2($filter, $resourceType, $expressionProvider); |
| 280 | - $this->request->setFilterInfo( $filterInfo ); |
|
| 280 | + $this->request->setFilterInfo($filterInfo); |
|
| 281 | 281 | |
| 282 | 282 | } |
| 283 | 283 | |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | private function _processCount() |
| 296 | 296 | { |
| 297 | - $inlineCount = $this->service->getHost()->getQueryStringItem( ODataConstants::HTTPQUERY_STRING_INLINECOUNT ); |
|
| 297 | + $inlineCount = $this->service->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_INLINECOUNT); |
|
| 298 | 298 | |
| 299 | 299 | //If it's not specified, we're done |
| 300 | - if(is_null($inlineCount)) return; |
|
| 300 | + if (is_null($inlineCount)) return; |
|
| 301 | 301 | |
| 302 | 302 | //If the service doesn't allow count requests..then throw an exception |
| 303 | 303 | if (!$this->service->getConfiguration()->getAcceptCountRequests()) { |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | //You can't specify $count & $inlinecount together |
| 317 | 317 | //TODO: ensure there's a test for this case see #55 |
| 318 | - if ($this->request->queryType == QueryType::COUNT() ) { |
|
| 318 | + if ($this->request->queryType == QueryType::COUNT()) { |
|
| 319 | 319 | throw ODataException::createBadRequestError( |
| 320 | 320 | Messages::queryProcessorInlineCountWithValueCount() |
| 321 | 321 | ); |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | if ($inlineCount === ODataConstants::URI_ROWCOUNT_ALLOPTION) { |
| 328 | 328 | $this->request->queryType = QueryType::ENTITIES_WITH_COUNT(); |
| 329 | 329 | |
| 330 | - $this->request->raiseMinVersionRequirement( 2, 0 ); |
|
| 331 | - $this->request->raiseResponseVersion( 2, 0 ); |
|
| 330 | + $this->request->raiseMinVersionRequirement(2, 0); |
|
| 331 | + $this->request->raiseResponseVersion(2, 0); |
|
| 332 | 332 | |
| 333 | 333 | } else { |
| 334 | 334 | throw ODataException::createBadRequestError( |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | */ |
| 356 | 356 | private function _processSkipToken() |
| 357 | 357 | { |
| 358 | - $skipToken = $this->service->getHost()->getQueryStringItem( ODataConstants::HTTPQUERY_STRING_SKIPTOKEN ); |
|
| 358 | + $skipToken = $this->service->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_SKIPTOKEN); |
|
| 359 | 359 | if (is_null($skipToken)) { |
| 360 | 360 | return; |
| 361 | 361 | } |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | $skipToken |
| 384 | 384 | ); |
| 385 | 385 | $this->request->setInternalSkipTokenInfo($internalSkipTokenInfo); |
| 386 | - $this->request->raiseMinVersionRequirement( 2, 0 ); |
|
| 387 | - $this->request->raiseResponseVersion( 2, 0 ); |
|
| 386 | + $this->request->raiseMinVersionRequirement(2, 0); |
|
| 387 | + $this->request->raiseResponseVersion(2, 0); |
|
| 388 | 388 | |
| 389 | 389 | |
| 390 | 390 | } |
@@ -402,26 +402,26 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | private function _processExpandAndSelect() |
| 404 | 404 | { |
| 405 | - $expand = $this->service->getHost()->getQueryStringItem( ODataConstants::HTTPQUERY_STRING_EXPAND ); |
|
| 405 | + $expand = $this->service->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_EXPAND); |
|
| 406 | 406 | |
| 407 | 407 | if (!is_null($expand)) { |
| 408 | - $this->_checkExpandOrSelectApplicable(ODataConstants::HTTPQUERY_STRING_EXPAND ); |
|
| 408 | + $this->_checkExpandOrSelectApplicable(ODataConstants::HTTPQUERY_STRING_EXPAND); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - $select = $this->service->getHost()->getQueryStringItem( ODataConstants::HTTPQUERY_STRING_SELECT ); |
|
| 411 | + $select = $this->service->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_SELECT); |
|
| 412 | 412 | |
| 413 | 413 | if (!is_null($select)) { |
| 414 | 414 | if (!$this->service->getConfiguration()->getAcceptProjectionRequests()) { |
| 415 | - throw ODataException::createBadRequestError( Messages::configurationProjectionsNotAccepted() ); |
|
| 415 | + throw ODataException::createBadRequestError(Messages::configurationProjectionsNotAccepted()); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - $this->_checkExpandOrSelectApplicable( ODataConstants::HTTPQUERY_STRING_SELECT ); |
|
| 418 | + $this->_checkExpandOrSelectApplicable(ODataConstants::HTTPQUERY_STRING_SELECT); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // We will generate RootProjectionNode in case of $link request also, but |
| 422 | 422 | // expand and select in this case must be null (we are ensuring this above) |
| 423 | 423 | // 'RootProjectionNode' is required while generating next page Link |
| 424 | - if ($this->_expandSelectApplicable || $this->request->isLinkUri() ) { |
|
| 424 | + if ($this->_expandSelectApplicable || $this->request->isLinkUri()) { |
|
| 425 | 425 | |
| 426 | 426 | $rootProjectionNode = ExpandProjectionParser::parseExpandAndSelectClause( |
| 427 | 427 | $this->request->getTargetResourceSetWrapper(), |
@@ -434,13 +434,13 @@ discard block |
||
| 434 | 434 | $this->service->getProvidersWrapper() |
| 435 | 435 | ); |
| 436 | 436 | if ($rootProjectionNode->isSelectionSpecified()) { |
| 437 | - $this->request->raiseMinVersionRequirement(2, 0 ); |
|
| 437 | + $this->request->raiseMinVersionRequirement(2, 0); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | if ($rootProjectionNode->hasPagedExpandedResult()) { |
| 441 | - $this->request->raiseResponseVersion( 2, 0 ); |
|
| 441 | + $this->request->raiseResponseVersion(2, 0); |
|
| 442 | 442 | } |
| 443 | - $this->request->setRootProjectionNode($rootProjectionNode ); |
|
| 443 | + $this->request->setRootProjectionNode($rootProjectionNode); |
|
| 444 | 444 | |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $uriProcessor->request->setUriProcessor($uriProcessor); |
| 115 | 115 | |
| 116 | 116 | //Parse the query string options of the request Uri. |
| 117 | - QueryProcessor::process( $uriProcessor->request, $service ); |
|
| 117 | + QueryProcessor::process($uriProcessor->request, $service); |
|
| 118 | 118 | |
| 119 | 119 | return $uriProcessor; |
| 120 | 120 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function executePut() |
| 177 | 177 | { |
| 178 | - return $this->executeBase(function ($uriProcessor, $segment) { |
|
| 178 | + return $this->executeBase(function($uriProcessor, $segment) { |
|
| 179 | 179 | $requestMethod = $uriProcessor->service->getOperationContext()->incomingRequest()->getMethod(); |
| 180 | 180 | $resourceSet = $segment->getTargetResourceSetWrapper(); |
| 181 | 181 | $keyDescriptor = $segment->getKeyDescriptor(); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function executePost() |
| 201 | 201 | { |
| 202 | - return $this->executeBase(function ($uriProcessor, $segment) { |
|
| 202 | + return $this->executeBase(function($uriProcessor, $segment) { |
|
| 203 | 203 | $requestMethod = $uriProcessor->service->getOperationContext()->incomingRequest()->getMethod(); |
| 204 | 204 | $resourceSet = $segment->getTargetResourceSetWrapper(); |
| 205 | 205 | $data = $uriProcessor->request->getData(); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | protected function executeDelete() |
| 229 | 229 | { |
| 230 | - return $this->executeBase(function ($uriProcessor, $segment) { |
|
| 230 | + return $this->executeBase(function($uriProcessor, $segment) { |
|
| 231 | 231 | $requestMethod = $uriProcessor->service->getOperationContext()->incomingRequest()->getMethod(); |
| 232 | 232 | $resourceSet = $segment->getTargetResourceSetWrapper(); |
| 233 | 233 | $keyDescriptor = $segment->getKeyDescriptor(); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | protected function executeBatch() |
| 248 | 248 | { |
| 249 | 249 | $callback = null; |
| 250 | - $post_callback = function ($uriProcessor, $segment) { |
|
| 250 | + $post_callback = function($uriProcessor, $segment) { |
|
| 251 | 251 | $requestMethod = $uriProcessor->service->getOperationContext()->incomingRequest()->getMethod(); |
| 252 | 252 | $resourceSet = $segment->getTargetResourceSetWrapper(); |
| 253 | 253 | $data = $uriProcessor->request->getData(); |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | return; |
| 351 | - return $this->executeBase(function ($uriProcessor, $segment) { |
|
| 351 | + return $this->executeBase(function($uriProcessor, $segment) { |
|
| 352 | 352 | $requestMethod = $uriProcessor->service->getOperationContext()->incomingRequest()->getMethod(); |
| 353 | 353 | $resourceSet = $segment->getTargetResourceSetWrapper(); |
| 354 | 354 | $data = $uriProcessor->request->getData(); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | * @return void |
| 462 | 462 | * |
| 463 | 463 | */ |
| 464 | - private function handleSegmentTargetsToResourceSet( SegmentDescriptor $segment ) { |
|
| 464 | + private function handleSegmentTargetsToResourceSet(SegmentDescriptor $segment) { |
|
| 465 | 465 | if ($segment->isSingleResult()) { |
| 466 | 466 | $entityInstance = $this->providers->getResourceFromResourceSet( |
| 467 | 467 | $segment->getTargetResourceSetWrapper(), |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | //and just work with the QueryResult in the object model serializer |
| 563 | 563 | $result = $segment->getResult(); |
| 564 | 564 | |
| 565 | - if(!$result instanceof QueryResult){ |
|
| 565 | + if (!$result instanceof QueryResult) { |
|
| 566 | 566 | //If the segment isn't a query result, then there's no paging or counting to be done |
| 567 | 567 | return; |
| 568 | 568 | } |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | //Have POData perform paging if necessary |
| 582 | - if(!$this->providers->handlesOrderedPaging() && !empty($result->results)){ |
|
| 582 | + if (!$this->providers->handlesOrderedPaging() && !empty($result->results)) { |
|
| 583 | 583 | $result->results = $this->performPaging($result->results); |
| 584 | 584 | } |
| 585 | 585 | |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | if (!empty($result)) { |
| 623 | 623 | $top = $this->request->getTopCount(); |
| 624 | 624 | $skip = $this->request->getSkipCount(); |
| 625 | - if(is_null($skip)) $skip = 0; |
|
| 625 | + if (is_null($skip)) $skip = 0; |
|
| 626 | 626 | |
| 627 | 627 | $result = array_slice($result, $skip, $top); |
| 628 | 628 | } |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | * @throws InvalidOperationException If this function invoked with non-navigation |
| 830 | 830 | * property instance. |
| 831 | 831 | */ |
| 832 | - private function _pushSegmentForNavigationProperty(ResourceProperty &$resourceProperty) |
|
| 832 | + private function _pushSegmentForNavigationProperty(ResourceProperty & $resourceProperty) |
|
| 833 | 833 | { |
| 834 | 834 | if ($resourceProperty->getTypeKind() == ResourceTypeKind::ENTITY) { |
| 835 | 835 | $this->assert( |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | * |
| 925 | 925 | * @return bool true if the segment was push, false otherwise |
| 926 | 926 | */ |
| 927 | - private function _pushSegment($segmentName, ResourceSetWrapper &$resourceSetWrapper) |
|
| 927 | + private function _pushSegment($segmentName, ResourceSetWrapper & $resourceSetWrapper) |
|
| 928 | 928 | { |
| 929 | 929 | $rootProjectionNode = $this->request->getRootProjectionNode(); |
| 930 | 930 | if (!is_null($rootProjectionNode) |
@@ -143,21 +143,17 @@ discard block |
||
| 143 | 143 | $requestMethod = $operationContext->incomingRequest()->getMethod(); |
| 144 | 144 | if ($requestMethod == HTTPRequestMethod::GET) { |
| 145 | 145 | $this->executeGet(); |
| 146 | - } |
|
| 147 | - elseif ($requestMethod == HTTPRequestMethod::PUT) { |
|
| 146 | + } elseif ($requestMethod == HTTPRequestMethod::PUT) { |
|
| 148 | 147 | $this->executePut(); |
| 149 | - } |
|
| 150 | - elseif ($requestMethod == HTTPRequestMethod::POST) { |
|
| 148 | + } elseif ($requestMethod == HTTPRequestMethod::POST) { |
|
| 151 | 149 | if ($this->request->getLastSegment()->getTargetKind() == TargetKind::BATCH()) { |
| 152 | 150 | $this->executeBatch(); |
| 153 | 151 | } else { |
| 154 | 152 | $this->executePost(); |
| 155 | 153 | } |
| 156 | - } |
|
| 157 | - elseif ($requestMethod == HTTPRequestMethod::DELETE) { |
|
| 154 | + } elseif ($requestMethod == HTTPRequestMethod::DELETE) { |
|
| 158 | 155 | $this->executeDelete(); |
| 159 | - } |
|
| 160 | - else { |
|
| 156 | + } else { |
|
| 161 | 157 | throw ODataException::createNotImplementedError(Messages::unsupportedMethod($requestMethod)); |
| 162 | 158 | } |
| 163 | 159 | } |
@@ -622,7 +618,9 @@ discard block |
||
| 622 | 618 | if (!empty($result)) { |
| 623 | 619 | $top = $this->request->getTopCount(); |
| 624 | 620 | $skip = $this->request->getSkipCount(); |
| 625 | - if(is_null($skip)) $skip = 0; |
|
| 621 | + if(is_null($skip)) { |
|
| 622 | + $skip = 0; |
|
| 623 | + } |
|
| 626 | 624 | |
| 627 | 625 | $result = array_slice($result, $skip, $top); |
| 628 | 626 | } |