Package io.meeds.appcenter.service
Class ApplicationCenterService
java.lang.Object
io.meeds.appcenter.service.ApplicationCenterService
A Service to access and store applications
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final org.exoplatform.commons.api.settings.data.Contextstatic final org.exoplatform.commons.api.settings.data.Scopestatic final StringSettingService key under which the whole app-center configuration is stored, serialized as a single JSON blob (seeApplicationCenterSettings).static final StringPrefix of the codes naming a field:<prefix><field>TooLongstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intLargest illustration of an application created from a Shortcuts portlet, in bytes.static final intMost applications a Shortcuts portlet lists in its SELECTED mode (D6).static final intMost suggestions returned by one call of the Shortcuts app suggester.static final Stringstatic final Stringstatic final Stringstatic final StringThe bundle of the titles the portlets show system applications with.static final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFavoriteApplication(long applicationId, String username) Add an application, identified by its technical id, as favorite of a userbooleancanAccess(Application application, String username) Whether a user may see an application.booleanbooleancanEditContextApplication(Application application, String username) Whether a user may edit an application from the settings of a Shortcuts portlet window: an administrator any application, whoever manages the applications of the window that created one that application only.voidClears the applications listed per category, after a change of a category or of a category link.createApplication(Application application) Create new Application that will be available for all users.createApplication(Application application, String username) Create new Application that will be available for all users.createContextApplication(ApplicationForm application, String settingName, String username) Creates an application from the settings of a Shortcuts portlet window, owned by that window: listed there only, never in the users' Application Center.createCopiedContextApplication(ApplicationForm application, byte[] illustration, String settingName) Creates, in the context of a copy of a Shortcuts portlet window, the copy of an application the source window created, when the copy is first rendered: owned by the copy, with the audience of the context the copy's setting recorded.createPersonalApplication(Application application, String username) Creates a personal URL application for the given user.voiddeleteApplication(Long applicationId) voiddeleteApplication(Long applicationId, String username) Delete application identified by its id and check if username has permission to delete it.voiddeleteContextApplication(long applicationId, String settingName, String username) Deletes an application created from the settings of a Shortcuts portlet window, from that window's settings.voiddeleteFavoriteApplication(Long applicationId, String username) Deletes an application identified by its id from favorite applications of uservoiddeletePersonalApplication(Long applicationId, String username) Deletes a personal URL application.voiddeleteSectionTemplateApplications(long templateId) Deletes the applications the windows of a section template's drafts created, every administrator's, once the template is deleted.voiddeleteSectionTemplateDraftLeftovers(String settingName, String draftPageReference, Collection<String> windowStorageIds) Deletes the applications an earlier editing session of a section template left behind on a user's draft page: the section-template editor saves the draft page again, with new windows, each time it opens the template, so that the applications of the windows it replaced are listed nowhere.voiddeleteSpaceApplications(long spaceId) Deletes the applications Shortcuts portlet windows created in the context of a deleted space: a space created later with the same name gets the same group, so the same audience.getActiveApplications(int offset, int limit, String keyword, String username) Retrieves the list of applications switch offset and limit of the query, a keyword to filter on title and url ofApplicationand the username to filter on authorized applicationsgetActiveApplications(int offset, int limit, String keyword, Locale locale, String username) Retrieves the list of applications switch offset and limit of the query, a keyword to filter on title and url ofApplicationand the username to filter on authorized applicationsgetApplication(long applicationId) Get an application by idgetApplicationCategoryIds(List<Long> applicationIds) getApplicationImageInputStream(long applicationId) Return theApplicationillustrationInputStream, if not found, the default imageInputStreamwill be retrievedgetApplicationImageInputStream(long applicationId, String dimensions) Return theApplicationillustrationInputStream, if not found, the default imageInputStreamwill be retrievedgetApplicationImageLastUpdated(long applicationId) Return theApplicationillustration last modifed timestamp (in ms), if not found, the default image last modifed timestamp will be retrievedgetApplicationPlacements(String username, String siteName) Retrieves the applications the given user stuck to each side of the layout, resolved and re-validated at read time, along with whether the given site is allowed to display stuck panels: only the meta site and the sites listed in its sidebar configuration are, by design.getApplications(int offset, int limit, String keyword) Retrieves the list of applications with offset, limit and a keyword that can be emptygetApplications(int offset, int limit, String keyword, Locale locale) Retrieves the list of applications with offset, limit and a keyword that can be emptygetApplicationShortcuts(String username) getContextApplications(ApplicationListFilter filter, Locale locale, String username) Reads the applications a Shortcuts portlet window lists, for a user editing its settings: asgetListedApplications(io.meeds.appcenter.model.ApplicationListFilter, java.util.Locale, java.lang.String), plus the applications the window created whose audience excludes the user, unless an administrator emptied that audience.getContextSuggestions(String settingName, String keyword, List<Long> excludedIds, int offset, int limit, Locale locale, String username) Suggests the applications a Shortcuts portlet window may list: active, non-personal applications the user may access, matching the keyword, read from the app-center.application cache and decorated on a copy.getListedApplications(ApplicationListFilter filter, Locale locale, String username) Reads the applications a Shortcuts portlet window lists.getMandatoryAndFavoriteApplications(org.springframework.data.domain.Pageable pageable, String username, Locale locale) Reads the mandatory and favorite applications of a user, never one created from a Shortcuts portlet, which only that portlet lists.getPinnedApplicationIds(String username) Retrieves the ids of the applications the given user pinned to the topbar, in pin order.Returns the global app-center settings, deserialized from the single JSON blob stored inSettingService.booleanisIllustrationTokenValid(long applicationId, String token, long lastModified) booleanisPlacementEligibleSite(String siteName) booleanisShown(Application application, String settingName, String username, boolean editor) Whether a Shortcuts portlet window's settings drawer lists an application to a user, the rule a copy of the window applies too.booleanReturns whether users are allowed to create personal URL apps.protected StringNormalizes an URL entered by an end user for a personal application.voidpinApplication(long applicationId, String username) Pins an active application the user can access to the user's topbar, after the applications already pinned, up toApplicationPinStorage.MAX_PINNED_APPLICATIONS.voidsaveSettings(ApplicationCenterSettings settings, String username) Persists the whole app-center settings blob.voidsetUserPersonalAppsEnabled(boolean enabled, String username) Enables or disables the user personal apps feature.voidstickApplication(long applicationId, PlacementSide side, String username) Sticks an application to one side of the layout for the given user, replacing the application previously stuck to that side if any.voidunpinApplication(long applicationId, String username) Unpins an application from the topbar of the given user.voidunstickApplication(PlacementSide side, String username) Removes the application stuck to the given side for the given user.voidupdateApplication(Application application) voidupdateApplication(Application application, String username) Update an existing application on datasource.updateContextApplication(long applicationId, ApplicationForm application, String settingName, String username) Updates an application created from the settings of a Shortcuts portlet window, from that window's settings, with the fields its form offers, each one validated as on creation, but a portlet instance it keeps, which it does not check again.voidupdateFavoriteApplicationOrder(ApplicationOrder applicationOrder, String userName) Deprecated, for removal: This API element is subject to removal in a future version.voidupdateFavoriteApplicationsOrder(List<ApplicationOrder> applicationOrders, String userName) Orders the favorite applications of a user, an application not yet favorite becoming one, unless mandatory.voidupdatePersonalApplication(Application application, String username) Updates a personal URL application.
-
Field Details
-
ANY_PERMISSION
- See Also:
-
DEFAULT_USERS_GROUP
- See Also:
-
DEFAULT_USERS_PERMISSION
- See Also:
-
EXTERNAL_USERS_PERMISSION
- See Also:
-
MAX_FAVORITE_APPS
- See Also:
-
APP_CENTER_SETTINGS_KEY
SettingService key under which the whole app-center configuration is stored, serialized as a single JSON blob (seeApplicationCenterSettings). Storing all settings under one key lets new settings be added as POJO fields without introducing a new setting key nor an upgrade plugin.- See Also:
-
DEFAULT_APP_IMAGE_NAME
- See Also:
-
DEFAULT_APP_IMAGE_BODY
- See Also:
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT- See Also:
-
APP_CENTER_CONTEXT
public static final org.exoplatform.commons.api.settings.data.Context APP_CENTER_CONTEXT -
APP_CENTER_SCOPE
public static final org.exoplatform.commons.api.settings.data.Scope APP_CENTER_SCOPE -
MAX_LISTED_APPLICATIONS
public static final int MAX_LISTED_APPLICATIONSMost applications a Shortcuts portlet lists in its SELECTED mode (D6).- See Also:
-
SYSTEM_APPLICATIONS_BUNDLE
The bundle of the titles the portlets show system applications with.- See Also:
-
MAX_SUGGESTIONS
public static final int MAX_SUGGESTIONSMost suggestions returned by one call of the Shortcuts app suggester.- See Also:
-
MAX_ILLUSTRATION_SIZE
public static final int MAX_ILLUSTRATION_SIZELargest illustration of an application created from a Shortcuts portlet, in bytes.- See Also:
-
NOT_FAVORITABLE_MESSAGE
- See Also:
-
NOT_CONTEXTUAL_MESSAGE
- See Also:
-
NOT_OWNED_MESSAGE
- See Also:
-
INVALID_UPLOAD_MESSAGE
- See Also:
-
INVALID_TYPE_MESSAGE
- See Also:
-
TOO_LARGE_MESSAGE
- See Also:
-
TITLE_MANDATORY_MESSAGE
- See Also:
-
TOO_MANY_CATEGORIES_MESSAGE
- See Also:
-
INVALID_URL_MESSAGE
- See Also:
-
INVALID_HELP_PAGE_URL_MESSAGE
- See Also:
-
INVALID_ICON_MESSAGE
- See Also:
-
CONTEXTUAL_MESSAGE_PREFIX
Prefix of the codes naming a field:<prefix><field>TooLong- See Also:
-
-
Constructor Details
-
ApplicationCenterService
public ApplicationCenterService()
-
-
Method Details
-
createApplication
public Application createApplication(Application application, String username) throws IllegalAccessException Create new Application that will be available for all users.- Parameters:
application- application to createusername- user making the operation- Returns:
- stored
Applicationin datasource - Throws:
IllegalAccessException- if user is not allowed to create an application
-
createApplication
Create new Application that will be available for all users.- Parameters:
application- application to create- Returns:
- stored
Applicationin datasource
-
getApplication
Get an application by id- Parameters:
applicationId- application to find- Returns:
- stored
Applicationin datasource
-
findSystemApplicationByUrl
-
updateApplication
public void updateApplication(Application application, String username) throws IllegalAccessException, ApplicationNotFoundException Update an existing application on datasource. If the application doesn't exit anApplicationNotFoundExceptionwill be thrown.- Parameters:
application- dto to update on storeusername- username storing application- Throws:
IllegalAccessException- if user is not allowed to update applicationApplicationNotFoundException- if application wasn't found
-
updateApplication
-
deleteApplication
public void deleteApplication(Long applicationId, String username) throws ApplicationNotFoundException, IllegalAccessException Delete application identified by its id and check if username has permission to delete it.- Parameters:
applicationId- technical identifier of applicationusername- user currently deleting application- Throws:
IllegalAccessException- if user is not allowed to delete applicationApplicationNotFoundException- if application wasn't found
-
deleteApplication
- Throws:
ApplicationNotFoundException
-
addFavoriteApplication
public void addFavoriteApplication(long applicationId, String username) throws ApplicationNotFoundException, IllegalAccessException Add an application, identified by its technical id, as favorite of a user- Parameters:
applicationId- technical application idusername- user login- Throws:
ApplicationNotFoundException- when application is not foundIllegalAccessException- if user hasn't access permission to the applicationIllegalArgumentException- with the message "appCenter.contextual.notFavoritable" for an application created from a Shortcuts portlet
-
deleteFavoriteApplication
Deletes an application identified by its id from favorite applications of user- Parameters:
applicationId- application technical identifierusername- login of user currently deleting application
-
getSettings
Returns the global app-center settings, deserialized from the single JSON blob stored inSettingService. When no blob is stored yet, sane defaults are returned (seegetStoredSettings()).- Returns:
- the current
ApplicationCenterSettings, nevernull
-
saveSettings
public void saveSettings(ApplicationCenterSettings settings, String username) throws IllegalAccessException Persists the whole app-center settings blob. The incoming settings are merged onto the currently stored ones (so a partial update never drops fields it didn't set) then serialized back as a single JSON blob. Admin only.- Parameters:
settings- the settings to persist, must not benullusername- the user performing the operation- Throws:
IllegalAccessException- if the user is not allowed to change app-center settings
-
isUserPersonalAppsEnabled
public boolean isUserPersonalAppsEnabled()Returns whether users are allowed to create personal URL apps.- Returns:
trueif the personal URL apps feature is enabled
-
setUserPersonalAppsEnabled
public void setUserPersonalAppsEnabled(boolean enabled, String username) throws IllegalAccessException Enables or disables the user personal apps feature. Admin only. The value is merged into the settings JSON blob (seesaveSettings(io.meeds.appcenter.model.ApplicationCenterSettings, java.lang.String)).- Parameters:
enabled- whether the personal apps feature should be enabledusername- the user performing the operation- Throws:
IllegalAccessException- if the user is not allowed to change app-center settings
-
createPersonalApplication
public Application createPersonalApplication(Application application, String username) throws IllegalAccessException Creates a personal URL application for the given user.- Throws:
IllegalAccessException
-
updatePersonalApplication
public void updatePersonalApplication(Application application, String username) throws IllegalAccessException, ApplicationNotFoundException Updates a personal URL application. Only the owner may update it. -
getApplicationPlacements
Retrieves the applications the given user stuck to each side of the layout, resolved and re-validated at read time, along with whether the given site is allowed to display stuck panels: only the meta site and the sites listed in its sidebar configuration are, by design. -
isPlacementEligibleSite
-
stickApplication
public void stickApplication(long applicationId, PlacementSide side, String username) throws IllegalAccessException, ApplicationNotFoundException Sticks an application to one side of the layout for the given user, replacing the application previously stuck to that side if any. -
unstickApplication
Removes the application stuck to the given side for the given user. A side already empty is left as is, so the operation stays idempotent. -
getPinnedApplicationIds
Retrieves the ids of the applications the given user pinned to the topbar, in pin order. The stored pins of applications that no longer exist or that were created from a Shortcuts portlet are left out, without rewriting the stored list. The pins of applications the user can't access or that are inactive are kept: the pages render only the pinned applications found in the user's own list of applications. The cache keeps no absent application, so a stored pin of a deleted application is read from the database at each call, until the user's next pin or unpin writes the list without it.- Parameters:
username- user login- Returns:
- the pinned application ids, an empty list for a blank username
-
pinApplication
public void pinApplication(long applicationId, String username) throws ApplicationNotFoundException, IllegalAccessException Pins an active application the user can access to the user's topbar, after the applications already pinned, up toApplicationPinStorage.MAX_PINNED_APPLICATIONS. An application created from a Shortcuts portlet can't be pinned. An application already pinned keeps its place. The written list drops the applications that no longer exist or that were created from a Shortcuts portlet, and keeps the ones the user can't access anymore, which the pages don't display and display again once the access is given back.- Parameters:
applicationId- technical application idusername- user login- Throws:
ApplicationNotFoundException- when the application doesn't existIllegalAccessException- when the user can't access the applicationIllegalArgumentException- when the application is inactive or was created from a Shortcuts portlet, or the user already pinned the maximum number of applications
-
unpinApplication
Unpins an application from the topbar of the given user. An application that isn't pinned is left as is, so the operation stays idempotent. The written list drops the applications that no longer exist or that were created from a Shortcuts portlet, aspinApplication(long, String)does.- Parameters:
applicationId- technical application idusername- user login
-
normalizePersonalUrl
Normalizes an URL entered by an end user for a personal application. The scheme is optional, so that "meeds.io" is stored as "https://meeds.io"; when it is omitted the host must be qualified, so that a plain word is rejected instead of silently becoming a link to a non existing host. Only http and https are accepted, which rules out "javascript:" links. Portal relative links ("/portal/dw", "./dw") are kept as is, but scheme relative ones ("//host", which a browser resolves to an external origin) are rejected. This method is the security boundary: the mirror written in ApplicationUrlService.js only exists to give an immediate feedback in the form, and both must be updated together.- Parameters:
url- the URL as entered by the user- Returns:
- the normalized URL, either an absolute http(s) link or a portal relative one
- Throws:
IllegalArgumentException- if the URL is blank or isn't an http(s) link
-
deletePersonalApplication
public void deletePersonalApplication(Long applicationId, String username) throws IllegalAccessException, ApplicationNotFoundException Deletes a personal URL application. Only the owner may delete it. -
getApplications
Retrieves the list of applications with offset, limit and a keyword that can be empty- Parameters:
offset- offset of the querylimit- limit of the query that can be less or equal to 0, which mean, getting all available applicationskeyword- used to search in title and url- Returns:
ApplicationListthat contains the list of applications
-
getApplications
Retrieves the list of applications with offset, limit and a keyword that can be empty- Parameters:
offset- offset of the querylimit- limit of the query that can be less or equal to 0, which mean, getting all available applicationskeyword- used to search in title and urllocale- used language to retrieve application title and description- Returns:
ApplicationListthat contains the list of applications
-
getActiveApplications
public ApplicationList getActiveApplications(int offset, int limit, String keyword, String username) Retrieves the list of applications switch offset and limit of the query, a keyword to filter on title and url ofApplicationand the username to filter on authorized applications- Parameters:
offset- offset of the querylimit- limit of the query that can be less or equal to 0, which mean, getting all available applicationskeyword- used to search in title and urlusername- login of user to use to filter on authorized applications- Returns:
ApplicationListthat contains theListof authorizedUserApplication
-
getActiveApplications
public ApplicationList getActiveApplications(int offset, int limit, String keyword, Locale locale, String username) Retrieves the list of applications switch offset and limit of the query, a keyword to filter on title and url ofApplicationand the username to filter on authorized applications- Parameters:
offset- offset of the querylimit- limit of the query that can be less or equal to 0, which mean, getting all available applicationskeyword- used to search in title and urlusername- login of user to use to filter on authorized applications- Returns:
ApplicationListthat contains theListof authorizedUserApplication
-
updateFavoriteApplicationOrder
@Deprecated(since="7.3.0", forRemoval=true) @Transactional(rollbackFor=java.lang.Exception.class) public void updateFavoriteApplicationOrder(ApplicationOrder applicationOrder, String userName) throws ApplicationNotFoundException, IllegalAccessException Deprecated, for removal: This API element is subject to removal in a future version.useupdateFavoriteApplicationsOrder(List, String), which checks every application before it writes any order; since 7.3.0, for removalUpdate favorite applications order for a user- Parameters:
applicationOrder-userName-- Throws:
ApplicationNotFoundExceptionIllegalAccessException
-
updateFavoriteApplicationsOrder
@Transactional(rollbackFor=java.lang.Exception.class) public void updateFavoriteApplicationsOrder(List<ApplicationOrder> applicationOrders, String userName) throws ApplicationNotFoundException, IllegalAccessException Orders the favorite applications of a user, an application not yet favorite becoming one, unless mandatory. Every application is checked before any order is written: the batch is refused as a whole when one of them does not exist, is not accessible to the user or was created from a Shortcuts portlet. The orders are written in one transaction: a write failing midway writes none.- Parameters:
applicationOrders- the applications and their orderuserName- the user- Throws:
ApplicationNotFoundException- when an application does not existIllegalAccessException- when the user may not access an applicationIllegalArgumentException- with the message "appCenter.contextual.notFavoritable" for an application created from a Shortcuts portlet
-
getApplicationImageLastUpdated
Return theApplicationillustration last modifed timestamp (in ms), if not found, the default image last modifed timestamp will be retrieved- Parameters:
applicationId- technical id of application- Returns:
- timestamp in milliseconds of last modified date of illustration
- Throws:
ApplicationNotFoundException- if application wasn't found
-
isIllustrationTokenValid
- Parameters:
applicationId- technical id of applicationtoken- the token of an illustration URLlastModified- the version of the illustration the URL names- Returns:
- true when the token is the one the application's illustration URL carries for that version
-
getApplicationImageInputStream
public InputStream getApplicationImageInputStream(long applicationId) throws ApplicationNotFoundException Return theApplicationillustrationInputStream, if not found, the default imageInputStreamwill be retrieved- Parameters:
applicationId- technical id of application- Returns:
InputStreamof application illustration- Throws:
ApplicationNotFoundException- if application wasn't found
-
getApplicationImageInputStream
public InputStream getApplicationImageInputStream(long applicationId, String dimensions) throws ApplicationNotFoundException Return theApplicationillustrationInputStream, if not found, the default imageInputStreamwill be retrieved- Parameters:
applicationId- technical id of applicationdimensions- Image dimensions to retrieve- Returns:
InputStreamof application illustration- Throws:
ApplicationNotFoundException- if application wasn't found
-
getSystemApplications
-
getCategoryIds
-
getMandatoryAndFavoriteApplications
public ApplicationList getMandatoryAndFavoriteApplications(org.springframework.data.domain.Pageable pageable, String username, Locale locale) Reads the mandatory and favorite applications of a user, never one created from a Shortcuts portlet, which only that portlet lists.- Parameters:
pageable- the page to readusername- the userlocale- the language of the labels, none when null- Returns:
- the applications
-
getListedApplications
public List<Application> getListedApplications(ApplicationListFilter filter, Locale locale, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException Reads the applications a Shortcuts portlet window lists. With application ids, in the order of its selection. With category ids, the applications linked to each category or to one of its sub-categories, grouped per category in the order of the selection, sorted by title within a group, each application once, where it first appears, and at mostMAX_LISTED_APPLICATIONS. Each application is read from the app-center.application cache, kept when it is active and the user may access it, and decorated on a copy with its labels and badge name only. Unknown and duplicate ids are skipped.- Parameters:
filter- the window's setting name and selected ids or category idslocale- the language of the labels and of the title order, none when nullusername- the viewer- Returns:
- the applications to list, never null
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the window's setting does not existIllegalArgumentException- when both ids and category ids are given, when more thanMAX_LISTED_APPLICATIONSids or more thanMyApplicationsSettingsService.MAX_LISTED_CATEGORIEScategory ids are selected
-
clearCategoryApplications
public void clearCategoryApplications()Clears the applications listed per category, after a change of a category or of a category link. -
getContextApplications
public List<Application> getContextApplications(ApplicationListFilter filter, Locale locale, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Reads the applications a Shortcuts portlet window lists, for a user editing its settings: asgetListedApplications(io.meeds.appcenter.model.ApplicationListFilter, java.util.Locale, java.lang.String), plus the applications the window created whose audience excludes the user, unless an administrator emptied that audience. The applications the window created carry their category ids, which its form edits: an empty list when they have none, null when they could not be read.- Parameters:
filter- the window's setting name and selected idslocale- the language of the labels, none when nullusername- the user editing the window's settings- Returns:
- the applications to list, never null
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the window's setting does not existIllegalAccessException- when the user may not edit the window's settingsIllegalArgumentException- when more thanMAX_LISTED_APPLICATIONSids are selected
-
getContextSuggestions
public List<Application> getContextSuggestions(String settingName, String keyword, List<Long> excludedIds, int offset, int limit, Locale locale, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Suggests the applications a Shortcuts portlet window may list: active, non-personal applications the user may access, matching the keyword, read from the app-center.application cache and decorated on a copy. An application created from a Shortcuts portlet is suggested to its own window only, whatever its audience unless an administrator emptied it, so that one left out of the list, by a failed save or a closed drawer, can be selected again; it carries its category ids as ongetContextApplications(io.meeds.appcenter.model.ApplicationListFilter, java.util.Locale, java.lang.String).- Parameters:
settingName- the window's CMS setting namekeyword- matched in title and url, all applications when blankexcludedIds- the applications already selected, never suggested, at mostMAX_LISTED_APPLICATIONSoffset- the number of matching applications to skiplimit- the maximum number of suggestions, at mostMAX_SUGGESTIONSlocale- the language of the labels, none when nullusername- the user editing the window's settings- Returns:
- the suggested applications, never null
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the window's setting does not existIllegalAccessException- when the user may not edit the window's settingsIllegalArgumentException- when more thanMAX_LISTED_APPLICATIONSids are excluded
-
createContextApplication
public Application createContextApplication(ApplicationForm application, String settingName, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Creates an application from the settings of a Shortcuts portlet window, owned by that window: listed there only, never in the users' Application Center. Its audience derives from the context the window's setting recorded server-side, the members of its space, or every platform user, internal and external alike, never from the request. Every field the form does not offer is forced, every one it offers is validated, and its illustration is read from an upload only.- Parameters:
application- the form's fieldssettingName- the window's CMS setting nameusername- the user creating the application- Returns:
- the created application, its badge resolved
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the window's setting, or the space of its context, does not existIllegalAccessException- when the user may not manage the window's applicationsIllegalArgumentException- when a field or the illustration is invalid, the message naming it
-
createCopiedContextApplication
public Application createCopiedContextApplication(ApplicationForm application, byte[] illustration, String settingName) throws org.exoplatform.commons.exception.ObjectNotFoundException Creates, in the context of a copy of a Shortcuts portlet window, the copy of an application the source window created, when the copy is first rendered: owned by the copy, with the audience of the context the copy's setting recorded. No right applies, as the first viewer of the copy can be anyone: the payload was written by the copy step or by an editor of the page, and the application is created in the copy's own context only. Every field is validated as oncreateContextApplication(io.meeds.appcenter.model.ApplicationForm, java.lang.String, java.lang.String), the one exception being a portlet instance, which needs only to exist. The illustration's type is decided from its content; an invalid or too large one is dropped, the application being created without it. Its categories are linked with no right checked, as the copy's first viewer can be anyone, a category that does not exist, or that fails to link, being skipped.- Parameters:
application- the copied application's fields and categoriesillustration- the copied illustration's content, null when nonesettingName- the copy's CMS setting name- Returns:
- the created application, with the categories it got
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the copy's setting, or the space of its context, does not existIllegalArgumentException- when a field is invalid, the message naming it
-
getApplicationCategoryIds
- Parameters:
applicationIds- application ids- Returns:
- the ids of each application's categories, read in one query, by application id, none for an application without category
-
deleteContextApplication
public void deleteContextApplication(long applicationId, String settingName, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Deletes an application created from the settings of a Shortcuts portlet window, from that window's settings.- Parameters:
applicationId- the application idsettingName- the window's CMS setting nameusername- the user deleting the application- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the window's setting does not exist, or when the application does not exist, or the window does not manage it and the user may not access itIllegalAccessException- when the user may not manage the window's applicationsIllegalArgumentException- with the message "appCenter.contextual.notContextual" for an application of the Application Center, "appCenter.contextual.notOwned" for one another window created
-
updateContextApplication
public Application updateContextApplication(long applicationId, ApplicationForm application, String settingName, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Updates an application created from the settings of a Shortcuts portlet window, from that window's settings, with the fields its form offers, each one validated as on creation, but a portlet instance it keeps, which it does not check again. Its owner, audience, order and every field the form does not offer keep their stored or forced value. Its badge binding is the administrators' to change: for another editor, a new type drops it, and so does, unless the badge is turned off, a new url a badge provider declares. Its illustration is replaced from an upload only, removed only on the form's explicit request, and kept otherwise. Its categories become the form's ones as far as they can: a category the user may not link or unlink, or that fails to, keeps its state, and none changes when the form sends no list of them or when the stored ones cannot be read.- Parameters:
applicationId- the application idapplication- the form's fieldssettingName- the window's CMS setting nameusername- the user updating the application- Returns:
- the updated application, as a listing tile without its permissions, its badge resolved, with its categories, null when they could not be read
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the window's setting does not exist, when the application does not exist, or the window does not manage it and the user may not access it, or when the update's own read of the application, or its read back once saved, finds noneIllegalAccessException- when the user may not manage the window's applicationsIllegalArgumentException- with the message "appCenter.contextual.notContextual" for an application of the Application Center, "appCenter.contextual.notOwned" for one another window created, or a message naming the invalid field or illustration
-
deleteSpaceApplications
public void deleteSpaceApplications(long spaceId) Deletes the applications Shortcuts portlet windows created in the context of a deleted space: a space created later with the same name gets the same group, so the same audience. One application failing to delete does not keep the others.- Parameters:
spaceId- the deleted space id
-
deleteSectionTemplateApplications
public void deleteSectionTemplateApplications(long templateId) Deletes the applications the windows of a section template's drafts created, every administrator's, once the template is deleted.- Parameters:
templateId- the deleted section template id
-
deleteSectionTemplateDraftLeftovers
public void deleteSectionTemplateDraftLeftovers(String settingName, String draftPageReference, Collection<String> windowStorageIds) Deletes the applications an earlier editing session of a section template left behind on a user's draft page: the section-template editor saves the draft page again, with new windows, each time it opens the template, so that the applications of the windows it replaced are listed nowhere. Kept: those of a window of the current draft page, among which the window being initialized, whatever their order of rendering, those of a window recorded on another draft page, another administrator's, and those whose window's setting cannot be read. Each application is checked when its turn comes, after all were selected: one created meanwhile waits for the next session, one deleted meanwhile is skipped. Nothing is deleted once the window being initialized no longer exists as committed: its render loaded the draft page before a later session saved it again, so that the given windows are not those of the current draft page. That window is read once, when the first application to delete is reached, after the selection, which lists the applications of such a later session's windows only once the draft page was saved again; a read that fails stops the deletion, its exception thrown.- Parameters:
settingName- the CMS setting name of the window being initialized, which names that window: when it does not, nothing is deleteddraftPageReference- the draft page the window is rendered onwindowStorageIds- the storage ids of the windows of that page, as the render loaded it
-
canEditContextApplication
Whether a user may edit an application from the settings of a Shortcuts portlet window: an administrator any application, whoever manages the applications of the window that created one that application only. When that window's setting no longer exists, or an administrator emptied the application's audience, administrators only.- Parameters:
application- the applicationusername- the user, blank for a guest- Returns:
- true when the user may edit the application
-
getApplicationShortcuts
-
canAccess
Whether a user may see an application. An application created from a Shortcuts portlet whose audience an administrator emptied is shown to administrators only, where any other application without permissions is shown to every platform user.- Parameters:
application- the applicationusername- the user, blank for a guest- Returns:
- true when the user may see the application
-
canEdit
-
isShown
public boolean isShown(Application application, String settingName, String username, boolean editor) Whether a Shortcuts portlet window's settings drawer lists an application to a user, the rule a copy of the window applies too.- Parameters:
application- the applicationsettingName- the window's CMS setting nameusername- the usereditor- whether the user may edit the window's settings- Returns:
- true for an application the user may access, and for an editor of the window's settings one the window manages
-
updateFavoriteApplicationsOrder(List, String), which checks every application before it writes any order; since 7.3.0, for removal