Skip to content

Commit d05bd80

Browse files
committed
Merge commit 'refs/pull/11/head' of https://github.com/magento/bulk-api-ce into async-bulk-webapi
2 parents ba5a84e + 090bef8 commit d05bd80

File tree

9 files changed

+571
-248
lines changed

9 files changed

+571
-248
lines changed

app/code/Magento/WebapiAsync/Controller/Rest/Asynchronous/InputParamsResolver.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class InputParamsResolver
4444
* @var \Magento\Webapi\Controller\Rest\InputParamsResolver
4545
*/
4646
private $inputParamsResolver;
47+
/**
48+
* @var bool
49+
*/
50+
private $isBulk;
4751

4852
/**
4953
* Initialize dependencies.
@@ -54,21 +58,24 @@ class InputParamsResolver
5458
* @param \Magento\Webapi\Controller\Rest\Router $router
5559
* @param \Magento\Webapi\Controller\Rest\RequestValidator $requestValidator
5660
* @param \Magento\Webapi\Controller\Rest\InputParamsResolver $inputParamsResolver
61+
* @param bool $isBulk
5762
*/
5863
public function __construct(
5964
RestRequest $request,
6065
ParamsOverrider $paramsOverrider,
6166
ServiceInputProcessor $inputProcessor,
6267
Router $router,
6368
RequestValidator $requestValidator,
64-
WebapiInputParamsResolver $inputParamsResolver
69+
WebapiInputParamsResolver $inputParamsResolver,
70+
$isBulk = false
6571
) {
6672
$this->request = $request;
6773
$this->paramsOverrider = $paramsOverrider;
6874
$this->serviceInputProcessor = $inputProcessor;
6975
$this->router = $router;
7076
$this->requestValidator = $requestValidator;
7177
$this->inputParamsResolver = $inputParamsResolver;
78+
$this->isBulk = $isBulk;
7279
}
7380

7481
/**
@@ -82,6 +89,9 @@ public function __construct(
8289
*/
8390
public function resolve()
8491
{
92+
if ($this->isBulk === false) {
93+
return [$this->inputParamsResolver->resolve()];
94+
}
8595
$this->requestValidator->validate();
8696
$webapiResolvedParams = [];
8797
$inputData = $this->request->getRequestData();

app/code/Magento/WebapiAsync/Controller/Rest/AsynchronousBulkRequestProcessor.php

Lines changed: 0 additions & 131 deletions
This file was deleted.

app/code/Magento/WebapiAsync/Controller/Rest/AsynchronousBulkSchemaRequestProcessor.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

app/code/Magento/WebapiAsync/Controller/Rest/AsynchronousRequestProcessor.php

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,51 @@
1111
use Magento\Framework\Exception\BulkException;
1212
use Magento\Webapi\Controller\Rest\RequestProcessorInterface;
1313
use Magento\Framework\Webapi\Rest\Response as RestResponse;
14-
use Magento\Webapi\Controller\Rest\InputParamsResolver;
14+
use Magento\WebapiAsync\Controller\Rest\Asynchronous\InputParamsResolver;
1515
use Magento\AsynchronousOperations\Model\MassSchedule;
1616
use Magento\AsynchronousOperations\Model\ConfigInterface as WebApiAsyncConfig;
1717
use Magento\Framework\Reflection\DataObjectProcessor;
1818
use Magento\AsynchronousOperations\Api\Data\AsyncResponseInterfaceFactory;
1919
use Magento\AsynchronousOperations\Api\Data\AsyncResponseInterface;
2020

21+
/**
22+
* Responsible for dispatching single and bulk requests.
23+
* Single requests dispatching represented by this class.
24+
* Bulk requests dispatching represented by virtualType of this class.
25+
*/
2126
class AsynchronousRequestProcessor implements RequestProcessorInterface
2227
{
2328
const PROCESSOR_PATH = "/^\\/async(\\/V.+)/";
29+
const BULK_PROCESSOR_PATH = "/^\\/async\/bulk(\\/V.+)/";
2430

2531
/**
2632
* @var \Magento\Framework\Webapi\Rest\Response
2733
*/
2834
private $response;
29-
3035
/**
31-
* @var InputParamsResolver
36+
* @var \Magento\WebapiAsync\Controller\Rest\Asynchronous\InputParamsResolver
3237
*/
3338
private $inputParamsResolver;
34-
3539
/**
3640
* @var MassSchedule
3741
*/
3842
private $asyncBulkPublisher;
39-
4043
/**
4144
* @var WebApiAsyncConfig
4245
*/
4346
private $webapiAsyncConfig;
44-
4547
/**
4648
* @var \Magento\Framework\Reflection\DataObjectProcessor
4749
*/
4850
private $dataObjectProcessor;
49-
5051
/**
5152
* @var AsyncResponseInterfaceFactory
5253
*/
5354
private $asyncResponseFactory;
55+
/**
56+
* @var string Regex pattern
57+
*/
58+
private $processorPath;
5459

5560
/**
5661
* Initialize dependencies.
@@ -61,21 +66,24 @@ class AsynchronousRequestProcessor implements RequestProcessorInterface
6166
* @param WebapiAsyncConfig $webapiAsyncConfig
6267
* @param DataObjectProcessor $dataObjectProcessor
6368
* @param AsyncResponseInterfaceFactory $asyncResponse
69+
* @param string $processorPath
6470
*/
6571
public function __construct(
6672
RestResponse $response,
6773
InputParamsResolver $inputParamsResolver,
6874
MassSchedule $asyncBulkPublisher,
6975
WebApiAsyncConfig $webapiAsyncConfig,
7076
DataObjectProcessor $dataObjectProcessor,
71-
AsyncResponseInterfaceFactory $asyncResponse
77+
AsyncResponseInterfaceFactory $asyncResponse,
78+
$processorPath = self::PROCESSOR_PATH
7279
) {
7380
$this->response = $response;
7481
$this->inputParamsResolver = $inputParamsResolver;
7582
$this->asyncBulkPublisher = $asyncBulkPublisher;
7683
$this->webapiAsyncConfig = $webapiAsyncConfig;
7784
$this->dataObjectProcessor = $dataObjectProcessor;
7885
$this->asyncResponseFactory = $asyncResponse;
86+
$this->processorPath = $processorPath;
7987
}
8088

8189
/**
@@ -84,12 +92,12 @@ public function __construct(
8492
public function process(\Magento\Framework\Webapi\Rest\Request $request)
8593
{
8694
$path = $request->getPathInfo();
87-
$path = preg_replace(self::PROCESSOR_PATH, "$1", $path);
95+
$path = preg_replace($this->processorPath, "$1", $path);
8896
$request->setPathInfo(
8997
$path
9098
);
9199

92-
$entitiesParamsArray = [$this->inputParamsResolver->resolve()];
100+
$entitiesParamsArray = $this->inputParamsResolver->resolve();
93101
$topicName = $this->getTopicName($request);
94102

95103
try {
@@ -133,7 +141,19 @@ public function canProcess(\Magento\Framework\Webapi\Rest\Request $request)
133141
return false;
134142
}
135143

136-
if (preg_match(self::PROCESSOR_PATH, $request->getPathInfo()) === 1) {
144+
if (preg_match($this->processorPath, $request->getPathInfo()) === 1) {
145+
return true;
146+
}
147+
return false;
148+
}
149+
150+
/**
151+
* @param \Magento\Framework\Webapi\Rest\Request $request
152+
* @return bool
153+
*/
154+
public function isBulk(\Magento\Framework\Webapi\Rest\Request $request)
155+
{
156+
if (preg_match(self::BULK_PROCESSOR_PATH, $request->getPathInfo()) === 1) {
137157
return true;
138158
}
139159
return false;

0 commit comments

Comments
 (0)