Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Dumas committed Aug 4, 2023
1 parent 800ba2b commit bb58d34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,3 @@ class MultiFetchRoutes(
}

}

object MultiFetchRoutes {

/**
* @return
* the [[Route]] for the multi-fetch operation
*/
def apply(identities: Identities, aclCheck: AclCheck, multiFetch: MultiFetch)(implicit
baseUri: BaseUri,
cr: RemoteContextResolution,
ordering: JsonKeyOrdering,
s: Scheduler
): Route = new MultiFetchRoutes(identities, aclCheck, multiFetch).routes

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MultiFetchRoutesSpec extends BaseRouteSpec {
)

private val routes = Route.seal(
MultiFetchRoutes(identities, aclCheck, multiFetch)
new MultiFetchRoutes(identities, aclCheck, multiFetch).routes
)

"The Multi fetch route" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.sdk.multifetch
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.JsonLdContent
import ch.epfl.bluebrain.nexus.delta.sdk.multifetch.model.MultiFetchResponse.Result
import ch.epfl.bluebrain.nexus.delta.sdk.multifetch.model.MultiFetchResponse.Result._
import ch.epfl.bluebrain.nexus.delta.sdk.multifetch.model.{MultiFetchRequest, MultiFetchResponse}
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.resources
Expand Down Expand Up @@ -33,15 +32,14 @@ object MultiFetch {
val fetchAllCached = aclCheck.fetchAll.memoizeOnSuccess
request.resources
.traverse { input =>
for {
authorized <- aclCheck.authorizeFor(input.project, resources.read, fetchAllCached)
resource <- if (authorized) fetchResource(input) else UIO.none
} yield {
if (authorized) resource.fold[Result](NotFound(input.id, input.project)) { content =>
Success(input.id, input.project, content)
}
else
AuthorizationFailed(input.id, input.project)
aclCheck.authorizeFor(input.project, resources.read, fetchAllCached).flatMap {
case true =>
fetchResource(input).map {
_.map(Success(input.id, input.project, _))
.getOrElse(NotFound(input.id, input.project))
}
case false =>
UIO.pure(AuthorizationFailed(input.id, input.project))
}
}
.map { resources =>
Expand Down

0 comments on commit bb58d34

Please sign in to comment.