Interface SearchRestrictionService

All Known Implementing Classes:
DefaultSearchRestrictionService

public interface SearchRestrictionService

Provides methods for managing persisted search restrictions based on SearchRestrictionModel as well on dynamic search restrictions which are stored directly in the session.

Please notice that any search restrictions are ignored if current logged user is admin or any other user with admin rights.

Spring Bean ID:
searchRestrictionService
  • Method Details

    • addSessionSearchRestrictions

      void addSessionSearchRestrictions(Collection<SessionSearchRestriction> restrictions)
      Adds session search restrictions to current session context. If currently there are some session search restrictions, passed as parameter collection of restrictions will be added to current one.

      Example usage:

       final ComposedTypeModel restrictedType = typeService.getComposedTypeForClass(LanguageModel.class);
       final SessionSearchRestriction restriction = new SessionSearchRestriction("someUniqueCode", "{active} IS TRUE", restrictedType);
       final Collection<SessionSearchRestriction> restrictions = new ArrayList<SessionSearchRestriction>();
       restrictions.add(restriction);
      
       searchRestrictionService.addSessionSearchRestrictions(restrictions);
       
      Parameters:
      restrictions - the restrictions collection to add to session.
    • addSessionSearchRestrictions

      void addSessionSearchRestrictions(SessionSearchRestriction... restrictions)
      Adds session search restrictions to current session context. If currently there are some session search restrictions, passed as parameter restriction(s) will be added to current one.

      Example usage:

       final ComposedTypeModel restrictedType = typeService.getComposedTypeForClass(LanguageModel.class);
       final SessionSearchRestriction restriction1 = new SessionSearchRestriction("someUniqueCode1", "{active} IS TRUE", restrictedType);
       final SessionSearchRestriction restriction2 = new SessionSearchRestriction("someUniqueCode2", "{foo}={bar}", restrictedType);
      
       searchRestrictionService.addSessionSearchRestrictions(restriction1, restriction2);
       
      Parameters:
      restrictions - the restrictions to add
    • clearSessionSearchRestrictions

      void clearSessionSearchRestrictions()
      Clear session search restrictions in current session context.
    • disableSearchRestrictions

      void disableSearchRestrictions()
      Disable search restrictions in current session context.
    • enableSearchRestrictions

      void enableSearchRestrictions()
      Enable search restrictions in current session context.
    • getActiveSearchRestrictions

      Collection<SearchRestrictionModel> getActiveSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, Collection<ComposedTypeModel> types)
      Gets only active search restrictions for given ComposedTypeModel.
      Parameters:
      principal - the principal for which restrictions will be searched
      includePrincipalGroups - determines whether include principal groups in search
      types - Collection of ComposedTypeModel objects for which restriction will be obtained.
      Returns:
      the active search restrictions collection.
    • getInactiveSearchRestrictions

      Collection<SearchRestrictionModel> getInactiveSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, Collection<ComposedTypeModel> types)
      Gets only inactive search restrictions for given ComposedTypeModel.
      Parameters:
      principal - the principal for which restrictions will be searched
      includePrincipalGroups - determines whether include principal groups in search
      types - Collection of ComposedTypeModel objects for which restriction will be obtained.
      Returns:
      the active search restrictions collection.
    • getSearchRestrictions

      Collection<SearchRestrictionModel> getSearchRestrictions(PrincipalModel principal, boolean includePrincipalGroups, Collection<ComposedTypeModel> types)
      Gets all (active and inactive) search restrictions for given ComposedTypeModel.
      Parameters:
      principal - the principal for which restrictions will be searched
      includePrincipalGroups - determines whether include principal groups in search
      types - Collection of ComposedTypeModel objects for which restriction will be obtained.
      Returns:
      the all search restrictions.
    • getSearchRestrictionsForType

      Collection<SearchRestrictionModel> getSearchRestrictionsForType(ComposedTypeModel type)
      Gets all search restrictions for type.
      Parameters:
      type - the type
      Returns:
      the search restrictions for type
    • getSessionSearchRestrictions

      Collection<SessionSearchRestriction> getSessionSearchRestrictions()
      Gets the session search restrictions from current session context.
      Returns:
      the session search restrictions collection.
    • getSessionSearchRestrictions

      Collection<SessionSearchRestriction> getSessionSearchRestrictions(ComposedTypeModel type)
      Gets the session search restrictions from current session context for particular ComposedTypeModel object.
      Parameters:
      type - the type for which which restriction will be obtained.
      Returns:
      the session search restrictions collection.
    • hasRestrictions

      boolean hasRestrictions(PrincipalModel principal, boolean includePrincipalGroups, ComposedTypeModel type)
      Checks whether type has search restrictions (session and persisted).
      Parameters:
      principal - the principal for which restrictions will be searched
      includePrincipalGroups - determines whether include principal groups in search
      type - the type for which check will be triggered.
      Returns:
      true if has restrictions, false otherwise.
    • isSearchRestrictionsEnabled

      boolean isSearchRestrictionsEnabled()
      Checks if search restrictions feature in current session context is enabled.
      Returns:
      true is search restrictions are enabled
    • removeSessionSearchRestrictions

      void removeSessionSearchRestrictions(Collection<SessionSearchRestriction> restrictions)
      Remove session search restrictions from current session context.
      Parameters:
      restrictions - the restrictions collection to remove from session.
    • removalAllSessionSearchRestrictions

      void removalAllSessionSearchRestrictions()
      Removes all session-scoped search restrictions from the current session.