Skip to content

Commit

Permalink
Remove the linking operation for S3 storages (#4797)
Browse files Browse the repository at this point in the history
* Remove the linking operation for S3 storages

* Release notes
  • Loading branch information
dantb authored Mar 14, 2024
1 parent 0466f5b commit 024157a
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ final class Files(
filename: String,
fileId: Iri
): IO[FileStorageMetadata] =
LinkFile(storage, remoteDiskStorageClient, config)
LinkFile(storage, remoteDiskStorageClient)
.apply(path, filename)
.adaptError { case e: StorageFileRejection => LinkRejection(fileId, storage.id, e) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations._
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.disk.{DiskStorageFetchFile, DiskStorageSaveFile}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.remote._
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.remote.client.RemoteDiskStorageClient
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.{S3StorageFetchFile, S3StorageLinkFile, S3StorageSaveFile}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.{S3StorageFetchFile, S3StorageSaveFile}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.{contexts, Storages}
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.ContextValue
Expand Down Expand Up @@ -102,10 +102,6 @@ object Storage {

def saveFile(config: StorageTypeConfig)(implicit as: ActorSystem, uuidf: UUIDF): SaveFile =
new S3StorageSaveFile(this, config)

def linkFile(config: StorageTypeConfig)(implicit as: ActorSystem, uuidf: UUIDF): LinkFile =
new S3StorageLinkFile(this, config)

}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations

import akka.actor.ActorSystem
import akka.http.scaladsl.model.Uri
import cats.effect.IO
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.FileStorageMetadata
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StoragesConfig.StorageTypeConfig
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.{Storage, StorageType}
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.StorageFileRejection.MoveFileRejection
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.remote.client.RemoteDiskStorageClient
Expand All @@ -28,14 +26,12 @@ object LinkFile {
/**
* Construct a [[LinkFile]] from the given ''storage''.
*/
def apply(storage: Storage, client: RemoteDiskStorageClient, config: StorageTypeConfig)(implicit
as: ActorSystem,
def apply(storage: Storage, client: RemoteDiskStorageClient)(implicit
uuidf: UUIDF
): LinkFile =
storage match {
case storage: Storage.DiskStorage => unsupported(storage.tpe)
case storage: Storage.S3Storage => storage.linkFile(config)
case storage: Storage.RemoteDiskStorage => storage.linkFile(client)
case _ => unsupported(storage.tpe)
}

private def unsupported(storageType: StorageType): LinkFile =
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import java.nio.charset.StandardCharsets.UTF_8
class MinioSpec extends Suites with MinioDocker {
override val nestedSuites: IndexedSeq[Suite] = Vector(
new S3StorageAccessSpec(this),
new S3StorageSaveAndFetchFileSpec(this),
new S3StorageLinkFileSpec(this)
new S3StorageSaveAndFetchFileSpec(this)
)
}

Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions docs/src/main/paradox/docs/delta/api/files-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Response

## Link using POST

Brings a file existing in a storage to Nexus Delta as a file resource. This operation is supported for files using `S3Storage` and `RemoteDiskStorage`.
Brings a file existing in a storage to Nexus Delta as a file resource. This operation is supported for files using `RemoteDiskStorage`.

```
POST /v1/files/{org_label}/{project_label}?storage={storageId}&tag={tagName}
Expand Down Expand Up @@ -150,7 +150,7 @@ Response

## Link using PUT

Brings a file existing in a storage to Nexus Delta as a file resource. This operation is supported for files using `S3Storage` and `RemoteDiskStorage`.
Brings a file existing in a storage to Nexus Delta as a file resource. This operation is supported for files using `RemoteDiskStorage`.

This alternative endpoint allows to specify the resource `@id`.

Expand Down
1 change: 1 addition & 0 deletions docs/src/main/paradox/docs/releases/v1.10-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ update operations.
#### Deprecations

* Storages can no longer be tagged, looked up by tag or have their tags fetched.
* S3 storages no longer support a linking operation.

### Resolvers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,48 +133,16 @@ class S3StorageSpec extends StorageSpec {
}

s"Linking in S3" should {
"link an existing file" in {
"be rejected" in {
val payload = Json.obj(
"filename" -> Json.fromString("logo.png"),
"path" -> Json.fromString(logoKey),
"mediaType" -> Json.fromString("image/png")
)
val fileId = s"${config.deltaUri}/resources/$projectRef/_/logo.png"
deltaClient.put[Json](s"/files/$projectRef/logo.png?storage=nxv:${storageId}2", payload, Coyote) {
(json, response) =>
response.status shouldEqual StatusCodes.Created
filterMetadataKeys(json) shouldEqual
jsonContentOf(
"kg/files/linking-metadata.json",
replacements(
Coyote,
"projId" -> projectRef,
"self" -> fileSelf(projectRef, fileId),
"endpoint" -> s3Endpoint,
"endpointBucket" -> s3BucketEndpoint,
"key" -> logoKey
): _*
)
(_, response) =>
response.status shouldEqual StatusCodes.BadRequest
}
}
}

"fail to link a nonexistent file" in {
val payload = Json.obj(
"filename" -> Json.fromString("logo.png"),
"path" -> Json.fromString("non/existent.png"),
"mediaType" -> Json.fromString("image/png")
)

deltaClient.put[Json](s"/files/$projectRef/nonexistent.png?storage=nxv:${storageId}2", payload, Coyote) {
(json, response) =>
response.status shouldEqual StatusCodes.BadRequest
json shouldEqual jsonContentOf(
"kg/files/linking-notfound.json",
"org" -> orgId,
"proj" -> projId,
"endpointBucket" -> s3BucketEndpoint
)
}
}
}

0 comments on commit 024157a

Please sign in to comment.