Class PeopleDirectoryService
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected org.exoplatform.social.core.manager.IdentityManagerstatic final Stringprotected org.exoplatform.portal.mop.service.LayoutServicestatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected org.exoplatform.services.organization.OrganizationServicestatic final Stringprotected org.exoplatform.social.core.profileproperty.ProfilePropertyServiceprotected ProfileSearchConnectorprotected org.exoplatform.social.core.manager.RelationshipManagerprotected org.exoplatform.social.core.space.spi.SpaceServicestatic final Stringstatic final Stringstatic final Stringprotected io.meeds.social.translation.service.TranslationServicestatic final Stringprotected org.exoplatform.portal.config.UserACLprotected UserPermissionServiceprotected org.exoplatform.portal.config.UserPortalConfigServicestatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanEditSettings(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String username) Whether a user may change the settings of one People Directory window.booleancanSetFilterOptions(String username) Whether a user may change the filter options of a People Directory window (the guest restriction, the attribute filter and the group filter): any user but an external one, a member of/platform/externals, who keeps the display options only, whatever grants them the edit right.booleancanSetGroupFilter(String username) Whether a user may set the group filter of a People Directory window: a user who may set its filter options (canSetFilterOptions(String)) and is a platform administrator, or a manager of at least one group, space or organizational unit (seegetManagedGroupIds(String)).booleancanViewDirectory(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String username) Whether a user may see the users a People Directory window lists: the view right of the page, or of the rendered site layout, that holds the window, found ascanEditSettings(PageKey, SiteKey, String, String)finds it.booleanclearsAttributeFilterToSet(String postedAttributeFilter, String username) Whether a save of the app's settings clears the marker of a directory whose attribute filter must be set again: only a save by an editor who may set the filter options that posts an attribute filter clears it; any other save keeps it, so that the directory keeps listing nobody.booleanclearsGroupsToSet(String postedGroupFilter, String username) Whether a save clears the marker of a directory whose groups must be set again: only a save by an editor who may set groups that posts a group filter, groups or the filter OFF, clears it; any other save keeps it, so that the directory keeps listing nobody.getAttributeFilter(String storedValue) The stored attribute filter as the directory applies it.List<io.meeds.social.people.model.PeopleDirectoryAttributeValue> getAttributeValues(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String attribute, String query, String username, Locale locale) The values an editor can select for an attribute of a People Directory window's filter: a dropdown property's options, or the distinct values the enabled users hold, owner-hidden values excluded, at mostMAX_ATTRIBUTE_VALUES_SUGGESTED.getDirectoryAttributeNames(String storedValue) The names of the profile attributes the directory filters on, which a viewer's advanced filter shows greyed out: the names only, never the values.List<io.meeds.social.people.model.PeopleDirectoryAttribute> getEditorAttributes(String storedValue, Locale locale) The stored attribute filter as the settings drawer shows it: each entry with its values labelled, and flagged when the attribute is no longer available.io.meeds.social.people.model.PeopleDirectoryEditorGroupsgetEditorGroups(String storedValue, String storedGroupsToSet, String username) The stored group filter as the settings drawer shows it to an editor: the groups the editor can select, as chips, whether other groups are applied, never named, for an editor who may set the filter how many, which count againstMAX_GROUPS, and whether stored groups no longer exist or the stored value cannot be read, so that the filter shows as set although no chip remains, and turning it OFF clears it.getGroupFilter(String storedValue, String storedGroupsToSet) The stored group filter as the directory applies it: the ids of the stored groups that still exist.getHeaderTranslations(String storedValue) The stored header as the directory uses it.getManagedGroupIds(String username) intgetPageSize(String storedValue) The stored number of items per page as the directory uses it.List<io.meeds.social.people.model.PeopleDirectoryGroup> getSelectableGroups(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String query, Collection<String> excludedGroupIds, String username) The groups an editor can select for a People Directory window's group filter: any group for a platform administrator, the groups the editor manages otherwise, each matched on its label or its id, ignoring case; at mostMAX_GROUPS_SUGGESTED, the groups the drawer already holds left out before the bound applies.booleanisAttributeFilterToSet(String storedValue) static booleanisDirectoryAttribute(org.exoplatform.social.core.profileproperty.model.ProfilePropertySetting setting) booleanisGroupsToSet(String storedValue) booleanisGuestRestriction(String storedValue) Whether the stored "Guests see only connections and space members" setting restricts guest viewers.normalizeAttributeFilter(String value) Validates a posted attribute filter: a JSON object mapping a profile property name to the values a listed user must hold one of.normalizeGroupFilter(String posted, String stored, String username) Validates a posted group filter and merges it with the stored one, for the editor saving it.normalizeGuestRestriction(String value) Validates a posted "Guests see only connections and space members" setting, stored astrueorfalse.Validates a posted header: a JSON object mapping a language to its label.normalizePageSize(String value) Validates a posted number of items per page.io.meeds.social.people.model.PeopleDirectoryPagesearch(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String storedAttributeFilter, String storedAttributeFilterToSet, String storedGroupFilter, String storedGroupsToSet, String storedGuestRestriction, String query, Map<String, String> viewerAttributes, boolean connectionsOnly, String username, int offset, int limit) One page of the users a People Directory window lists to a viewer: the users matching the window's attribute and group filters and the viewer's own criteria, of all the users or of the viewer's connections.
-
Field Details
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE- See Also:
-
MIN_PAGE_SIZE
public static final int MIN_PAGE_SIZE- See Also:
-
MAX_PAGE_SIZE
public static final int MAX_PAGE_SIZE- See Also:
-
MAX_HEADER_LENGTH
public static final int MAX_HEADER_LENGTH- See Also:
-
EMPTY_HEADER_TRANSLATIONS
- See Also:
-
PAGE_SIZE_OUT_OF_RANGE_MESSAGE
- See Also:
-
HEADER_TRANSLATIONS_INVALID_MESSAGE
- See Also:
-
HEADER_TOO_LONG_MESSAGE
- See Also:
-
MAX_ATTRIBUTES
public static final int MAX_ATTRIBUTES- See Also:
-
MAX_VALUES_PER_ATTRIBUTE
public static final int MAX_VALUES_PER_ATTRIBUTE- See Also:
-
MAX_VALUE_LENGTH
public static final int MAX_VALUE_LENGTH- See Also:
-
MAX_ATTRIBUTE_VALUES_SUGGESTED
public static final int MAX_ATTRIBUTE_VALUES_SUGGESTED- See Also:
-
MAX_LIMIT
public static final int MAX_LIMIT- See Also:
-
EMPTY_JSON_OBJECT
- See Also:
-
UNKNOWN_ATTRIBUTE_MESSAGE
- See Also:
-
ATTRIBUTE_FILTER_INVALID_MESSAGE
- See Also:
-
TOO_MANY_ATTRIBUTES_MESSAGE
- See Also:
-
TOO_MANY_VALUES_MESSAGE
- See Also:
-
VALUE_TOO_LONG_MESSAGE
- See Also:
-
INVALID_RANGE_MESSAGE
- See Also:
-
MAX_GROUPS
public static final int MAX_GROUPS- See Also:
-
MAX_GROUPS_SUGGESTED
public static final int MAX_GROUPS_SUGGESTED- See Also:
-
MAX_GROUP_QUERY_LENGTH
public static final int MAX_GROUP_QUERY_LENGTH- See Also:
-
EMPTY_JSON_ARRAY
- See Also:
-
GROUP_FILTER_INVALID_MESSAGE
- See Also:
-
GROUP_NOT_SELECTABLE_MESSAGE
- See Also:
-
TOO_MANY_GROUPS_MESSAGE
- See Also:
-
userAcl
@Autowired protected org.exoplatform.portal.config.UserACL userAcl -
layoutService
@Autowired protected org.exoplatform.portal.mop.service.LayoutService layoutService -
userPortalConfigService
@Autowired protected org.exoplatform.portal.config.UserPortalConfigService userPortalConfigService -
profilePropertyService
@Autowired protected org.exoplatform.social.core.profileproperty.ProfilePropertyService profilePropertyService -
translationService
@Autowired protected io.meeds.social.translation.service.TranslationService translationService -
identityManager
@Autowired protected org.exoplatform.social.core.manager.IdentityManager identityManager -
relationshipManager
@Autowired protected org.exoplatform.social.core.manager.RelationshipManager relationshipManager -
profileSearchConnector
-
userPermissionService
-
organizationService
@Autowired protected org.exoplatform.services.organization.OrganizationService organizationService -
spaceService
@Autowired protected org.exoplatform.social.core.space.spi.SpaceService spaceService
-
-
Constructor Details
-
PeopleDirectoryService
public PeopleDirectoryService()
-
-
Method Details
-
canEditSettings
public boolean canEditSettings(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String username) Whether a user may change the settings of one People Directory window.The right is bound to the window, never to the page the URL routes to: the portlet-viewer page renders any stored window by its id, so the page of the portal context does not necessarily hold the window. The window is looked up first in the stored layout of that page, whose edit right then applies, then in the layout the portal renders for the site (the meta site's when the site is displayed), whose edit right then applies. A window held by neither, such as a catalogue instance previewed in the portlet editor, has no editable settings.
The edit right is the portal's. On a space page, the members of the page's own space that its edit permission names, as a single
<membership type>:<space group>expression, get it too; an edit permission naming everyone, another group or several groups grants nothing more. On a site layout, the right is the portal's only.- Parameters:
pageKey- the page resolved from the portal context, may be nullsiteKey- the rendering site, may be nullwindowId- the storage id of the window being renderedusername- the user asking- Returns:
- true when the user may store the window's settings
-
canViewDirectory
public boolean canViewDirectory(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String username) Whether a user may see the users a People Directory window lists: the view right of the page, or of the rendered site layout, that holds the window, found ascanEditSettings(PageKey, SiteKey, String, String)finds it.- Parameters:
pageKey- the page resolved from the portal context, may be nullsiteKey- the rendering site, may be nullwindowId- the storage id of the windowusername- the user asking- Returns:
- true when the user may list the directory
-
normalizeAttributeFilter
Validates a posted attribute filter: a JSON object mapping a profile property name to the values a listed user must hold one of. An empty object means the directory is not filtered by attribute.- Parameters:
value- the posted value- Returns:
- the value to store, re-serialized, each attribute's values de-duplicated
- Throws:
IllegalArgumentException- withUNKNOWN_ATTRIBUTE_MESSAGEwhen a name is not the name of a directory attribute (a visible, active, top-level setting, other than email),TOO_MANY_ATTRIBUTES_MESSAGE,TOO_MANY_VALUES_MESSAGEorVALUE_TOO_LONG_MESSAGEbeyond a bound, andATTRIBUTE_FILTER_INVALID_MESSAGEwhen the value is not such an object, or an attribute has no value or a value that is not a non-blank text
-
getAttributeFilter
The stored attribute filter as the directory applies it. A value that failsnormalizeAttributeFilter(String), because another writer of the window's preferences stored it or because an attribute is no longer a directory attribute, gives null: the directory then lists nobody.- Parameters:
storedValue- the stored preference value, may be null- Returns:
- the values per attribute, empty when the directory is not filtered by attribute, null when it lists nobody
-
getDirectoryAttributeNames
The names of the profile attributes the directory filters on, which a viewer's advanced filter shows greyed out: the names only, never the values. A stored filter the directory cannot read gives none.- Parameters:
storedValue- the stored preference value, may be null- Returns:
- the attribute names, in their stored order
-
getEditorAttributes
public List<io.meeds.social.people.model.PeopleDirectoryAttribute> getEditorAttributes(String storedValue, Locale locale) The stored attribute filter as the settings drawer shows it: each entry with its values labelled, and flagged when the attribute is no longer available. Values the directory refuses are left to the drawer to flag; an entry stored with an invalid shape comes back with no value.- Parameters:
storedValue- the stored preference value, may be nulllocale- the editor's language, for the option labels- Returns:
- the attributes, in their stored order
-
search
public io.meeds.social.people.model.PeopleDirectoryPage search(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String storedAttributeFilter, String storedAttributeFilterToSet, String storedGroupFilter, String storedGroupsToSet, String storedGuestRestriction, String query, Map<String, String> viewerAttributes, boolean connectionsOnly, String username, int offset, int limit) throws IllegalAccessExceptionOne page of the users a People Directory window lists to a viewer: the users matching the window's attribute and group filters and the viewer's own criteria, of all the users or of the viewer's connections. The directory's filter is read from the window's stored preferences, never from the request; the viewer's criteria on an attribute the directory filters are ignored, since the directory wins.- Parameters:
pageKey- the page resolved from the portal context, may be nullsiteKey- the rendering site, may be nullwindowId- the storage id of the windowstoredAttributeFilter- the window's stored attribute filterstoredAttributeFilterToSet- the window's stored marker of a directory made from a template, whose attribute filter must be set again (isAttributeFilterToSet(String)): it then lists nobodystoredGroupFilter- the window's stored group filterstoredGroupsToSet- the window's stored marker of a directory whose groups must be set again (isGroupsToSet(String)): it then lists nobodystoredGuestRestriction- the window's stored "Guests see only connections and space members" setting: any value butfalse, a missing one included, restricts a guest viewer to the users whose profile they can open (isGuestRestriction(String))query- the viewer's name search, may be blankviewerAttributes- the viewer's advanced filter, one text per attribute, may be nullconnectionsOnly- whether only the viewer's connections are listedusername- the vieweroffset- the index of the first userlimit- the number of users, from 1 toMAX_LIMIT- Returns:
- the users of the page and their total number
- Throws:
IllegalAccessException- when the viewer may not view the page or site holding the windowIllegalArgumentException- withUNKNOWN_ATTRIBUTE_MESSAGEwhen a viewer attribute is not a visible, active, top-level setting, orINVALID_RANGE_MESSAGEfor an offset or a limit out of range
-
canSetFilterOptions
Whether a user may change the filter options of a People Directory window (the guest restriction, the attribute filter and the group filter): any user but an external one, a member of/platform/externals, who keeps the display options only, whatever grants them the edit right.- Parameters:
username- the user asking, may be null- Returns:
- true when the filter options are offered to the user
-
canSetGroupFilter
Whether a user may set the group filter of a People Directory window: a user who may set its filter options (canSetFilterOptions(String)) and is a platform administrator, or a manager of at least one group, space or organizational unit (seegetManagedGroupIds(String)).- Parameters:
username- the user asking, may be null- Returns:
- true when the group filter is offered to the user
-
getSelectableGroups
public List<io.meeds.social.people.model.PeopleDirectoryGroup> getSelectableGroups(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String query, Collection<String> excludedGroupIds, String username) throws IllegalAccessException The groups an editor can select for a People Directory window's group filter: any group for a platform administrator, the groups the editor manages otherwise, each matched on its label or its id, ignoring case; at mostMAX_GROUPS_SUGGESTED, the groups the drawer already holds left out before the bound applies.- Parameters:
pageKey- the page resolved from the portal context, may be nullsiteKey- the rendering site, may be nullwindowId- the storage id of the windowquery- a text the groups must contain, may be blankexcludedGroupIds- the groups the drawer already holds, at mostMAX_GROUPSof them read, may be nullusername- the editor- Returns:
- the groups, labelled
- Throws:
IllegalAccessException- when the user may not edit the window's settings or may not set its group filter
-
normalizeGroupFilter
Validates a posted group filter and merges it with the stored one, for the editor saving it. The filter of an editor who may not set it is kept as stored, whatever is posted. For an editor who may, the stored groups the editor cannot select stay applied, and the posted ones replace the others; an empty post turns the editor's part of the filter OFF. Either way the stored groups that no longer exist are dropped. A space's group is stored with its space's id, resolved here, never posted.- Parameters:
posted- the posted value: a JSON array of group ids,[]when the editor's group filter is OFFstored- the stored preference value, may be nullusername- the editor- Returns:
- the value to store: a JSON array of
{groupId, spaceId} - Throws:
IllegalArgumentException- withGROUP_FILTER_INVALID_MESSAGEwhen the post is not such an array,GROUP_NOT_SELECTABLE_MESSAGEwhen a posted group is not one the editor can select, orTOO_MANY_GROUPS_MESSAGEbeyondMAX_GROUPSexisting groupsIllegalStateException- when a stored group the editor cannot select cannot be looked up, never for an administrator: it is kept by refusing the save
-
getGroupFilter
The stored group filter as the directory applies it: the ids of the stored groups that still exist. A stored group that no longer exists, or a space's group whose space was deleted, matches nobody, and a value that is not a stored group filter lists nobody. A window carrying the marker of a directory whose groups must be set again (isGroupsToSet(String)), a directory made from a template, lists nobody until a user who may set groups saves its group filter.- Parameters:
storedValue- the stored group filter, may be nullstoredGroupsToSet- the stored marker, may be null- Returns:
- null when the directory is not filtered by group, the ids of the groups a listed user must belong to one of otherwise, empty when it lists nobody
-
getEditorGroups
public io.meeds.social.people.model.PeopleDirectoryEditorGroups getEditorGroups(String storedValue, String storedGroupsToSet, String username) The stored group filter as the settings drawer shows it to an editor: the groups the editor can select, as chips, whether other groups are applied, never named, for an editor who may set the filter how many, which count againstMAX_GROUPS, and whether stored groups no longer exist or the stored value cannot be read, so that the filter shows as set although no chip remains, and turning it OFF clears it. The marker of a directory whose groups must be set again (isGroupsToSet(String)) shows to an editor who may set groups as stored groups that no longer exist. Every editor, whether or not they may set groups, is told when the directory misses groups, never which.- Parameters:
storedValue- the stored group filter, may be nullstoredGroupsToSet- the stored marker, may be nullusername- the editor- Returns:
- the editor's groups
- Throws:
IllegalStateException- when a stored group cannot be looked up: the drawer then gets no group filter to post
-
isGroupsToSet
- Parameters:
storedValue- the stored marker of a directory whose groups must be set again, may be null- Returns:
- whether the marker is set: a directory made from a template carries it, since a template does not keep the groups of its directories
-
clearsGroupsToSet
Whether a save clears the marker of a directory whose groups must be set again: only a save by an editor who may set groups that posts a group filter, groups or the filter OFF, clears it; any other save keeps it, so that the directory keeps listing nobody.- Parameters:
postedGroupFilter- the posted group filter, null when none is postedusername- the editor saving- Returns:
- true when the marker is to be removed
-
isAttributeFilterToSet
- Parameters:
storedValue- the stored marker of a directory whose attribute filter must be set again, may be null- Returns:
- whether the marker is set: a directory made from a template that filtered by profile attribute carries it, since a template does not keep the attribute filter of its directories
-
clearsAttributeFilterToSet
Whether a save of the app's settings clears the marker of a directory whose attribute filter must be set again: only a save by an editor who may set the filter options that posts an attribute filter clears it; any other save keeps it, so that the directory keeps listing nobody. The marker is not a protected preference: a page editor who rewrites the window's preferences through the layout API can drop it, as they can add an unfiltered directory to the page anyway.- Parameters:
postedAttributeFilter- the posted attribute filter, null when none is postedusername- the editor saving- Returns:
- true when the marker is to be removed
-
getManagedGroupIds
-
getAttributeValues
public List<io.meeds.social.people.model.PeopleDirectoryAttributeValue> getAttributeValues(org.exoplatform.portal.mop.page.PageKey pageKey, org.exoplatform.portal.mop.SiteKey siteKey, String windowId, String attribute, String query, String username, Locale locale) throws IllegalAccessException The values an editor can select for an attribute of a People Directory window's filter: a dropdown property's options, or the distinct values the enabled users hold, owner-hidden values excluded, at mostMAX_ATTRIBUTE_VALUES_SUGGESTED.- Parameters:
pageKey- the page resolved from the portal context, may be nullsiteKey- the rendering site, may be nullwindowId- the storage id of the windowattribute- the profile property namequery- a text the values must contain, may be blankusername- the editorlocale- the editor's language, for the option labels- Returns:
- the values
- Throws:
IllegalAccessException- when the user may not edit the window's settings or may not set its filter options: the values are those of all users, an external user's visible ones or notIllegalArgumentException- withUNKNOWN_ATTRIBUTE_MESSAGEwhen the attribute is not a directory attribute
-
isDirectoryAttribute
public static boolean isDirectoryAttribute(org.exoplatform.social.core.profileproperty.model.ProfilePropertySetting setting) - Parameters:
setting- a profile property setting, may be null- Returns:
- whether a directory can filter on the property: a visible, active, top-level setting, other than email, whose value stays indexed for the name search when its owner hides it
-
normalizePageSize
Validates a posted number of items per page.- Parameters:
value- the posted value- Returns:
- the value to store
- Throws:
IllegalArgumentException- withPAGE_SIZE_OUT_OF_RANGE_MESSAGEwhen the value is not an integer fromMIN_PAGE_SIZEtoMAX_PAGE_SIZE
-
normalizeHeaderTranslations
Validates a posted header: a JSON object mapping a language to its label. Blank labels are dropped, so an empty result means the header is OFF.- Parameters:
value- the posted value- Returns:
- the value to store, re-serialized
- Throws:
IllegalArgumentException- withHEADER_TRANSLATIONS_INVALID_MESSAGEwhen the value is not such an object, orHEADER_TOO_LONG_MESSAGEwhen a label exceedsMAX_HEADER_LENGTHcharacters
-
isGuestRestriction
Whether the stored "Guests see only connections and space members" setting restricts guest viewers. It fails closed: any value but the literalfalse, a missing or unreadable one included, is ON.- Parameters:
storedValue- the stored preference value, may be null- Returns:
- true unless the setting is OFF
-
normalizeGuestRestriction
-
getPageSize
The stored number of items per page as the directory uses it. A value stored by another writer of the window's preferences (the layout editor stores any value) is brought back within the bounds; a missing or unreadable one gives the default.- Parameters:
storedValue- the stored preference value, may be null- Returns:
- a page size from
MIN_PAGE_SIZEtoMAX_PAGE_SIZE
-
getHeaderTranslations
The stored header as the directory uses it. A value another writer stored and that is not valid is read as no header.- Parameters:
storedValue- the stored preference value, may be null- Returns:
- a valid JSON object of language to label,
{}when none
-