Class ApplicationBadgePortletStorage

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

@Component public class ApplicationBadgePortletStorage extends Object
Translates between a PORTLET application's stored url and the portlet name a badge plugin declares.

A PORTLET catalog entry stores the portlet instance id chosen in the administration suggester, not the portlet-name from portlet.xml. A plugin can only declare the latter — instance ids are generated per deployment — so the two have to be mapped.

The whole mapping is cached as a single entry, deliberately: it is read for every application of every launcher render, and resolving one instance at a time would turn that into a query per application.

  • Field Details

  • Constructor Details

    • ApplicationBadgePortletStorage

      public ApplicationBadgePortletStorage()
  • Method Details

    • getPortletContentIdsByInstanceId

      @Cacheable(cacheNames="app-center.badge.portlet", key="\'portletContentIdsByInstanceId\'", sync=true) public Map<String,String> getPortletContentIdsByInstanceId()
      Returns:
      the contentId of every portlet instance, keyed by instance id as stored in an application's url
    • getPortletContentId

      public String getPortletContentId(String url)
      Parameters:
      url - an application url holding a portlet instance id
      Returns:
      the corresponding contentId, or null when unknown
    • getPortletInstanceUrls

      public List<String> getPortletInstanceUrls(Collection<String> declaredPortlets)
      Reverse lookup, used to find which applications a badge is bound to.
      Parameters:
      declaredPortlets - the portlet values a plugin declares, either a contentId or a bare portlet-name
      Returns:
      the urls of the matching portlet instances
    • matches

      public static boolean matches(String declared, String contentId)
      A plugin may declare either the full applicationName/portletName content id — unambiguous, and what the administration form matches on — or just the portlet name, as Layout's own portlet lookup also tolerates.
      Parameters:
      declared - the value declared by a badge plugin
      contentId - the content id of a portlet instance
      Returns:
      whether they designate the same portlet
    • clearCache

      @CacheEvict(cacheNames="app-center.badge.portlet", key="\'portletContentIdsByInstanceId\'") public void clearCache()
      Drops the mapping, so that a newly created or removed portlet instance is picked up before the cache would have expired on its own.