Class ApplicationCenterStorage

java.lang.Object
io.meeds.appcenter.storage.ApplicationCenterStorage

@Component public class ApplicationCenterStorage extends Object
Storage service to access / load and save applications. This service will be used , as well, to convert from JPA entity to DTO.
  • Field Details

    • NAME_SPACE

      public static final String NAME_SPACE
      See Also:
    • DEFAULT_LAST_MODIFIED

      public static final Long DEFAULT_LAST_MODIFIED
  • Constructor Details

    • ApplicationCenterStorage

      public ApplicationCenterStorage()
  • Method Details

    • createApplication

      public Application createApplication(Application application)
      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 create
      contextSettingName - the CMS setting name of the owning window
      contextSpaceId - 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

      @Cacheable("app-center.application") public Application getApplication(long applicationId)
    • getApplicationsByBadge

      public List<Application> 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.
      Parameters:
      badgeName - the badge identifier
      urls - the drawer and/or portlet names declared by the plugin, possibly empty
      Returns:
      the bound applications, never null
    • findSystemApplicationByUrl

      public Application findSystemApplicationByUrl(String url)
    • 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

      public void deleteApplicationFavorite(Long applicationId, String username)
    • getSystemApplications

      public List<Application> getSystemApplications()
    • isFavoriteApplication

      public boolean isFavoriteApplication(Long applicationId, String username)
    • countFavorites

      public long countFavorites(String username)
    • getApplicationImageLastUpdated

      public Long getApplicationImageLastUpdated(long fileId)
    • getApplicationImageInputStream

      public InputStream getApplicationImageInputStream(long fileId)
    • isIllustrationTokenValid

      public boolean isIllustrationTokenValid(long id, String token, long imageLastModified)
      Parameters:
      id - the application's id
      token - the token of an illustration URL
      imageLastModified - 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

      public List<Long> getApplicationIds(String keyword)
      Parameters:
      keyword - matched in title and url, all applications when blank
      Returns:
      the ids of the matching applications, sorted by title
    • getApplications

      public List<Application> getApplications(String keyword)
    • countApplications

      public long countApplications()
    • getContextApplicationIds

      public List<Long> getContextApplicationIds(long spaceId)
      Parameters:
      spaceId - a space id
      Returns:
      the ids of the applications created by Shortcuts portlet windows in that space's context
    • getContextApplicationIdsByOwnerPattern

      public List<Long> getContextApplicationIdsByOwnerPattern(String ownerPattern)
      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

      public 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.
      Parameters:
      uploadId - the upload id
      maxBytes - the bound
      Returns:
      at most maxBytes + 1 bytes of the upload, null when no completed upload has that id
    • removeUpload

      public void removeUpload(String uploadId)
      Removes an upload once its content is stored.
      Parameters:
      uploadId - the upload id
    • saveIllustration

      public Long saveIllustration(byte[] content, String mimeType)
      Stores an application illustration.
      Parameters:
      content - the image content
      mimeType - 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)