Skip to content

Commit

Permalink
Add ProjectEraseService to ProjectRestService
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone committed Jun 12, 2024
1 parent 4bea6ea commit af5e9b0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import zio.URLayer
import org.knora.webapi.config.AppConfig
import org.knora.webapi.responders.IriService
import org.knora.webapi.slice.admin.domain.AdminDomainModule
import org.knora.webapi.slice.admin.domain.service.DspIngestClient
import org.knora.webapi.slice.admin.repo.AdminRepoModule
import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper
import org.knora.webapi.slice.infrastructure.CacheManager
import org.knora.webapi.slice.ontology.domain.service.OntologyRepo
import org.knora.webapi.slice.ontology.repo.service.OntologyCache
import org.knora.webapi.slice.resourceinfo.domain.IriConverter
import org.knora.webapi.store.triplestore.api.TriplestoreService

object AdminModule {
Expand All @@ -22,8 +25,11 @@ object AdminModule {
// format: off
AppConfig &
CacheManager &
DspIngestClient &
IriService &
IriConverter &
OntologyRepo &
OntologyCache &
PredicateObjectMapper &
TriplestoreService
// format: on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.knora.webapi.slice.admin.domain.service.KnoraProjectService
import org.knora.webapi.slice.admin.domain.service.KnoraUserService
import org.knora.webapi.slice.admin.domain.service.KnoraUserToUserConverter
import org.knora.webapi.slice.admin.domain.service.PasswordService
import org.knora.webapi.slice.admin.domain.service.ProjectEraseService
import org.knora.webapi.slice.admin.domain.service.ProjectExportService
import org.knora.webapi.slice.admin.domain.service.ProjectImportService
import org.knora.webapi.slice.admin.domain.service.ProjectService
Expand Down Expand Up @@ -58,6 +59,7 @@ object AdminApiModule {
OntologyCache &
PasswordService &
PermissionsResponder &
ProjectEraseService &
ProjectExportService &
ProjectImportService &
ProjectService &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package org.knora.webapi.slice.admin.api.service

import zio.*

import dsp.errors.BadRequestException
import dsp.errors.ForbiddenException
import dsp.errors.NotFoundException
Expand All @@ -28,6 +27,7 @@ import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortname
import org.knora.webapi.slice.admin.domain.model.KnoraProject.Status
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.slice.admin.domain.service.KnoraProjectService
import org.knora.webapi.slice.admin.domain.service.ProjectEraseService
import org.knora.webapi.slice.admin.domain.service.ProjectExportService
import org.knora.webapi.slice.admin.domain.service.ProjectImportService
import org.knora.webapi.slice.admin.domain.service.ProjectService
Expand All @@ -41,6 +41,7 @@ final case class ProjectRestService(
projectService: ProjectService,
knoraProjectService: KnoraProjectService,
permissionResponder: PermissionsResponder,
projectEraseService: ProjectEraseService,
projectExportService: ProjectExportService,
projectImportService: ProjectImportService,
userService: UserService,
Expand Down Expand Up @@ -136,6 +137,10 @@ final case class ProjectRestService(
internal <- projectService
.findByShortcode(shortcode)
.someOrFail(NotFoundException(s"$shortcode not found"))
project <- knoraProjectService
.findByShortcode(shortcode)
.someOrFail(NotFoundException(s"$shortcode not found"))
_ <- projectEraseService.eraseProject(project)
external <- format.toExternal(ProjectOperationResponseADM(internal))
} yield external

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import org.knora.webapi.slice.admin.domain.service.maintenance.MaintenanceServic
import org.knora.webapi.slice.admin.repo.AdminRepoModule
import org.knora.webapi.slice.infrastructure.CacheManager
import org.knora.webapi.slice.ontology.domain.service.OntologyRepo
import org.knora.webapi.slice.ontology.repo.service.OntologyCache
import org.knora.webapi.slice.resourceinfo.domain.IriConverter
import org.knora.webapi.store.triplestore.api.TriplestoreService

object AdminDomainModule {
Expand All @@ -28,8 +30,11 @@ object AdminDomainModule {
AdminRepoModule.Provided &
AppConfig &
CacheManager &
DspIngestClient &
IriService &
IriConverter &
OntologyRepo &
OntologyCache &
TriplestoreService
// format: on

Expand All @@ -44,6 +49,7 @@ object AdminDomainModule {
MaintenanceService &
PasswordService &
ProjectService &
ProjectEraseService &
UserService
// format: on

Expand All @@ -56,6 +62,7 @@ object AdminDomainModule {
KnoraUserToUserConverter.layer,
MaintenanceService.layer,
PasswordService.layer,
ProjectEraseService.layer,
ProjectService.layer,
UserService.layer,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package org.knora.webapi.slice.admin.domain.service

import zio.Chunk
import zio.Task

import org.knora.webapi.messages.store.triplestoremessages.StringLiteralV2
import org.knora.webapi.slice.admin.domain.model.GroupDescriptions
import org.knora.webapi.slice.admin.domain.model.GroupIri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.knora.webapi.slice.admin.domain.service
import zio.Chunk
import zio.Task
import zio.ZIO
import zio.ZLayer

import org.knora.webapi.slice.admin.domain.model.AdministrativePermissionRepo
import org.knora.webapi.slice.admin.domain.model.DefaultObjectAccessPermissionRepo
Expand Down Expand Up @@ -59,3 +60,7 @@ final case class ProjectEraseService(
userService.findByGroupMembership(group).flatMap(userService.removeUsersFromGroup(_, group)),
)
}

object ProjectEraseService {
val layer = ZLayer.derive[ProjectEraseService]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.knora.webapi.messages.OntologyConstants.KnoraAdmin.KnoraAdminPrefixEx
import org.knora.webapi.messages.OntologyConstants.KnoraBase.KnoraBasePrefixExpansion
import org.knora.webapi.slice.admin.AdminConstants.adminDataNamedGraph
import org.knora.webapi.slice.admin.AdminConstants.permissionsDataNamedGraph
import org.knora.webapi.slice.admin.domain.model.DefaultObjectAccessPermission

object Vocabulary {
object KnoraAdmin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,19 @@ import zio.NonEmptyChunk
import zio.Task
import zio.ZIO
import zio.ZLayer

import org.knora.webapi.messages.OntologyConstants.KnoraAdmin
import org.knora.webapi.messages.OntologyConstants.KnoraBase
import org.knora.webapi.slice.admin.AdminConstants.permissionsDataNamedGraph
import org.knora.webapi.slice.admin.domain.model.AdministrativePermission
import org.knora.webapi.slice.admin.domain.model.AdministrativePermissionPart
import org.knora.webapi.slice.admin.domain.model.AdministrativePermissionRepo
import org.knora.webapi.slice.admin.domain.model.DefaultObjectAccessPermission
import org.knora.webapi.slice.admin.domain.model.DefaultObjectAccessPermissionRepo
import org.knora.webapi.slice.admin.domain.model.GroupIri
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.Permission.Administrative
import org.knora.webapi.slice.admin.domain.model.PermissionIri
import org.knora.webapi.slice.admin.repo.rdf.RdfConversions.*
import org.knora.webapi.slice.admin.repo.rdf.Vocabulary
import org.knora.webapi.slice.common.repo.rdf.Errors.ConversionError
import org.knora.webapi.slice.common.repo.rdf.Errors.RdfError
import org.knora.webapi.slice.common.repo.rdf.RdfResource
import org.knora.webapi.slice.resourceinfo.domain.InternalIri
import org.knora.webapi.store.triplestore.api.TriplestoreService
import org.knora.webapi.store.triplestore.errors.TriplestoreResponseException

final case class DefaultObjectAccessPermissionRepoLive(
triplestore: TriplestoreService,
Expand Down

0 comments on commit af5e9b0

Please sign in to comment.