Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused legacy routes #8293

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions app/controllers/LegacyApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,6 @@ class LegacyApiController @Inject()(annotationController: AnnotationController,
} yield adaptedResult
}

def updateTaskV8(taskId: String): Action[LegacyTaskParameters] =
sil.SecuredAction.async(validateJson[LegacyTaskParameters]) { implicit request =>
val params = request.body
for {
dataset <- datasetDAO.findOneByIdOrNameAndOrganization(params.datasetId,
params.dataSet,
request.identity._organization)
paramsWithDatasetId = TaskParameters.fromLegacyTaskParameters(params, dataset._id)
requestWithUpdatedBody = request.withBody(paramsWithDatasetId)
result <- taskController.update(taskId)(requestWithUpdatedBody)
adaptedResult <- replaceInResult(addLegacyDataSetFieldToTask)(result)
} yield adaptedResult
}

def tasksForProjectV8(id: String,
limit: Option[Int] = None,
pageNumber: Option[Int] = None,
Expand All @@ -153,23 +139,6 @@ class LegacyApiController @Inject()(annotationController: AnnotationController,
} yield replacedResults
}

def annotationInfoV8(id: String, timestamp: Long): Action[AnyContent] = sil.SecuredAction.async { implicit request =>
for {
_ <- Fox.successful(logVersioned(request))
result <- annotationController.infoWithoutType(id, timestamp)(request)
adaptedResult <- replaceInResult(addDataSetToTaskInAnnotation)(result)
} yield adaptedResult
}

def annotationsForTaskV8(taskId: String): Action[AnyContent] =
sil.SecuredAction.async { implicit request =>
for {
_ <- Fox.successful(logVersioned(request))
result <- annotationController.annotationsForTask(taskId)(request)
adaptedResult <- replaceInResult(addDataSetToTaskInAnnotation)(result)
} yield adaptedResult
}

/* provide v7 */

def listDatasetsV7(isActive: Option[Boolean],
Expand Down Expand Up @@ -256,17 +225,6 @@ class LegacyApiController @Inject()(annotationController: AnnotationController,
}
}

private def addDataSetToTaskInAnnotation(jsResult: JsObject): Fox[JsObject] = {
val taskObjectOpt = (jsResult \ "task").asOpt[JsObject]
taskObjectOpt
.map(task =>
for {
adaptedTask <- addLegacyDataSetFieldToTask(task)
adaptedJsResult <- tryo(jsResult - "task" + ("task" -> adaptedTask)).toFox
} yield adaptedJsResult)
.getOrElse(Fox.successful(jsResult))
}

private def addLegacyDataSetFieldToTaskCreationResult(jsResult: JsObject) =
for {
tasksResults <- tryo((jsResult \ "tasks").as[List[JsObject]]).toFox
Expand Down
12 changes: 0 additions & 12 deletions conf/webknossos.versioned.routes
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ GET /v8/datasets/:organizationId/:datasetName/isValidNewName co
GET /v8/datasets/:organizationId/:datasetName controllers.LegacyApiController.readDatasetV8(organizationId: String, datasetName: String, sharingToken: Option[String])
GET /v8/tasks/:id controllers.LegacyApiController.readTaskV8(id: String)
POST /v8/tasks controllers.LegacyApiController.createTaskV8()
PUT /v8/tasks/:id controllers.LegacyApiController.updateTaskV8(id: String)
GET /v8/projects/:id/tasks controllers.LegacyApiController.tasksForProjectV8(id: String, limit: Option[Int], pageNumber: Option[Int], includeTotalCount: Option[Boolean])
GET /v8/annotations/:id/info controllers.LegacyApiController.annotationInfoV8(id: String, timestamp: Long)
GET /v8/tasks/:id/annotations controllers.LegacyApiController.annotationsForTaskV8(id: String)

-> /v8/ webknossos.latest.Routes
#v7: support changes to v9
Expand All @@ -38,10 +35,7 @@ GET /v7/datasets/:organizationId/:datasetName/isValidNewName co
GET /v7/datasets/:organizationId/:datasetName controllers.LegacyApiController.readDatasetV8(organizationId: String, datasetName: String, sharingToken: Option[String])
GET /v7/tasks/:id controllers.LegacyApiController.readTaskV8(id: String)
POST /v7/tasks controllers.LegacyApiController.createTaskV8()
PUT /v7/tasks/:id controllers.LegacyApiController.updateTaskV8(id: String)
GET /v7/projects/:id/tasks controllers.LegacyApiController.tasksForProjectV8(id: String, limit: Option[Int], pageNumber: Option[Int], includeTotalCount: Option[Boolean])
GET /v7/annotations/:id/info controllers.LegacyApiController.annotationInfoV8(id: String, timestamp: Long)
GET /v7/tasks/:id/annotations controllers.LegacyApiController.annotationsForTaskV8(id: String)

# v7: support changes to v8
GET /v7/datasets controllers.LegacyApiController.listDatasetsV7(isActive: Option[Boolean], isUnreported: Option[Boolean], organizationName: Option[String], onlyMyOrganization: Option[Boolean], uploaderId: Option[String], folderId: Option[String], includeSubfolders: Option[Boolean], searchQuery: Option[String], limit: Option[Int], compact: Option[Boolean])
Expand All @@ -55,10 +49,7 @@ PATCH /v6/datasets/:organizationId/:datasetName/teams co
GET /v6/datasets/:organizationId/:datasetName/isValidNewName controllers.LegacyApiController.isValidNewNameV8(datasetName: String, organizationId: String)
GET /v6/tasks/:id controllers.LegacyApiController.readTaskV8(id: String)
POST /v6/tasks controllers.LegacyApiController.createTaskV8()
PUT /v6/tasks/:id controllers.LegacyApiController.updateTaskV8(id: String)
GET /v6/projects/:id/tasks controllers.LegacyApiController.tasksForProjectV8(id: String, limit: Option[Int], pageNumber: Option[Int], includeTotalCount: Option[Boolean])
GET /v6/annotations/:id/info controllers.LegacyApiController.annotationInfoV8(id: String, timestamp: Long)
GET /v6/tasks/:id/annotations controllers.LegacyApiController.annotationsForTaskV8(id: String)


# v6: support changes to v7
Expand All @@ -75,10 +66,7 @@ PATCH /v5/datasets/:organizationId/:datasetName/teams co
GET /v5/datasets/:organizationId/:datasetName/isValidNewName controllers.LegacyApiController.isValidNewNameV8(datasetName: String, organizationId: String)
GET /v5/tasks/:id controllers.LegacyApiController.readTaskV8(id: String)
POST /v5/tasks controllers.LegacyApiController.createTaskV8()
PUT /v5/tasks/:id controllers.LegacyApiController.updateTaskV8(id: String)
GET /v5/projects/:id/tasks controllers.LegacyApiController.tasksForProjectV8(id: String, limit: Option[Int], pageNumber: Option[Int], includeTotalCount: Option[Boolean])
GET /v5/annotations/:id/info controllers.LegacyApiController.annotationInfoV8(id: String, timestamp: Long)
GET /v5/tasks/:id/annotations controllers.LegacyApiController.annotationsForTaskV8(id: String)

# v5: support changes to v7
GET /v5/datasets controllers.LegacyApiController.listDatasetsV6(isActive: Option[Boolean], isUnreported: Option[Boolean], organizationName: Option[String], onlyMyOrganization: Option[Boolean], uploaderId: Option[String], folderId: Option[String], includeSubfolders: Option[Boolean], searchQuery: Option[String], limit: Option[Int], compact: Option[Boolean])
Expand Down