Class WidgetService
java.lang.Object
io.meeds.ide.service.WidgetService
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringMarker of an unpublished copy: set at the copy, removed at publication onlystatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe live page reference or site key the draft belongs tostatic final StringThe storage id of the draft window the copy was made forstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateWidget(Widget widget, String username) voiddeleteWidget(long widgetId, String username) getWidget(long id) The widget as a reader may see it: an unpublished copy is readable by the editors of the layout it belongs to only, so that its id is never confirmed to anyone else; any other widget is readable as todaygetWidgetByPortletId(long portletInstanceId) booleanisDraftCopy(Widget widget) static StringlayoutKey(org.exoplatform.portal.mop.SiteKey siteKey) voidpublishDraftCopies(String layoutKey, org.exoplatform.portal.config.model.ModelObject publishedLayout, String publisher) Marks published every unpublished copy a window of the published layout references and whose owner layout is that layout; the ownership markers stay, since ownership keeps deciding copy against in-place on the next draft.io.meeds.layout.model.ApplicationCodereadWidgetCodeOnApplication(io.meeds.layout.model.ApplicationSettingsContext context) The code a window renders, as the layout reads describe it: the code a never-rendered window carries in its data.init preference (an empty code, three null parts, when it is blank or holds no code, as the render builds an empty widget from it), else the widget its widgetId names, else the catalog instance's widget (also for a widgetId naming a deleted widget), else noneupdateWidget(Widget widget, String username) updateWidgetCodeOnApplication(io.meeds.layout.model.ApplicationSettingsContext context, String liveLayoutKey, String html, String css, String js, String username) Writes a window's widget code on the user's draft, by ownership: in place when the window's widget is a copy this window owns on this layout, otherwise into a copy the window is pointed at, so that the published layout keeps rendering the previous code until publication.
-
Field Details
-
IDE_WIDGET_CREATED_EVENT
- See Also:
-
IDE_WIDGET_UPDATED_EVENT
- See Also:
-
NOT_ADMINISTRATOR_USER
- See Also:
-
WIDGET_PORTLET_NAME
- See Also:
-
WIDGET_ID_PREFERENCE
- See Also:
-
PORTLET_INSTANCE_ID_PREFERENCE
- See Also:
-
DATA_INIT_PREFERENCE
- See Also:
-
DRAFT_COPY_PROPERTY
Marker of an unpublished copy: set at the copy, removed at publication only- See Also:
-
OWNER_WINDOW_PROPERTY
The storage id of the draft window the copy was made for- See Also:
-
OWNER_LAYOUT_PROPERTY
The live page reference or site key the draft belongs to- See Also:
-
WIDGET_CODE_NOT_SAVED
- See Also:
-
LAYOUT_BUSY
- See Also:
-
UNPUBLISHED_COPY
- See Also:
-
-
Constructor Details
-
WidgetService
public WidgetService()
-
-
Method Details
-
getWidget
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException
-
getWidget
public Widget getWidget(long id, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException The widget as a reader may see it: an unpublished copy is readable by the editors of the layout it belongs to only, so that its id is never confirmed to anyone else; any other widget is readable as today- Parameters:
id- the widget idusername- the reader, null when anonymous- Returns:
- the widget
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when no widget has that idIllegalAccessException- when the widget is an unpublished copy the reader may not edit the layout of
-
isDraftCopy
- Parameters:
widget- a widget- Returns:
- whether it is a copy made for a draft window and not published yet
-
readWidgetCodeOnApplication
public io.meeds.layout.model.ApplicationCode readWidgetCodeOnApplication(io.meeds.layout.model.ApplicationSettingsContext context) The code a window renders, as the layout reads describe it: the code a never-rendered window carries in its data.init preference (an empty code, three null parts, when it is blank or holds no code, as the render builds an empty widget from it), else the widget its widgetId names, else the catalog instance's widget (also for a widgetId naming a deleted widget), else none- Parameters:
context- the window- Returns:
- the code; null when the window has none: no data.init, and no widgetId naming a widget and no catalog instance widget, or a widgetId naming an unpublished copy the user may not read, which stops the read with no fallback
-
updateWidgetCodeOnApplication
public Widget updateWidgetCodeOnApplication(io.meeds.layout.model.ApplicationSettingsContext context, String liveLayoutKey, String html, String css, String js, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Writes a window's widget code on the user's draft, by ownership: in place when the window's widget is a copy this window owns on this layout, otherwise into a copy the window is pointed at, so that the published layout keeps rendering the previous code until publication. The copy is created with its code, then the window's widgetId preference is set to it and its data.init cleared in one preference write; a failure of that write deletes the copy, which nothing references. Runs under the per-window lock the settings writes take.- Parameters:
context- the window on the user's draft, its preferences loadedliveLayoutKey- the live page reference or site key the draft belongs tohtml- the HTML to write, null to keep the current onecss- the CSS to write, null to keep the current onejs- the JavaScript to write, null to keep the current oneusername- the administrator writing- Returns:
- the widget the window now renders
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the window no longer existsIllegalAccessException- when the user is not an administrator or may not edit the layout
-
publishDraftCopies
public void publishDraftCopies(String layoutKey, org.exoplatform.portal.config.model.ModelObject publishedLayout, String publisher) Marks published every unpublished copy a window of the published layout references and whose owner layout is that layout; the ownership markers stay, since ownership keeps deciding copy against in-place on the next draft. Only the copies the publishing user wrote are marked published: a draft is its author's, so a copy reaches the live page through its author's publish, and a copy another editor's draft references (a forged widgetId preference) stays unpublished, readable by the layout's editors only. Called by the publication listener alone.- Parameters:
layoutKey- the live page reference or site key just publishedpublishedLayout- the published layout's tree, read back after the savepublisher- the user who published
-
layoutKey
- Parameters:
siteKey- a site key- Returns:
- the key a copy's owner layout records for a site, the form the publication listener and the REST gating rebuild
-
getWidgetByPortletId
-
createWidget
public Widget createWidget(Widget widget, String username) throws org.exoplatform.commons.ObjectAlreadyExistsException, IllegalAccessException - Throws:
org.exoplatform.commons.ObjectAlreadyExistsExceptionIllegalAccessException
-
updateWidget
public Widget updateWidget(Widget widget, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException - Throws:
org.exoplatform.commons.exception.ObjectNotFoundExceptionIllegalAccessException
-
deleteWidget
public void deleteWidget(long widgetId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException - Throws:
org.exoplatform.commons.exception.ObjectNotFoundExceptionIllegalAccessException
-