Package io.meeds.appcenter.storage
Class ApplicationCenterStorage
java.lang.Object
io.meeds.appcenter.storage.ApplicationCenterStorage
Storage service to access / load and save applications. This service will be
used , as well, to convert from JPA entity to DTO.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddApplicationToUserFavorite(long applicationId, String username) longlongcountFavorites(String username) createApplication(Application application) Creates an application of the Application Center: whatever the application carries, it is owned by no Shortcuts portlet window.createContextApplication(Application application, String contextSettingName, long contextSpaceId) Creates an application owned by a Shortcuts portlet window.voiddeleteApplication(long applicationId) voiddeleteApplicationFavorite(Long applicationId, String username) voiddeleteIllustration(long fileId) Deletes an application illustration that no application uses.getApplication(long applicationId) getApplicationIds(String keyword) getApplicationImageInputStream(long fileId) getApplicationImageLastUpdated(long fileId) getApplications(String keyword) getApplicationsByBadge(String badgeName, List<String> urls) Retrieves the applications a badge is bound to, either explicitly through their stored badge name, or implicitly through a url the plugin declares.getContextApplicationIds(long spaceId) getContextApplicationIdsByOwnerPattern(String ownerPattern) getMandatoryAndFavoriteApplications(String username, org.springframework.data.domain.Pageable pageable) booleanisFavoriteApplication(Long applicationId, String username) booleanisIllustrationTokenValid(long id, String token, long imageLastModified) byte[]readUpload(String uploadId, int maxBytes) Reads the start of an upload, at most one byte more than the given bound, so that a caller tells an upload above the bound without reading it whole.voidremoveUpload(String uploadId) Removes an upload once its content is stored.saveIllustration(byte[] content, String mimeType) Stores an application illustration.voidupdateApplication(Application application) voidupdateContextApplication(Application application) Updates an application owned by a Shortcuts portlet window.voidupdateFavoriteApplicationOrder(long applicationId, String username, Long order)
-
Field Details
-
NAME_SPACE
- See Also:
-
DEFAULT_LAST_MODIFIED
-
-
Constructor Details
-
ApplicationCenterStorage
public ApplicationCenterStorage()
-
-
Method Details
-
createApplication
Creates an application of the Application Center: whatever the application carries, it is owned by no Shortcuts portlet window.- Parameters:
application- the application to create- Returns:
- the created application
-
createContextApplication
public Application createContextApplication(Application application, String contextSettingName, long contextSpaceId) Creates an application owned by a Shortcuts portlet window. The application is stored as given, its illustration file id included: the caller decides every field, no upload is read here. When the database refuses the application, its illustration is deleted.- Parameters:
application- the application to createcontextSettingName- the CMS setting name of the owning windowcontextSpaceId- the space of the window's context, 0 for the platform context- Returns:
- the created application
-
updateContextApplication
@CacheEvict(cacheNames="app-center.application", key="#p0.getId()") public void updateContextApplication(Application application) throws ApplicationNotFoundException Updates an application owned by a Shortcuts portlet window. The application is stored as given, its illustration file id included: the caller decides every field, no upload is read here. Its owner and system flag stay the stored ones. The illustration it replaces or removes is deleted once the application is saved. A new illustration is the caller's: it deletes it when the update fails.- Parameters:
application- the application to update- Throws:
ApplicationNotFoundException- when the application no longer exists as the update reads it
-
updateApplication
@CacheEvict(cacheNames="app-center.application", key="#p0.getId()") public void updateApplication(Application application) -
deleteApplication
@CacheEvict(cacheNames="app-center.application", key="#p0") public void deleteApplication(long applicationId) throws ApplicationNotFoundException - Throws:
ApplicationNotFoundException
-
getApplication
-
getApplicationsByBadge
Retrieves the applications a badge is bound to, either explicitly through their stored badge name, or implicitly through a url the plugin declares.- Parameters:
badgeName- the badge identifierurls- the drawer and/or portlet names declared by the plugin, possibly empty- Returns:
- the bound applications, never null
-
findSystemApplicationByUrl
-
addApplicationToUserFavorite
public FavoriteApplicationEntity addApplicationToUserFavorite(long applicationId, String username) throws ApplicationNotFoundException - Throws:
ApplicationNotFoundException
-
updateFavoriteApplicationOrder
public void updateFavoriteApplicationOrder(long applicationId, String username, Long order) throws ApplicationNotFoundException - Throws:
ApplicationNotFoundException
-
deleteApplicationFavorite
-
getSystemApplications
-
isFavoriteApplication
-
countFavorites
-
getApplicationImageLastUpdated
-
getApplicationImageInputStream
-
isIllustrationTokenValid
- Parameters:
id- the application's idtoken- the token of an illustration URLimageLastModified- 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
-
getApplicationIds
- Parameters:
keyword- matched in title and url, all applications when blank- Returns:
- the ids of the matching applications, sorted by title
-
getApplications
-
countApplications
public long countApplications() -
getContextApplicationIds
- Parameters:
spaceId- a space id- Returns:
- the ids of the applications created by Shortcuts portlet windows in that space's context
-
getContextApplicationIdsByOwnerPattern
- Parameters:
ownerPattern- a LIKE pattern over the CMS setting names of Shortcuts portlet windows- Returns:
- the ids of the applications created by the windows whose setting name matches the pattern
-
readUpload
Reads the start of an upload, at most one byte more than the given bound, so that a caller tells an upload above the bound without reading it whole.- Parameters:
uploadId- the upload idmaxBytes- the bound- Returns:
- at most maxBytes + 1 bytes of the upload, null when no completed upload has that id
-
removeUpload
Removes an upload once its content is stored.- Parameters:
uploadId- the upload id
-
saveIllustration
Stores an application illustration.- Parameters:
content- the image contentmimeType- the image type, decided from the content- Returns:
- the id of the stored file
-
deleteIllustration
public void deleteIllustration(long fileId) Deletes an application illustration that no application uses.- Parameters:
fileId- the id of the stored file
-
getMandatoryAndFavoriteApplications
public List<UserApplication> getMandatoryAndFavoriteApplications(String username, org.springframework.data.domain.Pageable pageable)
-