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 Stringstatic final Stringstatic final intstatic 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) booleancreateApplication(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.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.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.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 idgetApplicationImageInputStream(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) getMandatoryAndFavoriteApplications(org.springframework.data.domain.Pageable pageable, String username, Locale locale) Returns the global app-center settings, deserialized from the single JSON blob stored inSettingService.booleanisPlacementEligibleSite(String siteName) booleanReturns whether users are allowed to create personal URL apps.protected StringNormalizes an URL entered by an end user for a personal application.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.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.voidupdateFavoriteApplicationOrder(ApplicationOrder applicationOrder, String userName) Update favorite applications order for a uservoidupdatePersonalApplication(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:
-
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
-
-
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 application
-
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. -
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
public void updateFavoriteApplicationOrder(ApplicationOrder applicationOrder, String userName) throws ApplicationNotFoundException Update favorite applications order for a user- Parameters:
applicationOrder-userName-- Throws:
ApplicationNotFoundException
-
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
-
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) -
getApplicationShortcuts
-
canAccess
-
canEdit
-