Skip to content

Commit

Permalink
Recover org rejection
Browse files Browse the repository at this point in the history
  • Loading branch information
dantb committed Sep 29, 2023
1 parent 4950c40 commit 668d5a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
package ch.epfl.bluebrain.nexus.delta.routes

import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.{Directive1, MissingQueryParamRejection, Route}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.{Directive1, MissingQueryParamRejection, Route}
import cats.implicits._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.OrganizationsRoutes.OrganizationInput
import ch.epfl.bluebrain.nexus.delta.sdk.OrganizationResource
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.ce.DeltaDirectives.{emit => emitCE}
import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling
import ch.epfl.bluebrain.nexus.delta.sdk.directives.AuthDirectives
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.ce.DeltaDirectives.{emit => emitCE}
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives
import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaSchemeDirectives}
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.implicits._
import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri
import ch.epfl.bluebrain.nexus.delta.sdk.model.search.PaginationConfig
import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchParams.OrganizationSearchParams
import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchResults
import ch.epfl.bluebrain.nexus.delta.sdk.model.search.{PaginationConfig, SearchResults}
import ch.epfl.bluebrain.nexus.delta.sdk.model.search.SearchResults._
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.OrganizationDeleter
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.Organizations
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.model.Organization
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.model.OrganizationRejection
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.{OrganizationDeleter, Organizations}
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.model.{Organization, OrganizationRejection}
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.model.OrganizationRejection._
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions._
import io.circe.Decoder
Expand Down Expand Up @@ -119,12 +115,12 @@ final class OrganizationsRoutes(
}
}
},
// Deprecate organization
// Deprecate or delete organization
delete {
parameter("rev".as[Int].?, "prune".?(false)) {
case (_, true) =>
authorizeFor(id, orgs.delete).apply {
emitCE(orgDeleter.delete(id))
emitCE(orgDeleter.delete(id).attemptNarrow[OrganizationRejection])
}
case (Some(rev), false) =>
authorizeFor(id, orgs.write).apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class OrganizationDeleterSuite extends BioSuite with IOFixedClock with ConfigFix
IO.from(orgDeleter.delete(org).attemptNarrow[OrganizationNonEmpty]).hideErrors

def assertDeletionFailed(result: Either[OrganizationNonEmpty, Unit]) = for {
eventPartitionDeleted <- orgPartitionIsDeleted("scoped_events", org1) //.map(_.isEmpty)
statePartitionDeleted <- orgPartitionIsDeleted("scoped_states", org1) //.map(_.isEmpty)
eventPartitionDeleted <- orgPartitionIsDeleted("scoped_events", org1)
statePartitionDeleted <- orgPartitionIsDeleted("scoped_states", org1)
fetchedProject <- projects.fetch(projRef)
orgResult <- orgs.fetch(org1).map(_.value.label)
aclExists <- acls.fetch(AclAddress.fromOrg(org1)).attempt.map(_.isRight)
Expand Down

0 comments on commit 668d5a2

Please sign in to comment.