Repository navigation
feat: Expose GET /admin/projects/iri/{iriUrlEncoded} as zio-http route - #2355
Conversation
lastFile:webapi/src/main/scala/org/knora/webapi/core/HttpServerWithZIOHttp.scala
Codecov ReportBase: 86.68% // Head: 86.45% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2355 +/- ##
==========================================
- Coverage 86.68% 86.45% -0.23%
==========================================
Files 250 271 +21
Lines 28252 28270 +18
==========================================
- Hits 24490 24441 -49
- Misses 3762 3829 +67
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
b16f9cc to
5600a18
Compare
5600a18 to
ba8ca55
Compare
…, and remove new needless implicit class tag
55a5348 to
ad5b367
Compare
…e.getSingleProjectADMRequest
BalduinLandolt
left a comment
There was a problem hiding this comment.
Very nice to have the authenticator separated out like this!
Some questions/remarks:
- Why did you rename
ProjectsServicetoRestProjectsService? What are our naming conventions in this regard? - Maybe I'm overlooking something... but I think the addition of
HealthRouteZis not reflected in the PR title/description. - Otherwise, some comments in the files directly.
| val layer: URLayer[ProjectsService with AppConfig, ProjectsRouteZ] = ZLayer.fromFunction(ProjectsRouteZ.apply _) | ||
| val layer: ZLayer[AppConfig with RestProjectsService, Nothing, ProjectsRouteZ] = | ||
| ZLayer.fromFunction(ProjectsRouteZ.apply _) |
There was a problem hiding this comment.
Why not keep URLayer?
mpro7
left a comment
There was a problem hiding this comment.
Feel free to apply my suggestions - mainly Docstrings improvements.
| * Migrated from [[org.knora.webapi.http.status.ApiStatusCodes]] | ||
| * | ||
| * The possible values for the HTTP status code that is returned as part of each Knora API v2 response. | ||
| * migrated from [[org.knora.webapi.http.status.ApiStatusCodes]] |
There was a problem hiding this comment.
| * migrated from [[org.knora.webapi.http.status.ApiStatusCodes]] | |
| * Migrated from [[org.knora.webapi.http.status.ApiStatusCodes]] |
| * @param name ??? | ||
| * @param severity ??? |
| * | ||
| * ```failure``` A [[BadRequestException]] with the `errorMsg` | ||
| */ | ||
| def urlDecode(value: String, errorMsg: String = ""): Task[String] = |
There was a problem hiding this comment.
Do we actually need the second parameter errorMsg?
There was a problem hiding this comment.
Yes, different Routes might want create their own error messages in the BadRequestException. In this PR it is "Failed to url decode IRI parameter." in the route. I did not want to hardcode that particular message into the RouteUtil as it should not assume that all encoded params are IRIs.
| // Returns a single project identified by an urlencoded IRI | ||
| case Method.GET -> !! / "admin" / "projects" / "iri" / iriUrlEncoded => | ||
| RouteUtilZ | ||
| .urlDecode(iriUrlEncoded, "Failed to url decode IRI parameter.") |
There was a problem hiding this comment.
| .urlDecode(iriUrlEncoded, "Failed to url decode IRI parameter.") | |
| .urlDecode(iriUrlEncoded, s"Failed to URL decode IRI from parameter: ${iriUrlEncoded}.") |
| .apply(Assertion.equalTo(expectedRequest), Expectation.value(expectedResponse)) | ||
|
|
||
| private val expectNoInteraction = ActorToZioBridgeMock.empty | ||
| private val systemUnderTest = ZIO.service[RestProjectsService] |
There was a problem hiding this comment.
| private val systemUnderTest = ZIO.service[RestProjectsService] | |
| private val serviceUnderTest = ZIO.service[RestProjectsService] |
| actual <- RouteUtilZ.urlDecode("http%3A%2F%2Frdfh.ch%2Fprojects%2FLw3FC39BSzCwvmdOaTyLqQ") | ||
| } yield assertTrue(actual == "http://rdfh.ch/projects/Lw3FC39BSzCwvmdOaTyLqQ") | ||
| }, | ||
| test("given an empty value should return BadRequestException") { |
There was a problem hiding this comment.
| test("given an empty value should return BadRequestException") { | |
| test("given an empty valu, return BadRequestException") { |
| final case class RestProjectsService(bridge: ActorToZioBridge) { | ||
|
|
||
| /** | ||
| * Finds the project by its [[ProjectIdentifierADM]] and returns the information as a [[ProjectGetResponseADM]]. |
There was a problem hiding this comment.
| * Finds the project by its [[ProjectIdentifierADM]] and returns the information as a [[ProjectGetResponseADM]]. | |
| * Finds the project by its [[IRI]] and returns the information as a [[ProjectGetResponseADM]]. |
…desZ.scala Co-authored-by: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com>
Co-authored-by: irinaschubert <irina.schubert@dasch.swiss>
Co-authored-by: Marcin Procyk <marcin.procyk@dasch.swiss>
Co-authored-by: Marcin Procyk <marcin.procyk@dasch.swiss>
Co-authored-by: Marcin Procyk <marcin.procyk@dasch.swiss>
…scala Co-authored-by: irinaschubert <irina.schubert@dasch.swiss>
…scala Co-authored-by: irinaschubert <irina.schubert@dasch.swiss>
Pull Request Checklist
Task Description/Number
Picking up from the last
mob/mainsession I have finalised the changes from that branch.Changes include:
GET /admin/projects/iri/{iriUrlEncoded}as zio-http route.requestingUserfield fromProjectGetRequestADM.AuthenticatorService- a zio service for interaction withAuthenticatoras a preparation for other routes.Basic Requirements
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Does this PR change client-test-data?