Class PeopleListPortlet

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

public class PeopleListPortlet extends org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet
People Directory application. The class is glue: the edit right and the validity of the stored values are PeopleDirectoryService's decisions, taken on the page, the site and the window id read from the portal context, never from a request parameter.

The JSP reads what it trusts through the static methods of this class, never through a request attribute: GenericDispatchedViewPortlet copies every stored preference into a request attribute of the same name, and the layout editor can store a preference under any name, so a stored canEdit would otherwise answer for the edit right.

  • Field Details

  • Constructor Details

    • PeopleListPortlet

      public PeopleListPortlet()
  • Method Details

    • canEdit

      public static boolean canEdit(String username)
      Whether the current user may change the settings of the window being rendered.
      Parameters:
      username - the current user, may be null
      Returns:
      true when the settings drawer may be offered and saved
    • canSetGroupFilter

      public static boolean canSetGroupFilter(String username)
      Parameters:
      username - the current user, may be null
      Returns:
      whether the group filter is offered to the user in the settings drawer, who must also be allowed to edit the window
    • canSetFilterOptions

      public static boolean canSetFilterOptions(String username)
      Parameters:
      username - the current user, may be null
      Returns:
      whether the filter options (guest restriction, attribute and group filters) are offered to the user in the settings drawer, who must also be allowed to edit the window: an external editor keeps the display options only
    • isDirectoryFiltered

      public static boolean isDirectoryFiltered(javax.portlet.PortletPreferences preferences)
      Parameters:
      preferences - the window preferences
      Returns:
      whether the directory filters its users by profile attribute or by group, or lists nobody because its stored filter is no longer valid: the empty state then names the directory's filter, not the viewer's
    • directoryAttributes

      public static String directoryAttributes(javax.portlet.PortletPreferences preferences)
      Parameters:
      preferences - the window preferences
      Returns:
      the names of the profile attributes the directory filters on, for every viewer: the advanced filter shows them greyed out
    • isAttributeFilterToSet

      public static boolean isAttributeFilterToSet(javax.portlet.PortletPreferences preferences)
      Parameters:
      preferences - the window preferences
      Returns:
      whether the window carries the marker of a directory made from a template, whose attribute filter must be set again: it lists nobody, and the settings drawer says why and enables Apply
    • isAttributeFilterInvalid

      public static boolean isAttributeFilterInvalid(javax.portlet.PortletPreferences preferences)
      Parameters:
      preferences - the window preferences
      Returns:
      whether the stored attribute filter is one the directory cannot read, so that it lists nobody: the settings drawer then shows no attribute, and Apply replaces the stored value
    • storedGroups

      public static String storedGroups(javax.portlet.PortletPreferences preferences, String username)
      The group filter as the settings drawer shows it, for a user who may edit the window: the stored groups the user can select, and whether other groups are applied, never named. The other viewers get nothing of it.
      Parameters:
      preferences - the window preferences
      username - the editor
      Returns:
      a JSON object {groups: [{groupId, label}], otherGroupsApplied, otherGroupsCount, unresolvableGroups, groupFilterInvalid, missingGroups, groupStoreUnavailable}; when the group store cannot be read, no group and groupStoreUnavailable, so that the drawer gets no group filter to post and an Apply drops none of the stored groups
    • canSetGroupFilter

      public static boolean canSetGroupFilter(String username, org.json.JSONObject groups)
      Parameters:
      username - the editor
      groups - the result of storedGroups(PortletPreferences, String), as a JSON object
      Returns:
      whether the editor may set the group filter in this drawer: never while the group store cannot be read
    • storedAttributes

      public static String storedAttributes(javax.portlet.PortletPreferences preferences, Locale locale)
      The attribute filter as the settings drawer shows it, for a user who may edit the window: the values the filter stores are not shown to the other viewers.
      Parameters:
      preferences - the window preferences
      locale - the editor's language
      Returns:
      a JSON array of {name, values: [{value, label}], available}
    • storedPageSize

      public static int storedPageSize(javax.portlet.PortletPreferences preferences)
      Parameters:
      preferences - the window preferences
      Returns:
      the number of users listed per page
    • storedGuestRestriction

      public static boolean storedGuestRestriction(javax.portlet.PortletPreferences preferences)
      Parameters:
      preferences - the window's preferences
      Returns:
      whether the window restricts guest viewers, ON unless the stored value is false
    • storedHeaderTranslations

      public static String storedHeaderTranslations(javax.portlet.PortletPreferences preferences)
      Parameters:
      preferences - the window preferences
      Returns:
      the header labels per language, {} when the header is OFF
    • storedFilter

      public static String storedFilter(javax.portlet.PortletPreferences preferences)
      Parameters:
      preferences - the window preferences
      Returns:
      the quick filter the directory opens with: all or connections
    • 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 portlet's resources, each behind a right and varying with the viewer, so never cached: settings, the stored settings as the directory uses them, which the settings drawer reads back after a save (a refusal of processAction(ActionRequest, ActionResponse) is answered with a 200 by the portal, so only the stored values tell whether the save was applied); users, the users the directory lists to the viewer, filtered server-side by the window's stored filter; attributeValues, the values an editor can select for a filter attribute; groups, the groups an editor can select for the group filter. An anonymous request is refused before anything is read.
      Specified by:
      serveResource in interface javax.portlet.ResourceServingPortlet
      Overrides:
      serveResource in class javax.portlet.GenericPortlet
      Throws:
      javax.portlet.PortletException
      IOException