Class ComponentSerializer
Components
into DataObject
.
Since some components include implicit file uploads, such as FileDisplay
and Thumbnail
,
the included FileUpload
instances can be accessed using getFileUploads(Collection)
.
Each uploaded file is referenced in the respective components using attachment://filename
.
This separation is done to simplify persistence of these components in preferred formats. For instance, you might want to store the components as JSON Blobs but the files in an object storage.
You can use ComponentDeserializer
to deserialize the output again,
make sure you also provide any implicit FileUpload
instances.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetFileUploads
(Collection<? extends Component> components) Returns the implicitFileUpload
instances used byserializeAll(Collection)
.serializeAll
(Collection<? extends Component> components) Serializes the provided components intoDataObject
instances.
-
Constructor Details
-
ComponentSerializer
public ComponentSerializer()
-
-
Method Details
-
serializeAll
Serializes the provided components intoDataObject
instances.Some components that would implicitly upload a file, for instance
Thumbnail
, will reference the file using a URI with this formatattachment://filename
. Thefilename
refers to aFileUpload
provided bygetFileUploads(Collection)
, with a correspondingname
.- Parameters:
components
- The components to serialized intoDataObjects
- Returns:
List
ofDataObject
- Throws:
IllegalArgumentException
- Ifnull
is provided
-
getFileUploads
@Nonnull public List<FileUpload> getFileUploads(@Nonnull Collection<? extends Component> components) Returns the implicitFileUpload
instances used byserializeAll(Collection)
.- Parameters:
components
- The components to take theFileUploads
from- Returns:
- The implicit
FileUpload
instances for the provided components - Throws:
IllegalArgumentException
- Ifnull
is provided
-