Skip to content

Commit 03b3ba5

Browse files
committed
UPDATE: using Project object
1 parent 06dd0f2 commit 03b3ba5

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

wps/controllers/processes_exec_rest.classic.php

Lines changed: 16 additions & 8 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,30 @@ 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');
3837
$data = $this->request->getBody();
3938

39+
$project = null;
40+
41+
if (!is_null($projectName) && !is_null($repository)) {
42+
try {
43+
$repoObj = lizmap::getRepository($repository);
44+
if (is_null($repoObj)) {
45+
throw new Exception('Repository not found.');
46+
}
47+
$project = $repoObj->getProject($projectName);
48+
} catch (Exception $e) {
49+
return Error::setJSONError($rep, 404, $e->getMessage());
50+
}
51+
}
52+
4053
try {
4154
if ($processID != null) {
42-
$repositoryObject = lizmap::getRepository($repository);
43-
if (is_null($repositoryObject)) {
44-
throw new \Exception('No repository "'.$repository.'" found', 404);
45-
}
46-
$path = Utils::getLastPartPath($repositoryObject->getOriginalPath());
4755
$url = UrlServerUtil::retrieveServerURL('pygiswps_server_url').
4856
'processes/'.
4957
$processID.
5058
'/execution'.
51-
'?map='.$path.$project.'.qgs';
59+
'?map='.$project->getRelativeQgisPath();
5260
$response = RequestHandler::curlRequestPOST($url, $data);
5361
} else {
5462
$response = Error::setJSONError($rep, '400', 'Process id not found.');

wps/controllers/processes_rest.classic.php

Lines changed: 16 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,26 @@ 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+
$project = null;
41+
42+
if (!is_null($projectName) && !is_null($repository)) {
43+
try {
44+
$repoObj = lizmap::getRepository($repository);
45+
if (is_null($repoObj)) {
46+
throw new Exception('Repository not found.');
47+
}
48+
$project = $repoObj->getProject($projectName);
49+
} catch (Exception $e) {
50+
return Error::setJSONError($rep, 404, $e->getMessage());
51+
}
52+
}
4153

4254
try {
4355
if ($processID != null) {
4456
$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';
57+
if (!is_null($project)) {
58+
$url = $url.'?map='.$project->getRelativeQgisPath();
5259
}
5360
$response = RequestHandler::curlRequestGET($url);
5461
} else {

0 commit comments

Comments
 (0)