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 implicitFileUploadinstances used byserializeAll(Collection).getFileUploads(Component component) Returns the implicitFileUploadinstances used byserialize(Component).Serializes the provided component into aDataObjectinstance.serializeAll(Collection<? extends Component> components) Serializes the provided components intoDataObjectinstances.
-
Constructor Details
-
ComponentSerializer
public ComponentSerializer()
-
-
Method Details
-
serialize
Serializes the provided component into aDataObjectinstance.Some components that would implicitly upload a file, for instance
Thumbnail, will reference the file using a URI with this formatattachment://filename. Thefilenamerefers to aFileUploadprovided bygetFileUploads(Component), with a correspondingname.- Parameters:
component- The component to serialized intoDataObject- Returns:
- Serialized
DataObjectfor the provided component - Throws:
IllegalArgumentException- Ifnullis provided
-
serializeAll
Serializes the provided components intoDataObjectinstances.Some components that would implicitly upload a file, for instance
Thumbnail, will reference the file using a URI with this formatattachment://filename. Thefilenamerefers to aFileUploadprovided bygetFileUploads(Collection), with a correspondingname.- Parameters:
components- The components to serialized intoDataObjects- Returns:
ListofDataObject- Throws:
IllegalArgumentException- Ifnullis provided
-
getFileUploads
Returns the implicitFileUploadinstances used byserialize(Component).- Parameters:
component- The component to take theFileUploadsfrom- Returns:
- The implicit
FileUploadinstances for the provided component - Throws:
IllegalArgumentException- Ifnullis provided
-
getFileUploads
@Nonnull public List<FileUpload> getFileUploads(@Nonnull Collection<? extends Component> components) Returns the implicitFileUploadinstances used byserializeAll(Collection).- Parameters:
components- The components to take theFileUploadsfrom- Returns:
- The implicit
FileUploadinstances for the provided components - Throws:
IllegalArgumentException- Ifnullis provided
-