diff --git a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/OrganizationsRoutes.scala b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/OrganizationsRoutes.scala index 89b7ed42f4..f40c746dfb 100644 --- a/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/OrganizationsRoutes.scala +++ b/delta/app/src/main/scala/ch/epfl/bluebrain/nexus/delta/routes/OrganizationsRoutes.scala @@ -1,8 +1,8 @@ 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 @@ -10,23 +10,19 @@ 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 @@ -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 { diff --git a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/organizations/OrganizationDeleterSuite.scala b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/organizations/OrganizationDeleterSuite.scala index 0ae2f69fb1..fe129c61c8 100644 --- a/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/organizations/OrganizationDeleterSuite.scala +++ b/delta/sdk/src/test/scala/ch/epfl/bluebrain/nexus/delta/sdk/organizations/OrganizationDeleterSuite.scala @@ -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)