Skip to content

Commit

Permalink
Fix Dataset not found message (#4244)
Browse files Browse the repository at this point in the history
* change error message when dataset name is not available
* update changelog
* Merge branch 'master' into fix-dataset-not-found-message
* Merge refs/heads/master into fix-dataset-not-found-message
  • Loading branch information
youri-k authored and bulldozer-boy[bot] committed Aug 22, 2019
1 parent 6515c6c commit 34c2d95
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
### Fixed
- Data for disabled or invisible layers will no longer be downloaded, saving bandwidth and speeding up webKnossos in general. [#4202](https://github.com/scalableminds/webknossos/pull/4202)
- Fixed tooltip not disappearing in the statistics view in certain circumstances. [#4219](https://github.com/scalableminds/webknossos/pull/4219)
- Fixed the error messages when trying to access a dataset with insufficient permissions. [#4244](https://github.com/scalableminds/webknossos/pull/4244)

### Removed
-
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/AnnotationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class AnnotationController @Inject()(
private def duplicateAnnotation(annotation: Annotation, user: User)(implicit ctx: DBAccessContext,
m: MessagesProvider): Fox[Annotation] =
for {
dataSet <- dataSetDAO.findOne(annotation._dataSet)(GlobalAccessContext) ?~> "dataSet.notFound" ~> NOT_FOUND
dataSet <- dataSetDAO.findOne(annotation._dataSet)(GlobalAccessContext) ?~> "dataSet.nonExistent" ~> NOT_FOUND
_ <- bool2Fox(dataSet.isUsable) ?~> Messages("dataSet.notImported", dataSet.name)
tracingStoreClient <- tracingStoreService.clientFor(dataSet)
newSkeletonTracingReference <- Fox.runOptional(annotation.skeletonTracingId)(id =>
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/AnnotationIOController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class AnnotationIOController @Inject()(nmlWriter: NmlWriter,
organizationNameOpt <- assertAllOnSameOrganization(parseSuccesses.flatMap(s => s.organizationName)) ?~> "nml.file.differentDatasets"
organizationIdOpt <- Fox.runOptional(organizationNameOpt) {
organizationDAO.findOneByName(_)(GlobalAccessContext).map(_._id)
} ?~> Messages("dataSet.notFound", dataSetName) ~> FORBIDDEN
} ?~> Messages("organization.notFound", organizationNameOpt.getOrElse("")) ~> NOT_FOUND
organizationId <- Fox.fillOption(organizationIdOpt) {
dataSetDAO.getOrganizationForDataSet(dataSetName)(GlobalAccessContext)
} ?~> Messages("dataSet.noAccess", dataSetName) ~> FORBIDDEN
Expand Down Expand Up @@ -282,7 +282,7 @@ class AnnotationIOController @Inject()(nmlWriter: NmlWriter,
restrictions <- provider.restrictionsFor(typ, annotationId)
name <- provider.nameFor(annotation) ?~> "annotation.name.impossible"
_ <- restrictions.allowDownload(issuingUser) ?~> "annotation.download.notAllowed" ~> FORBIDDEN
dataSet <- dataSetDAO.findOne(annotation._dataSet)(GlobalAccessContext) ?~> "dataSet.notFound" ~> NOT_FOUND
dataSet <- dataSetDAO.findOne(annotation._dataSet)(GlobalAccessContext) ?~> "dataSet.nonExistent" ~> NOT_FOUND
organization <- organizationDAO.findOne(dataSet._organization)(GlobalAccessContext) ?~> "organization.notFound" ~> NOT_FOUND
(downloadStream, fileName) <- tracingToDownloadStream(dataSet, annotation, name, organization.name)
} yield {
Expand Down
12 changes: 6 additions & 6 deletions app/models/annotation/AnnotationService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class AnnotationService @Inject()(annotationInformationProvider: AnnotationInfor
}

for {
dataSet <- dataSetDAO.findOne(annotation._dataSet) ?~> "dataSet.notFound"
dataSet <- dataSetDAO.findOne(annotation._dataSet) ?~> "dataSet.nonExistent"
dataSource <- dataSetService.dataSourceFor(dataSet).flatMap(_.toUsable) ?~> "dataSource.notFound"
_ <- createNewTracings(dataSet, dataSource) ?~> "makeHybrid.createTracings.failed"
} yield ()
Expand Down Expand Up @@ -251,8 +251,8 @@ class AnnotationService @Inject()(annotationInformationProvider: AnnotationInfor
ctx: DBAccessContext): Fox[Annotation] = {
def useAsTemplateAndInsert(annotation: Annotation) =
for {
dataSetName <- dataSetDAO.getNameById(annotation._dataSet)(GlobalAccessContext) ?~> "dataSet.notFound"
dataSet <- dataSetDAO.findOne(annotation._dataSet) ?~> "dataSet.noAccess"
dataSetName <- dataSetDAO.getNameById(annotation._dataSet)(GlobalAccessContext) ?~> "dataSet.nonExistent"
dataSet <- dataSetDAO.findOne(annotation._dataSet) ?~> Messages("dataSet.noAccess", dataSetName)
(newSkeletonId, newVolumeId) <- tracingFromBase(annotation, dataSet) ?~> s"Failed to use annotation base as template for task ${task._id} with annotation base ${annotation._id}"
newAnnotation = annotation.copy(
_id = initializingAnnotationId,
Expand Down Expand Up @@ -566,7 +566,7 @@ class AnnotationService @Inject()(annotationInformationProvider: AnnotationInfor
_ = logger.warn(
s"Resetting annotation ${annotation._id} to base, discarding skeleton tracing ${annotation.skeletonTracingId}")
annotationBase <- baseForTask(task._id)
dataSet <- dataSetDAO.findOne(annotationBase._dataSet)(GlobalAccessContext) ?~> "dataSet.notFound"
dataSet <- dataSetDAO.findOne(annotationBase._dataSet)(GlobalAccessContext) ?~> "dataSet.nonExistent"
(newSkeletonIdOpt, newVolumeIdOpt) <- tracingFromBase(annotationBase, dataSet)
_ <- Fox
.bool2Fox(newSkeletonIdOpt.isDefined || newVolumeIdOpt.isDefined) ?~> "annotation.needsEitherSkeletonOrVolume"
Expand Down Expand Up @@ -598,7 +598,7 @@ class AnnotationService @Inject()(annotationInformationProvider: AnnotationInfor
restrictionsOpt: Option[AnnotationRestrictions] = None): Fox[JsObject] = {
implicit val ctx = GlobalAccessContext
for {
dataSet <- dataSetDAO.findOne(annotation._dataSet) ?~> "dataSet.notFound"
dataSet <- dataSetDAO.findOne(annotation._dataSet) ?~> "dataSet.nonExistent"
organization <- organizationDAO.findOne(dataSet._organization) ?~> "organization.notFound"
task = annotation._task.toFox.flatMap(taskId => taskDAO.findOne(taskId))
taskJson <- task.flatMap(t => taskService.publicWrites(t)).getOrElse(JsNull)
Expand Down Expand Up @@ -647,7 +647,7 @@ class AnnotationService @Inject()(annotationInformationProvider: AnnotationInfor
//for Explorative Annotations list
def compactWrites(annotation: Annotation)(implicit ctx: DBAccessContext): Fox[JsObject] =
for {
dataSet <- dataSetDAO.findOne(annotation._dataSet)(GlobalAccessContext) ?~> "dataSet.notFound"
dataSet <- dataSetDAO.findOne(annotation._dataSet)(GlobalAccessContext) ?~> "dataSet.nonExistent"
organization <- organizationDAO.findOne(dataSet._organization)(GlobalAccessContext) ?~> "organization.notFound"
} yield {
Json.obj(
Expand Down
1 change: 1 addition & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ braintracing.exists=Great, you already have an account on braintracing.org. Plea
dataSet=Dataset
dataSet.file=Dataset ZIP File
dataSet.notFound=Dataset {0} doesn’t exist
dataSet.nonExistent=The requested DataSet doesn’t exist.
dataSet.noAccess=Could not access DataSet {0}. Does your team have access?
dataSet.notImported=Dataset {0} is not imported
dataSet.name.invalid=A dataset name can only contain letters, digits and underscores
Expand Down

0 comments on commit 34c2d95

Please sign in to comment.