Package io.meeds.appcenter.service
Class MyApplicationsSettingsService
java.lang.Object
io.meeds.appcenter.service.MyApplicationsSettingsService
Settings of the Shortcuts portlet (AppCenterMyApplicationsPortlet): who may
change them, which preferences a settings write may store, and the header
title keyed on the portlet's CMS setting name.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe metadata type of social's categories, which social keeps privatestatic final StringThe tiles' color, empty for none: a transparent tile, with the skin's border color when outlined.static final Stringstatic final Stringstatic final StringThe icon size, in pixels.static final StringWhether the apps stay on one line, ignored by the COLUMN template.static final Stringstatic final StringLists the apps each viewer marked as favorite, the default.static final StringLists the apps chosen in the settings.static final Stringstatic final intstatic final intstatic final intMost categories a Shortcuts portlet lists the apps of (D6).static final intstatic final intstatic final Stringstatic final Stringstatic final StringLists the apps of the categories picked.static final StringLists the apps picked one by one, in applicationIds, the default.static final Stringstatic final StringReference a shared-layout window's setting records in place of a page: a window of a configured shared layout has no storage id, so no generated name to carry its kind.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringHow the apps are displayed: ROW, CARDS or COLUMN.static final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanEditLegacyHeaderTitle(String username) Whether a user may change a header title stored under a legacy numeric object id, the random applicationId the portlet used before the title was keyed on the setting name: administrators only.booleancanEditSettings(String settingName, String username) Whether a user may change the settings of a Shortcuts portlet window, header title included: the page-content right of the window's page, in the space owning that page's site, whatever space its setting recorded, the site edit right for a site-layout window, administrators only for a shared-layout window, whose context is the platform's whatever space its setting recorded, and for a window whose setting was recorded on a section-template draft page, whatever its name.voidcopyHeaderTitle(String sourceKey, String settingName) Copies the header title, every language, from one key to another when the latter holds none: from the legacy applicationId key to the setting name, or from the setting name a window gave up to the one it got.generateSectionTemplateDraftSettingName(String storageId, long templateId) Generates the setting name of a window of a section-template draft page: Untitled-STORAGEID-sdraft-TEMPLATEID-UUID, so that the applications of the template's earlier editing sessions, and those to delete with the template, are told by their owner's name.generateSettingName(String storageId, WindowKind windowKind) Generates the setting name of a window: Untitled-STORAGEID-UUID for a page window, with a site- or shared- marker before the UUID for a site-layout or a shared-layout window, so that its name tells which right and which context apply to it.static StringgetAlignment(String storedValue) Reads a stored alignment, horizontal or vertical: START, CENTER or END, START being the left in a left-to-right page and the top vertically.getApplicationIds(String storedValue) Reads stored application ids: the ordered ids, without duplicates, empty for a value that is not a list of at mostApplicationCenterService.MAX_LISTED_APPLICATIONSids.getCategoryIds(String storedValue) Reads stored category ids: the ordered ids, without duplicates, empty for a value that is not a list of at mostMAX_LISTED_CATEGORIESids.static StringReads a stored color: #RRGGBB or #RRGGBBAA.longgetContextSpaceId(String settingName, String pageReference) Decides the space a window's setting records: the space owning the site of the recorded page reference, for a page window as for a site-layout window, whose recorded page is on the site whose layout holds it, whatever site's navigation rendered the page; none for a shared-layout window, which a configured layout renders on every page of the sites it serves.static BooleangetDisplayFlag(String storedValue) Reads a stored display flag: showSeeMore, listInRow, showIcon, showName or outlined.static IntegergetIconSize(String storedValue) Reads a stored icon size.static StringgetListingMode(String storedValue) Reads a stored listing mode: FAVORITES or SELECTED, FAVORITES for any other value or none.getSectionTemplateDraftNamePattern(long templateId) getSectionTemplateDraftStorageId(String settingName, long templateId) longgetSectionTemplateId(String pageReference) static StringgetSelectionMode(String storedValue) Reads a stored selection mode: MANUAL or CATEGORY, MANUAL for any other value or none.io.meeds.social.cms.model.CMSSettinggetSetting(String settingName) getSettingPageReference(String settingName, String pageReference, org.exoplatform.portal.mop.SiteKey layoutSite) Decides the page reference a window's setting records and is compared with: for a site-layout window, the rendered page's name on the site whose layout holds the window, whatever page and site render it, so that its context, its right and the check of its name follow that site; the rendered page otherwise.Decides a settings write of a Shortcuts portlet window: refuses a user who may not edit the window's settings, before reading any parameter, then keeps only the preferences the portlet owns, each with a valid value.static StringgetTemplate(String storedValue) Reads a stored template: ROW, CARDS or COLUMN, null for any other value or none, which renders the legacy layout.getWritableSettings(String settingName, Map<String, String> parameters) Filters the parameters of a settings write down to the preferences the Shortcuts portlet owns, each with a valid value.booleanhasSetting(String settingName) booleanisContextDeleted(String settingName, String pageReference) Whether a window's context no longer exists: the page its setting records is on a space's group site, or on a space's public site, and that space is gone, or on a portal site that was removed.booleanisSectionTemplateDraftName(String settingName) booleankeepsSettingName(String settingName, String storageId, WindowKind windowKind, String pageReference, Supplier<Collection<String>> otherWindowNames) Whether a window keeps the setting name its preferences carry.
-
Field Details
-
SETTING_TYPE
- See Also:
-
HEADER_TITLE_FIELD
- See Also:
-
MAX_APPS_TO_LIST
- See Also:
-
SHOW_HEADER
- See Also:
-
LISTING_MODE
- See Also:
-
LISTING_MODE_FAVORITES
Lists the apps each viewer marked as favorite, the default.- See Also:
-
LISTING_MODE_SELECTED
Lists the apps chosen in the settings.- See Also:
-
SELECTION_MODE
- See Also:
-
SELECTION_MODE_MANUAL
Lists the apps picked one by one, in applicationIds, the default.- See Also:
-
SELECTION_MODE_CATEGORY
Lists the apps of the categories picked.- See Also:
-
APPLICATION_IDS
- See Also:
-
CATEGORY_IDS
- See Also:
-
TEMPLATE
How the apps are displayed: ROW, CARDS or COLUMN. A window with none renders the legacy layout (D3).- See Also:
-
TEMPLATE_ROW
- See Also:
-
TEMPLATE_CARDS
- See Also:
-
TEMPLATE_COLUMN
- See Also:
-
SHOW_SEE_MORE
- See Also:
-
LIST_IN_ROW
Whether the apps stay on one line, ignored by the COLUMN template.- See Also:
-
SHOW_ICON
- See Also:
-
ICON_SIZE
The icon size, in pixels.- See Also:
-
SHOW_NAME
- See Also:
-
COLOR
The tiles' color, empty for none: a transparent tile, with the skin's border color when outlined.- See Also:
-
OUTLINED
- See Also:
-
H_ALIGN
- See Also:
-
V_ALIGN
- See Also:
-
ALIGN_START
- See Also:
-
ALIGN_CENTER
- See Also:
-
ALIGN_END
- See Also:
-
MIN_ICON_SIZE
public static final int MIN_ICON_SIZE- See Also:
-
MAX_ICON_SIZE
public static final int MAX_ICON_SIZE- See Also:
-
MAX_LISTED_CATEGORIES
public static final int MAX_LISTED_CATEGORIESMost categories a Shortcuts portlet lists the apps of (D6).- See Also:
-
CATEGORY_METADATA_TYPE
The metadata type of social's categories, which social keeps private- See Also:
-
MIN_APPS_TO_LIST
public static final int MIN_APPS_TO_LIST- See Also:
-
MAX_APPS_TO_LIST_LIMIT
public static final int MAX_APPS_TO_LIST_LIMIT- See Also:
-
SHARED_LAYOUT_REFERENCE
Reference a shared-layout window's setting records in place of a page: a window of a configured shared layout has no storage id, so no generated name to carry its kind. It names no page.- See Also:
-
-
Constructor Details
-
MyApplicationsSettingsService
public MyApplicationsSettingsService()
-
-
Method Details
-
canEditSettings
Whether a user may change the settings of a Shortcuts portlet window, header title included: the page-content right of the window's page, in the space owning that page's site, whatever space its setting recorded, the site edit right for a site-layout window, administrators only for a shared-layout window, whose context is the platform's whatever space its setting recorded, and for a window whose setting was recorded on a section-template draft page, whatever its name. A shared-layout window is told by its generated name, or, for a window of a configured shared layout, which has no storage id, so no generated name, by theSHARED_LAYOUT_REFERENCEits setting records; such a window whose setting was recorded before keeps the right of the page that first rendered it.- Parameters:
settingName- the window's CMS setting nameusername- the user, null or anonymous for a guest- Returns:
- true when the user may write the window's settings
-
canEditLegacyHeaderTitle
Whether a user may change a header title stored under a legacy numeric object id, the random applicationId the portlet used before the title was keyed on the setting name: administrators only.- Parameters:
username- the user, null or anonymous for a guest- Returns:
- true when the user is an administrator
-
getSettingsToStore
public Map<String,String> getSettingsToStore(String settingName, String username, Map<String, String> parameters) throws IllegalAccessExceptionDecides a settings write of a Shortcuts portlet window: refuses a user who may not edit the window's settings, before reading any parameter, then keeps only the preferences the portlet owns, each with a valid value.- Parameters:
settingName- the window's CMS setting name, read from its stored preferences, never from the requestusername- the user, null or anonymous for a guestparameters- posted parameters- Returns:
- the preferences to store, by name
- Throws:
IllegalAccessException- when the user may not edit the settingsIllegalArgumentException- when the write selects the SELECTED listing mode with no application to list
-
getWritableSettings
Filters the parameters of a settings write down to the preferences the Shortcuts portlet owns, each with a valid value. Any other name, among which name, applicationId, data.init, canEdit and settingName, and any invalid value is dropped, and so is the id of an application that no longer exists or that another Shortcuts portlet window created, and of a category that no longer exists. The selection mode, the application ids and the category ids are stored only with a listing mode, both lists whatever the selection mode, so that switching modes keeps the other list. A write selecting the SELECTED listing mode is refused as a whole unless it selects the MANUAL mode with at least one application, or the CATEGORY mode with at least one category: a SELECTED listing is never stored empty.- Parameters:
settingName- the window's CMS setting nameparameters- posted parameters- Returns:
- the preferences to store, by name
- Throws:
IllegalArgumentException- when the write selects the SELECTED listing mode with nothing to list
-
getListingMode
Reads a stored listing mode: FAVORITES or SELECTED, FAVORITES for any other value or none.- Parameters:
storedValue- the listingMode preference- Returns:
- the listing mode to render
-
getSelectionMode
Reads a stored selection mode: MANUAL or CATEGORY, MANUAL for any other value or none.- Parameters:
storedValue- the selectionMode preference- Returns:
- the selection mode to render
-
getApplicationIds
Reads stored application ids: the ordered ids, without duplicates, empty for a value that is not a list of at mostApplicationCenterService.MAX_LISTED_APPLICATIONSids.- Parameters:
storedValue- the applicationIds preference, comma-separated- Returns:
- the ids to render, never null
-
getCategoryIds
Reads stored category ids: the ordered ids, without duplicates, empty for a value that is not a list of at mostMAX_LISTED_CATEGORIESids.- Parameters:
storedValue- the categoryIds preference, comma-separated- Returns:
- the ids to render, never null
-
getTemplate
Reads a stored template: ROW, CARDS or COLUMN, null for any other value or none, which renders the legacy layout.- Parameters:
storedValue- the template preference- Returns:
- the template to render, or null
-
getDisplayFlag
Reads a stored display flag: showSeeMore, listInRow, showIcon, showName or outlined.- Parameters:
storedValue- the preference- Returns:
- true or false, null for any other value or none, which the template's default replaces
-
getIconSize
Reads a stored icon size.- Parameters:
storedValue- the iconSize preference- Returns:
- the size, from
MIN_ICON_SIZEtoMAX_ICON_SIZE, null for any other value or none, which the template's default replaces
-
getColor
Reads a stored color: #RRGGBB or #RRGGBBAA.- Parameters:
storedValue- the color preference- Returns:
- the color, empty for any other value or none: no color
-
getAlignment
Reads a stored alignment, horizontal or vertical: START, CENTER or END, START being the left in a left-to-right page and the top vertically.- Parameters:
storedValue- the hAlign or vAlign preference- Returns:
- the alignment, null for any other value or none, which the template's default replaces
-
copyHeaderTitle
Copies the header title, every language, from one key to another when the latter holds none: from the legacy applicationId key to the setting name, or from the setting name a window gave up to the one it got. Reads and writes go through the ACL-free translation API: the copy runs at render, for any viewer.- Parameters:
sourceKey- the key the header title is stored undersettingName- the window's CMS setting name
-
generateSettingName
Generates the setting name of a window: Untitled-STORAGEID-UUID for a page window, with a site- or shared- marker before the UUID for a site-layout or a shared-layout window, so that its name tells which right and which context apply to it.- Parameters:
storageId- the window's storage idwindowKind- where the window is placed- Returns:
- a new setting name
-
generateSectionTemplateDraftSettingName
Generates the setting name of a window of a section-template draft page: Untitled-STORAGEID-sdraft-TEMPLATEID-UUID, so that the applications of the template's earlier editing sessions, and those to delete with the template, are told by their owner's name.- Parameters:
storageId- the window's storage idtemplateId- the section template id- Returns:
- a new setting name
-
getSectionTemplateId
- Parameters:
pageReference- a page reference- Returns:
- the id of the section template whose draft page the reference names, section_draft_TEMPLATE_USER in the global site, 0 for any other page
-
isSectionTemplateDraftName
- Parameters:
settingName- a Shortcuts portlet window's CMS setting name- Returns:
- true when the name was generated for a window of a section-template draft page
-
getSectionTemplateDraftStorageId
- Parameters:
settingName- a Shortcuts portlet window's CMS setting nametemplateId- a section template id- Returns:
- the storage id of the window of that template's draft page the name was generated for, null for any other name
-
getSectionTemplateDraftNamePattern
- Parameters:
templateId- a section template id- Returns:
- a LIKE pattern matching at least the setting names generated for
the windows of that template's draft pages, to check one by one
with
getSectionTemplateDraftStorageId(String, long)
-
getContextSpaceId
Decides the space a window's setting records: the space owning the site of the recorded page reference, for a page window as for a site-layout window, whose recorded page is on the site whose layout holds it, whatever site's navigation rendered the page; none for a shared-layout window, which a configured layout renders on every page of the sites it serves.- Parameters:
settingName- the window's CMS setting namepageReference- the page reference the window's setting records, seegetSettingPageReference(String, String, SiteKey)- Returns:
- the space id to record, 0 for the platform context
-
isContextDeleted
Whether a window's context no longer exists: the page its setting records is on a space's group site, or on a space's public site, and that space is gone, or on a portal site that was removed. A space's public site is removed with its space, after which nothing tells it from another removed site. A shared-layout window's context is the platform's.- Parameters:
settingName- the window's CMS setting namepageReference- the page reference the window's setting records- Returns:
- true when the window's space or portal site was deleted
-
getSettingPageReference
public String getSettingPageReference(String settingName, String pageReference, org.exoplatform.portal.mop.SiteKey layoutSite) Decides the page reference a window's setting records and is compared with: for a site-layout window, the rendered page's name on the site whose layout holds the window, whatever page and site render it, so that its context, its right and the check of its name follow that site; the rendered page otherwise. A site renders the pages of other sites, and a displayed site renders the meta portal's layout.- Parameters:
settingName- the window's CMS setting namepageReference- the page the window is rendered onlayoutSite- the site whose layout holds a site-layout window- Returns:
- the page reference to record and compare
-
keepsSettingName
public boolean keepsSettingName(String settingName, String storageId, WindowKind windowKind, String pageReference, Supplier<Collection<String>> otherWindowNames) Whether a window keeps the setting name its preferences carry. A layout copy carries the preferences of its source, the setting name included, and a page editor may rewrite it: such a window would act in the context of another window's setting. It keeps its name when the name was generated for it: its storage id and the marker of its kind of window. Otherwise, a page window keeps an unmarked name recorded on this page that no other window of the page carries, as after a same-page publish, and a site-layout window keeps a site-marked name recorded on this site that no other window of the site carries, whatever space their setting recorded, since the space is read from the recorded page (getContextSpaceId(String, String)). Every other name is given up, a shared-layout window's and a section-template draft window's included. The decision on a name generated for another storage id is memoised per window.- Parameters:
settingName- the name the window's preferences carry, not blankstorageId- the window's storage id, not blankwindowKind- where the window is placedpageReference- the page reference the window's setting records, seegetSettingPageReference(String, String, SiteKey)otherWindowNames- reads the setting names of the other windows of the page, or of the site for a site-layout window- Returns:
- true when the window keeps its setting name
-
hasSetting
- Parameters:
settingName- a Shortcuts portlet window's CMS setting name- Returns:
- true when the window's setting exists
-
getSetting
- Parameters:
settingName- a Shortcuts portlet window's CMS setting name- Returns:
- the window's setting, recorded server-side when the window was first rendered, null when it does not exist
-