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 Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringThe marker of a directory whose attribute filter must be set again, which layout's preference plugin writes on a template copy and which is never postedstatic final Stringstatic final Stringstatic final Stringstatic final StringThe request parameter carrying the viewer's people filter.static final Stringstatic final Stringstatic final Stringstatic final StringThe marker of a directory whose groups must be set again, which a directory made from a template carries instead of its source's groups.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringPrefix of a parameter carrying one criterion of the viewer's own filter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanWhether the current user may change the settings of the window being rendered.static booleancanSetFilterOptions(String username) static booleancanSetGroupFilter(String username) static booleancanSetGroupFilter(String username, org.json.JSONObject groups) static StringdirectoryAttributes(javax.portlet.PortletPreferences preferences) static booleanisAttributeFilterInvalid(javax.portlet.PortletPreferences preferences) static booleanisAttributeFilterToSet(javax.portlet.PortletPreferences preferences) static booleanisDirectoryFiltered(javax.portlet.PortletPreferences preferences) voidprocessAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response) voidserveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response) 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 ofprocessAction(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.static StringstoredAttributes(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.static StringstoredFilter(javax.portlet.PortletPreferences preferences) static StringstoredGroups(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.static booleanstoredGuestRestriction(javax.portlet.PortletPreferences preferences) static StringstoredHeaderTranslations(javax.portlet.PortletPreferences preferences) static intstoredPageSize(javax.portlet.PortletPreferences preferences) Methods inherited from class org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet
doView, initMethods inherited from class javax.portlet.GenericPortlet
destroy, doDispatch, doEdit, doHeaders, doHelp, getContainerRuntimeOptions, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, processEvent, render
-
Field Details
-
HEADER_TRANSLATIONS_PREFERENCE
- See Also:
-
PAGE_SIZE_PREFERENCE
- See Also:
-
GUEST_RESTRICTION_PREFERENCE
- See Also:
-
FILTER_PREFERENCE
- See Also:
-
DEFAULT_FILTER
- See Also:
-
CONNECTIONS_FILTER
- See Also:
-
FILTER_PARAMETER
The request parameter carrying the viewer's people filter.- See Also:
-
ATTRIBUTE_FILTER_PREFERENCE
- See Also:
-
GROUP_FILTER_PREFERENCE
- See Also:
-
GROUPS_TO_SET_PREFERENCE
The marker of a directory whose groups must be set again, which a directory made from a template carries instead of its source's groups. It is written by layout's preference plugin and never posted: among this portlet's writers, onlyprocessAction(ActionRequest, ActionResponse)removes it. A layout write of the window's preferences can drop it too, and the directory then lists what its attribute filter allows, no group being involved.- See Also:
-
ATTRIBUTE_FILTER_TO_SET_PREFERENCE
The marker of a directory whose attribute filter must be set again, which layout's preference plugin writes on a template copy and which is never posted- See Also:
-
SETTINGS_RESOURCE_ID
- See Also:
-
USERS_RESOURCE_ID
- See Also:
-
ATTRIBUTE_VALUES_RESOURCE_ID
- See Also:
-
GROUPS_RESOURCE_ID
- See Also:
-
VIEWER_ATTRIBUTE_PREFIX
Prefix of a parameter carrying one criterion of the viewer's own filter.- See Also:
-
USERS_REST_PATH
- See Also:
-
USERS_EXPAND
- See Also:
-
-
Constructor Details
-
PeopleListPortlet
public PeopleListPortlet()
-
-
Method Details
-
canEdit
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
- 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
- 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
- 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
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 preferencesusername- the editor- Returns:
- a JSON object
{groups: [{groupId, label}], otherGroupsApplied, otherGroupsCount, unresolvableGroups, groupFilterInvalid, missingGroups, groupStoreUnavailable}; when the group store cannot be read, no group andgroupStoreUnavailable, so that the drawer gets no group filter to post and an Apply drops none of the stored groups
-
canSetGroupFilter
- Parameters:
username- the editorgroups- the result ofstoredGroups(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
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 preferenceslocale- 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
- Parameters:
preferences- the window preferences- Returns:
- the header labels per language,
{}when the header is OFF
-
storedFilter
- 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:
processActionin interfacejavax.portlet.Portlet- Overrides:
processActionin classjavax.portlet.GenericPortlet- Throws:
IOExceptionjavax.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 ofprocessAction(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:
serveResourcein interfacejavax.portlet.ResourceServingPortlet- Overrides:
serveResourcein classjavax.portlet.GenericPortlet- Throws:
javax.portlet.PortletExceptionIOException
-