Class AvatarServiceImpl

    • Constructor Detail

      • AvatarServiceImpl

        @Inject
        public AvatarServiceImpl​(AvatarRepository avatarRepository)
    • Method Detail

      • getUserDefault

        @NotNull
        public @NotNull CacheableAvatarSupplier getUserDefault​(int size)
        Description copied from interface: AvatarService
        Retrieves a stable default user avatar, suitable for display in anonymous contexts.
        Specified by:
        getUserDefault in interface AvatarService
        Parameters:
        size - the size to retrieve the avatar in
        Returns:
        an AvatarSupplier which can be used to read the avatar
      • getForUser

        @Nullable
        public @Nullable CacheableAvatarSupplier getForUser​(@NotNull
                                                            @NotNull Principal user,
                                                            int size)
        Description copied from interface: AvatarService
        Retrieves the current avatar for the specified user. If no explicit avatar has been set, a null will be returned.
        Specified by:
        getForUser in interface AvatarService
        Parameters:
        user - the user to retrieve the avatar for
        size - the size to retrieve the avatar in
        Returns:
        an AvatarSupplier which can be used to read the avatar
      • saveForUser

        public void saveForUser​(@NotNull
                                @NotNull Principal user,
                                @NotNull
                                @NotNull Supplier<AvatarSupplier> metaSupplier)
        Description copied from interface: AvatarService
        Saves the avatar contained in the provided avatarSupplier obtained from the provided metaSupplier as the new avatar for the specified User, removing any previously-stored avatar.

        Previous avatars are not maintained. The only way to restore a previous avatar is to save it again.

        Specified by:
        saveForUser in interface AvatarService
        Parameters:
        user - the user whose avatar is being set
        metaSupplier - a supplier providing access to the new avatar to use
      • isUserAvatarStored

        public boolean isUserAvatarStored​(@NotNull
                                          @NotNull Principal user)
        Description copied from interface: AvatarService
        Checks whether the user has an avatar stored.
        Specified by:
        isUserAvatarStored in interface AvatarService
        Parameters:
        user - the user to check
        Returns:
        true if the user's avatar is stored.
      • deleteForUser

        public void deleteForUser​(@NotNull
                                  @NotNull Principal user)
        Description copied from interface: AvatarService
        Delete the avatar associated with a user.

        This will revert the avatar of the user in the UI to their Gravatar image (if the Gravatar integration is enabled) or to the default user avatar (if the Gravatar integration is disabled)

        Specified by:
        deleteForUser in interface AvatarService
        Parameters:
        user - the user whose (local) avatar will be removed
      • deleteForUser

        public void deleteForUser​(@NotNull
                                  @NotNull String userName)
        Description copied from interface: AvatarService
        Delete the avatar associated with a user's name.

        This will revert the avatar of the user in the UI to their Gravatar image (if the Gravatar integration is enabled) or to the default user avatar (if the Gravatar integration is disabled)

        Specified by:
        deleteForUser in interface AvatarService
        Parameters:
        userName - the user's name whose (local) avatar will be removed
      • moveForUser

        public void moveForUser​(@NotNull
                                @NotNull String oldUserName,
                                @NotNull
                                @NotNull String newUserName)
        Description copied from interface: AvatarService
        Moves the avatar associated with a user to another user.
        Specified by:
        moveForUser in interface AvatarService
        Parameters:
        oldUserName - the user whose avatar will be moved
        newUserName - the user whose avatar will be replaced
      • getMaxUploadSize

        public long getMaxUploadSize()
        Description copied from interface: AvatarService
        Retrieves the maximum size, in bytes, for uploaded avatars. Avatars larger than this will be rejected by the server.
        Specified by:
        getMaxUploadSize in interface AvatarService
        Returns:
        the maximum size, in bytes, for uploaded avatars