Package io.meeds.appcenter.service
Class MyApplicationsCopyService
java.lang.Object
io.meeds.appcenter.service.MyApplicationsCopyService
Copies of a Shortcuts portlet window (AppCenterMyApplicationsPortlet): a
section duplicated, a page saved as a template, a site or space created
from a template, a template exported. The copy step carries the
applications the window created and its header title by value, in the
copy's data.init preference, since it knows nothing of where the copy
lands; the first render of the copy that finds them creates its own
applications from them, in its own context. The window's preferences are
read and written as committed (
PortletWindowStorage), and a
consumption is claimed on this node, so that two first renders of a copy
on one node name it once and consume it once.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconsumeCopy(String settingName, String payload, String applicationIds) Consumes what a copy of a Shortcuts portlet window carries, at its first render: creates, owned by the copy, one application per application it carries that its list names, with no right checked and every field validated again, and gives the copy the header title it carries when it has none.consumeWindowCopy(String storageId, String settingName) Consumes what a copy of a window carries, when it is rendered under the name it holds as committed and still carries it: seeconsumeCopy(String, String, String).getCopyPreferences(Map<String, String> preferences, boolean draft, String username) Computes the preferences of a copy of a Shortcuts portlet window: every preference but its setting name, the legacy header key and data.init, plus data.init carrying, by value, its header title and the applications it created that it lists, active, with an audience: one whose audience an administrator emptied is never copied, whoever makes the copy.getOrStoreSettingName(String storageId, Supplier<String> nameGenerator) Names a window rendered with no name, a new window or a copy: the name it holds as committed, which another render stored meanwhile, or else a new one, stored.voidsaveWindowPreference(String storageId, String name, String value) Writes a preference of a window over its committed preferences, never over a render's earlier view of them.
-
Field Details
-
NAME_PREFERENCE
The window's CMS setting name, which a copy never carries.- See Also:
-
APPLICATION_ID_PREFERENCE
The legacy key of the header title, which a copy never carries.- See Also:
-
DATA_INIT_PREFERENCE
What a copy carries until its first render consumes it.- See Also:
-
-
Constructor Details
-
MyApplicationsCopyService
public MyApplicationsCopyService()
-
-
Method Details
-
getCopyPreferences
public Map<String,String> getCopyPreferences(Map<String, String> preferences, boolean draft, String username) Computes the preferences of a copy of a Shortcuts portlet window: every preference but its setting name, the legacy header key and data.init, plus data.init carrying, by value, its header title and the applications it created that it lists, active, with an audience: one whose audience an administrator emptied is never copied, whoever makes the copy. When a user copies the window, they are those the window's settings drawer lists to that user: those the user may access, and for a user who may edit the window's settings, those the window manages whatever their audience. A data.init the window did not consume yet is carried as it is, whatever its setting name. A draft of the window, which the editor publishes back over it, keeps its preferences unchanged.- Parameters:
preferences- the window's preferences, null when it has nonedraft- whether the preferences are those of a draft of the same windowusername- the user the copy is made for, null when no user does it, which carries every application with an audience- Returns:
- the copy's preferences, by name
-
consumeCopy
Consumes what a copy of a Shortcuts portlet window carries, at its first render: creates, owned by the copy, one application per application it carries that its list names, with no right checked and every field validated again, and gives the copy the header title it carries when it has none. A carried application whose fields are refused is not created.- Parameters:
settingName- the copy's CMS setting namepayload- the copy's data.init preferenceapplicationIds- the copy's applicationIds preference, which still names the source window's applications- Returns:
- the copy's applicationIds: a copied application replaced by the one created, an Application Center application and one the copy owns kept, any other dropped
-
getOrStoreSettingName
Names a window rendered with no name, a new window or a copy: the name it holds as committed, which another render stored meanwhile, or else a new one, stored. Two first renders of a copy then initialize it under one name.- Parameters:
storageId- the window's storage idnameGenerator- generates a new name for the window- Returns:
- the window's name
-
saveWindowPreference
Writes a preference of a window over its committed preferences, never over a render's earlier view of them.- Parameters:
storageId- the window's storage idname- the preference namevalue- the preference value
-
consumeWindowCopy
Consumes what a copy of a window carries, when it is rendered under the name it holds as committed and still carries it: seeconsumeCopy(String, String, String). The applications are created by the render; then one short task on the window (PortletWindowStorage.callOnWindow(java.lang.String, java.util.function.Function<io.meeds.appcenter.storage.PortletWindow, T>, java.lang.Runnable)) reads it again and, when it still holds that name and that payload, writes its list and blanks its data.init. Otherwise, or when that task fails, the render deletes them; when the render stops waiting, the task's outcome is unknown and they are kept. A render meeting a consumption of the same window by this node consumes nothing: the claim lasts until that task ended, whether its render still waits or not. A render whose view carries a payload already consumed read the window from a stale cache entry, which is emptied.- Parameters:
storageId- the window's storage idsettingName- the name the window is rendered under- Returns:
- the window's preferences as committed once consumed, null when a consumption of the window by this node is running
- Throws:
WindowPreferencesTimeoutException- when the render stops waiting, the write still running
-