Class DefaultContentRestrictionServiceValidator
- java.lang.Object
-
- com.atlassian.confluence.api.impl.service.permissions.DefaultContentRestrictionServiceValidator
-
- All Implemented Interfaces:
ContentRestrictionService.Validator
public class DefaultContentRestrictionServiceValidator extends Object implements ContentRestrictionService.Validator
Default implementation ofContentRestrictionService.Validator
Contains per-service-operation methods as we used to in other services/validators. Also contains some package-private methods for performing more granular checks. Validation by validator should be the first thing to do on all the public service methods ofContentRestrictionService
implementations.- Since:
- 5.10
-
-
Constructor Summary
Constructors Constructor Description DefaultContentRestrictionServiceValidator(ContentEntityManagerInternal contentEntityManager, PermissionManager permissionManager, ConfluenceUserResolver confluenceUserResolver, com.atlassian.user.GroupManager groupManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidationResult
validateAddDirectRestrictionForSubject(ContentId contentId, OperationKey operationKey, Subject subject)
Validates that: OperationKey supplied is supported Subject supplied is either User or a Group and does exist Content specified exists AND can be viewed by the currently logged-in user Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specifiedValidationResult
validateAddRestrictions(ContentId contentId, Collection<? extends ContentRestriction> contentRestrictions)
Validates that: Content specified exists AND can be viewed by the currently logged-in user Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specified Input data is enough to proceed with the operation Input data should not conflict with any restrictions existingValidationResult
validateDeleteAllDirectRestrictions(ContentId contentId)
Validates that: Content specified exists AND can be viewed by the currently logged-in user Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specifiedValidationResult
validateDeleteDirectRestrictionForSubject(ContentId contentId, OperationKey operationKey, Subject subject)
Validates that: OperationKey supplied is supported Subject supplied is either User or a Group Content specified exists AND can be viewed by the currently logged-in user Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specifiedValidationResult
validateGetRestrictions(ContentId contentId)
Validates whether content specified exists and whether currently logged in user can read restrictions on a content specified.ValidationResult
validateGetRestrictionsForOperation(ContentId contentId, OperationKey opKey)
Validates whether OperationKey supplied is supported, whether content specified exists, whether currently logged in user can read restrictions on a content specifiedValidationResult
validateHasDirectRestrictionsForSubject(ContentId contentId, OperationKey operationKey, Subject subject)
Validates that: OperationKey supplied is supported Subject supplied is either User or a Group Content specified exists AND can be viewed by the currently logged-in userValidationResult
validateUpdateRestrictions(ContentId contentId, Collection<? extends ContentRestriction> contentRestrictions)
Validates that: Content specified exists AND can be viewed by the currently logged-in user Input data is enough to proceed with the operation Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specified Returns first of the failed validation results or aValidationResult
which is both authorised and valid.
-
-
-
Constructor Detail
-
DefaultContentRestrictionServiceValidator
public DefaultContentRestrictionServiceValidator(ContentEntityManagerInternal contentEntityManager, PermissionManager permissionManager, ConfluenceUserResolver confluenceUserResolver, com.atlassian.user.GroupManager groupManager)
-
-
Method Detail
-
validateUpdateRestrictions
public ValidationResult validateUpdateRestrictions(ContentId contentId, Collection<? extends ContentRestriction> contentRestrictions)
Description copied from interface:ContentRestrictionService.Validator
Validates that: Content specified exists AND can be viewed by the currently logged-in user Input data is enough to proceed with the operation Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specified Returns first of the failed validation results or aValidationResult
which is both authorised and valid.- Specified by:
validateUpdateRestrictions
in interfaceContentRestrictionService.Validator
- Parameters:
contentId
- identifier of a content for which the check should be performedcontentRestrictions
-Collection
of something which can be cast toContentRestriction
s.- Returns:
ValidationResult
whereValidationResult.isValid() == false
orValidationResult.isAuthorized() == false
in case something is wrong with the data passed. Returns completely okay ValidationResult otherwise.
-
validateAddRestrictions
public ValidationResult validateAddRestrictions(ContentId contentId, Collection<? extends ContentRestriction> contentRestrictions)
Description copied from interface:ContentRestrictionService.Validator
Validates that: Content specified exists AND can be viewed by the currently logged-in user Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specified Input data is enough to proceed with the operation Input data should not conflict with any restrictions existing- Specified by:
validateAddRestrictions
in interfaceContentRestrictionService.Validator
- Parameters:
contentId
- identifier of a content for which the check should be performedcontentRestrictions
-Collection
of something which can be cast toContentRestriction
s.- Returns:
ValidationResult
whereValidationResult.isValid() == false
orValidationResult.isAuthorized() == false
in case something is wrong with the data passed. Returns completely okay ValidationResult otherwise.
-
validateDeleteAllDirectRestrictions
public ValidationResult validateDeleteAllDirectRestrictions(ContentId contentId)
Description copied from interface:ContentRestrictionService.Validator
Validates that: Content specified exists AND can be viewed by the currently logged-in user Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specified- Specified by:
validateDeleteAllDirectRestrictions
in interfaceContentRestrictionService.Validator
- Parameters:
contentId
- identifier of a content for which the check should be performed- Returns:
ValidationResult
whereValidationResult.isValid() == false
orValidationResult.isAuthorized() == false
in case something is wrong with the data passed. Returns completely okay ValidationResult otherwise.
-
validateHasDirectRestrictionsForSubject
public ValidationResult validateHasDirectRestrictionsForSubject(ContentId contentId, OperationKey operationKey, Subject subject)
Description copied from interface:ContentRestrictionService.Validator
Validates that: OperationKey supplied is supported Subject supplied is either User or a Group Content specified exists AND can be viewed by the currently logged-in user- Specified by:
validateHasDirectRestrictionsForSubject
in interfaceContentRestrictionService.Validator
- Parameters:
contentId
- identifier of a content for which the check should be performed- Returns:
ValidationResult
whereValidationResult.isValid() == false
orValidationResult.isAuthorized() == false
in case something is wrong with the data passed. Returns completely okay ValidationResult otherwise.
-
validateDeleteDirectRestrictionForSubject
public ValidationResult validateDeleteDirectRestrictionForSubject(ContentId contentId, OperationKey operationKey, Subject subject)
Description copied from interface:ContentRestrictionService.Validator
Validates that: OperationKey supplied is supported Subject supplied is either User or a Group Content specified exists AND can be viewed by the currently logged-in user Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specified- Specified by:
validateDeleteDirectRestrictionForSubject
in interfaceContentRestrictionService.Validator
- Returns:
- validation result
-
validateAddDirectRestrictionForSubject
public ValidationResult validateAddDirectRestrictionForSubject(ContentId contentId, OperationKey operationKey, Subject subject)
Description copied from interface:ContentRestrictionService.Validator
Validates that: OperationKey supplied is supported Subject supplied is either User or a Group and does exist Content specified exists AND can be viewed by the currently logged-in user Currently logged-in user is allowed to alter ContentRestrictions on and edit the content specified- Specified by:
validateAddDirectRestrictionForSubject
in interfaceContentRestrictionService.Validator
- Returns:
- validation result
-
validateGetRestrictions
public ValidationResult validateGetRestrictions(ContentId contentId)
Description copied from interface:ContentRestrictionService.Validator
Validates whether content specified exists and whether currently logged in user can read restrictions on a content specified.- Specified by:
validateGetRestrictions
in interfaceContentRestrictionService.Validator
- Parameters:
contentId
- identifier of a content for which the check should be performed- Returns:
ValidationResult
whereValidationResult.isValid() == false
in case content is missing or unavailable.
-
validateGetRestrictionsForOperation
public ValidationResult validateGetRestrictionsForOperation(ContentId contentId, OperationKey opKey)
Description copied from interface:ContentRestrictionService.Validator
Validates whether OperationKey supplied is supported, whether content specified exists, whether currently logged in user can read restrictions on a content specified- Specified by:
validateGetRestrictionsForOperation
in interfaceContentRestrictionService.Validator
- Parameters:
contentId
- identifier of a content for which the check should be performedopKey
-OperationKey
which user tries to obtain restrictions for- Returns:
ValidationResult
whereValidationResult.isValid() == false
in case content is missing or unavailable orOperationKey
supplied is not supported.- See Also:
ContentRestrictionService.Validator.validateGetRestrictions(ContentId)
-
-