Class SubspacesListPortlet

java.lang.Object
javax.portlet.GenericPortlet
org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet
io.meeds.social.portlet.SubspacesListPortlet
All Implemented Interfaces:
javax.portlet.EventPortlet, javax.portlet.Portlet, javax.portlet.PortletConfig, javax.portlet.ResourceServingPortlet

public class SubspacesListPortlet extends org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet
Portlet listing the sub-spaces of the space whose page hosts it. The class is glue only: preferences in, SpaceService calls, nothing decided here. Its three preferences are declared in portlet.xml and written only through processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse), under the parent space management guard, so that showHiddenSubspaces — the flag that lets a page expose hidden sub-spaces to non-members — is never influenced by a client value.
  • Field Details

    • HEADER_TRANSLATIONS_PREFERENCE

      public static final String HEADER_TRANSLATIONS_PREFERENCE
      See Also:
    • SHOW_HIDDEN_SUBSPACES_PREFERENCE

      public static final String SHOW_HIDDEN_SUBSPACES_PREFERENCE
      See Also:
    • SUBSPACES_LIMIT_PREFERENCE

      public static final String SUBSPACES_LIMIT_PREFERENCE
      See Also:
    • DEFAULT_SUBSPACES_LIMIT

      public static final int DEFAULT_SUBSPACES_LIMIT
      See Also:
    • MIN_SUBSPACES_LIMIT

      public static final int MIN_SUBSPACES_LIMIT
      See Also:
    • MAX_SUBSPACES_LIMIT

      public static final int MAX_SUBSPACES_LIMIT
      See Also:
    • LIMIT_OUT_OF_RANGE_MESSAGE

      public static final String LIMIT_OUT_OF_RANGE_MESSAGE
      See Also:
    • HEADER_TRANSLATIONS_INVALID_MESSAGE

      public static final String HEADER_TRANSLATIONS_INVALID_MESSAGE
      See Also:
    • SHOW_HIDDEN_SUBSPACES_INVALID_MESSAGE

      public static final String SHOW_HIDDEN_SUBSPACES_INVALID_MESSAGE
      See Also:
    • LIMIT_PARAMETER

      public static final String LIMIT_PARAMETER
      See Also:
    • AVATAR_RESOURCE_ID

      public static final String AVATAR_RESOURCE_ID
      Resource id of the second resource this portlet serves: the avatar of one listed sub-space (<portlet:resourceURL id="avatar"> in the JSP).
      See Also:
    • SPACE_ID_PARAMETER

      public static final String SPACE_ID_PARAMETER
      See Also:
    • SPACE_ID_INVALID_MESSAGE

      public static final String SPACE_ID_INVALID_MESSAGE
      See Also:
    • PARENT_SPACE_NOT_FOUND_MESSAGE

      public static final String PARENT_SPACE_NOT_FOUND_MESSAGE
      Bodies of the 404 and 403 answers. A fixed message code per status, as backend-spring.md §5 asks: the Service's own sentence names the acting user and the space id, which is troubleshooting detail for LOG.debug, not something to hand a client.
      See Also:
    • ACCESS_DENIED_MESSAGE

      public static final String ACCESS_DENIED_MESSAGE
      See Also:
    • AVATAR_CACHE_CONTROL

      public static final String AVATAR_CACHE_CONTROL
      Browser cache of a widget-served avatar. The URL carries no last-modified marker, so the cache is short and private.
      See Also:
    • AVATAR_THUMBNAIL_SIZE

      public static final int AVATAR_THUMBNAIL_SIZE
      Same thumbnail size as the space avatar REST endpoint's default, so both paths serve the same bytes for the same space.
      See Also:
    • DEFAULT_AVATAR_MIME_TYPE

      public static final String DEFAULT_AVATAR_MIME_TYPE
      See Also:
    • MAX_RESOURCE_LIMIT

      public static final int MAX_RESOURCE_LIMIT
      Hard bound of one resource call. The 'see more' drawer lists every sub-space at once (no pagination yet), so the cap is what keeps one parent with an unexpected number of sub-spaces from making the call unbounded. A constant rather than a property: the real bound is the parent template's subspacesMaxLimit, and beyond this the answer is pagination, not a bigger number.
      See Also:
  • Constructor Details

    • SubspacesListPortlet

      public SubspacesListPortlet()
  • Method Details

    • storedLimit

      public static int storedLimit(javax.portlet.PortletPreferences preferences)
      The stored number of rows, brought back inside MIN_SUBSPACES_LIMIT..MAX_SUBSPACES_LIMIT.

      processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse) refuses a value outside those bounds, but it is not the only writer: a preference imported through the layout editor bypasses it entirely, so every reader clamps. This one is shared with the JSP rather than duplicated there, so the three places that read the preference cannot drift apart: an unclamped value feeds both the avatar resource's listing bound — where a large one is a big query on the render path and a negative one makes the Service throw IllegalArgumentException, which that method does not catch — and the envelope the widget re-seats its settings from, where a negative one makes the widget's own slice drop rows from the end.

      Parameters:
      preferences - the portlet preferences to read
      Returns:
      the stored limit, never outside the bounds the widget can render
    • isParentSpaceContext

      public static boolean isParentSpaceContext()
      Whether the page this portlet renders on hosts a space that may carry sub-spaces — the same question serveResource(javax.portlet.ResourceRequest, javax.portlet.ResourceResponse) answers, asked of the same SpaceService and resolved from the page, never from a request parameter.

      Read by the JSP so that the widget is not booted at all outside a parent space: it used to boot everywhere, render its loading state and only then remove itself, which flashed a loading placeholder on every space that is not a parent one (PO feedback on EXO-89270).

      Shared with the JSP the way storedLimit(javax.portlet.PortletPreferences) is, rather than carried there as a render attribute: GenericDispatchedViewPortlet.doView copies every stored preference into a request attribute of the same name, after this class has had its turn, and a page editor may store a preference under any name at all (PageLayoutService.updatePageApplicationPreferences). No attribute name is therefore safe from being answered by a preference.

      Returns:
      true when the hosting space may carry sub-spaces
    • processAction

      public void processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response) throws IOException, javax.portlet.PortletException
      Specified by:
      processAction in interface javax.portlet.Portlet
      Overrides:
      processAction in class javax.portlet.GenericPortlet
      Throws:
      IOException
      javax.portlet.PortletException
    • serveResource

      public void serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) throws javax.portlet.PortletException, IOException
      Answers the widget with everything it needs to render, in one envelope: whether the hosting space is a parent space at all, what the viewer may do on it, and the sub-spaces they may see. Every decision is the SpaceService's; this method only reads the trusted preference and the page context.

      The space is resolved from the page (SpaceUtils.getSpaceByContext()), never from a request parameter, and showHiddenSubspaces is read from the portlet preferences, never from the request: a client value must not be able to widen what is listed.

      Specified by:
      serveResource in interface javax.portlet.ResourceServingPortlet
      Overrides:
      serveResource in class javax.portlet.GenericPortlet
      Throws:
      javax.portlet.PortletException
      IOException