Interface ContentBodyConversionService
-
- All Known Implementing Classes:
ContentBodyConversionServiceImpl
@ExperimentalApi public interface ContentBodyConversionService
Provides methods for convertingContentBody
instances to otherContentRepresentation
s. Converting a ContentBody to the same ContentRepresentation will perform a validation/sanitisation of the body.When creating or updating content, the incoming ContentBody will be converted to
ContentRepresentation.STORAGE
format. Note that currently, the only officially supported STORAGE conversions are fromContentRepresentation.STORAGE
(checked for validity) and fromContentRepresentation.EDITOR
.- Since:
- 5.5
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description ContentBody
convert(ContentBody body, ContentRepresentation representation)
Same as callingconvert(ContentBody, ContentRepresentation, Expansion...)
with an empty expansion.ContentBody
convert(ContentBody body, ContentRepresentation representation, Expansion... expansions)
Convert a ContentBody value into another format, performing validation during the conversion.ContentBody
convertBody(Content content, ContentRepresentation representation)
Same as callingconvertBody(Content, ContentRepresentation, Expansion...)
with an empty expansion.ContentBody
convertBody(Content content, ContentRepresentation representation, Expansion... expansions)
Convert the single ContentBody value in aContent
body map into another format, performing validation during the conversion.com.atlassian.fugue.Option<ContentBody>
getBodyToConvert(Content content, ContentRepresentation toFormat)
Deprecated.since 6.13.0, use {selectBodyForRepresentation(Content, ContentRepresentation)
}default Optional<ContentBody>
selectBodyForRepresentation(Content content, ContentRepresentation toFormat)
Given aContent
object for which the body could be converted to a givenContentRepresentation
, returns theContentBody
that would be used for the conversion.
-
-
-
Method Detail
-
convertBody
ContentBody convertBody(Content content, ContentRepresentation representation, Expansion... expansions) throws ServiceException
Convert the single ContentBody value in aContent
body map into another format, performing validation during the conversion.This is a wrapper method for
convert(ContentBody, ContentRepresentation, Expansion... expansions)
that assumes a single entry in the Body map to save the calling code having to manually extract it.- Parameters:
content
- the content to convert the ContentBody of, if this specifies a contentId then the persisted content will be used to generated the conversionContext.representation
- theContentRepresentation
to convert toexpansions
- determins the expansion done on the conversion. This expansion must match the expansions available toContentBody
. An example expansion string would be'webresource'
.- Returns:
- the converted body
- Throws:
BadRequestException
- if any validation errors are found during the conversionNotFoundException
- if content specifies a contentId that does not existServiceException
-
convertBody
ContentBody convertBody(Content content, ContentRepresentation representation) throws ServiceException
Same as callingconvertBody(Content, ContentRepresentation, Expansion...)
with an empty expansion.- Parameters:
content
- the content to convert the ContentBody of, if this specifies a contentId then the persisted content will be used to generated the conversionContext.representation
- theContentRepresentation
to convert to- Returns:
- the converted body
- Throws:
BadRequestException
- if any validation errors are found during the conversionNotFoundException
- if content specifies a contentId that does not existServiceException
-
convert
ContentBody convert(ContentBody body, ContentRepresentation representation, Expansion... expansions) throws ServiceException
Convert a ContentBody value into another format, performing validation during the conversion.- Parameters:
body
- the content to convertrepresentation
- theContentRepresentation
to convert toexpansions
- determins the expansion done on the conversion. This expansion must match the expansions available toContentBody
. An example expansion string would be'webresource'
.- Returns:
- the converted body
- Throws:
BadRequestException
- if any validation errors are found during the conversionNotFoundException
- if the contentBody specifies a contentId that does not existServiceException
-
convert
ContentBody convert(ContentBody body, ContentRepresentation representation) throws ServiceException
Same as callingconvert(ContentBody, ContentRepresentation, Expansion...)
with an empty expansion.- Parameters:
body
- the content to convertrepresentation
- theContentRepresentation
to convert to- Returns:
- the converted body
- Throws:
BadRequestException
- if any validation errors are found during the conversionNotFoundException
- if the contentBody specifies a contentId that does not existServiceException
-
getBodyToConvert
@Deprecated com.atlassian.fugue.Option<ContentBody> getBodyToConvert(Content content, ContentRepresentation toFormat)
Deprecated.since 6.13.0, use {selectBodyForRepresentation(Content, ContentRepresentation)
}Given aContent
object for which the body could be converted to a givenContentRepresentation
, returns theContentBody
that would be used for the conversion.If the supplied Content contains no ContentBody objects, or if none of those ContentBodies are suitable for conversion into the ContentRepresentation, an Option.none() result will be returned.
- Parameters:
content
- content to convert the body oftoFormat
- the representation that will be converted to- Returns:
- an Option with either the ContentBody that will be used in the conversion, or nothing
-
selectBodyForRepresentation
default Optional<ContentBody> selectBodyForRepresentation(Content content, ContentRepresentation toFormat)
Given aContent
object for which the body could be converted to a givenContentRepresentation
, returns theContentBody
that would be used for the conversion.If the supplied Content contains no ContentBody objects, or if none of those ContentBodies are suitable for conversion into the ContentRepresentation, an Option.none() result will be returned.
- Parameters:
content
- content to convert the body oftoFormat
- the representation that will be converted to- Returns:
- an Optional with either the ContentBody that will be used in the conversion, or nothing
- Since:
- 6.13.0
-
-