@Service
class LabelService(repository: LabelRepository, val trackableRepository: TrackableRepository, val issueService: IssueService) : NamedAuditedNodeService<Label, LabelRepository>

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

Parameters

repository

the associated repository used for CRUD functionality

trackableRepository

used to find Trackables by id

issueService

used to remove Labels from Issues

Constructors

Link copied to clipboard
constructor(repository: LabelRepository, trackableRepository: TrackableRepository, issueService: IssueService)

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

Functions

Link copied to clipboard

Adds a Label to a Trackable Checks the authorization status

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
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 createdAuditedNode(node: AuditedNode, createdBy: User)

Updates node after it was created without an Input Should be called after the node was constructed Sets AuditedNode.createdBy and AuditedNode.lastModifiedBy

Link copied to clipboard
suspend fun createLabel(authorizationContext: GropiusAuthorizationContext, input: CreateLabelInput): Label

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

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

Removes a Label from all Trackables by id Does not actually delete it to keep it visible in issue histories 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
private suspend fun removeLabelFromIssues(label: Label, issues: Collection<Issue>, byUser: User)

Removes label for each Issue in issues now byUser. Saves issues

Link copied to clipboard

Removes a Label from a Trackable Deletes the Label if it's the last Trackable the Label was on Checks the authorization status

Link copied to clipboard
suspend fun updateAuditedNode(node: AuditedNode, lastModifiedBy: User, lastModifiedAt: OffsetDateTime)

Updates node after it was updated without an UpdateNodeInput Sets AuditedNode.lastModifiedBy and AuditedNode.lastModifiedAt

Link copied to clipboard
suspend fun updateLabel(authorizationContext: GropiusAuthorizationContext, input: UpdateLabelInput): Label

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

Link copied to clipboard
suspend fun updateNamedAuditedNode(node: NamedAuditedNode, input: UpdateNamedNodeInput, lastModifiedBy: User, lastModifiedAt: OffsetDateTime)

Updates node based on input Calls updateAuditedNode Updates name and description