Skip to content

Commit 146b076

Browse files
committed
UPDATE: using Project object
1 parent 06dd0f2 commit 146b076

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

wps/controllers/processes_exec_rest.classic.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* @license https://www.mozilla.org/MPL/ Mozilla Public Licence
1010
*/
1111

12-
use LizmapApi\Utils;
1312
use LizmapWPS\WPS\Authenticator;
1413
use LizmapWPS\WPS\Error;
1514
use LizmapWPS\WPS\RequestHandler;
@@ -34,21 +33,22 @@ public function post(): object
3433

3534
$processID = $this->param('processid');
3635
$repository = $this->param('repository');
37-
$project = $this->param('project');
36+
$projectName = $this->param('project');
37+
38+
$project = lizmap::getRepository($repository)->getProject($projectName);
39+
3840
$data = $this->request->getBody();
3941

4042
try {
4143
if ($processID != null) {
42-
$repositoryObject = lizmap::getRepository($repository);
43-
if (is_null($repositoryObject)) {
44-
throw new \Exception('No repository "'.$repository.'" found', 404);
44+
if (is_null($project)) {
45+
throw new \Exception('No project or repository found.', 404);
4546
}
46-
$path = Utils::getLastPartPath($repositoryObject->getOriginalPath());
4747
$url = UrlServerUtil::retrieveServerURL('pygiswps_server_url').
4848
'processes/'.
4949
$processID.
5050
'/execution'.
51-
'?map='.$path.$project.'.qgs';
51+
'?map='.$project->getRelativeQgisPath();
5252
$response = RequestHandler::curlRequestPOST($url, $data);
5353
} else {
5454
$response = Error::setJSONError($rep, '400', 'Process id not found.');

wps/controllers/processes_rest.classic.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* @license https://www.mozilla.org/MPL/ Mozilla Public Licence
1010
*/
1111

12-
use LizmapApi\Utils;
1312
use LizmapWPS\WPS\Authenticator;
1413
use LizmapWPS\WPS\Error;
1514
use LizmapWPS\WPS\RequestHandler;
@@ -37,18 +36,15 @@ public function get(): object
3736
$url = UrlServerUtil::retrieveServerURL('pygiswps_server_url').'processes';
3837
$processID = $this->param('processid');
3938
$repository = $this->param('repository');
40-
$project = $this->param('project');
39+
$projectName = $this->param('project');
40+
41+
$project = lizmap::getRepository($repository)->getProject($projectName);
4142

4243
try {
4344
if ($processID != null) {
4445
$url = $url.'/'.$processID;
45-
if ($repository != null && $project != null) {
46-
$repositoryObject = lizmap::getRepository($repository);
47-
if (is_null($repositoryObject)) {
48-
throw new \Exception('No repository "'.$repository.'" found', 404);
49-
}
50-
$path = Utils::getLastPartPath($repositoryObject->getOriginalPath());
51-
$url = $url.'?map='.$path.$project.'.qgs';
46+
if ($project) {
47+
$url = $url.'?map='.$project->getRelativeQgisPath();
5248
}
5349
$response = RequestHandler::curlRequestGET($url);
5450
} else {

0 commit comments

Comments
 (0)