diff --git a/integration/src/test/scala/org/knora/sipi/SipiClientTestDelegator.scala b/integration/src/test/scala/org/knora/sipi/SipiClientTestDelegator.scala index eed65733d9..7c8ef102e9 100644 --- a/integration/src/test/scala/org/knora/sipi/SipiClientTestDelegator.scala +++ b/integration/src/test/scala/org/knora/sipi/SipiClientTestDelegator.scala @@ -45,15 +45,6 @@ case class SipiServiceTestDelegator( if (whichSipi.useLive) { live } else { mock } - /** - * Asks Sipi for metadata about a file in the tmp folder, served from the 'knora.json' route. - * - * @param filename the path to the file. - * @return a [[FileMetadataSipiResponse]] containing the requested metadata. - */ - override def getFileMetadataFromSipiTemp(filename: String): Task[FileMetadataSipiResponse] = - sipiService.getFileMetadataFromSipiTemp(filename) - /** * Asks DSP-Ingest for metadata about a file in permanent location, served from the 'knora.json' route. * diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala index 1363050b0f..aa580ca20a 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala @@ -40,8 +40,6 @@ import org.knora.webapi.messages.v2.responder.resourcemessages.ReadResourceV2 import org.knora.webapi.messages.v2.responder.standoffmessages.* import org.knora.webapi.messages.v2.responder.valuemessages.ValueContentV2.FileInfo import org.knora.webapi.routing.RouteUtilZ -import org.knora.webapi.routing.v2.AssetIngestState -import org.knora.webapi.routing.v2.AssetIngestState.* import org.knora.webapi.slice.admin.api.model.MaintenanceRequests.AssetId import org.knora.webapi.slice.admin.api.model.Project import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortcode @@ -476,7 +474,6 @@ case class ReadOtherValueV2( /** * Represents a Knora value to be created in an existing resource. * - * @param ingestState indicates the state of the file, either ingested or in temp folder * @param resourceIri the resource the new value should be attached to. * @param resourceClassIri the resource class that the client believes the resource belongs to. * @param propertyIri the property of the new value. If the client wants to create a link, this must be a link value property. @@ -496,7 +493,6 @@ case class CreateValueV2( valueUUID: Option[UUID] = None, valueCreationDate: Option[Instant] = None, permissions: Option[String] = None, - ingestState: AssetIngestState = AssetInTemp, ) /** A trait for classes representing information to be updated in a value. */ @@ -552,7 +548,6 @@ case class UpdateValueContentV2( permissions: Option[String] = None, valueCreationDate: Option[Instant] = None, newValueVersionIri: Option[SmartIri] = None, - ingestState: AssetIngestState = AssetInTemp, ) extends UpdateValueV2 /** @@ -678,7 +673,6 @@ object ValueContentV2 { * Given the jsonLd contains a FileValueHasFilename, it will try to fetch the FileInfo from Sipi or Dsp-Ingest. * * @param shortcode The shortcode of the project - * @param ingestState The state of the file, either ingested already or in Sipi temp folder * @param jsonLd the jsonLd object * @return Some FileInfo if FileValueHasFilename found and the remote service returned the metadata. * None if FileValueHasFilename is not found in the jsonLd object. @@ -686,7 +680,6 @@ object ValueContentV2 { */ def getFileInfo( shortcode: Shortcode, - ingestState: AssetIngestState, jsonLd: JsonLDObject, ): ZIO[SipiService, Throwable, Option[FileInfo]] = fileInfoFromExternal(jsonLd.getString(FileValueHasFilename).toOption.flatten, shortcode) diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/ResourceUtilV2.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/ResourceUtilV2.scala index 039d676977..2e508b7abb 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/ResourceUtilV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/ResourceUtilV2.scala @@ -23,8 +23,6 @@ import org.knora.webapi.messages.v2.responder.resourcemessages.ReadResourceV2 import org.knora.webapi.messages.v2.responder.valuemessages.FileValueContentV2 import org.knora.webapi.messages.v2.responder.valuemessages.ReadValueV2 import org.knora.webapi.messages.v2.responder.valuemessages.StillImageExternalFileValueContentV2 -import org.knora.webapi.routing.v2.AssetIngestState -import org.knora.webapi.routing.v2.AssetIngestState.* import org.knora.webapi.slice.admin.domain.model.Permission import org.knora.webapi.slice.admin.domain.model.User import org.knora.webapi.store.iiif.api.SipiService @@ -91,17 +89,6 @@ trait ResourceUtilV2 { fileValues: Seq[FileValueContentV2], requestingUser: User, ): Task[T] - - def doSipiPostUpdateIfInTemp[T <: UpdateResultInProject]( - ingestState: AssetIngestState, - updateTask: Task[T], - fileValues: Seq[FileValueContentV2], - requestingUser: User, - ): Task[T] = - ingestState match { - case AssetIngested => updateTask - case AssetInTemp => doSipiPostUpdate(updateTask, fileValues, requestingUser) - } } final case class ResourceUtilV2Live(triplestore: TriplestoreService, sipiService: SipiService) diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/ValuesResponderV2.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/ValuesResponderV2.scala index e2895a263b..d4c3053984 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/ValuesResponderV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/ValuesResponderV2.scala @@ -319,8 +319,7 @@ final case class ValuesResponderV2( // If we were creating a file value, have Sipi move the file to permanent storage if the update // was successful, or delete the temporary file if the update failed. - resourceUtilV2.doSipiPostUpdateIfInTemp( - valueToCreate.ingestState, + resourceUtilV2.doSipiPostUpdate( triplestoreUpdateFuture, valueToCreate.valueContent.asOpt[FileValueContentV2].toSeq, requestingUser, @@ -956,8 +955,7 @@ final case class ValuesResponderV2( makeTaskFutureToUpdateValueContent(updateValueContentV2), ) - resourceUtilV2.doSipiPostUpdateIfInTemp( - updateValueContentV2.ingestState, + resourceUtilV2.doSipiPostUpdate( triplestoreUpdate, updateValueContentV2.valueContent.asOpt[FileValueContentV2].toSeq, requestingUser, diff --git a/webapi/src/main/scala/org/knora/webapi/store/iiif/api/SipiService.scala b/webapi/src/main/scala/org/knora/webapi/store/iiif/api/SipiService.scala index 96ae4ef350..00c00f35e6 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/iiif/api/SipiService.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/iiif/api/SipiService.scala @@ -61,14 +61,6 @@ object FileMetadataSipiResponse { trait SipiService { - /** - * Asks Sipi for metadata about a file in the tmp folder, served from the 'knora.json' route. - * - * @param filename the path to the file. - * @return a [[FileMetadataSipiResponse]] containing the requested metadata. - */ - def getFileMetadataFromSipiTemp(filename: String): Task[FileMetadataSipiResponse] - /** * Asks DSP-Ingest for metadata about a file in permanent location, served from the 'knora.json' route. * @@ -112,5 +104,4 @@ trait SipiService { * @return The path to the downloaded asset. If the asset could not be downloaded, [[None]] is returned. */ def downloadAsset(asset: Asset, targetDir: Path, user: User): Task[Option[Path]] - } diff --git a/webapi/src/main/scala/org/knora/webapi/store/iiif/impl/SipiServiceLive.scala b/webapi/src/main/scala/org/knora/webapi/store/iiif/impl/SipiServiceLive.scala index 40339e1c73..ab2d966bb9 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/iiif/impl/SipiServiceLive.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/iiif/impl/SipiServiceLive.scala @@ -12,7 +12,6 @@ import sttp.client3.SttpBackend import sttp.client3.httpclient.zio.HttpClientZioBackend import sttp.model.Uri import zio.* -import zio.json.DecoderOps import zio.json.ast.Json import zio.nio.file.Path @@ -22,7 +21,6 @@ import dsp.errors.BadRequestException import dsp.errors.NotFoundException import org.knora.webapi.config.Sipi import org.knora.webapi.messages.store.sipimessages.* -import org.knora.webapi.messages.util.KnoraSystemInstances import org.knora.webapi.messages.v2.responder.SuccessResponseV2 import org.knora.webapi.slice.admin.api.model.MaintenanceRequests.AssetId import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortcode @@ -31,7 +29,6 @@ import org.knora.webapi.slice.admin.domain.service.Asset import org.knora.webapi.slice.admin.domain.service.DspIngestClient import org.knora.webapi.slice.infrastructure.Jwt import org.knora.webapi.slice.infrastructure.JwtService -import org.knora.webapi.slice.infrastructure.Scope as AuthScope import org.knora.webapi.slice.security.ScopeResolver import org.knora.webapi.store.iiif.api.FileMetadataSipiResponse import org.knora.webapi.store.iiif.api.SipiService @@ -54,24 +51,6 @@ final case class SipiServiceLive( s"${sipiConfig.internalBaseUrl}/${asset.belongsToProject.value}/${asset.internalFilename}" } - /** - * Asks Sipi for metadata about a file, served from the 'knora.json' route. - * - * @param filename the file name - * @return a [[FileMetadataSipiResponse]] containing the requested metadata. - */ - override def getFileMetadataFromSipiTemp(filename: String): Task[FileMetadataSipiResponse] = - for { - jwt <- jwtService.createJwt(KnoraSystemInstances.Users.SystemUser.userIri, AuthScope.admin) - request = quickRequest - .get(uri"${sipiConfig.internalBaseUrl}/tmp/$filename/knora.json") - .header("Authorization", s"Bearer ${jwt.jwtString}") - body <- doSipiRequest(request) - res <- ZIO - .fromEither(body.fromJson[FileMetadataSipiResponse]) - .mapError(e => SipiException(s"Invalid response from Sipi: $e, $body")) - } yield res - override def getFileMetadataFromDspIngest(shortcode: Shortcode, assetId: AssetId): Task[FileMetadataSipiResponse] = for { response <- dspIngestClient.getAssetInfo(shortcode, assetId) diff --git a/webapi/src/main/scala/org/knora/webapi/store/iiif/impl/SipiServiceMock.scala b/webapi/src/main/scala/org/knora/webapi/store/iiif/impl/SipiServiceMock.scala index d08916813a..120d2c144e 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/iiif/impl/SipiServiceMock.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/iiif/impl/SipiServiceMock.scala @@ -48,9 +48,6 @@ case class SipiServiceMock(ref: Ref[Map[SipiMockMethodName, Task[Object]]]) exte ref.set(SipiMockMethodName.values.map(_ -> fail).toMap) } - override def getFileMetadataFromSipiTemp(filename: String): Task[FileMetadataSipiResponse] = - getReturnValue(GetFileMetadataFromSipiTemp) - def moveTemporaryFileToPermanentStorage( moveTemporaryFileToPermanentStorageRequestV2: MoveTemporaryFileToPermanentStorageRequest, ): Task[SuccessResponseV2] = diff --git a/webapi/src/test/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueContentV2Spec.scala b/webapi/src/test/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueContentV2Spec.scala index ae976f68cd..df2cea890b 100644 --- a/webapi/src/test/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueContentV2Spec.scala +++ b/webapi/src/test/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueContentV2Spec.scala @@ -44,44 +44,21 @@ object ValueContentV2Spec extends ZIOSpecDefault { override def spec: Spec[Any, Option[Throwable]] = suite("ValueContentV2.getFileInfo")( - suite("Given the asset is present in the tmp folder of Sipi")( - test("When getting file metadata with AssetInTemp from Sipi, then it should succeed") { - for { - temp <- ValueContentV2.getFileInfo(shortcode0001, AssetInTemp, jsonLdObj).some - } yield assertTrue(temp.metadata == expected) - }, - test("When getting file metadata with AssetIngested from dsp-ingest, then it should fail") { - for { - exit <- ValueContentV2.getFileInfo(shortcode0001, AssetIngested, jsonLdObj).exit - } yield assert(exit)(failsWithA[AssertionException]) - }, - ).provide(mockSipi(AssetInTemp)), suite("Given the asset is ingested")( - test("When getting file metadata with AssetInTemp from Sipi, then it should fail") { - for { - exit <- ValueContentV2.getFileInfo(shortcode0001, AssetInTemp, jsonLdObj).exit - } yield assert(exit)(failsWithA[AssertionException]) - }, test("When getting file metadata with AssetIngested from dsp-ingest, then it should succeed") { for { - ingested <- ValueContentV2.getFileInfo(shortcode0001, AssetIngested, jsonLdObj).some + ingested <- ValueContentV2.getFileInfo(shortcode0001, jsonLdObj).some } yield assertTrue(ingested.metadata == expected) }, - ).provide(mockSipi(AssetIngested)), + ).provide(mockSipi()), ) - private def mockSipi(flag: AssetIngestState) = ZLayer.succeed(new SipiService { - - override def getFileMetadataFromSipiTemp(filename: String): Task[FileMetadataSipiResponse] = - if (flag == AssetInTemp) { ZIO.succeed(expected) } - else { ZIO.fail(AssertionException("fail")) } - + private def mockSipi() = ZLayer.succeed(new SipiService { override def getFileMetadataFromDspIngest( shortcode: KnoraProject.Shortcode, assetId: AssetId, ): Task[FileMetadataSipiResponse] = - if (flag == AssetIngested) { ZIO.succeed(expected) } - else { ZIO.fail(AssertionException("fail")) } + ZIO.succeed(expected) // The following are unsupported operations because they are not used in the test def moveTemporaryFileToPermanentStorage(