Package org.cyclos.impl.users
Class GroupsHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.users.GroupsHandlerImpl
-
- All Implemented Interfaces:
BasicGroupListViewFactoryAccessor,GroupListViewFactoryAccessor,GroupsHandler,GroupsHandlerInternal
@Component public class GroupsHandlerImpl extends BaseNetworkedHandlerImpl implements GroupsHandlerInternal
Implementation forGroupsHandler.
WARNING: All methods returning a collection of (basic)groups are to be implemented in this class (and NOT in GroupServiceImpl). If needed, the implementation is delegated to SessionData. Rule of thumb for placing implementations of group retrieving methods:- filtering away disabled groups is always done in GroupsHandler and never in SessionData.
- Other filtering is preferable done in GroupsHandler.
- Cases in which the returned result depends on the type of the Session (User, System, Guest), are (logically) placed in SessionData.
- Queries are placed in SessionData if they are simple and don't filter on disabled groups. More complicated filtering via the query is done in GroupsHandler, except when the result depends on the Session type.
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.impl.users.GroupsHandler
VO_MAPPINGS
-
-
Constructor Summary
Constructors Constructor Description GroupsHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GroupListViewFactoryImplaccessibles()Returns a container for theGroupList.ACCESSIBLEgroup listGroupListViewFactoryImplads()Returns a container for theGroupList.ADSgroup list without applying the group visibility.GroupListViewFactoryall()Only for administrators or system it will include disabled groups, for members it returns the same asBasicGroupListViewFactoryAccessor.accessibles().GroupListViewFactoryImpldirectory()Returns a view factory for theGroupList.DIRECTORYgroup list.Set<Group>flatten(Collection<? extends BasicGroup> basicGroups)Expands the given groups / group sets into a set of groups.Set<Group>flattenVOs(Collection<? extends BasicGroupVO> basicGroupVOs)SeeGroupsHandler.flatten(Collection), but takes the VO's as input.Set<Group>flattenVOs(Collection<? extends BasicGroupVO> basicGroupVOs, boolean includeDisabledGroups)SeeGroupsHandler.flatten(Collection), but takes the VO's as input, and includes disabled groups depending on the boolean parameter.Set<BasicGroup>getAccessibleBasicGroups(boolean overBrokered, BasicGroup basicGroup, ProductsAccessor products)Gets accessible basic groups for the given group and products.Set<AdminGroup>getAccessibleGlobalGroups()Returns the accessible admin global groups the logged user can access.Set<UserGroup>getAccessibleUserGroups(User user)Returns the accessible groups with type=USER and enabled=true for the given userConversionHandlergetConversionHandler()Returns the unique conversion handler present in the context (as a utility for theGroupListView)Set<BasicGroupVO>getDefaultGroupFilter(boolean overBrokered, Collection<? extends BasicGroupVO> availableGroups)Returns the groups used by default for searches, if any, contained in the available for search collectionSet<BasicGroup>getDefaultGroupFilter(boolean overBrokered, BasicGroup group, ProductsAccessor products)Returns the groups used by default for searches, if any, for the given group and accessorGroupVisibilitygetGroupVisibility(boolean overBrokered)Returns theGroupVisibilityfor the current user.GroupVisibilitygetGroupVisibility(ProductsAccessor accessor, boolean overBrokered)Returns theGroupVisibilityin the given accessor or the one for the current user when null.List<InitialGroupVO>getPossiblePublicInitialGroups()Returns the groups either a public user may use to register himself, or a broker to register a new memberSet<Group>getPossibleRegistrationGroups(boolean onlyUserGroups, boolean asMember)Returns the possible groups for registering new users for the logged user: if admin: all visible groups if admin products allow registration (Permission.USERS_REGISTER). if broker: depends on the flag asMember: if true then all groups for registration according to the member products, otherwise all groups for registration according to the broker products.List<InitialGroupVO>getPossibleRegistrationInitialGroups(boolean asMember)Same as {@link #getPossibleRegistrationGroups(false, boolean)} but in case of a broker registering "as member" or a member the name and description are those set for registration.Set<BasicGroup>getSearchOnGroups(boolean overBrokered, BasicGroup group, ProductsAccessor products)Returns the groups a user can search other users on with the given group and productsSet<BasicGroup>getUserDirectoryOnGroups(BasicGroup group, ProductsAccessor products)Returns the groups a user can view on the directory (map) with the given group and productsSet<BasicGroup>getViewProfileOnGroups()Returns the groups the logged user can view profile of usersSet<BasicGroup>getViewProfileOnGroups(BasicGroup group, ProductsAccessor products)Returns the groups a user view profile with the given group and productsvoidinitialize()GroupListViewFactorymenu()Returns a view factory for theGroupList.MENUgroup list.List<BasicGroupVO>sortHierarchy(Collection<? extends BasicGroup> groups)Returns a sorted list with the groups hierarchically organizedGroupListViewFactoryImplusers()Returns a view factory for theGroupList.USERSgroup list.GroupListViewFactoryviewFactory(Collection<? extends BasicGroup> basicGroups)Return a view factory for the given set of basic groups.GroupListViewFactoryviewFactory(GroupList list)Returns a view factory for working with brokeredMembers = false and without applying group visibility.GroupListViewFactoryAccessorvisibles()This method must be used to send the available groups to use as filter (e.g in a search data) and must used in conjunction withGroupListView.check(Collection)to check the selected groups in the corresponding search.
It applies theGroupVisibilitybefore returning the groups (the other factory methods (BasicGroupListViewFactoryAccessor.accessibles(),GroupListViewFactoryAccessor.ads(), etc) don't).
For examples how to use it please search for references to this method.
Guests hasGroupVisibility.NONEas visibility then a factory returning empty views is returned (never null) and administrators hasGroupVisibility.GROUP.-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
accessibles
public GroupListViewFactoryImpl accessibles()
Returns a container for theGroupList.ACCESSIBLEgroup list- Specified by:
accessiblesin interfaceBasicGroupListViewFactoryAccessor
-
ads
public GroupListViewFactoryImpl ads()
Returns a container for theGroupList.ADSgroup list without applying the group visibility.- Specified by:
adsin interfaceGroupListViewFactoryAccessor
-
all
public GroupListViewFactory all()
Description copied from interface:GroupsHandlerOnly for administrators or system it will include disabled groups, for members it returns the same asBasicGroupListViewFactoryAccessor.accessibles(). This method must be used if we want to include the disabled basic groups in the views returned by the factory. We directly return a factory because only the accessible groups has support to include disabled.- Specified by:
allin interfaceGroupsHandler
-
directory
public GroupListViewFactoryImpl directory()
Description copied from interface:GroupListViewFactoryAccessorReturns a view factory for theGroupList.DIRECTORYgroup list.- Specified by:
directoryin interfaceGroupListViewFactoryAccessor
-
flatten
public Set<Group> flatten(Collection<? extends BasicGroup> basicGroups)
Description copied from interface:GroupsHandlerExpands the given groups / group sets into a set of groups. Of each encountered groupSet, all the belonging groups are added. The groupset itself is left out.
Disabled groups are included if they are explicitly included in the input collection. If the disabled group belongs to a groupset, and this groupset is included in the input collection (without the disabled group itself being explicitly included), then the disabled group is NOT included in the result. So if you want to include any disabled group, be sure to add it explicitly in the input parameter.- Specified by:
flattenin interfaceGroupsHandler
-
flattenVOs
public Set<Group> flattenVOs(Collection<? extends BasicGroupVO> basicGroupVOs)
Description copied from interface:GroupsHandlerSeeGroupsHandler.flatten(Collection), but takes the VO's as input.- Specified by:
flattenVOsin interfaceGroupsHandler
-
flattenVOs
public Set<Group> flattenVOs(Collection<? extends BasicGroupVO> basicGroupVOs, boolean includeDisabledGroups)
Description copied from interface:GroupsHandlerSeeGroupsHandler.flatten(Collection), but takes the VO's as input, and includes disabled groups depending on the boolean parameter.- Specified by:
flattenVOsin interfaceGroupsHandlerincludeDisabledGroups- boolean, if false, the behavior is as flattenVOs(Collection). If true, the disabled groups are included if they are part of a groupSet which is selected, no matter if they are explicitly selected or not.
-
getAccessibleBasicGroups
public Set<BasicGroup> getAccessibleBasicGroups(boolean overBrokered, BasicGroup basicGroup, ProductsAccessor products)
Description copied from interface:GroupsHandlerInternalGets accessible basic groups for the given group and products. Groupsets are included, but groups with enabled=false are excluded. If groupsets are included, their contained groups are automatically also included.- Specified by:
getAccessibleBasicGroupsin interfaceGroupsHandlerInternal
-
getAccessibleGlobalGroups
public Set<AdminGroup> getAccessibleGlobalGroups()
Description copied from interface:GroupsHandlerReturns the accessible admin global groups the logged user can access. If the logged user is not global then an empty set is returned. Otherwise, if it has theRole.GLOBAL_ADMINrole then returns all global groups, it not, returns a set containing its own group.- Specified by:
getAccessibleGlobalGroupsin interfaceGroupsHandler
-
getAccessibleUserGroups
public Set<UserGroup> getAccessibleUserGroups(User user)
Description copied from interface:GroupsHandlerReturns the accessible groups with type=USER and enabled=true for the given user- Specified by:
getAccessibleUserGroupsin interfaceGroupsHandler
-
getConversionHandler
public ConversionHandler getConversionHandler()
Description copied from interface:GroupsHandlerInternalReturns the unique conversion handler present in the context (as a utility for theGroupListView)- Specified by:
getConversionHandlerin interfaceGroupsHandlerInternal
-
getDefaultGroupFilter
public Set<BasicGroup> getDefaultGroupFilter(boolean overBrokered, BasicGroup group, ProductsAccessor products)
Description copied from interface:GroupsHandlerInternalReturns the groups used by default for searches, if any, for the given group and accessor- Specified by:
getDefaultGroupFilterin interfaceGroupsHandlerInternal
-
getDefaultGroupFilter
public Set<BasicGroupVO> getDefaultGroupFilter(boolean overBrokered, Collection<? extends BasicGroupVO> availableGroups)
Description copied from interface:GroupsHandlerInternalReturns the groups used by default for searches, if any, contained in the available for search collection- Specified by:
getDefaultGroupFilterin interfaceGroupsHandlerInternal
-
getGroupVisibility
public GroupVisibility getGroupVisibility(boolean overBrokered)
Description copied from interface:GroupsHandlerReturns theGroupVisibilityfor the current user. As broker we must have the same or bigger visibility than as member, so when brokering, it is used as base-line the visibility set in member products.- Specified by:
getGroupVisibilityin interfaceGroupsHandler
-
getGroupVisibility
public GroupVisibility getGroupVisibility(ProductsAccessor accessor, boolean overBrokered)
Description copied from interface:GroupsHandlerInternalReturns theGroupVisibilityin the given accessor or the one for the current user when null. As broker we must have the same or bigger visibility than as member, so when brokering, it is used as base-line the visibility set in member products.- Specified by:
getGroupVisibilityin interfaceGroupsHandlerInternal
-
getPossiblePublicInitialGroups
public List<InitialGroupVO> getPossiblePublicInitialGroups()
Description copied from interface:GroupsHandlerReturns the groups either a public user may use to register himself, or a broker to register a new member- Specified by:
getPossiblePublicInitialGroupsin interfaceGroupsHandler
-
getPossibleRegistrationGroups
public Set<Group> getPossibleRegistrationGroups(boolean onlyUserGroups, boolean asMember)
Description copied from interface:GroupsHandlerReturns the possible groups for registering new users for the logged user:- if admin: all visible groups if admin products allow registration (Permission.USERS_REGISTER).
- if broker: depends on the flag asMember: if true then all groups for registration according to the member products, otherwise all groups for registration according to the broker products. In both cases the groups are filtered by the accessible groups.
- if member / operator: then all groups for registration according to the member products filtered by the accessible groups.
- Specified by:
getPossibleRegistrationGroupsin interfaceGroupsHandler- Parameters:
onlyUserGroups- if true then only user groups will be returned.asMember- only used in case of the logged user is a broker.
-
getPossibleRegistrationInitialGroups
public List<InitialGroupVO> getPossibleRegistrationInitialGroups(boolean asMember)
Description copied from interface:GroupsHandlerSame as {@link #getPossibleRegistrationGroups(false, boolean)} but in case of a broker registering "as member" or a member the name and description are those set for registration.- Specified by:
getPossibleRegistrationInitialGroupsin interfaceGroupsHandler
-
getSearchOnGroups
public Set<BasicGroup> getSearchOnGroups(boolean overBrokered, BasicGroup group, ProductsAccessor products)
Description copied from interface:GroupsHandlerInternalReturns the groups a user can search other users on with the given group and products- Specified by:
getSearchOnGroupsin interfaceGroupsHandlerInternal
-
getUserDirectoryOnGroups
public Set<BasicGroup> getUserDirectoryOnGroups(BasicGroup group, ProductsAccessor products)
Description copied from interface:GroupsHandlerInternalReturns the groups a user can view on the directory (map) with the given group and products- Specified by:
getUserDirectoryOnGroupsin interfaceGroupsHandlerInternal
-
getViewProfileOnGroups
public Set<BasicGroup> getViewProfileOnGroups()
Description copied from interface:GroupsHandlerReturns the groups the logged user can view profile of users- Specified by:
getViewProfileOnGroupsin interfaceGroupsHandler
-
getViewProfileOnGroups
public Set<BasicGroup> getViewProfileOnGroups(BasicGroup group, ProductsAccessor products)
Description copied from interface:GroupsHandlerInternalReturns the groups a user view profile with the given group and products- Specified by:
getViewProfileOnGroupsin interfaceGroupsHandlerInternal
-
initialize
@PostConstruct public void initialize()
-
menu
public GroupListViewFactory menu()
Description copied from interface:GroupListViewFactoryAccessorReturns a view factory for theGroupList.MENUgroup list.- Specified by:
menuin interfaceGroupListViewFactoryAccessor
-
sortHierarchy
public List<BasicGroupVO> sortHierarchy(Collection<? extends BasicGroup> groups)
Description copied from interface:GroupsHandlerInternalReturns a sorted list with the groups hierarchically organized- Specified by:
sortHierarchyin interfaceGroupsHandlerInternal
-
users
public GroupListViewFactoryImpl users()
Description copied from interface:GroupListViewFactoryAccessorReturns a view factory for theGroupList.USERSgroup list.- Specified by:
usersin interfaceGroupListViewFactoryAccessor
-
viewFactory
public GroupListViewFactory viewFactory(Collection<? extends BasicGroup> basicGroups)
Description copied from interface:GroupsHandlerReturn a view factory for the given set of basic groups.- Specified by:
viewFactoryin interfaceGroupsHandler
-
viewFactory
public GroupListViewFactory viewFactory(GroupList list)
Description copied from interface:GroupsHandlerReturns a view factory for working with brokeredMembers = false and without applying group visibility.- Specified by:
viewFactoryin interfaceGroupsHandler
-
visibles
public GroupListViewFactoryAccessor visibles()
Description copied from interface:GroupsHandlerThis method must be used to send the available groups to use as filter (e.g in a search data) and must used in conjunction withGroupListView.check(Collection)to check the selected groups in the corresponding search.
It applies theGroupVisibilitybefore returning the groups (the other factory methods (BasicGroupListViewFactoryAccessor.accessibles(),GroupListViewFactoryAccessor.ads(), etc) don't).
For examples how to use it please search for references to this method.
Guests hasGroupVisibility.NONEas visibility then a factory returning empty views is returned (never null) and administrators hasGroupVisibility.GROUP.- Specified by:
visiblesin interfaceGroupsHandler
-
-