Class LayoutImageService
java.lang.Object
io.meeds.layout.service.LayoutImageService
The images a layout write consumes, as the editor's background inputs save
them: each upload id of the call is resolved while the description is
applied and before any write, then saved as an attachment of its background
keyed on the live page or site, as the user, through the attachment
service's edit check; the attachment URL replaces the placeholder in the
layout before the draft is written; the upload resources are released
whether the write succeeds or fails, and the attachments created are
deleted when the write that follows them fails.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattach(ImageConsumption images, String username) Saves each claimed image as an attachment of its target, as the user, and records its URL on the consumptionvoidcompensate(ImageConsumption images) Deletes the attachments the call created, when the layout write that followed them failedconsumption(String keyPrefix, String username) booleanisConsumable(String uploadId, String username) voidrelease(ImageConsumption images) Releases every upload resource the call claimed: a consumed one is already gone, an unconsumed one goes with the failed callvoidsubstitute(LayoutModel root, ImageConsumption images) Replaces every placeholder of the layout tree with the URL of the attachment saved for it
-
Field Details
-
IMAGE_NOT_SAVED
- See Also:
-
ATTACHMENT_URL
- See Also:
-
IMAGE_TYPES
-
-
Constructor Details
-
LayoutImageService
public LayoutImageService()
-
-
Method Details
-
consumption
- Parameters:
keyPrefix- the live page's or site's storage id, page_<id> or site_<id>, the first segment of every attachment key the call createsusername- the user consuming the ids- Returns:
- the consumption the call's writers claim their upload ids on: a staged resource the user may consume, owner-less or their own, and of an image type the upload tool stages
-
isConsumable
-
attach
public void attach(ImageConsumption images, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Saves each claimed image as an attachment of its target, as the user, and records its URL on the consumption- Parameters:
images- the call's consumptionusername- the user writing the layout- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when a target no longer existsIllegalAccessException- when the user may not edit a target
-
substitute
Replaces every placeholder of the layout tree with the URL of the attachment saved for it- Parameters:
root- the layout to writeimages- the call's consumption, its attachments saved
-
compensate
Deletes the attachments the call created, when the layout write that followed them failed- Parameters:
images- the call's consumption
-
release
Releases every upload resource the call claimed: a consumed one is already gone, an unconsumed one goes with the failed call- Parameters:
images- the call's consumption
-