From a6c8f2bc3b78c556106e879d037f2a001306aae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Thu, 12 Dec 2024 09:17:34 +0100 Subject: [PATCH 1/4] fix: Dummy filenames may not contain a file extension, remove it only if it exists (DEV-4227) (#3442) --- .../v2/responder/valuemessages/ValueMessagesV2.scala | 2 +- .../slice/admin/api/model/MaintenanceRequests.scala | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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 9d74c5e028..066bcb7d2d 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 @@ -713,7 +713,7 @@ object ValueContentV2 { for { sipiService <- ZIO.service[SipiService] assetId <- ZIO - .fromEither(AssetId.from(filename.substring(0, filename.indexOf('.')))) + .fromEither(AssetId.fromFilename(filename)) .mapError(msg => BadRequestException(s"Invalid value for 'fileValueHasFilename': $msg")) meta <- sipiService.getFileMetadataFromDspIngest(shortcode, assetId).mapError { case NotFoundException(_) => diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/MaintenanceRequests.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/MaintenanceRequests.scala index 28ce82bdfa..73ff481e28 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/MaintenanceRequests.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/MaintenanceRequests.scala @@ -21,7 +21,14 @@ import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortcode object MaintenanceRequests { type AssetId = String Refined MatchesRegex["^[a-zA-Z0-9-_]{4,}$"] - object AssetId extends RefinedTypeOps[AssetId, String] + object AssetId extends RefinedTypeOps[AssetId, String] { + + def fromFilename(filename: String): Either[String, AssetId] = { + val withoutFileExtension = + if filename.contains(".") then filename.substring(0, filename.indexOf('.')) else filename + AssetId.from(withoutFileExtension) + } + } final case class Dimensions(width: Int Refined Positive, height: Int Refined Positive) From a29e9dddfe2bb2f826146a069edd0cf5bda64d14 Mon Sep 17 00:00:00 2001 From: DaSCH Bot <50987250+daschbot@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:35:14 +0800 Subject: [PATCH 2/4] chore: Patch dependency updates (#3444) --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index dfab19f67c..e3ac451a02 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -127,7 +127,7 @@ object Dependencies { // found/added by the plugin but deleted anyway val commonsLang3 = "org.apache.commons" % "commons-lang3" % "3.17.0" - val tapirVersion = "1.11.9" + val tapirVersion = "1.11.10" val tapir = Seq( "com.softwaremill.sttp.tapir" %% "tapir-pekko-http-server" % tapirVersion, From b54c53bcd9a9d1a1a9fa43fdfa959714b9f152ed Mon Sep 17 00:00:00 2001 From: DaSCH Bot <50987250+daschbot@users.noreply.github.com> Date: Tue, 17 Dec 2024 18:24:00 +0800 Subject: [PATCH 3/4] chore(main): Release 31.1.0 (#3440) --- CHANGELOG.md | 22 ++++++++++++++++++++++ version.txt | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 741dbbf3ac..34516fa70b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [31.1.0](https://github.com/dasch-swiss/dsp-api/compare/v31.0.0...v31.1.0) (2024-12-16) + + +### Maintenances + +* Patch dependency updates ([#3444](https://github.com/dasch-swiss/dsp-api/issues/3444)) ([a29e9dd](https://github.com/dasch-swiss/dsp-api/commit/a29e9dddfe2bb2f826146a069edd0cf5bda64d14)) + + +### Enhancements + +* Split license into licenseText and licenseUri (DEV-4398) ([#3436](https://github.com/dasch-swiss/dsp-api/issues/3436)) ([76d2db2](https://github.com/dasch-swiss/dsp-api/commit/76d2db25a75ffd43294e2d1d25e98f53f5d0e275)) + + +### Bug Fixes + +* Dummy filenames may not contain a file extension, remove it only if it exists (DEV-4227) ([#3442](https://github.com/dasch-swiss/dsp-api/issues/3442)) ([a6c8f2b](https://github.com/dasch-swiss/dsp-api/commit/a6c8f2bc3b78c556106e879d037f2a001306aae5)) + + +### Tests + +* Add test data to anything project ([#3441](https://github.com/dasch-swiss/dsp-api/issues/3441)) ([3660ae6](https://github.com/dasch-swiss/dsp-api/commit/3660ae63dca8809174c432605e21912e5143fe55)) + ## [31.0.0](https://github.com/dasch-swiss/dsp-api/compare/v30.22.0...v31.0.0) (2024-12-02) diff --git a/version.txt b/version.txt index 221a8da0b5..cc85ff7699 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -31.0.0 +31.1.0 From c87233b382035a34704cc4bb9c16f59601dbe525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Thu, 19 Dec 2024 09:05:04 +0100 Subject: [PATCH 4/4] feat: Remove license and copyright from Project (DEV-4479) (#3445) --- .../org/knora/webapi/ProjectEraseIT.scala | 3 - .../it/v2/CopyrightAndLicensesSpec.scala | 152 +----------------- .../IntegrationTestAdminJsonProtocol.scala | 3 - .../admin/ProjectRestServiceSpec.scala | 24 --- .../sharedtestdata/SharedTestDataADM.scala | 30 ---- .../knora-ontologies/knora-admin.ttl | 13 +- .../resources/knora-ontologies/knora-base.ttl | 2 +- .../resourcemessages/ResourceMessagesV2.scala | 36 ----- .../valuemessages/ValueMessagesV2.scala | 15 -- .../main/scala/org/knora/webapi/package.scala | 2 +- .../responders/v2/ValuesResponderV2.scala | 33 +--- .../resources/CreateResourceV2Handler.scala | 12 +- .../webapi/slice/admin/api/Examples.scala | 6 - ...rojectsEndpointsRequestsAndResponses.scala | 6 - .../admin/api/model/ProjectsMessagesADM.scala | 6 - .../admin/domain/model/KnoraProject.scala | 3 - .../domain/service/KnoraProjectRepo.scala | 3 - .../domain/service/KnoraProjectService.scala | 6 - .../admin/domain/service/ProjectService.scala | 6 - .../repo/service/KnoraProjectRepoLive.scala | 42 ++--- .../org/knora/webapi/TestDataFactory.scala | 3 - .../service/KnoraProjectServiceSpec.scala | 55 ------- .../domain/service/ProjectServiceSpec.scala | 6 - .../service/KnoraProjectRepoLiveSpec.scala | 11 +- 24 files changed, 24 insertions(+), 454 deletions(-) delete mode 100644 webapi/src/test/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectServiceSpec.scala diff --git a/integration/src/test/scala/org/knora/webapi/ProjectEraseIT.scala b/integration/src/test/scala/org/knora/webapi/ProjectEraseIT.scala index 1ec53592e3..dfd542331a 100644 --- a/integration/src/test/scala/org/knora/webapi/ProjectEraseIT.scala +++ b/integration/src/test/scala/org/knora/webapi/ProjectEraseIT.scala @@ -83,9 +83,6 @@ object ProjectEraseIT extends E2EZSpec { None, KnoraProject.Status.Active, KnoraProject.SelfJoin.CanJoin, - None, - None, - None, ), ), ).orDie diff --git a/integration/src/test/scala/org/knora/webapi/it/v2/CopyrightAndLicensesSpec.scala b/integration/src/test/scala/org/knora/webapi/it/v2/CopyrightAndLicensesSpec.scala index afe1254416..13a9225b76 100644 --- a/integration/src/test/scala/org/knora/webapi/it/v2/CopyrightAndLicensesSpec.scala +++ b/integration/src/test/scala/org/knora/webapi/it/v2/CopyrightAndLicensesSpec.scala @@ -13,7 +13,6 @@ import zio.* import zio.http.Body import zio.http.Response import zio.test.* -import zio.test.TestAspect import java.net.URLEncoder import scala.jdk.CollectionConverters.IteratorHasAsScala @@ -30,7 +29,6 @@ import org.knora.webapi.models.filemodels.UploadFileRequest import org.knora.webapi.slice.admin.domain.model.KnoraProject.CopyrightAttribution import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseText import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseUri -import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortcode import org.knora.webapi.slice.admin.domain.service.KnoraProjectService import org.knora.webapi.slice.common.KnoraIris.ValueIri import org.knora.webapi.slice.common.jena.JenaConversions.given @@ -45,13 +43,7 @@ object CopyrightAndLicensesSpec extends E2EZSpec { private val aLicenseText = LicenseText.unsafeFrom("CC BY-SA 4.0") private val aLicenseUri = LicenseUri.unsafeFrom("https://creativecommons.org/licenses/by-sa/4.0/") - private val projectCopyrightAttribution = CopyrightAttribution.unsafeFrom("2024, On Project") - private val projectLicenseText = LicenseText.unsafeFrom("Apache-2.0") - private val projectLicenseUri = LicenseUri.unsafeFrom("https://www.apache.org/licenses/LICENSE-2.0") - - private val givenProjectHasNoCopyrightAttributionAndLicenseSuite = suite( - "given the project does not have a license and does not have a copyright attribution ", - )( + private val givenProjectHasNoCopyrightAttributionAndLicenseSuite = suite("Creating Resources")( test( "when creating a resource without copyright attribution and license" + "the creation response should not contain the license and copyright attribution", @@ -118,124 +110,12 @@ object CopyrightAndLicensesSpec extends E2EZSpec { actualLicenseUri == aLicenseUri.value, ) }, - test( - "when creating a resource without copyright attribution and license " + - "and when providing the project with copyright attribution and license " + - "and then updating the value" + - "the response when getting the updated value should contain the license and copyright attribution of the project", - ) { - for { - createResourceResponseModel <- createStillImageResource() - _ <- addCopyrightAttributionAndLicenseToProject() - resourceId <- resourceId(createResourceResponseModel) - valueId <- valueId(createResourceResponseModel) - _ <- updateValue(resourceId, valueId) - valueGetResponse <- getValueFromApi(createResourceResponseModel) - actualCopyright <- copyrightValue(valueGetResponse) - actualLicenseText <- licenseTextValue(valueGetResponse) - actualLicenseUri <- licenseUriValue(valueGetResponse) - } yield assertTrue( - actualCopyright == projectCopyrightAttribution.value, - actualLicenseText == projectLicenseText.value, - actualLicenseUri == projectLicenseUri.value, - ) - }, - ) @@ TestAspect.before(removeCopyrightAttributionAndLicenseFromProject()) - - private val givenProjectHasCopyrightAttributionAndLicenseSuite = suite( - "given the project has a license and has a copyright attribution", - )( - test( - "when creating a resource without copyright attribution and without license " + - "then the response when getting the created value should contain the default license and default copyright attribution", - ) { - for { - createResourceResponseModel <- createStillImageResource() - valueResponseModel <- getValueFromApi(createResourceResponseModel) - actualCopyright <- copyrightValue(valueResponseModel) - actualLicenseText <- licenseTextValue(valueResponseModel) - actualLicenseUri <- licenseUriValue(valueResponseModel) - } yield assertTrue( - actualCopyright == projectCopyrightAttribution.value, - actualLicenseText == projectLicenseText.value, - actualLicenseUri == projectLicenseUri.value, - ) - }, - test( - "when creating a resource without copyright attribution and without license " + - "then the create response contain the license and copyright attribution from resource", - ) { - for { - createResourceResponseModel <- createStillImageResource() - actualCopyright <- copyrightValue(createResourceResponseModel) - actualLicenseText <- licenseTextValue(createResourceResponseModel) - actualLicenseUri <- licenseUriValue(createResourceResponseModel) - } yield assertTrue( - actualCopyright == projectCopyrightAttribution.value, - actualLicenseText == projectLicenseText.value, - actualLicenseUri == projectLicenseUri.value, - ) - }, - test( - "when creating a resource with copyright attribution and license " + - "then the create response contain the license and copyright attribution from resource", - ) { - for { - createResourceResponseModel <- - createStillImageResource(Some(aCopyrightAttribution), Some(aLicenseText), Some(aLicenseUri)) - actualCopyright <- copyrightValue(createResourceResponseModel) - actualLicenseText <- licenseTextValue(createResourceResponseModel) - actualLicenseUri <- licenseUriValue(createResourceResponseModel) - } yield assertTrue( - actualCopyright == aCopyrightAttribution.value, - actualLicenseText == aLicenseText.value, - actualLicenseUri == aLicenseUri.value, - ) - }, - test( - "when creating a resource with copyright attribution and without license " + - "then the response when getting the created value should contain the license and copyright attribution from resource", - ) { - for { - createResourceResponseModel <- - createStillImageResource(Some(aCopyrightAttribution), Some(aLicenseText), Some(aLicenseUri)) - valueResponseModel <- getValueFromApi(createResourceResponseModel) - actualCopyright <- copyrightValue(valueResponseModel) - actualLicenseText <- licenseTextValue(valueResponseModel) - actualLicenseUri <- licenseUriValue(valueResponseModel) - } yield assertTrue( - actualCopyright == aCopyrightAttribution.value, - actualLicenseText == aLicenseText.value, - actualLicenseUri == aLicenseUri.value, - ) - }, - ) @@ TestAspect.before(addCopyrightAttributionAndLicenseToProject()) + ) val e2eSpec: Spec[Scope & env, Any] = suite("Copyright Attribution and Licenses")( givenProjectHasNoCopyrightAttributionAndLicenseSuite, - givenProjectHasCopyrightAttributionAndLicenseSuite, ) - private def removeCopyrightAttributionAndLicenseFromProject() = - setCopyrightAttributionAndLicenseToProject(None, None, None) - private def addCopyrightAttributionAndLicenseToProject() = - setCopyrightAttributionAndLicenseToProject( - Some(projectCopyrightAttribution), - Some(projectLicenseText), - Some(projectLicenseUri), - ) - private def setCopyrightAttributionAndLicenseToProject( - copyrightAttribution: Option[CopyrightAttribution], - licenseText: Option[LicenseText], - licenseUri: Option[LicenseUri], - ) = - for { - projectService <- ZIO.service[KnoraProjectService] - prj <- projectService.findByShortcode(Shortcode.unsafeFrom("0001")).someOrFail(new Exception("Project not found")) - change = prj.copy(copyrightAttribution = copyrightAttribution, licenseText = licenseText, licenseUri = licenseUri) - updated <- projectService.save(change) - } yield updated - private def failResponse(msg: String)(response: Response) = response.body.asString.flatMap(bodyStr => ZIO.fail(Exception(s"$msg\nstatus: ${response.status}\nbody: $bodyStr"))) @@ -262,34 +142,6 @@ object CopyrightAndLicensesSpec extends E2EZSpec { } yield createResourceResponseModel } - private def updateValue(resourceIri: String, valueId: ValueIri) = { - val jsonLd = - s""" - |{ - | "@id": "${resourceIri}", - | "@type": "anything:ThingPicture", - | "knora-api:hasStillImageFileValue": { - | "@id" : "${valueId.smartIri.toComplexSchema.toIri}", - | "@type": "knora-api:StillImageFileValue", - | "knora-api:fileValueHasFilename": "test.jpg" - | }, - | "@context": { - | "knora-api": "http://api.knora.org/ontology/knora-api/v2#", - | "anything": "http://0.0.0.0:3333/ontology/0001/anything/v2#" - | } - |} - |""".stripMargin - for { - _ <- Console.printLine(jsonLd) - _ <- ModelOps.fromJsonLd(jsonLd).mapError(Exception(_)) - responseBody <- - sendPutRequestAsRoot("/v2/values", Body.fromString(jsonLd)) - .filterOrElseWith(_.status.isSuccess)(failResponse(s"Value update failed $valueId resource $resourceIri.")) - .flatMap(_.body.asString) - model <- ModelOps.fromJsonLd(responseBody).mapError(Exception(_)) - } yield model - } - private def getResourceFromApi(resourceId: String) = for { responseBody <- sendGetRequest(s"/v2/resources/${URLEncoder.encode(resourceId, "UTF-8")}") .filterOrElseWith(_.status.isSuccess)(failResponse(s"Failed to get resource $resourceId.")) diff --git a/integration/src/test/scala/org/knora/webapi/messages/admin/responder/IntegrationTestAdminJsonProtocol.scala b/integration/src/test/scala/org/knora/webapi/messages/admin/responder/IntegrationTestAdminJsonProtocol.scala index c45046f6be..84f0f407a6 100644 --- a/integration/src/test/scala/org/knora/webapi/messages/admin/responder/IntegrationTestAdminJsonProtocol.scala +++ b/integration/src/test/scala/org/knora/webapi/messages/admin/responder/IntegrationTestAdminJsonProtocol.scala @@ -193,9 +193,6 @@ object IntegrationTestAdminJsonProtocol extends TriplestoreJsonProtocol { "ontologies", "status", "selfjoin", - "copyrightAttribution", - "licenseText", - "licenseUri", ), ) diff --git a/integration/src/test/scala/org/knora/webapi/responders/admin/ProjectRestServiceSpec.scala b/integration/src/test/scala/org/knora/webapi/responders/admin/ProjectRestServiceSpec.scala index 5a33822e5e..6837cea10c 100644 --- a/integration/src/test/scala/org/knora/webapi/responders/admin/ProjectRestServiceSpec.scala +++ b/integration/src/test/scala/org/knora/webapi/responders/admin/ProjectRestServiceSpec.scala @@ -162,9 +162,6 @@ class ProjectRestServiceSpec extends CoreSpec with ImplicitSender { logo = Some(Logo.unsafeFrom("/fu/bar/baz.jpg")), status = Status.Active, selfjoin = SelfJoin.CannotJoin, - copyrightAttribution = Some(CopyrightAttribution.unsafeFrom("2024, Example Project")), - licenseText = Some(LicenseText.unsafeFrom("CC-BY-4.0")), - licenseUri = Some(LicenseUri.unsafeFrom("https://creativecommons.org/licenses/by/4.0/")), ), SharedTestDataADM.rootUser, ), @@ -177,12 +174,6 @@ class ProjectRestServiceSpec extends CoreSpec with ImplicitSender { received.project.description should be( Seq(StringLiteralV2.from(value = "project description", language = Some("en"))), ) - received.project.copyrightAttribution should be(Some(CopyrightAttribution.unsafeFrom("2024, Example Project"))) - received.project.licenseText should be(Some(LicenseText.unsafeFrom("CC-BY-4.0"))) - received.project.licenseUri should be( - Some(LicenseUri.unsafeFrom("https://creativecommons.org/licenses/by/4.0/")), - ) - newProjectIri.set(received.project.id) // Check Administrative Permissions @@ -265,9 +256,6 @@ class ProjectRestServiceSpec extends CoreSpec with ImplicitSender { logo = Some(Logo.unsafeFrom("/fu/bar/baz.jpg")), status = Status.Active, selfjoin = SelfJoin.CannotJoin, - None, - None, - None, ), SharedTestDataADM.rootUser, ), @@ -280,9 +268,6 @@ class ProjectRestServiceSpec extends CoreSpec with ImplicitSender { received.project.description should be( Seq(StringLiteralV2.from(value = "project description", language = Some("en"))), ) - received.project.copyrightAttribution should be(None) - received.project.licenseText should be(None) - received.project.licenseUri should be(None) } "CREATE a project that its info has special characters" in { @@ -305,9 +290,6 @@ class ProjectRestServiceSpec extends CoreSpec with ImplicitSender { logo = Some(Logo.unsafeFrom("/fu/bar/baz.jpg")), status = Status.Active, selfjoin = SelfJoin.CannotJoin, - None, - None, - None, ), SharedTestDataADM.rootUser, ), @@ -340,9 +322,6 @@ class ProjectRestServiceSpec extends CoreSpec with ImplicitSender { logo = Some(Logo.unsafeFrom("/fu/bar/baz.jpg")), status = Status.Active, selfjoin = SelfJoin.CannotJoin, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ), SharedTestDataADM.rootUser, ), @@ -365,9 +344,6 @@ class ProjectRestServiceSpec extends CoreSpec with ImplicitSender { logo = Some(Logo.unsafeFrom("/fu/bar/baz.jpg")), status = Status.Active, selfjoin = SelfJoin.CannotJoin, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ), SharedTestDataADM.rootUser, ), diff --git a/integration/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala b/integration/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala index d55946c45f..f40a35403f 100644 --- a/integration/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala +++ b/integration/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala @@ -169,9 +169,6 @@ object SharedTestDataADM { ), status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) /* represents the full ProjectADM of the default shared ontologies project */ @@ -186,9 +183,6 @@ object SharedTestDataADM { ontologies = Seq.empty[IRI], status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) /** @@ -301,9 +295,6 @@ object SharedTestDataADM { ontologies = Seq(SharedOntologyTestDataADM.IMAGES_ONTOLOGY_IRI), status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) /* represents the full ProjectADM of the images project in the external format */ @@ -318,9 +309,6 @@ object SharedTestDataADM { ontologies = Seq(SharedOntologyTestDataADM.IMAGES_ONTOLOGY_IRI_LocalHost), status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) /* represents the full GroupADM of the images ProjectAdmin group */ @@ -484,9 +472,6 @@ object SharedTestDataADM { ontologies = Seq(SharedOntologyTestDataADM.INCUNABULA_ONTOLOGY_IRI), status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) /* represents the ProjectADM of the incunabula project in the external format*/ @@ -522,9 +507,6 @@ object SharedTestDataADM { ontologies = Seq(SharedOntologyTestDataADM.INCUNABULA_ONTOLOGY_IRI_LocalHost), status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) /** @@ -637,9 +619,6 @@ object SharedTestDataADM { ontologies = Seq(SharedOntologyTestDataADM.ANYTHING_ONTOLOGY_IRI, SharedOntologyTestDataADM.SomethingOntologyIri), status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) def anythingProjectExternal: Project = Project( @@ -656,9 +635,6 @@ object SharedTestDataADM { ), status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) /* represents the full GroupADM of the Thing searcher group */ @@ -696,9 +672,6 @@ object SharedTestDataADM { ), status = true, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) /* represents the user profile of 'superuser' as found in admin-data.ttl */ @@ -748,8 +721,5 @@ object SharedTestDataADM { ontologies = Seq("http://www.knora.org/ontology/0804/dokubib"), status = false, selfjoin = false, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) } diff --git a/webapi/src/main/resources/knora-ontologies/knora-admin.ttl b/webapi/src/main/resources/knora-ontologies/knora-admin.ttl index cd4ab9a89c..68bea7fbb1 100644 --- a/webapi/src/main/resources/knora-ontologies/knora-admin.ttl +++ b/webapi/src/main/resources/knora-ontologies/knora-admin.ttl @@ -1,4 +1,4 @@ - ### +### # * Copyright © 2021 - 2024 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. # * SPDX-License-Identifier: Apache-2.0 ### @@ -382,16 +382,7 @@ owl:cardinality "1"^^xsd:nonNegativeInteger ], [ rdf:type owl:Restriction ; owl:onProperty :hasSelfJoinEnabled ; - owl:cardinality "1"^^xsd:nonNegativeInteger ], - [ rdf:type owl:Restriction ; - owl:onProperty knora-base:hasCopyrightAttribution ; - owl:maxCardinality "1"^^xsd:nonNegativeInteger ], - [ rdf:type owl:Restriction ; - owl:onProperty knora-base:hasLicenseText ; - owl:maxCardinality "1"^^xsd:nonNegativeInteger ], - [ rdf:type owl:Restriction ; - owl:onProperty knora-base:hasLicenseUri ; - owl:maxCardinality "1"^^xsd:nonNegativeInteger ]; + owl:cardinality "1"^^xsd:nonNegativeInteger ] ; rdfs:comment "Represents a project that uses Knora."@en . diff --git a/webapi/src/main/resources/knora-ontologies/knora-base.ttl b/webapi/src/main/resources/knora-ontologies/knora-base.ttl index ccbf4297ab..c2caed9f30 100644 --- a/webapi/src/main/resources/knora-ontologies/knora-base.ttl +++ b/webapi/src/main/resources/knora-ontologies/knora-base.ttl @@ -20,7 +20,7 @@ rdf:type owl:Ontology ; rdfs:label "The Knora base ontology"@en ; :attachedToProject knora-admin:SystemProject ; - :ontologyVersion "knora-base v43" . + :ontologyVersion "knora-base v44" . ################################################################# diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala index ebb620db04..e226264b3b 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala @@ -5,8 +5,6 @@ package org.knora.webapi.messages.v2.responder.resourcemessages -import monocle.Optional - import java.time.Instant import java.util.UUID @@ -26,15 +24,10 @@ import org.knora.webapi.messages.util.rdf.* import org.knora.webapi.messages.util.standoff.StandoffTagUtilV2 import org.knora.webapi.messages.util.standoff.XMLUtil import org.knora.webapi.messages.v2.responder.* -import org.knora.webapi.messages.v2.responder.resourcemessages.ResourceMessagesV2Optics.CreateResourceV2Optics -import org.knora.webapi.messages.v2.responder.resourcemessages.ResourceMessagesV2Optics.CreateValueInNewResourceV2Optics import org.knora.webapi.messages.v2.responder.standoffmessages.MappingXMLtoStandoff import org.knora.webapi.messages.v2.responder.valuemessages.* import org.knora.webapi.messages.v2.responder.valuemessages.ValueMessagesV2Optics.* import org.knora.webapi.slice.admin.api.model.Project -import org.knora.webapi.slice.admin.domain.model.KnoraProject.CopyrightAttribution -import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseText -import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseUri import org.knora.webapi.slice.admin.domain.model.KnoraProject.ProjectIri import org.knora.webapi.slice.admin.domain.model.Permission import org.knora.webapi.slice.admin.domain.model.User @@ -633,35 +626,6 @@ case class CreateResourceV2( ) } -object CreateResourceV2 { - def replaceCopyrightAndLicenceIfMissing( - licenseText: Option[LicenseText], - licenseUri: Option[LicenseUri], - copyrightAttribution: Option[CopyrightAttribution], - cr: CreateResourceV2, - ): CreateResourceV2 = { - def createValuesWith( - pred: FileValueV2 => Boolean, - ): Optional[Seq[CreateValueInNewResourceV2], CreateValueInNewResourceV2] = - CreateValueInNewResourceV2Optics.elements(cv => - CreateValueInNewResourceV2Optics.fileValue.getOption(cv).exists(pred), - ) - - def fileValueWith(pred: FileValueV2 => Boolean): Optional[CreateResourceV2, FileValueV2] = - CreateResourceV2Optics - .values(createValuesWith(pred).getOption(_).isDefined) - .andThen(createValuesWith(pred)) - .andThen(CreateValueInNewResourceV2Optics.fileValue) - - def replaceIfEmpty[T](newValue: Option[T], opt: Optional[FileValueV2, Option[T]]) = - fileValueWith(opt.getOption(_).flatten.isEmpty).andThen(opt).replace(newValue) - - replaceIfEmpty(licenseText, FileValueV2Optics.licenseTextOption) - .andThen(replaceIfEmpty(licenseUri, FileValueV2Optics.licenseUriOption)) - .andThen(replaceIfEmpty(copyrightAttribution, FileValueV2Optics.copyrightAttributionOption))(cr) - } -} - /** * Represents a request to create a resource. * 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 066bcb7d2d..cc70389e88 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,7 +40,6 @@ import org.knora.webapi.messages.v2.responder.* 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.messages.v2.responder.valuemessages.ValueMessagesV2Optics.FileValueContentV2Optics import org.knora.webapi.routing.RouteUtilZ import org.knora.webapi.slice.admin.api.model.MaintenanceRequests.AssetId import org.knora.webapi.slice.admin.api.model.Project @@ -673,20 +672,6 @@ sealed trait ValueContentV2 extends KnoraContentV2[ValueContentV2] with WithAsIs * Generates instances of value content classes (subclasses of [[ValueContentV2]]) from JSON-LD input. */ object ValueContentV2 { - def replaceCopyrightAndLicenceIfMissing( - licenseText: Option[LicenseText], - licenseUri: Option[LicenseUri], - copyrightAttribution: Option[CopyrightAttribution], - vc: ValueContentV2, - ): ValueContentV2 = vc match { - case fvc: FileValueContentV2 => { - val lt = FileValueContentV2Optics.licenseTextOption.filter(_.isEmpty).replace(licenseText) - val lu = FileValueContentV2Optics.licenseUriOption.filter(_.isEmpty).replace(licenseUri) - val cp = FileValueContentV2Optics.copyrightAttributionOption.filter(_.isEmpty).replace(copyrightAttribution) - lt.andThen(lu).andThen(cp)(fvc) - } - case other => other - } final case class FileInfo(filename: IRI, metadata: FileMetadataSipiResponse) diff --git a/webapi/src/main/scala/org/knora/webapi/package.scala b/webapi/src/main/scala/org/knora/webapi/package.scala index 82c9853cf7..135c2d8eb7 100644 --- a/webapi/src/main/scala/org/knora/webapi/package.scala +++ b/webapi/src/main/scala/org/knora/webapi/package.scala @@ -14,7 +14,7 @@ package object webapi { * The version of `knora-base` and of the other built-in ontologies that this version of Knora requires. * Must be the same as the object of `knora-base:ontologyVersion` in the `knora-base` ontology being used. */ - val KnoraBaseVersion: Int = 43 + val KnoraBaseVersion: Int = 44 val KnoraBaseVersionString: String = s"$versionPrefix$KnoraBaseVersion" /** 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 93c91d13cd..f8adbeb633 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 @@ -91,14 +91,7 @@ final case class ValuesResponderV2( submittedInternalPropertyIri <- ZIO.attempt(valueToCreate.propertyIri.toOntologySchema(InternalSchema)) - submittedInternalValueContent = ValueContentV2 - .replaceCopyrightAndLicenceIfMissing( - project.licenseText, - project.licenseUri, - project.copyrightAttribution, - valueToCreate.valueContent, - ) - .toOntologySchema(InternalSchema) + submittedInternalValueContent = valueToCreate.valueContent.toOntologySchema(InternalSchema) // Get ontology information about the submitted property. propertyInfoRequestForSubmittedProperty = @@ -705,16 +698,8 @@ final case class ValuesResponderV2( ) // Convert the submitted value content to the internal schema. - project = resourceInfo.projectADM - submittedInternalValueContent = - ValueContentV2 - .replaceCopyrightAndLicenceIfMissing( - project.licenseText, - project.licenseUri, - project.copyrightAttribution, - updateValue.valueContent, - ) - .toOntologySchema(InternalSchema) + project = resourceInfo.projectADM + submittedInternalValueContent = updateValue.valueContent.toOntologySchema(InternalSchema) // Check that the object of the adjusted property (the value to be created, or the target of the link to be created) will have // the correct type for the adjusted property's knora-base:objectClassConstraint. @@ -1024,12 +1009,6 @@ final case class ValuesResponderV2( currentTime: Instant = valueCreationDate.getOrElse(Instant.now) // Generate a SPARQL update. - newValue: ValueContentV2 = ValueContentV2.replaceCopyrightAndLicenceIfMissing( - resourceInfo.projectADM.licenseText, - resourceInfo.projectADM.licenseUri, - resourceInfo.projectADM.copyrightAttribution, - newValueVersion, - ) sparqlUpdate = sparql.v2.txt.addValueVersion( dataNamedGraph = dataNamedGraph, resourceIri = resourceInfo.resourceIri, @@ -1037,10 +1016,10 @@ final case class ValuesResponderV2( currentValueIri = currentValue.valueIri, newValueIri = newValueIri, valueTypeIri = currentValue.valueContent.valueType, - value = newValue, + value = newValueVersion, valueCreator = valueCreator, valuePermissions = valuePermissions, - maybeComment = newValue.comment, + maybeComment = newValueVersion.comment, linkUpdates = standoffLinkUpdates, currentTime = currentTime, requestingUser = requestingUser.id, @@ -1052,7 +1031,7 @@ final case class ValuesResponderV2( } yield UnverifiedValueV2( newValueIri = newValueIri, newValueUUID = currentValue.valueHasUUID, - valueContent = newValue.unescape, + valueContent = newValueVersion.unescape, permissions = valuePermissions, creationDate = currentTime, ) diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/resources/CreateResourceV2Handler.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/resources/CreateResourceV2Handler.scala index 299f19ab7c..62f86fe6b5 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/resources/CreateResourceV2Handler.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/resources/CreateResourceV2Handler.scala @@ -170,17 +170,7 @@ final case class CreateResourceV2Handler( project = createResourceRequestV2.createResource.projectADM // Convert the resource to the internal ontology schema. - internalCreateResource <- - ZIO.attempt( - CreateResourceV2 - .replaceCopyrightAndLicenceIfMissing( - project.licenseText, - project.licenseUri, - project.copyrightAttribution, - createResourceRequestV2.createResource, - ) - .toOntologySchema(InternalSchema), - ) + internalCreateResource <- ZIO.attempt(createResourceRequestV2.createResource.toOntologySchema(InternalSchema)) // Check link targets and list nodes that should exist. _ <- checkStandoffLinkTargets( diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/Examples.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/Examples.scala index bfc6d7a304..f669607840 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/Examples.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/Examples.scala @@ -23,9 +23,6 @@ import org.knora.webapi.slice.admin.domain.model.GroupIri import org.knora.webapi.slice.admin.domain.model.GroupName import org.knora.webapi.slice.admin.domain.model.GroupSelfJoin import org.knora.webapi.slice.admin.domain.model.GroupStatus -import org.knora.webapi.slice.admin.domain.model.KnoraProject.CopyrightAttribution -import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseText -import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseUri import org.knora.webapi.slice.admin.domain.model.KnoraProject.ProjectIri import org.knora.webapi.slice.admin.domain.model.User import org.knora.webapi.slice.admin.domain.model.UserIri @@ -96,9 +93,6 @@ object Examples { status = true, ontologies = Seq.empty, selfjoin = false, - copyrightAttribution = Some(CopyrightAttribution.unsafeFrom("2024, Example Project")), - licenseText = Some(LicenseText.unsafeFrom("CC-BY-4.0")), - licenseUri = Some(LicenseUri.unsafeFrom("http://example.com/license")), ) private val group = Group( diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/ProjectsEndpointsRequestsAndResponses.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/ProjectsEndpointsRequestsAndResponses.scala index 2119abbf07..89b8bce775 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/ProjectsEndpointsRequestsAndResponses.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/ProjectsEndpointsRequestsAndResponses.scala @@ -27,9 +27,6 @@ object ProjectsEndpointsRequestsAndResponses { logo: Option[Logo] = None, status: Status, selfjoin: SelfJoin, - copyrightAttribution: Option[CopyrightAttribution], - licenseText: Option[LicenseText], - licenseUri: Option[LicenseUri], ) object ProjectCreateRequest { implicit val codec: JsonCodec[ProjectCreateRequest] = DeriveJsonCodec.gen[ProjectCreateRequest] @@ -43,9 +40,6 @@ object ProjectsEndpointsRequestsAndResponses { logo: Option[Logo] = None, status: Option[Status] = None, selfjoin: Option[SelfJoin] = None, - copyrightAttribution: Option[CopyrightAttribution] = None, - licenseText: Option[LicenseText] = None, - licenseUri: Option[LicenseUri] = None, ) object ProjectUpdateRequest { implicit val codec: JsonCodec[ProjectUpdateRequest] = DeriveJsonCodec.gen[ProjectUpdateRequest] diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/ProjectsMessagesADM.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/ProjectsMessagesADM.scala index c3d24874fc..dcb3b218f2 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/ProjectsMessagesADM.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/ProjectsMessagesADM.scala @@ -11,9 +11,6 @@ import zio.json.JsonCodec import org.knora.webapi.IRI import org.knora.webapi.messages.admin.responder.AdminKnoraResponseADM import org.knora.webapi.messages.store.triplestoremessages.StringLiteralV2 -import org.knora.webapi.slice.admin.api.Codecs.ZioJsonCodec.copyrightAttribution -import org.knora.webapi.slice.admin.api.Codecs.ZioJsonCodec.licenseText -import org.knora.webapi.slice.admin.api.Codecs.ZioJsonCodec.licenseUri import org.knora.webapi.slice.admin.domain.model.KnoraProject.* import org.knora.webapi.slice.admin.domain.model.RestrictedView import org.knora.webapi.slice.admin.domain.model.User @@ -43,9 +40,6 @@ case class Project( ontologies: Seq[IRI], status: Boolean, selfjoin: Boolean, - copyrightAttribution: Option[CopyrightAttribution], - licenseText: Option[LicenseText], - licenseUri: Option[LicenseUri], ) extends Ordered[Project] { def projectIri: ProjectIri = ProjectIri.unsafeFrom(id) diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/KnoraProject.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/KnoraProject.scala index ebc4f7a29e..d012d3e839 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/KnoraProject.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/KnoraProject.scala @@ -36,9 +36,6 @@ case class KnoraProject( status: Status, selfjoin: SelfJoin, restrictedView: RestrictedView, - copyrightAttribution: Option[CopyrightAttribution], - licenseText: Option[LicenseText], - licenseUri: Option[LicenseUri], ) extends EntityWithId[ProjectIri] object KnoraProject { diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectRepo.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectRepo.scala index 06c29481dc..0e231dce98 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectRepo.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectRepo.scala @@ -47,9 +47,6 @@ object KnoraProjectRepo { KnoraProject.Status.Active, KnoraProject.SelfJoin.CannotJoin, RestrictedView.default, - None, - None, - None, ) val SystemProject: KnoraProject = makeBuiltIn( diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectService.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectService.scala index b5bacb7bbb..01f04803ca 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectService.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectService.scala @@ -52,9 +52,6 @@ final case class KnoraProjectService(knoraProjectRepo: KnoraProjectRepo, ontolog req.status, req.selfjoin, RestrictedView.default, - req.copyrightAttribution, - req.licenseText, - req.licenseUri, ) project <- knoraProjectRepo.save(project) } yield project @@ -100,9 +97,6 @@ final case class KnoraProjectService(knoraProjectRepo: KnoraProjectRepo, ontolog logo = updateReq.logo.orElse(project.logo), status = updateReq.status.getOrElse(project.status), selfjoin = updateReq.selfjoin.getOrElse(project.selfjoin), - copyrightAttribution = updateReq.copyrightAttribution.orElse(project.copyrightAttribution), - licenseText = updateReq.licenseText.orElse(project.licenseText), - licenseUri = updateReq.licenseUri.orElse(project.licenseUri), ), ) } yield updated diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectService.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectService.scala index 0597bd7e14..82a2db205a 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectService.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectService.scala @@ -56,9 +56,6 @@ final case class ProjectService( ontologies, knoraProject.status.value, knoraProject.selfjoin.value, - knoraProject.copyrightAttribution, - knoraProject.licenseText, - knoraProject.licenseUri, ), ) @@ -76,9 +73,6 @@ final case class ProjectService( status = Status.from(project.status), selfjoin = SelfJoin.from(project.selfjoin), restrictedView, - project.copyrightAttribution, - project.licenseText, - project.licenseUri, ) def setProjectRestrictedView(project: Project, settings: RestrictedView): Task[RestrictedView] = diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/repo/service/KnoraProjectRepoLive.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/repo/service/KnoraProjectRepoLive.scala index a2f02ae5dc..ed3c02cbfd 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/repo/service/KnoraProjectRepoLive.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/repo/service/KnoraProjectRepoLive.scala @@ -7,18 +7,13 @@ package org.knora.webapi.slice.admin.repo.service import org.eclipse.rdf4j.common.net.ParsedIRI import org.eclipse.rdf4j.model.vocabulary.RDF -import org.eclipse.rdf4j.model.vocabulary.XSD import org.eclipse.rdf4j.sparqlbuilder.graphpattern.TriplePattern import org.eclipse.rdf4j.sparqlbuilder.rdf.Iri import org.eclipse.rdf4j.sparqlbuilder.rdf.Rdf -import org.eclipse.rdf4j.sparqlbuilder.rdf.Rdf.literalOfType import zio.* import org.knora.webapi.messages.OntologyConstants.KnoraAdmin import org.knora.webapi.messages.OntologyConstants.KnoraAdmin.* -import org.knora.webapi.messages.OntologyConstants.KnoraBase.HasCopyrightAttribution -import org.knora.webapi.messages.OntologyConstants.KnoraBase.HasLicenseText -import org.knora.webapi.messages.OntologyConstants.KnoraBase.HasLicenseUri import org.knora.webapi.slice.admin.domain.model.KnoraProject import org.knora.webapi.slice.admin.domain.model.KnoraProject.* import org.knora.webapi.slice.admin.domain.model.RestrictedView @@ -53,9 +48,6 @@ final case class KnoraProjectRepoLive( Vocabulary.KnoraAdmin.projectLongname, Vocabulary.KnoraAdmin.projectRestrictedViewSize, Vocabulary.KnoraAdmin.projectRestrictedViewWatermark, - Vocabulary.KnoraBase.hasCopyrightAttribution, - Vocabulary.KnoraBase.hasLicenseText, - Vocabulary.KnoraBase.hasLicenseUri, ), ) @@ -99,19 +91,16 @@ object KnoraProjectRepoLive { } yield size.orElse(watermark).getOrElse(RestrictedView.default) for { - iri <- resource.getSubjectIri - shortcode <- resource.getStringLiteralOrFail[Shortcode](ProjectShortcode) - shortname <- resource.getStringLiteralOrFail[Shortname](ProjectShortname) - longname <- resource.getStringLiteral[Longname](ProjectLongname) - description <- resource.getLangStringLiteralsOrFail[Description](ProjectDescription) - keywords <- resource.getStringLiterals[Keyword](ProjectKeyword) - logo <- resource.getStringLiteral[Logo](ProjectLogo) - status <- resource.getBooleanLiteralOrFail[Status](StatusProp) - selfjoin <- resource.getBooleanLiteralOrFail[SelfJoin](HasSelfJoinEnabled) - copyrightAttribution <- resource.getStringLiteral[CopyrightAttribution](HasCopyrightAttribution) - licenseText <- resource.getStringLiteral[LicenseText](HasLicenseText) - licenseUri <- resource.getUriLiteral[LicenseUri](HasLicenseUri) - restrictedView <- getRestrictedView + iri <- resource.getSubjectIri + shortcode <- resource.getStringLiteralOrFail[Shortcode](ProjectShortcode) + shortname <- resource.getStringLiteralOrFail[Shortname](ProjectShortname) + longname <- resource.getStringLiteral[Longname](ProjectLongname) + description <- resource.getLangStringLiteralsOrFail[Description](ProjectDescription) + keywords <- resource.getStringLiterals[Keyword](ProjectKeyword) + logo <- resource.getStringLiteral[Logo](ProjectLogo) + status <- resource.getBooleanLiteralOrFail[Status](StatusProp) + selfjoin <- resource.getBooleanLiteralOrFail[SelfJoin](HasSelfJoinEnabled) + restrictedView <- getRestrictedView } yield KnoraProject( id = ProjectIri.unsafeFrom(iri.value), shortcode = shortcode, @@ -123,9 +112,6 @@ object KnoraProjectRepoLive { status = status, selfjoin = selfjoin, restrictedView = restrictedView, - copyrightAttribution = copyrightAttribution, - licenseText = licenseText, - licenseUri = licenseUri, ) } @@ -151,14 +137,6 @@ object KnoraProjectRepoLive { pattern.andHas(Vocabulary.KnoraAdmin.projectRestrictedViewWatermark, watermark) } - project.copyrightAttribution.foreach(attr => - pattern.andHas(Vocabulary.KnoraBase.hasCopyrightAttribution, attr.value), - ) - project.licenseText.foreach(text => pattern.andHas(Vocabulary.KnoraBase.hasLicenseText, text.value)) - project.licenseUri.foreach(uri => - pattern.andHas(Vocabulary.KnoraBase.hasLicenseUri, literalOfType(uri.value, XSD.ANYURI)), - ) - pattern } } diff --git a/webapi/src/test/scala/org/knora/webapi/TestDataFactory.scala b/webapi/src/test/scala/org/knora/webapi/TestDataFactory.scala index 21ea3787ee..aa361d10d1 100644 --- a/webapi/src/test/scala/org/knora/webapi/TestDataFactory.scala +++ b/webapi/src/test/scala/org/knora/webapi/TestDataFactory.scala @@ -99,8 +99,5 @@ object TestDataFactory { Status.Active, SelfJoin.CannotJoin, RestrictedView.default, - Some(CopyrightAttribution.unsafeFrom("2024, Example Project")), - Some(LicenseText.unsafeFrom("CC-BY-4.0")), - Some(LicenseUri.unsafeFrom("https://creativecommons.org/licenses/by/4.0/")), ) } diff --git a/webapi/src/test/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectServiceSpec.scala b/webapi/src/test/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectServiceSpec.scala deleted file mode 100644 index 4d2d6c4f2e..0000000000 --- a/webapi/src/test/scala/org/knora/webapi/slice/admin/domain/service/KnoraProjectServiceSpec.scala +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2021 - 2024 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.knora.webapi.slice.admin.domain.service - -import zio.ZIO -import zio.test.* -import zio.test.Assertion.* - -import org.knora.webapi.TestDataFactory -import org.knora.webapi.messages.StringFormatter -import org.knora.webapi.slice.admin.api.model.ProjectsEndpointsRequestsAndResponses.ProjectUpdateRequest -import org.knora.webapi.slice.admin.domain.model.KnoraProject.CopyrightAttribution -import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseText -import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseUri -import org.knora.webapi.slice.admin.domain.repo.KnoraProjectRepoInMemory -import org.knora.webapi.slice.ontology.repo.service.OntologyRepoInMemory -import org.knora.webapi.slice.resourceinfo.domain.IriConverter - -object KnoraProjectServiceSpec extends ZIOSpecDefault { - - private val projectService = ZIO.serviceWithZIO[KnoraProjectService] - private val repo = ZIO.serviceWithZIO[KnoraProjectRepoInMemory] - - private val updateSuite = suite("updateProject")( - test("should update the license and copyright attribution") { - val project = TestDataFactory.someProject - for { - _ <- repo(_.save(project)) - updateRequest = ProjectUpdateRequest( - copyrightAttribution = Some(CopyrightAttribution.unsafeFrom("Foo")), - licenseText = Some(LicenseText.unsafeFrom("CC BY 4.0")), - licenseUri = Some(LicenseUri.unsafeFrom("https://creativecommons.org/licenses/by/4.0/")), - ) - actual <- projectService(_.updateProject(project, updateRequest)) - } yield assertTrue( - actual == project.copy( - copyrightAttribution = Some(CopyrightAttribution.unsafeFrom("Foo")), - licenseText = Some(LicenseText.unsafeFrom("CC BY 4.0")), - licenseUri = Some(LicenseUri.unsafeFrom("https://creativecommons.org/licenses/by/4.0/")), - ), - ) - }, - ) - val spec = suite("KnoraProjectService")(updateSuite) - .provide( - KnoraProjectService.layer, - KnoraProjectRepoInMemory.layer, - OntologyRepoInMemory.emptyLayer, - IriConverter.layer, - StringFormatter.test, - ) -} diff --git a/webapi/src/test/scala/org/knora/webapi/slice/admin/domain/service/ProjectServiceSpec.scala b/webapi/src/test/scala/org/knora/webapi/slice/admin/domain/service/ProjectServiceSpec.scala index 974404c509..659c4433b8 100644 --- a/webapi/src/test/scala/org/knora/webapi/slice/admin/domain/service/ProjectServiceSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/slice/admin/domain/service/ProjectServiceSpec.scala @@ -35,9 +35,6 @@ object ProjectServiceSpec extends ZIOSpecDefault { ontologies = List.empty, status = true, selfjoin = true, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) assertTrue( ProjectService.projectDataNamedGraphV2(p).value == s"http://www.knora.org/data/$shortcode/$shortname", @@ -58,9 +55,6 @@ object ProjectServiceSpec extends ZIOSpecDefault { status = Status.Active, selfjoin = SelfJoin.CanJoin, restrictedView = RestrictedView.default, - copyrightAttribution = None, - licenseText = None, - licenseUri = None, ) assertTrue( ProjectService diff --git a/webapi/src/test/scala/org/knora/webapi/slice/admin/repo/service/KnoraProjectRepoLiveSpec.scala b/webapi/src/test/scala/org/knora/webapi/slice/admin/repo/service/KnoraProjectRepoLiveSpec.scala index 45f1cba405..3b73a13640 100644 --- a/webapi/src/test/scala/org/knora/webapi/slice/admin/repo/service/KnoraProjectRepoLiveSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/slice/admin/repo/service/KnoraProjectRepoLiveSpec.scala @@ -18,11 +18,8 @@ import zio.test.check import org.knora.webapi.messages.StringFormatter import org.knora.webapi.slice.admin.AdminConstants import org.knora.webapi.slice.admin.domain.model.KnoraProject -import org.knora.webapi.slice.admin.domain.model.KnoraProject.CopyrightAttribution import org.knora.webapi.slice.admin.domain.model.KnoraProject.Description import org.knora.webapi.slice.admin.domain.model.KnoraProject.Keyword -import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseText -import org.knora.webapi.slice.admin.domain.model.KnoraProject.LicenseUri import org.knora.webapi.slice.admin.domain.model.KnoraProject.Logo import org.knora.webapi.slice.admin.domain.model.KnoraProject.Longname import org.knora.webapi.slice.admin.domain.model.KnoraProject.ProjectIri @@ -48,9 +45,6 @@ object KnoraProjectRepoLiveSpec extends ZIOSpecDefault { Status.Active, SelfJoin.CannotJoin, RestrictedView.default, - Some(CopyrightAttribution.unsafeFrom("2024, Example Project")), - Some(LicenseText.unsafeFrom("Apache-2.0")), - Some(LicenseUri.unsafeFrom("https://www.apache.org/licenses/LICENSE-2.0.html")), ) private val someProjectTrig = @@ -69,10 +63,7 @@ object KnoraProjectRepoLiveSpec extends ZIOSpecDefault { | knora-admin:projectLogo "logo.png" ; | knora-admin:status true ; | knora-admin:hasSelfJoinEnabled false ; - | knora-admin:projectRestrictedViewSize "!128,128" ; - | knora-base:hasCopyrightAttribution "2024, Example Project" ; - | knora-base:hasLicenseText "Apache-2.0" ; - | knora-base:hasLicenseUri "https://www.apache.org/licenses/LICENSE-2.0.html"^^xsd:anyURI . + | knora-admin:projectRestrictedViewSize "!128,128" . |} |""".stripMargin