fix: [workflow] Importing blueprints

pull/8653/head
Jakub Onderka 2022-10-10 22:26:08 +02:00
parent 1edaa324b4
commit 6da7ba5b7a
2 changed files with 8 additions and 5 deletions

View File

@ -101,11 +101,8 @@ class WorkflowBlueprintsController extends AppController
public function import()
{
if ($this->request->is('post') || $this->request->is('put')) {
$workflowBlueprintData = JsonTool::decode($this->request->data['WorkflowBlueprint']['json']);
if ($workflowBlueprintData === null) {
throw new MethodNotAllowedException(__('Error while decoding JSON'));
}
$this->request->data['WorkflowBlueprint']['data'] = JsonTool::encode($workflowBlueprintData);
$workflowBlueprintData = $this->_jsonDecode($this->request->data['WorkflowBlueprint']['json']);
$this->request->data = $workflowBlueprintData;
$this->add();
}
}
@ -117,6 +114,10 @@ class WorkflowBlueprintsController extends AppController
'id' => $id,
]
]);
if (empty($workflowBlueprint)) {
throw new NotFoundException(__('Invalid workflow blueprint'));
}
$content = JsonTool::encode($workflowBlueprint, true);
$this->response->body($content);
$this->response->type('json');

View File

@ -19,6 +19,7 @@ class WorkflowBlueprint extends AppModel
public $validate = [
'name' => 'stringNotEmpty',
'value' => [
'stringNotEmpty' => [
'rule' => ['stringNotEmpty']
@ -111,6 +112,7 @@ class WorkflowBlueprint extends AppModel
*
* @param boolean $force
* @return void
* @throws Exception
*/
public function update($force=false)
{