@Service
class ViewService(repository: ViewRepository, val projectRepository: ProjectRepository, val layoutService: LayoutService, val nodeRepository: NodeRepository, val componentTemplateRepository: ComponentTemplateRepository) : NamedNodeService<View, ViewRepository>

Service for Views. Provides functions to create, update and delete

Parameters

repository

the associated repository used for CRUD functionality

projectRepository

used to get Projects by id

layoutService

used to update the layout of a View

nodeRepository

used to save the View

componentTemplateRepository

used to get ComponentTemplates by id

Constructors

Link copied to clipboard
constructor(repository: ViewRepository, projectRepository: ProjectRepository, layoutService: LayoutService, nodeRepository: NodeRepository, componentTemplateRepository: ComponentTemplateRepository)

Properties

Link copied to clipboard
@Autowired
lateinit var authorizationChecker: AuthorizationChecker

Injected, used for the checkPermission function

Link copied to clipboard

Injected, used to get a user based on a GropiusAuthorizationContext

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
suspend fun checkIsAdmin(authorizationContext: GropiusAuthorizationContext, errorMessage: String)

Checks if the user defined by authorizationContext is a global admin

Link copied to clipboard
private suspend fun checkManageViewsPermission(project: Project, authorizationContext: GropiusAuthorizationContext)

Checks that the user has ProjectPermission.MANAGE_VIEWS on the provided project

Link copied to clipboard
suspend fun checkPermission(node: Node, permission: Permission, errorMessage: String)

Checks if the permission is granted on node If checkPermission on the permission.context is false, no permission is evaluated Does not handle the case that the user is an admin

Link copied to clipboard
suspend fun createView(authorizationContext: GropiusAuthorizationContext, input: CreateViewInput): View

Creates a new View based on the provided input Checks the authorization status

Link copied to clipboard
suspend fun deleteView(authorizationContext: GropiusAuthorizationContext, input: DeleteNodeInput)

Deletes a View by id Checks the authorization status

Link copied to clipboard
suspend fun evaluatePermission(node: Node, permission: Permission): Boolean

Evaluates if the permission is granted on node If checkPermission on the permission.context is false, no permission is evaluated Does not handle the case that the user is an admin

Link copied to clipboard
suspend fun getUser(authorizationContext: GropiusAuthorizationContext): GropiusUser

Gets a GropiusUser based on the userId from the authorizationContext

Link copied to clipboard

Updates node based on input Updates name and description

Link copied to clipboard
suspend fun updateView(authorizationContext: GropiusAuthorizationContext, input: UpdateViewInput): View

Updates a View based on the provided input Checks the authorization status