Class ApplicationSettingsService
java.lang.Object
io.meeds.layout.service.ApplicationSettingsService
The registry of the application settings plugins and the rules every
configuration of placed applications follows: an application without a
plugin is not configurable, every application is validated before the
first one is applied, each one is applied through its plugin while its
window is locked on this node, and a failure after the first apply names
the applications already applied, nothing being undone.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPlugin(ApplicationSettingsPlugin plugin) Registers a plugin, replacing the one registered for the same portletvoidapply(List<ApplicationSettingsContext> contexts, List<Map<String, Object>> settings, List<String> requestedIds) Applies validated settings application after application, each window locked on this node while its plugin writes.org.exoplatform.portal.config.model.ApplicationdropNullEntries(Map<String, Object> settings) getSettingsSchema(String contentId) getSiteHomePageReference(org.exoplatform.portal.mop.SiteKey siteKey) The page a setting of a site-container window hangs on: the page of the first navigation item of the site, in tree order, that references a page and is displayed, or scheduled and within its publication window, whatever that page's own access permissions.booleanisConfigurable(String contentId, boolean siteContainer) booleanisOwner(ApplicationSettingsContext context) voidmarkOwner(ApplicationSettingsContext context, Map<String, String> keys) Stores the keys a plugin created for the window with the ownership marker naming the window, every other preference keptnewContext(org.exoplatform.portal.config.model.Application window, org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, org.exoplatform.portal.mop.SiteKey liveSiteKey, String pageReference, boolean draft, String username) readSettings(ApplicationSettingsContext context) voidremovePlugin(String portletName) <T> TrunLocked(String layoutKey, long applicationId, LayoutWrite<T> write) Runs a write on one window under the node-local lock every tool write on that window takes (a settings write, a widget code write): a lock not obtained within the timeout refuses the write with LAYOUT_BUSY and writes nothingvoidupdatePreferences(ApplicationSettingsContext context, Map<String, String> preferences) Sets the given preferences of the window, every other preference kept, through the page or the site writer, which check the user's edit right on the layout holding the windowvoidvalidate(List<ApplicationSettingsContext> contexts, List<Map<String, Object>> settings, List<String> requestedIds) Checks every application before anything is written: a plugin configures it where it sits, and its plugin accepts the settings for the context's user
-
Field Details
-
OWNER_PREFERENCE
- See Also:
-
APPLICATION_NOT_FOUND
- See Also:
-
APPLICATION_NOT_ALLOWED
- See Also:
-
NOT_CONFIGURABLE
- See Also:
-
NOT_CONFIGURABLE_IN_SITE_CONTAINER
- See Also:
-
APPLICATION_NOT_SAVED
- See Also:
-
LAYOUT_BUSY
- See Also:
-
APPLIED_BEFORE_FAILURE
- See Also:
-
VALUE_NOT_ACCEPTED
- See Also:
-
-
Constructor Details
-
ApplicationSettingsService
public ApplicationSettingsService()
-
-
Method Details
-
addPlugin
Registers a plugin, replacing the one registered for the same portlet -
removePlugin
-
isConfigurable
- Parameters:
contentId- the application content id, app/portletsiteContainer- whether the window sits in a site container- Returns:
- whether a plugin configures the application there
-
getSettingsSchema
-
newContext
public ApplicationSettingsContext newContext(org.exoplatform.portal.config.model.Application window, org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, org.exoplatform.portal.mop.SiteKey liveSiteKey, String pageReference, boolean draft, String username) - Parameters:
window- a window of the stored treepageKey- the page holding it, null in a site containersiteKey- the site holding itliveSiteKey- the live site, whose space the setting belongs topageReference- the live page reference: the page's for a page window, the live site's home page for a site-container window, which the caller reads once per site (getSiteHomePageReference(SiteKey)), null while that site has nonedraft- whether the window is the user's draftusername- the acting user- Returns:
- the plugins' context of the window
-
getSiteHomePageReference
The page a setting of a site-container window hangs on: the page of the first navigation item of the site, in tree order, that references a page and is displayed, or scheduled and within its publication window, whatever that page's own access permissions. Its editors may change the window's setting, and whoever may access that page may read the setting, so a first page restricted to a group keeps the setting from the site's other viewers, as a window the site layout editor placed takes the right of the page the site first rendered it on.- Parameters:
siteKey- the live site- Returns:
- the page reference, null while no such item of the site references a page
-
readSettings
- Returns:
- the settings of a configurable window as its plugin reads them for the context's user, null when it has none, when the user may not read them or when the plugin fails
-
validate
public void validate(List<ApplicationSettingsContext> contexts, List<Map<String, Object>> settings, List<String> requestedIds) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundExceptionChecks every application before anything is written: a plugin configures it where it sits, and its plugin accepts the settings for the context's user- Parameters:
contexts- the windows, in the order of the callsettings- their settings, null-valued entries already droppedrequestedIds- the ids the call named, for the refusals- Throws:
IllegalAccessException- when an application's own rule refuses the userorg.exoplatform.commons.exception.ObjectNotFoundException- when a referenced object does not existIllegalArgumentException- when no plugin configures an application where it sits, when a list holds a null item, or when a plugin refuses a value, with its fixed textIllegalStateException- when a plugin answers a fixed state refusal, or fails without a fixed text, answered as the application not saved
-
apply
public void apply(List<ApplicationSettingsContext> contexts, List<Map<String, Object>> settings, List<String> requestedIds) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundExceptionApplies validated settings application after application, each window locked on this node while its plugin writes. A failure of the first application is answered as is; a later one names the applications already applied, which stay applied.- Parameters:
contexts- the windows, asvalidate(List, List, List)checked them, possibly re-pointed at the draft's copiessettings- their validated settingsrequestedIds- the ids the call named- Throws:
IllegalAccessException- when the first application is refusedorg.exoplatform.commons.exception.ObjectNotFoundException- when the first application's object disappeared
-
isOwner
- Returns:
- whether the window carries the ownership marker naming itself: the keys it carries were created for it on this layout version
-
markOwner
public void markOwner(ApplicationSettingsContext context, Map<String, String> keys) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundExceptionStores the keys a plugin created for the window with the ownership marker naming the window, every other preference kept- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
updatePreferences
public void updatePreferences(ApplicationSettingsContext context, Map<String, String> preferences) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundExceptionSets the given preferences of the window, every other preference kept, through the page or the site writer, which check the user's edit right on the layout holding the window- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
dropNullEntries
-
pathOf
-
atPath
-
runLocked
public <T> T runLocked(String layoutKey, long applicationId, LayoutWrite<T> write) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Runs a write on one window under the node-local lock every tool write on that window takes (a settings write, a widget code write): a lock not obtained within the timeout refuses the write with LAYOUT_BUSY and writes nothing- Type Parameters:
T- what the write returns- Parameters:
layoutKey- the page reference or the site key the window belongs toapplicationId- the window's storage idwrite- the write- Returns:
- what the write returns
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- from the writeIllegalAccessException- from the write
-