Interface ProfileRepository

  • All Superinterfaces:
    org.craftercms.commons.mongo.CrudRepository<Profile>
    All Known Implementing Classes:
    ProfileRepositoryImpl

    public interface ProfileRepository
    extends org.craftercms.commons.mongo.CrudRepository<Profile>
    DB repository for Profiles.
    Author:
    avasquez
    • Method Detail

      • findOneByQuery

        Profile findOneByQuery​(String query,
                               String... attributesToReturn)
                        throws org.craftercms.commons.mongo.MongoDataException
        Returns the single profile that matches the specified query
        Parameters:
        query - the Mongo query used to search for the profiles
        attributesToReturn - the names of the attributes to return with the profile (null to return all attributes)
        Returns:
        the profile, or null if not found
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • findById

        Profile findById​(String id,
                         String... attributesToReturn)
                  throws org.craftercms.commons.mongo.MongoDataException
        Returns the profile with the given ID.
        Parameters:
        id - the profile's ID
        attributesToReturn - the name of the attributes to return (null to return all)
        Returns:
        the profile found, or null if not found
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • findByTenantAndUsername

        Profile findByTenantAndUsername​(String tenantName,
                                        String username,
                                        String... attributesToReturn)
                                 throws org.craftercms.commons.mongo.MongoDataException
        Returns the profile for the given tenant name and username.
        Parameters:
        tenantName - the tenant's name
        username - the profile's username
        attributesToReturn - the name of the attributes to return (null to return all)
        Returns:
        the profile found, or null if not found
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • findByQuery

        Iterable<Profile> findByQuery​(String query,
                                      String sortBy,
                                      SortOrder sortOrder,
                                      Integer start,
                                      Integer count,
                                      String... attributesToReturn)
                               throws org.craftercms.commons.mongo.MongoDataException
        Returns the profiles that match the specified query.
        Parameters:
        query - the Mongo query used to search for the profiles. Must not contain the $where operator, the tenant's name (already specified) or any non-readable attribute by the application
        attributesToReturn - the names of the attributes to return with the profile (null to return all attributes)
        Returns:
        the list of profiles found, or null if none match the query
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • findByIds

        Iterable<Profile> findByIds​(List<String> ids,
                                    String sortBy,
                                    SortOrder sortOrder,
                                    String... attributesToReturn)
                             throws org.craftercms.commons.mongo.MongoDataException
        Returns the profiles with the given IDs.
        Parameters:
        ids - the IDs of the profiles to return
        sortBy - profile attribute to sort the list by (optional)
        sortOrder - the sort order (either ASC or DESC) (optional)
        attributesToReturn - the name of the attributes to return (null to return all)
        Returns:
        the profiles for the given IDs
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • findRange

        Iterable<Profile> findRange​(String tenantName,
                                    String sortBy,
                                    SortOrder sortOrder,
                                    Integer start,
                                    Integer count,
                                    String... attributesToReturn)
                             throws org.craftercms.commons.mongo.MongoDataException
        Returns a range of profiles for the given tenant.
        Parameters:
        tenantName - the tenant's name
        sortBy - profile attribute to sort the list by (optional)
        sortOrder - the sort order (either ASC or DESC) (optional)
        start - from the entire list of results, the position where the actual results should start (useful for pagination) (optional)
        count - the number of profiles to return (optional)
        attributesToReturn - the names of the attributes to return for each profile (null to return all)
        Returns:
        the range of profiles
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • findByTenantAndRole

        Iterable<Profile> findByTenantAndRole​(String tenantName,
                                              String role,
                                              String sortBy,
                                              SortOrder sortOrder,
                                              String... attributesToReturn)
                                       throws org.craftercms.commons.mongo.MongoDataException
        Returns the profiles with the given roles for the given tenant.
        Parameters:
        tenantName - the tenant's name
        role - the role the profile's must have
        sortBy - profile attribute to sort the list by (optional)
        sortOrder - the sort order (either ASC or DESC) (optional)
        attributesToReturn - the names of the attributes to return for each profile (null to return all)
        Returns:
        the matching profiles
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • findByTenantAndExistingAttribute

        Iterable<Profile> findByTenantAndExistingAttribute​(String tenantName,
                                                           String attributeName,
                                                           String sortBy,
                                                           SortOrder sortOrder,
                                                           String... attributesToReturn)
                                                    throws org.craftercms.commons.mongo.MongoDataException
        Returns the profiles that have the given attribute, with any value, for the given tenant.
        Parameters:
        tenantName - the tenant's name
        attributeName - the name of the attribute profiles must have
        sortBy - profile attribute to sort the list by (optional)
        sortOrder - the sort order (either ASC or DESC) (optional)
        attributesToReturn - the names of the attributes to return for each profile (null to return all)
        Returns:
        the matching profiles
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • findByTenantAndAttributeValue

        Iterable<Profile> findByTenantAndAttributeValue​(String tenantName,
                                                        String attributeName,
                                                        String attributeValue,
                                                        String sortBy,
                                                        SortOrder sortOrder,
                                                        String... attributesToReturn)
                                                 throws org.craftercms.commons.mongo.MongoDataException
        Returns the profiles that have the given attribute with the given value for the given tenant.
        Parameters:
        tenantName - the tenant's name
        attributeName - the name of the attribute profiles must have
        attributeValue - the value of the attribute profiles must have
        sortBy - profile attribute to sort the list by (optional)
        sortOrder - the sort order (either ASC or DESC) (optional)
        attributesToReturn - the names of the attributes to return for each profile (null to return all)
        Returns:
        the matching profiles
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • countByTenant

        long countByTenant​(String tenantName)
                    throws org.craftercms.commons.mongo.MongoDataException
        Returns the count of profiles for the given tenant.
        Parameters:
        tenantName - the tenant's name
        Returns:
        the count of profiles for the tenant
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • removeAll

        void removeAll​(String tenantName)
                throws org.craftercms.commons.mongo.MongoDataException
        Removes all the profiles associated to the given tenant.
        Parameters:
        tenantName - the tenant's name
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • removeRoleFromAll

        void removeRoleFromAll​(String tenantName,
                               String role)
                        throws org.craftercms.commons.mongo.MongoDataException
        Removes the role of all profiles of to the given tenant.
        Parameters:
        tenantName - the tenant's name
        role - the name of the role to remove
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • removeAttributeFromAll

        void removeAttributeFromAll​(String tenantName,
                                    String attributeName)
                             throws org.craftercms.commons.mongo.MongoDataException
        Removes the attribute of all profiles of to the given tenant.
        Parameters:
        tenantName - the tenant's name
        attributeName - the name of the attribute to remove
        Throws:
        org.craftercms.commons.mongo.MongoDataException
      • updateAllWithDefaultValue

        void updateAllWithDefaultValue​(String tenantName,
                                       String attributeName,
                                       Object defaultValue)
                                throws org.craftercms.commons.mongo.MongoDataException
        Updates all the profiles of a given tenant with the default value of an attribute, only if they don't have the attribute value set yet.
        Parameters:
        tenantName - the tenant's name
        attributeName - the attribute's name
        defaultValue - the default attribute value
        Throws:
        org.craftercms.commons.mongo.MongoDataException