Skip to content

Commit

Permalink
Return new setting
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone committed Mar 4, 2024
1 parent 3a25f22 commit 8c48d46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@

package org.knora.webapi.slice.admin.api.service

import zio.*
import zio.macros.accessible

import dsp.errors.BadRequestException
import dsp.errors.NotFoundException
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM.*
import org.knora.webapi.messages.admin.responder.projectsmessages.*
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM.*
import org.knora.webapi.responders.admin.ProjectsResponderADM
import org.knora.webapi.slice.admin.api.model.ProjectDataGetResponseADM
import org.knora.webapi.slice.admin.api.model.ProjectExportInfoResponse
Expand All @@ -30,6 +27,8 @@ import org.knora.webapi.slice.admin.domain.service.ProjectExportService
import org.knora.webapi.slice.admin.domain.service.ProjectImportService
import org.knora.webapi.slice.common.api.AuthorizationRestService
import org.knora.webapi.slice.common.api.KnoraResponseRenderer
import zio.*
import zio.macros.accessible

@accessible
trait ProjectADMRestService {
Expand Down Expand Up @@ -284,8 +283,8 @@ final case class ProjectsADMRestServiceLive(
project <- projectRepo.findById(id).someOrFail(NotFoundException(s"Project '${getId(id)}' not found."))
_ <- permissionService.ensureSystemAdminOrProjectAdmin(user, project)
restrictedView <- req.toRestrictedView
_ <- projectService.setProjectRestrictedView(project, restrictedView)
} yield RestrictedViewResponse.from(restrictedView)
newSettings <- projectService.setProjectRestrictedView(project, restrictedView)
} yield RestrictedViewResponse.from(newSettings)

Check warning on line 287 in webapi/src/main/scala/org/knora/webapi/slice/admin/api/service/ProjectsADMRestService.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/slice/admin/api/service/ProjectsADMRestService.scala#L283-L287

Added lines #L283 - L287 were not covered by tests

override def exportProject(shortcodeStr: String, user: User): Task[Unit] =
convertStringToShortcodeId(shortcodeStr).flatMap(exportProject(_, user))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ final case class ProjectADMService(
.map(_ :+ projectGraph)
}

def setProjectRestrictedView(project: KnoraProject, settings: RestrictedView): Task[Unit] = {
def setProjectRestrictedView(project: KnoraProject, settings: RestrictedView): Task[RestrictedView] = {
val newSettings = settings match {
case RestrictedView.Watermark(false) => RestrictedView.default
case s => s

Check warning on line 102 in webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectADMService.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectADMService.scala#L101-L102

Added lines #L101 - L102 were not covered by tests
}
projectRepo.setProjectRestrictedView(project, newSettings)
projectRepo.setProjectRestrictedView(project, newSettings).as(newSettings)

Check warning on line 104 in webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectADMService.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectADMService.scala#L104

Added line #L104 was not covered by tests
}

def setProjectRestrictedView(project: ProjectADM, settings: RestrictedView): Task[Unit] =
def setProjectRestrictedView(project: ProjectADM, settings: RestrictedView): Task[RestrictedView] =
setProjectRestrictedView(toKnoraProject(project), settings)
}

Expand Down

0 comments on commit 8c48d46

Please sign in to comment.