Class SimpleValidationResult
- java.lang.Object
-
- com.atlassian.confluence.api.model.validation.SimpleValidationResult
-
- All Implemented Interfaces:
ValidationResult
public class SimpleValidationResult extends Object implements ValidationResult
Represents the simplest kind of ValidationResult.- Since:
- 5.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleValidationResult.Builder
-
Field Summary
Fields Modifier and Type Field Description static ValidationResult
FORBIDDEN
A singleton unauthorized result.static ValidationResult
NOT_ALLOWED_IN_READ_ONLY_MODE
A singleton notAllowedInReadOnlyMode resultstatic ValidationResult
VALID
A singleton valid result.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SimpleValidationResult.Builder
builder()
ServiceException
convertToServiceException(String errorMsg)
Converts this validation result into aServiceException
without throwing.Collection<ValidationError>
getErrors()
Returns an iterable of the errors (if any) stored in this result.boolean
isAllowedInReadOnlyMode()
Checks for allowedInReadOnlyMode status.boolean
isAuthorized()
Checks for authorization status.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.atlassian.confluence.api.model.validation.ValidationResult
isNotSuccessful, isSuccessful, isValid, throwIfInvalid, throwIfInvalid, throwIfNotSuccessful, throwIfNotSuccessful, throwIfNotValid
-
-
-
-
Field Detail
-
VALID
public static final ValidationResult VALID
A singleton valid result.
-
FORBIDDEN
public static final ValidationResult FORBIDDEN
A singleton unauthorized result.
-
NOT_ALLOWED_IN_READ_ONLY_MODE
public static final ValidationResult NOT_ALLOWED_IN_READ_ONLY_MODE
A singleton notAllowedInReadOnlyMode result- Since:
- 6.8.0
-
-
Method Detail
-
isAuthorized
public boolean isAuthorized()
Description copied from interface:ValidationResult
Checks for authorization status. Does NOT imply thevalidity check
.- Specified by:
isAuthorized
in interfaceValidationResult
- Returns:
true
if the current user is permitted to perform the execution that the validation is for,false
otherwise.- See Also:
ValidationResult.isValid()
,ValidationResult.isSuccessful()
-
isAllowedInReadOnlyMode
public boolean isAllowedInReadOnlyMode()
Description copied from interface:ValidationResult
Checks for allowedInReadOnlyMode status. Does NOT imply thevalidity check
.- Specified by:
isAllowedInReadOnlyMode
in interfaceValidationResult
- Returns:
true
if the current user is allowed to perform the execution in read-only mode that the validation is for,false
otherwise.- See Also:
ValidationResult.isValid()
,ValidationResult.isSuccessful()
-
getErrors
public Collection<ValidationError> getErrors()
Description copied from interface:ValidationResult
Returns an iterable of the errors (if any) stored in this result. By contract having any errors here MUST also result inValidationResult.isValid()
returningfalse
.Default implementation of
ValidationResult.isValid()
is safe fornull
values. Be cautious about returningnull
if not using the default implementation forValidationResult.isValid()
.- Specified by:
getErrors
in interfaceValidationResult
- Returns:
- an iterable of the errors stored in this result.
- See Also:
ValidationResult.isValid()
,ValidationError
-
convertToServiceException
public ServiceException convertToServiceException(String errorMsg)
Description copied from interface:ValidationResult
Converts this validation result into aServiceException
without throwing. Implementations of this method should reasonably analyze the internals of this ValidationResult and return appropriate subclass ofServiceException
which is most suitable for the case.This method is used internally in the default implementations of
ValidationResult.throwIfNotSuccessful()
andValidationResult.throwIfNotSuccessful(String)
- Specified by:
convertToServiceException
in interfaceValidationResult
- Parameters:
errorMsg
- message to put in the Exception returned- Returns:
- instance of appropriate
ServiceException
subclass. - See Also:
ValidationResult.throwIfNotSuccessful()
,ValidationResult.throwIfNotSuccessful(String)
-
builder
public static SimpleValidationResult.Builder builder()
-
-