diff --git a/lib/Service/RowService.php b/lib/Service/RowService.php index 4b433a635..8ea7242fc 100644 --- a/lib/Service/RowService.php +++ b/lib/Service/RowService.php @@ -71,7 +71,7 @@ public function findAllByTable(int $tableId, string $userId, ?int $limit = null, } } catch (Exception $e) { $this->logger->error($e->getMessage()); - throw new InternalError($e->getMessage(), $e->getCode(), $e); + throw new InternalError($e->getMessage()); } } @@ -98,7 +98,7 @@ public function findAllByView(int $viewId, string $userId, ?int $limit = null, ? } } catch (Exception $e) { $this->logger->error($e->getMessage()); - throw new InternalError($e->getMessage(), $e->getCode(), $e); + throw new InternalError($e->getMessage()); } } @@ -115,7 +115,7 @@ public function find(int $id): Row2 { $columns = $this->columnMapper->findAllByTable($id); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } try { @@ -125,7 +125,7 @@ public function find(int $id): Row2 { throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); } catch (NotFoundError $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } // security @@ -151,7 +151,7 @@ public function create(?int $tableId, ?int $viewId, array $data): Row2 { if ($this->userId === null || $this->userId === '') { $e = new \Exception('No user id in context, but needed.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } if ($viewId) { @@ -162,7 +162,7 @@ public function create(?int $tableId, ?int $viewId, array $data): Row2 { throw new NotFoundError("Given view could not be found. More details can be found in the log."); } catch (InternalError|Exception|MultipleObjectsReturnedException $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } // security @@ -176,20 +176,20 @@ public function create(?int $tableId, ?int $viewId, array $data): Row2 { $table = $this->tableMapper->find($tableId); } catch (DoesNotExistException $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new NotFoundError("Given table could not be found. More details can be found in the log.", $e->getCode(), $e); + throw new NotFoundError("Given table could not be found. More details can be found in the log."); } catch (MultipleObjectsReturnedException|Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } // security if (!$this->permissionsService->canCreateRows($table, 'table')) { - throw new PermissionError('create row at the table id = '.$tableId.' is not allowed.', $e->getCode(), $e); + throw new PermissionError('create row at the table id = '.$tableId.' is not allowed.'); } $columns = $this->columnMapper->findAllByTable($tableId); } else { - throw new InternalError('Cannot create row without table or view in context', $e->getCode(), $e); + throw new InternalError('Cannot create row without table or view in context'); } $data = $this->cleanupData($data, $columns, $tableId, $viewId); @@ -202,7 +202,7 @@ public function create(?int $tableId, ?int $viewId, array $data): Row2 { return $this->row2Mapper->insert($row2, $this->columnMapper->findAllByTable($tableId)); } catch (InternalError|Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } } @@ -230,7 +230,7 @@ private function cleanupData(array $data, array $columns, ?int $tableId, ?int $v if (!$column) { $e = new \Exception('No column found, can not parse value.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } // parse given value to respect the column type value format @@ -290,16 +290,16 @@ private function getRowById(int $rowId): Row2 { if ($this->row2Mapper->getTableIdForRow($rowId) === null) { $e = new \Exception('No table id in row, but needed.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } $row = $this->row2Mapper->find($rowId, $this->columnMapper->findAllByTable($this->row2Mapper->getTableIdForRow($rowId))); $row->markAsLoaded(); } catch (InternalError|DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } catch (NotFoundError $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } $this->tmpRows[$rowId] = $row; return $row; @@ -328,10 +328,10 @@ public function updateSet( $item = $this->getRowById($id); } catch (InternalError $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } catch (NotFoundError $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } if ($viewId) { @@ -339,24 +339,24 @@ public function updateSet( if (!$this->permissionsService->canUpdateRowsByViewId($viewId)) { $e = new \Exception('Update row is not allowed.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } try { $view = $this->viewMapper->find($viewId); } catch (InternalError|MultipleObjectsReturnedException|Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } catch (DoesNotExistException $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } // is row in view? if($this->row2Mapper->isRowInViewPresent($id, $view, $userId)) { $e = new \Exception('Update row is not allowed.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } // fetch all needed columns @@ -364,7 +364,7 @@ public function updateSet( $columns = $this->columnMapper->findMultiple($view->getColumnsArray()); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } } else { // if no view id is set, we assume a table and take the tableId from the row @@ -374,13 +374,13 @@ public function updateSet( if (!$this->permissionsService->canUpdateRowsByTableId($tableId)) { $e = new \Exception('Update row is not allowed.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } try { $columns = $this->columnMapper->findAllByTable($tableId); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } } @@ -415,10 +415,10 @@ public function delete(int $id, ?int $viewId, string $userId): Row2 { $item = $this->getRowById($id); } catch (InternalError $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } catch (NotFoundError $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new NotFoundError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } if ($viewId) { @@ -426,26 +426,26 @@ public function delete(int $id, ?int $viewId, string $userId): Row2 { if (!$this->permissionsService->canDeleteRowsByViewId($viewId)) { $e = new \Exception('Update row is not allowed.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } try { $view = $this->viewMapper->find($viewId); } catch (InternalError|DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } $rowIds = $this->mapper->getRowIdsOfView($view, $userId); if(!in_array($id, $rowIds)) { $e = new \Exception('Update row is not allowed.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } } else { // security if (!$this->permissionsService->canDeleteRowsByTableId($item->getTableId())) { $e = new \Exception('Update row is not allowed.'); $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new PermissionError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new PermissionError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } } @@ -453,7 +453,7 @@ public function delete(int $id, ?int $viewId, string $userId): Row2 { return $this->row2Mapper->delete($item); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage(), $e->getCode(), $e); + throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage()); } }