diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/Storages.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/Storages.scala index f01b946fc6..4711d1201a 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/Storages.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/Storages.scala @@ -8,7 +8,7 @@ import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.Storages._ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StoragesConfig.StorageTypeConfig import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageCommand._ -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageEvent.{StorageCreated, StorageDeprecated, StorageTagAdded, StorageUndeprecated, StorageUpdated} +import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageEvent._ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageRejection._ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageValue.DiskStorageValue import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model._ @@ -26,10 +26,8 @@ import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContext import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ApiMappings import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution -import ch.epfl.bluebrain.nexus.delta.sourcing.ScopedEntityDefinition.Tagger import ch.epfl.bluebrain.nexus.delta.sourcing._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.Subject -import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import ch.epfl.bluebrain.nexus.delta.sourcing.model.{EntityType, ProjectRef} import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem import fs2.Stream @@ -183,34 +181,6 @@ final class Storages private ( } yield res }.span("updateStorage") - /** - * Add a tag to an existing storage - * - * @param id - * the storage identifier to expand as the id of the storage - * @param projectRef - * the project where the storage belongs - * @param tag - * the tag name - * @param tagRev - * the tag revision - * @param rev - * the current revision of the storage - */ - def tag( - id: IdSegment, - projectRef: ProjectRef, - tag: UserTag, - tagRev: Int, - rev: Int - )(implicit subject: Subject): IO[StorageResource] = { - for { - pc <- fetchContext.onModify(projectRef) - iri <- expandIri(id, pc) - res <- eval(TagStorage(iri, projectRef, tagRev, tag, rev, subject)) - } yield res - }.span("tagStorage") - /** * Deprecate an existing storage * @@ -262,10 +232,8 @@ final class Storages private ( notFound = StorageNotFound(iri, project) state <- id match { case Latest(_) => log.stateOr(project, iri, notFound) - case Revision(_, rev) => - log.stateOr(project, iri, rev, notFound, RevisionNotFound) - case Tag(_, tag) => - log.stateOr(project, iri, tag, notFound, TagNotFound(tag)) + case Revision(_, rev) => log.stateOr(project, iri, rev, notFound, RevisionNotFound) + case t: Tag => IO.raiseError(FetchByTagNotSupported(t)) } } yield state.toResource }.span("fetchStorage") @@ -354,7 +322,6 @@ object Storages { e.project, e.value, e.source, - Tags.empty, e.rev, deprecated = false, e.instant, @@ -369,7 +336,7 @@ object Storages { } def tagAdded(e: StorageTagAdded): Option[StorageState] = state.map { s => - s.copy(rev = e.rev, tags = s.tags + (e.tag -> e.targetRev), updatedAt = e.instant, updatedBy = e.subject) + s.copy(rev = e.rev, updatedAt = e.instant, updatedBy = e.subject) } def deprecated(e: StorageDeprecated): Option[StorageState] = state.map { s => @@ -464,16 +431,6 @@ object Storages { } yield StorageUpdated(c.id, c.project, value, c.source, s.rev + 1, instant, c.subject) } - def tag(c: TagStorage) = state match { - case None => IO.raiseError(StorageNotFound(c.id, c.project)) - case Some(s) if s.rev != c.rev => IO.raiseError(IncorrectRev(c.rev, s.rev)) - case Some(s) if c.targetRev <= 0 || c.targetRev > s.rev => IO.raiseError(RevisionNotFound(c.targetRev, s.rev)) - case Some(s) => - clock.realTimeInstant.map( - StorageTagAdded(c.id, c.project, s.value.tpe, c.targetRev, c.tag, s.rev + 1, _, c.subject) - ) - } - def deprecate(c: DeprecateStorage) = state match { case None => IO.raiseError(StorageNotFound(c.id, c.project)) case Some(s) if s.rev != c.rev => IO.raiseError(IncorrectRev(c.rev, s.rev)) @@ -493,7 +450,6 @@ object Storages { cmd match { case c: CreateStorage => create(c) case c: UpdateStorage => update(c) - case c: TagStorage => tag(c) case c: DeprecateStorage => deprecate(c) case c: UndeprecateStorage => undeprecate(c) } @@ -505,21 +461,11 @@ object Storages { fetchPermissions: IO[Set[Permission]], clock: Clock[IO] ): ScopedEntityDefinition[Iri, StorageState, StorageCommand, StorageEvent, StorageRejection] = - ScopedEntityDefinition( + ScopedEntityDefinition.untagged( entityType, StateMachine(None, evaluate(access, fetchPermissions, config, clock)(_, _), next), StorageEvent.serializer, StorageState.serializer, - Tagger[StorageEvent]( - { - case r: StorageTagAdded => Some(r.tag -> r.targetRev) - case _ => None - }, - { _ => - None - } - ), - _ => None, onUniqueViolation = (id: Iri, c: StorageCommand) => c match { case c: CreateStorage => ResourceAlreadyExists(id, c.project) diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/Storage.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/Storage.scala index b31392f729..0ee5c8a18d 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/Storage.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/Storage.scala @@ -15,7 +15,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.ContextValue import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.JsonLdContent -import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, IdSegmentRef, Tags} +import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, IdSegmentRef} import ch.epfl.bluebrain.nexus.delta.sdk.{OrderingFields, ResourceShift} import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import io.circe.syntax._ @@ -35,12 +35,6 @@ sealed trait Storage extends Product with Serializable { */ def project: ProjectRef - /** - * @return - * the tag -> rev mapping - */ - def tags: Tags - /** * @return * the original json document provided at creation or update @@ -77,7 +71,6 @@ object Storage { id: Iri, project: ProjectRef, value: DiskStorageValue, - tags: Tags, source: Json ) extends Storage { override val default: Boolean = value.default @@ -97,7 +90,6 @@ object Storage { id: Iri, project: ProjectRef, value: S3StorageValue, - tags: Tags, source: Json ) extends Storage { @@ -122,7 +114,6 @@ object Storage { id: Iri, project: ProjectRef, value: RemoteDiskStorageValue, - tags: Tags, source: Json ) extends Storage { override val default: Boolean = value.default diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageCommand.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageCommand.scala index e15ccb3511..3580ea6bdf 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageCommand.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageCommand.scala @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.Subject import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef -import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import io.circe.Json /** @@ -87,25 +86,6 @@ object StorageCommand { subject: Subject ) extends StorageCommand - /** - * Command to tag a storage - * - * @param id - * the storage identifier - * @param project - * the project the storage belongs to - * @param targetRev - * the revision that is being aliased with the provided ''tag'' - * @param tag - * the tag of the alias for the provided ''tagRev'' - * @param rev - * the last known revision of the storage - * @param subject - * the identity associated to this command - */ - final case class TagStorage(id: Iri, project: ProjectRef, targetRev: Int, tag: UserTag, rev: Int, subject: Subject) - extends StorageCommand - /** * Command to deprecate a storage * diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageRejection.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageRejection.scala index 271d0672bd..efa5e751b7 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageRejection.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageRejection.scala @@ -13,10 +13,10 @@ import ch.epfl.bluebrain.nexus.delta.rdf.{RdfError, Vocabulary} import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.JsonLdRejection import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.JsonLdRejection.UnexpectedId import ch.epfl.bluebrain.nexus.delta.sdk.marshalling.HttpResponseFields +import ch.epfl.bluebrain.nexus.delta.sdk.model.IdSegmentRef import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContext.ContextRejection import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef -import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import io.circe.syntax._ import io.circe.{Encoder, JsonObject} @@ -47,14 +47,10 @@ object StorageRejection { final case class RevisionNotFound(provided: Int, current: Int) extends StorageFetchRejection(s"Revision requested '$provided' not found, last known revision is '$current'.") - /** - * Rejection returned when a subject intends to retrieve a storage at a specific tag, but the provided tag does not - * exist. - * - * @param tag - * the provided tag - */ - final case class TagNotFound(tag: UserTag) extends StorageFetchRejection(s"Tag requested '$tag' not found.") + final case class FetchByTagNotSupported(tag: IdSegmentRef.Tag) + extends StorageFetchRejection( + s"Fetching storages by tag is no longer supported. Id ${tag.value.asString} and tag ${tag.tag.value}" + ) /** * Rejection returned when attempting to update/fetch a storage with an id that doesn't exist. @@ -235,12 +231,12 @@ object StorageRejection { implicit final val storageRejectionHttpResponseFields: HttpResponseFields[StorageRejection] = HttpResponseFields { case RevisionNotFound(_, _) => StatusCodes.NotFound - case TagNotFound(_) => StatusCodes.NotFound case StorageNotFound(_, _) => StatusCodes.NotFound case DefaultStorageNotFound(_) => StatusCodes.NotFound case ResourceAlreadyExists(_, _) => StatusCodes.Conflict case IncorrectRev(_, _) => StatusCodes.Conflict case ProjectContextRejection(rej) => rej.status + case FetchByTagNotSupported(_) => StatusCodes.BadRequest case StorageNotAccessible(_, _) => StatusCodes.BadRequest case _ => StatusCodes.BadRequest } diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageState.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageState.scala index 0ed5a8b001..600202e2d0 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageState.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageState.scala @@ -4,7 +4,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.Storage.{Dis import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageValue.{DiskStorageValue, RemoteDiskStorageValue, S3StorageValue} import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.{schemas, StorageResource} import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri -import ch.epfl.bluebrain.nexus.delta.sdk.model.{ResourceF, ResourceUris, Tags} +import ch.epfl.bluebrain.nexus.delta.sdk.model.{ResourceF, ResourceUris} import ch.epfl.bluebrain.nexus.delta.sourcing.Serializer import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.Subject import ch.epfl.bluebrain.nexus.delta.sourcing.model.ResourceRef.Latest @@ -48,7 +48,6 @@ final case class StorageState( project: ProjectRef, value: StorageValue, source: Json, - tags: Tags, rev: Int, deprecated: Boolean, createdAt: Instant, @@ -63,9 +62,9 @@ final case class StorageState( def storage: Storage = value match { - case value: DiskStorageValue => DiskStorage(id, project, value, tags, source) - case value: S3StorageValue => S3Storage(id, project, value, tags, source) - case value: RemoteDiskStorageValue => RemoteDiskStorage(id, project, value, tags, source) + case value: DiskStorageValue => DiskStorage(id, project, value, source) + case value: S3StorageValue => S3Storage(id, project, value, source) + case value: RemoteDiskStorageValue => RemoteDiskStorage(id, project, value, source) } def toResource: StorageResource = diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutes.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutes.scala index 6f8f650c21..26b0e27c7a 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutes.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutes.scala @@ -19,7 +19,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities import ch.epfl.bluebrain.nexus.delta.sdk.implicits._ import ch.epfl.bluebrain.nexus.delta.sdk.marshalling.RdfMarshalling import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri -import ch.epfl.bluebrain.nexus.delta.sdk.model.routes.Tag import io.circe.Json import kamon.instrumentation.akka.http.TracingDirectives.operationName @@ -163,37 +162,6 @@ final class StoragesRoutes( } } }, - (pathPrefix("tags") & pathEndOrSingleSlash) { - operationName(s"$prefixSegment/storages/{org}/{project}/{id}/tags") { - concat( - // Fetch a storage tags - (get & idSegmentRef(id) & authorizeFor(project, Read)) { id => - emit( - storages - .fetch(id, project) - .map(_.value.tags) - .attemptNarrow[StorageRejection] - .rejectOn[StorageNotFound] - ) - }, - // Tag a storage - (post & parameter("rev".as[Int])) { rev => - authorizeFor(project, Write).apply { - entity(as[Tag]) { case Tag(tagRev, tag) => - emit( - Created, - storages - .tag(id, project, tag, tagRev, rev) - .flatTap(index(project, _, mode)) - .mapValue(_.metadata) - .attemptNarrow[StorageRejection] - ) - } - } - } - ) - } - }, (pathPrefix("statistics") & get & pathEndOrSingleSlash) { authorizeFor(project, Read).apply { emit(storagesStatistics.get(id, project).attemptNarrow[StorageRejection]) diff --git a/delta/plugins/storage/src/test/resources/storages/storage-disk-state.json b/delta/plugins/storage/src/test/resources/storages/storage-disk-state.json index ef1d40f738..b373bc4118 100644 --- a/delta/plugins/storage/src/test/resources/storages/storage-disk-state.json +++ b/delta/plugins/storage/src/test/resources/storages/storage-disk-state.json @@ -30,9 +30,6 @@ "capacity": 1000, "maxFileSize": 50 }, - "tags": { - "mytag": 3 - }, "createdAt": "1970-01-01T00:00:00Z", "createdBy": { "subject": "username", diff --git a/delta/plugins/storage/src/test/resources/storages/storage-remote-state.json b/delta/plugins/storage/src/test/resources/storages/storage-remote-state.json index 4658b59fb1..1bb197d24c 100644 --- a/delta/plugins/storage/src/test/resources/storages/storage-remote-state.json +++ b/delta/plugins/storage/src/test/resources/storages/storage-remote-state.json @@ -30,9 +30,6 @@ "writePermission": "remote/write", "maxFileSize": 52 }, - "tags": { - "mytag": 3 - }, "createdAt": "1970-01-01T00:00:00Z", "createdBy": { "subject": "username", diff --git a/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json b/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json index 7935114203..17b65e9ad1 100644 --- a/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json +++ b/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json @@ -32,9 +32,6 @@ "writePermission": "s3/write", "maxFileSize": 51 }, - "tags": { - "mytag": 3 - }, "createdAt": "1970-01-01T00:00:00Z", "createdBy": { "subject": "username", diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/batch/BatchCopySuite.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/batch/BatchCopySuite.scala index 014ad46d98..5d2003e3c1 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/batch/BatchCopySuite.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/batch/BatchCopySuite.scala @@ -21,7 +21,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress import ch.epfl.bluebrain.nexus.delta.sdk.acls.{AclCheck, AclSimpleCheck} import ch.epfl.bluebrain.nexus.delta.sdk.error.ServiceError.AuthorizationFailed import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller -import ch.epfl.bluebrain.nexus.delta.sdk.model.{IdSegment, IdSegmentRef, Tags} +import ch.epfl.bluebrain.nexus.delta.sdk.model.{IdSegment, IdSegmentRef} import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.User import ch.epfl.bluebrain.nexus.delta.sourcing.model.{ProjectRef, ResourceRef} import ch.epfl.bluebrain.nexus.testkit.Generators @@ -239,16 +239,16 @@ class BatchCopySuite extends NexusSuite with StorageFixtures with Generators wit private def genDiskStorageWithCapacity(capacity: Long) = { val limitedDiskVal = diskVal.copy(capacity = Some(capacity)) - DiskStorage(nxv + genString(), genProject().ref, limitedDiskVal, Tags.empty, json"""{"disk": "value"}""") + DiskStorage(nxv + genString(), genProject().ref, limitedDiskVal, json"""{"disk": "value"}""") } private def genDiskStorage() = genDiskStorageWithCapacity(1000L) private def genRemoteStorage() = - RemoteDiskStorage(nxv + genString(), genProject().ref, remoteVal, Tags.empty, json"""{"disk": "value"}""") + RemoteDiskStorage(nxv + genString(), genProject().ref, remoteVal, json"""{"disk": "value"}""") private def genS3Storage() = - S3Storage(nxv + genString(), genProject().ref, s3Val, Tags.empty, json"""{"disk": "value"}""") + S3Storage(nxv + genString(), genProject().ref, s3Val, json"""{"disk": "value"}""") } object BatchCopySuite { diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageGen.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageGen.scala index 0a0f6a2d5d..8b007f8eb3 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageGen.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageGen.scala @@ -2,7 +2,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.storage.storages import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.{StorageState, StorageValue} import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri -import ch.epfl.bluebrain.nexus.delta.sdk.model.Tags import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Subject} import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import io.circe.Json @@ -18,7 +17,6 @@ object StorageGen { source: Json = Json.obj(), rev: Int = 1, deprecated: Boolean = false, - tags: Tags = Tags.empty, createdBy: Subject = Anonymous, updatedBy: Subject = Anonymous ): StorageState = { @@ -27,7 +25,6 @@ object StorageGen { project, value, source, - tags, rev, deprecated, Instant.EPOCH, @@ -44,10 +41,9 @@ object StorageGen { source: Json = Json.obj(), rev: Int = 1, deprecated: Boolean = false, - tags: Tags = Tags.empty, createdBy: Subject = Anonymous, updatedBy: Subject = Anonymous ): StorageResource = - storageState(id, project, value, source, rev, deprecated, tags, createdBy, updatedBy).toResource + storageState(id, project, value, source, rev, deprecated, createdBy, updatedBy).toResource } diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragesSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragesSpec.scala index 44a411701e..9af3fc698c 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragesSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragesSpec.scala @@ -11,7 +11,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.ConfigFixtures import ch.epfl.bluebrain.nexus.delta.sdk.generators.ProjectGen import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.{Caller, ServiceAccount} import ch.epfl.bluebrain.nexus.delta.sdk.implicits._ -import ch.epfl.bluebrain.nexus.delta.sdk.model.{IdSegmentRef, Tags} +import ch.epfl.bluebrain.nexus.delta.sdk.model.IdSegmentRef import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContextDummy import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Authenticated, Group, User} @@ -136,37 +136,6 @@ private class StoragesSpec } } - "tagging a storage" should { - - "succeed" in { - storages.tag(rdId, projectRef, tag, tagRev = 1, 1).accepted shouldEqual - resourceFor( - rdId, - projectRef, - remoteVal, - remoteFieldsJson, - rev = 2, - createdBy = bob, - updatedBy = bob, - tags = Tags(tag -> 1) - ) - } - - "reject if it doesn't exists" in { - storages.tag(nxv + "other", projectRef, tag, tagRev = 1, 1).rejectedWith[StorageNotFound] - } - - "reject if project does not exist" in { - val projectRef = ProjectRef(org, Label.unsafe("other")) - - storages.tag(rdId, projectRef, tag, tagRev = 2, 2).rejectedWith[ProjectContextRejection] - } - - "reject if project is deprecated" in { - storages.tag(rdId, deprecatedProject.ref, tag, tagRev = 2, 2).rejectedWith[ProjectContextRejection] - } - } - "deprecating a storage" should { "succeed" in { @@ -202,23 +171,6 @@ private class StoragesSpec "reject if project is deprecated" in { storages.deprecate(s3Id, deprecatedProject.ref, 1).rejectedWith[ProjectContextRejection] } - - "allow tagging" in { - val payload = s3FieldsJson deepMerge json"""{"@id": "$s3Id", "default": false}""" - storages.tag(s3Id, projectRef, tag, tagRev = 3, 3).accepted shouldEqual - resourceFor( - s3Id, - projectRef, - s3Val.copy(default = false), - payload, - rev = 4, - deprecated = true, - createdBy = bob, - updatedBy = bob, - tags = Tags(tag -> 3) - ) - } - } "undeprecating a storage" should { @@ -280,8 +232,7 @@ private class StoragesSpec remoteFieldsJson, rev = 2, createdBy = bob, - updatedBy = bob, - tags = Tags(tag -> 1) + updatedBy = bob ) "succeed" in { @@ -297,9 +248,9 @@ private class StoragesSpec storages.fetch(IdSegmentRef(rdId, 1), projectRef).accepted shouldEqual resourceRev1 } - "reject if tag does not exist" in { - val otherTag = UserTag.unsafe("other") - storages.fetch(IdSegmentRef(rdId, otherTag), projectRef).rejected shouldEqual TagNotFound(otherTag) + "reject fetch by tag" in { + val id = IdSegmentRef.Tag(rdId, UserTag.unsafe("other")) + storages.fetch(id, projectRef).rejected shouldEqual FetchByTagNotSupported(id) } "reject if revision does not exist" in { diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragesStmSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragesStmSpec.scala index 4ac9f95743..e2866ae968 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragesStmSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragesStmSpec.scala @@ -4,13 +4,13 @@ import cats.effect.IO import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StorageGen.storageState import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.Storages.{evaluate, next} import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StoragesConfig.{DiskStorageConfig, StorageTypeConfig} -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageCommand.{CreateStorage, DeprecateStorage, TagStorage, UndeprecateStorage, UpdateStorage} -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageEvent.{StorageCreated, StorageDeprecated, StorageTagAdded, StorageUndeprecated, StorageUpdated} -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageRejection.{DifferentStorageType, IncorrectRev, InvalidMaxFileSize, InvalidStorageType, PermissionsAreNotDefined, ResourceAlreadyExists, RevisionNotFound, StorageIsDeprecated, StorageIsNotDeprecated, StorageNotAccessible, StorageNotFound} +import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageCommand.{CreateStorage, DeprecateStorage, UndeprecateStorage, UpdateStorage} +import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageEvent._ +import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageRejection.{DifferentStorageType, IncorrectRev, InvalidMaxFileSize, InvalidStorageType, PermissionsAreNotDefined, ResourceAlreadyExists, StorageIsDeprecated, StorageIsNotDeprecated, StorageNotAccessible, StorageNotFound} import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageType.{DiskStorage => DiskStorageType} import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageValue.{DiskStorageValue, RemoteDiskStorageValue, S3StorageValue} import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.{AbsolutePath, DigestAlgorithm} -import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, Tags} +import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.User import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag @@ -78,18 +78,6 @@ class StoragesStmSpec extends CatsEffectSpec with StorageFixtures { } } - "create a new event from a TagStorage command" in { - val state = storageState(dId, project, diskVal, rev = 3) - eval(Some(state), TagStorage(dId, project, 2, UserTag.unsafe("myTag"), 3, alice)).accepted shouldEqual - StorageTagAdded(dId, project, DiskStorageType, 2, UserTag.unsafe("myTag"), 4, epoch, alice) - } - - "create a new event from a TagStorage command when storage is deprecated" in { - val state = storageState(dId, project, diskVal, rev = 3, deprecated = true) - eval(Some(state), TagStorage(dId, project, 2, UserTag.unsafe("myTag"), 3, alice)).accepted shouldEqual - StorageTagAdded(dId, project, DiskStorageType, 2, UserTag.unsafe("myTag"), 4, epoch, alice) - } - "create a new event from a DeprecateStorage command" in { val state = storageState(dId, project, diskVal, rev = 3) eval(Some(state), DeprecateStorage(dId, project, 3, alice)).accepted shouldEqual @@ -106,7 +94,6 @@ class StoragesStmSpec extends CatsEffectSpec with StorageFixtures { val state = storageState(dId, project, diskVal) val commands = List( UpdateStorage(dId, project, diskFields, Json.obj(), 2, alice), - TagStorage(dId, project, 1, UserTag.unsafe("tag"), 2, alice), DeprecateStorage(dId, project, 2, alice), UndeprecateStorage(dId, project, 2, alice) ) @@ -189,7 +176,6 @@ class StoragesStmSpec extends CatsEffectSpec with StorageFixtures { "reject with StorageNotFound" in { val commands = List( UpdateStorage(dId, project, diskFields, Json.obj(), 2, alice), - TagStorage(dId, project, 1, UserTag.unsafe("tag"), 2, alice), DeprecateStorage(dId, project, 2, alice) ) forAll(commands) { cmd => @@ -218,12 +204,6 @@ class StoragesStmSpec extends CatsEffectSpec with StorageFixtures { } } - "reject with RevisionNotFound" in { - val state = storageState(dId, project, diskVal) - eval(Some(state), TagStorage(dId, project, 3, UserTag.unsafe("myTag"), 1, alice)).rejected shouldEqual - RevisionNotFound(provided = 3, current = 1) - } - "reject with DifferentStorageType" in { val diskCurrent = storageState(dId, project, diskVal) val s3Current = storageState(s3Id, project, s3Val) @@ -300,16 +280,14 @@ class StoragesStmSpec extends CatsEffectSpec with StorageFixtures { current.copy(rev = 2, value = diskVal, source = diskFieldsJson, updatedAt = time2, updatedBy = alice) } - "from a new StorageTagAdded event" in { - val tag1 = UserTag.unsafe("tag1") - val tag2 = UserTag.unsafe("tag2") - val event = StorageTagAdded(dId, project, DiskStorageType, 1, tag2, 3, time2, alice) - val current = storageState(dId, project, diskVal, tags = Tags(tag1 -> 2), rev = 2) + "from a new StorageTagAdded event, only the revision is updated" in { + val event = StorageTagAdded(dId, project, DiskStorageType, 1, UserTag.unsafe("unused"), 3, time2, alice) + val current = storageState(dId, project, diskVal, rev = 2) next(None, event) shouldEqual None next(Some(current), event).value shouldEqual - current.copy(rev = 3, updatedAt = time2, updatedBy = alice, tags = Tags(tag1 -> 2, tag2 -> 1)) + current.copy(rev = 3, updatedAt = time2, updatedBy = alice) } "from a new StorageDeprecated event" in { diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala index fb3d95ff4b..cad6dae12b 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala @@ -2,10 +2,9 @@ package ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClassUtils import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StorageFixtures -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageEvent.{StorageCreated, StorageDeprecated, StorageTagAdded, StorageUndeprecated, StorageUpdated} +import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageEvent._ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageType.{DiskStorage => DiskStorageType} import ch.epfl.bluebrain.nexus.delta.sdk.SerializationSuite -import ch.epfl.bluebrain.nexus.delta.sdk.model.Tags import ch.epfl.bluebrain.nexus.delta.sdk.model.metrics.EventMetric._ import ch.epfl.bluebrain.nexus.delta.sdk.sse.SseEncoder.SseData import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Subject, User} @@ -94,7 +93,6 @@ class StorageSerializationSuite extends SerializationSuite with StorageFixtures projectRef, value, source, - Tags(UserTag.unsafe("mytag") -> 3), rev = 1, deprecated = false, createdAt = instant, diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSpec.scala index 6db47db691..4aae2dc3d2 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSpec.scala @@ -4,9 +4,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.RemoteContextResolutionFixt import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StorageFixtures import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.Storage._ import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.nxv -import ch.epfl.bluebrain.nexus.delta.sdk.model.Tags import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ -import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef} import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsEffectSpec @@ -14,12 +12,11 @@ class StorageSpec extends CatsEffectSpec with RemoteContextResolutionFixture wit "A Storage" should { val project = ProjectRef(Label.unsafe("org"), Label.unsafe("project")) - val tag = UserTag.unsafe("tag") val diskStorage = - DiskStorage(nxv + "disk", project, diskVal, Tags.empty, json"""{"disk": "value"}""") - val s3Storage = S3Storage(nxv + "s3", project, s3Val, Tags(tag -> 1), json"""{"s3": "value"}""") + DiskStorage(nxv + "disk", project, diskVal, json"""{"disk": "value"}""") + val s3Storage = S3Storage(nxv + "s3", project, s3Val, json"""{"s3": "value"}""") val remoteStorage = - RemoteDiskStorage(nxv + "remote", project, remoteVal, Tags.empty, json"""{"remote": "value"}""") + RemoteDiskStorage(nxv + "remote", project, remoteVal, json"""{"remote": "value"}""") "be compacted" in { forAll( diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/disk/DiskStorageSaveFileSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/disk/DiskStorageSaveFileSpec.scala index f8fa87d30b..5c16fd2908 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/disk/DiskStorageSaveFileSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/disk/DiskStorageSaveFileSpec.scala @@ -13,7 +13,6 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.{AbsolutePat import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.AkkaSourceHelpers import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.SaveFileRejection.ResourceAlreadyExists import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.permissions.{read, write} -import ch.epfl.bluebrain.nexus.delta.sdk.model.Tags import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.testkit.remotestorage.RemoteStorageDocker @@ -38,7 +37,7 @@ class DiskStorageSaveFileSpec val iri = iri"http://localhost/disk" val project = ProjectRef.unsafe("org", "project") val value = DiskStorageValue(default = true, DigestAlgorithm.default, volume, read, write, Some(100), 10) - val storage = DiskStorage(iri, project, value, Tags.empty, Json.obj()) + val storage = DiskStorage(iri, project, value, Json.obj()) val uuid = UUID.fromString("8049ba90-7cc6-4de5-93a1-802c04200dcc") val content = "file content" val entity = HttpEntity(content) diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageLinkFileSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageLinkFileSpec.scala index 19cae29fd5..c2d1901214 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageLinkFileSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageLinkFileSpec.scala @@ -18,7 +18,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.permissions.{read, import ch.epfl.bluebrain.nexus.delta.sdk.ConfigFixtures import ch.epfl.bluebrain.nexus.delta.sdk.auth.{AuthTokenProvider, Credentials} import ch.epfl.bluebrain.nexus.delta.sdk.http.{HttpClient, HttpClientConfig} -import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, Tags} +import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef} import ch.epfl.bluebrain.nexus.testkit.remotestorage.RemoteStorageDocker @@ -64,7 +64,7 @@ class RemoteStorageLinkFileSpec(docker: RemoteStorageDocker) write, 10 ) - storage = RemoteDiskStorage(iri, project, storageValue, Tags.empty, Json.obj()) + storage = RemoteDiskStorage(iri, project, storageValue, Json.obj()) } "RemoteDiskStorage linking operations" should { diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageSaveAndFetchFileSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageSaveAndFetchFileSpec.scala index 7e0f5d127f..b68a8ce3f9 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageSaveAndFetchFileSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/remote/RemoteStorageSaveAndFetchFileSpec.scala @@ -19,7 +19,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.permissions.{read, import ch.epfl.bluebrain.nexus.delta.sdk.ConfigFixtures import ch.epfl.bluebrain.nexus.delta.sdk.auth.{AuthTokenProvider, Credentials} import ch.epfl.bluebrain.nexus.delta.sdk.http.{HttpClient, HttpClientConfig} -import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, Tags} +import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef} import ch.epfl.bluebrain.nexus.testkit.remotestorage.RemoteStorageDocker @@ -67,7 +67,7 @@ class RemoteStorageSaveAndFetchFileSpec(docker: RemoteStorageDocker) write, 10 ) - storage = RemoteDiskStorage(iri, project, storageValue, Tags.empty, Json.obj()) + storage = RemoteDiskStorage(iri, project, storageValue, Json.obj()) } "RemoteDiskStorage operations" should { diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageLinkFileSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageLinkFileSpec.scala index 01aa211478..89333e1b0d 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageLinkFileSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageLinkFileSpec.scala @@ -16,7 +16,6 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.AkkaSou import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.FetchFileRejection.FileNotFound import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.MinioSpec._ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.permissions.{read, write} -import ch.epfl.bluebrain.nexus.delta.sdk.model.Tags import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.testkit.minio.MinioDocker @@ -59,7 +58,7 @@ class S3StorageLinkFileSpec(docker: MinioDocker) maxFileSize = 20 ) createBucket(storageValue).accepted - storage = S3Storage(iri, project, storageValue, Tags.empty, Json.obj()) + storage = S3Storage(iri, project, storageValue, Json.obj()) attributes = FileAttributes( uuid, s"http://bucket3.$VirtualHost:${docker.hostConfig.port}/org/project/8/0/4/9/b/a/9/0/myfile.txt", diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageSaveAndFetchFileSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageSaveAndFetchFileSpec.scala index cd575fd70c..198dc43a2b 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageSaveAndFetchFileSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageSaveAndFetchFileSpec.scala @@ -16,7 +16,6 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.Storage import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.SaveFileRejection.ResourceAlreadyExists import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.MinioSpec._ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.permissions.{read, write} -import ch.epfl.bluebrain.nexus.delta.sdk.model.Tags import ch.epfl.bluebrain.nexus.delta.sdk.syntax._ import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import ch.epfl.bluebrain.nexus.testkit.minio.MinioDocker @@ -60,7 +59,7 @@ class S3StorageSaveAndFetchFileSpec(docker: MinioDocker) maxFileSize = 20 ) createBucket(storageValue).accepted - storage = S3Storage(iri, project, storageValue, Tags.empty, Json.obj()) + storage = S3Storage(iri, project, storageValue, Json.obj()) attributes = FileAttributes( uuid, s"http://bucket2.$VirtualHost:${docker.hostConfig.port}/org/project/8/0/4/9/b/a/9/0/myfile.txt", diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutesSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutesSpec.scala index b80a151ced..ee07165999 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutesSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutesSpec.scala @@ -13,7 +13,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.{DigestAlgor import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.{contexts => storageContexts, _} import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary -import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.{contexts, nxv} +import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.nxv import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution} import ch.epfl.bluebrain.nexus.delta.sdk.IndexingAction import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclSimpleCheck @@ -50,7 +50,6 @@ class StoragesRoutesSpec extends BaseRouteSpec with StorageFixtures { fileContexts.files -> ContextValue.fromFile("contexts/files.json"), Vocabulary.contexts.metadata -> ContextValue.fromFile("contexts/metadata.json"), Vocabulary.contexts.error -> ContextValue.fromFile("contexts/error.json"), - Vocabulary.contexts.tags -> ContextValue.fromFile("contexts/tags.json"), Vocabulary.contexts.search -> ContextValue.fromFile("contexts/search.json") ) @@ -294,34 +293,13 @@ class StoragesRoutesSpec extends BaseRouteSpec with StorageFixtures { } } - "tag a storage" in { - val payload = json"""{"tag": "mytag", "rev": 1}""" - // the revision is 2 because this storage has been updated to default = false - Post( - "/v1/storages/myorg/myproject/remote-disk-storage/tags?rev=2", - payload.toEntity - ) ~> asWriter ~> routes ~> check { - status shouldEqual StatusCodes.Created - response.asJson shouldEqual - storageMetadata( - projectRef, - rdId, - StorageType.RemoteDiskStorage, - rev = 3, - createdBy = writer, - updatedBy = writer - ) - } - } - "fail to fetch a storage and do listings without resources/read permission" in { val endpoints = List( "/v1/storages/myorg/myproject/caches", - "/v1/storages/myorg/myproject/remote-disk-storage", - "/v1/storages/myorg/myproject/remote-disk-storage/tags" + "/v1/storages/myorg/myproject/remote-disk-storage" ) forAll(endpoints) { endpoint => - forAll(List("", "?rev=1", "?tags=mytag")) { suffix => + forAll(List("", "?rev=1")) { suffix => Get(s"$endpoint$suffix") ~> routes ~> check { response.shouldBeForbidden } @@ -339,7 +317,7 @@ class StoragesRoutesSpec extends BaseRouteSpec with StorageFixtures { } } - "fetch a storage by rev and tag" in { + "fetch a storage by rev" in { val endpoints = List( "/v1/storages/myorg/myproject/remote-disk-storage", "/v1/resources/myorg/myproject/_/remote-disk-storage", @@ -349,14 +327,12 @@ class StoragesRoutesSpec extends BaseRouteSpec with StorageFixtures { s"/v1/resources/myorg/myproject/storage/$remoteIdEncoded" ) forAll(endpoints) { endpoint => - forAll(List("rev=1", "tag=mytag")) { param => - Get(s"$endpoint?$param") ~> asReader ~> routes ~> check { - status shouldEqual StatusCodes.OK - response.asJson shouldEqual jsonContentOf( - "storages/remote-storage-fetched.json", - "self" -> self(rdId) - ) - } + Get(s"$endpoint?rev=1") ~> asReader ~> routes ~> check { + status shouldEqual StatusCodes.OK + response.asJson shouldEqual jsonContentOf( + "storages/remote-storage-fetched.json", + "self" -> self(rdId) + ) } } } @@ -377,46 +353,19 @@ class StoragesRoutesSpec extends BaseRouteSpec with StorageFixtures { } } - "fetch a storage original payload by rev or tag" in { + "fetch a storage original payload by rev" in { val endpoints = List( "/v1/storages/myorg/myproject/remote-disk-storage/source", s"/v1/storages/myorg/myproject/$remoteIdEncoded/source" ) forAll(endpoints) { endpoint => - forAll(List("rev=1", "tag=mytag")) { param => - Get(s"$endpoint?$param") ~> asReader ~> routes ~> check { - status shouldEqual StatusCodes.OK - response.asJson shouldEqual remoteFieldsJson - } + Get(s"$endpoint?rev=1") ~> asReader ~> routes ~> check { + status shouldEqual StatusCodes.OK + response.asJson shouldEqual remoteFieldsJson } } } - "fetch the storage tags" in { - Get("/v1/resources/myorg/myproject/_/remote-disk-storage/tags?rev=1") ~> asReader ~> routes ~> check { - status shouldEqual StatusCodes.OK - response.asJson shouldEqual json"""{"tags": []}""".addContext(contexts.tags) - } - Get("/v1/storages/myorg/myproject/remote-disk-storage/tags") ~> asReader ~> routes ~> check { - status shouldEqual StatusCodes.OK - response.asJson shouldEqual json"""{"tags": [{"rev": 1, "tag": "mytag"}]}""".addContext(contexts.tags) - } - } - - "return not found if tag not found" in { - Get("/v1/storages/myorg/myproject/remote-disk-storage?tag=myother") ~> asReader ~> routes ~> check { - status shouldEqual StatusCodes.NotFound - response.asJson shouldEqual jsonContentOf("errors/tag-not-found.json", "tag" -> "myother") - } - } - - "reject if provided rev and tag simultaneously" in { - Get("/v1/storages/myorg/myproject/remote-disk-storage?tag=mytag&rev=1") ~> asReader ~> routes ~> check { - status shouldEqual StatusCodes.BadRequest - response.asJson shouldEqual jsonContentOf("errors/tag-and-rev-error.json") - } - } - "get storage statistics for an existing entry" in { Get("/v1/storages/myorg/myproject/remote-disk-storage/statistics") ~> asReader ~> routes ~> check { status shouldEqual StatusCodes.OK diff --git a/docs/src/main/paradox/docs/delta/api/assets/storages/tag.sh b/docs/src/main/paradox/docs/delta/api/assets/storages/tag.sh deleted file mode 100644 index e9613d1bac..0000000000 --- a/docs/src/main/paradox/docs/delta/api/assets/storages/tag.sh +++ /dev/null @@ -1,7 +0,0 @@ -curl -X POST \ - -H "Content-Type: application/json" \ - "http://localhost:8080/v1/storages/myorg/myproject/remote/tags?rev=2" -d \ - '{ - "tag": "mytag", - "rev": 1 - }' \ No newline at end of file diff --git a/docs/src/main/paradox/docs/delta/api/assets/storages/tagged.json b/docs/src/main/paradox/docs/delta/api/assets/storages/tagged.json deleted file mode 100644 index a3bd65ad63..0000000000 --- a/docs/src/main/paradox/docs/delta/api/assets/storages/tagged.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "@context": [ - "https://bluebrain.github.io/nexus/contexts/storages-metadata.json", - "https://bluebrain.github.io/nexus/contexts/metadata.json" - ], - "@id": "http://localhost:8080/v1/resources/myorg/myproject/_/remote", - "@type": [ - "Storage", - "RemoteDiskStorage" - ], - "_algorithm": "SHA-256", - "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/storages.json", - "_createdAt": "2021-05-11T12:22:19.195Z", - "_createdBy": "http://localhost:8080/v1/anonymous", - "_deprecated": false, - "_incoming": "http://localhost:8080/v1/storages/myorg/myproject/remote/incoming", - "_outgoing": "http://localhost:8080/v1/storages/myorg/myproject/remote/outgoing", - "_project": "http://localhost:8080/v1/projects/myorg/myproject", - "_rev": 3, - "_self": "http://localhost:8080/v1/storages/myorg/myproject/remote", - "_updatedAt": "2021-05-11T12:28:08.479Z", - "_updatedBy": "http://localhost:8080/v1/anonymous" -} diff --git a/docs/src/main/paradox/docs/delta/api/storages-api.md b/docs/src/main/paradox/docs/delta/api/storages-api.md index 43eafb79d3..5e9d8bfb70 100644 --- a/docs/src/main/paradox/docs/delta/api/storages-api.md +++ b/docs/src/main/paradox/docs/delta/api/storages-api.md @@ -196,37 +196,6 @@ Payload Response : @@snip [updated.json](assets/storages/updated.json) -## Tag - -Links a storage revision to a specific name. - -Tagging a storage is considered to be an update as well. - -``` -POST /v1/storages/{org_label}/{project_label}/{storage_id}/tags?rev={previous_rev} - { - "tag": "{name}", - "rev": {rev} - } -``` - -... where - -- `{previous_rev}`: Number - the last known revision for the storage. -- `{name}`: String - label given to the storage at specific revision. -- `{rev}`: Number - the revision to link the provided `{name}`. - -**Example** - -Request -: @@snip [tag.sh](assets/storages/tag.sh) - -Payload -: @@snip [tag.json](assets/tag.json) - -Response -: @@snip [tagged.json](assets/storages/tagged.json) - ## Deprecate Locks the storage, so no further operations can be performed. It will also not be taken into account by the diff --git a/docs/src/main/paradox/docs/releases/v1.10-release-notes.md b/docs/src/main/paradox/docs/releases/v1.10-release-notes.md index 5dc41c5ba4..795aea3561 100644 --- a/docs/src/main/paradox/docs/releases/v1.10-release-notes.md +++ b/docs/src/main/paradox/docs/releases/v1.10-release-notes.md @@ -66,6 +66,10 @@ Previously deprecated storages can now be undeprecated. @ref:[More information](../delta/api/storages-api.md#undeprecate) +#### Remove the ability to tag storages + +Storages can no longer be tagged, looked up by tag or have their tags fetched. + ### Global search #### Fetch search suites endpoint