From ede5197923b02792e9b4b5ac06853703b51a7f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20B=C3=BC=C3=9Femeyer?= Date: Mon, 2 Dec 2024 17:48:53 +0100 Subject: [PATCH] add some error message --- app/controllers/DatasetController.scala | 4 ++-- app/models/dataset/DataStore.scala | 2 +- app/models/dataset/DatasetService.scala | 2 +- app/models/user/UserService.scala | 4 ++-- conf/messages | 4 +++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/DatasetController.scala b/app/controllers/DatasetController.scala index 142cda633f..59e0af498b 100755 --- a/app/controllers/DatasetController.scala +++ b/app/controllers/DatasetController.scala @@ -207,7 +207,7 @@ class DatasetController @Inject()(userService: UserService, searchQuery, recursive.getOrElse(false), limit) ?~> "dataset.list.failed" - js <- listGrouped(datasets, request.identity) ?~> "dataset.list.failed" + js <- listGrouped(datasets, request.identity) ?~> "dataset.list.grouping.failed" } yield Json.toJson(js) } _ = Fox.runOptional(request.identity)(user => userDAO.updateLastActivity(user._id)) @@ -223,7 +223,7 @@ class DatasetController @Inject()(userService: UserService, groupedByOrga = datasets.groupBy(_._organization).toList js <- Fox.serialCombined(groupedByOrga) { byOrgaTuple: (String, List[Dataset]) => for { - organization <- organizationDAO.findOne(byOrgaTuple._1)(GlobalAccessContext) + organization <- organizationDAO.findOne(byOrgaTuple._1)(GlobalAccessContext) ?~> "organization.notFound" groupedByDataStore = byOrgaTuple._2.groupBy(_._dataStore).toList result <- Fox.serialCombined(groupedByDataStore) { byDataStoreTuple: (String, List[Dataset]) => for { diff --git a/app/models/dataset/DataStore.scala b/app/models/dataset/DataStore.scala index e4450c3cf1..1b4cb17530 100644 --- a/app/models/dataset/DataStore.scala +++ b/app/models/dataset/DataStore.scala @@ -114,7 +114,7 @@ class DataStoreDAO @Inject()(sqlClient: SqlClient)(implicit ec: ExecutionContext for { accessQuery <- readAccessQuery r <- run(q"SELECT $columns FROM $existingCollectionName WHERE name = $name AND $accessQuery".as[DatastoresRow]) - parsed <- parseFirst(r, name) + parsed <- parseFirst(r, name) ?~> "dataStore.notFound" } yield parsed def findOneByUrl(url: String)(implicit ctx: DBAccessContext): Fox[DataStore] = diff --git a/app/models/dataset/DatasetService.scala b/app/models/dataset/DatasetService.scala index 20cf025fba..1649801169 100644 --- a/app/models/dataset/DatasetService.scala +++ b/app/models/dataset/DatasetService.scala @@ -349,7 +349,7 @@ class DatasetService @Inject()(organizationDAO: OrganizationDAO, organizationDAO.findOne(dataset._organization) ?~> "organization.notFound" } dataStore <- Fox.fillOption(dataStore) { - dataStoreFor(dataset) + dataStoreFor(dataset) ?~> "dataStore.notFound" } teams <- teamService.allowedTeamsForDataset(dataset, cumulative = false, requestingUserOpt) ?~> "dataset.list.fetchAllowedTeamsFailed" teamsJs <- Fox.serialCombined(teams)(t => teamService.publicWrites(t, Some(organization))) ?~> "dataset.list.teamWritesFailed" diff --git a/app/models/user/UserService.scala b/app/models/user/UserService.scala index be07b9d611..e8a1872e7f 100755 --- a/app/models/user/UserService.scala +++ b/app/models/user/UserService.scala @@ -279,11 +279,11 @@ class UserService @Inject()(conf: WkConf, userExperiencesDAO.findAllExperiencesForUser(_user) def teamMembershipsFor(_user: ObjectId): Fox[List[TeamMembership]] = - userDAO.findTeamMembershipsForUser(_user) + userDAO.findTeamMembershipsForUser(_user) ?~> "user.team.memberships.failed" def teamManagerMembershipsFor(_user: ObjectId): Fox[List[TeamMembership]] = for { - teamMemberships <- teamMembershipsFor(_user) + teamMemberships <- teamMembershipsFor(_user) ?~> "user.team.memberships.failed" } yield teamMemberships.filter(_.isTeamManager) def teamManagerTeamIdsFor(_user: ObjectId): Fox[List[ObjectId]] = diff --git a/conf/messages b/conf/messages index 34aa12fa2a..eb03c7c06f 100644 --- a/conf/messages +++ b/conf/messages @@ -68,6 +68,7 @@ user.notAuthorised=You are not authorized to view this resource. Please log in. user.id.notFound=We could not find a user id in the request. user.id.invalid=The provided user id is invalid. user.creation.failed=Failed to create user +user.team.memberships.failed=Failed to retrieve team memberships for user oidc.disabled=OIDC is disabled oidc.configuration.invalid=OIDC configuration is invalid @@ -88,7 +89,8 @@ dataset.name.alreadyTaken=This name is already being used by a different dataset dataset.source.usableButNoScale=Dataset {0} is marked as active but has no scale. dataset.import.fileAccessDenied=Cannot create organization folder. Please make sure WEBKNOSSOS has write permissions in the “binaryData” directory dataset.type.invalid=External data set of type “{0}” is not supported -dataset.list.failed=Failed to retrieve list of data sets. +dataset.list.failed=Failed to retrieve list of datasets. +dataset.list.grouping.failed=Failed group retrieved datasets. dataset.list.writesFailed=Failed to write json for dataset {0} dataset.noMags=Data layer does not contain mags dataset.sampledOnlyBlack=Sampled data positions contained only black data