Class UserAvatarResource

java.lang.Object
de.unigoettingen.sub.commons.contentlib.servlet.rest.ContentServerResource
de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource
io.goobi.viewer.api.rest.v1.authentication.UserAvatarResource

@Path("/users/{userId}/avatar") public class UserAvatarResource extends de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource
REST resource for uploading, retrieving, and deleting user avatar images.
Author:
Florian Alpers
  • Nested Class Summary

    Nested classes/interfaces inherited from class de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource

    de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource.ImageStreamingOutput, de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource.PdfStreamingOutput

    Nested classes/interfaces inherited from class de.unigoettingen.sub.commons.contentlib.servlet.rest.ContentServerResource

    de.unigoettingen.sub.commons.contentlib.servlet.rest.ContentServerResource.ResourceStatus
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
     

    Fields inherited from class de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource

    BACKSLASH_REPLACEMENT, context, IIIF_VERSION, imageURI, PERCENT_REPLACEMENT, QUESTION_MARK_REPLACEMENT, request, REQUEST_ATTRIBUTE_ERROR, resourceURI, response, SLASH_REPLACEMENT

    Fields inherited from class de.unigoettingen.sub.commons.contentlib.servlet.rest.ContentServerResource

    cacheManager, MEDIA_TYPE_APPLICATION_JSONLD, REQUEST_TYPE_IMAGE, REQUEST_TYPE_METSPDF, REQUEST_TYPE_PDF, requestId, requestMap
  • Constructor Summary

    Constructors
    Constructor
    Description
    UserAvatarResource(ContainerRequestContext context, HttpServletRequest request, HttpServletResponse response, Long userId, de.unigoettingen.sub.commons.cache.ContentServerCacheManager cacheManager)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    createResourceURI(HttpServletRequest request, String directory, String filename)
     
    static Path
    getAvatarFilePath(String uploadFilename, Long userId)
     
    static String
     
    static URI
     
    static Optional<Path>
     
    static Path
     
    Redirects to the canonical info.json url of this user's avatar image.
    static void
    removeFromImageCache(Path file, de.unigoettingen.sub.commons.cache.ContentServerCacheManager cacheManager)
     
    uploadAvatarFile(boolean enabled, String uploadFilename, InputStream uploadedInputStream, org.glassfish.jersey.media.multipart.FormDataContentDisposition fileDetail)
    Uploads a new avatar image for the currently authenticated user.

    Methods inherited from class de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource

    addContentHeader, createImageURI, createResourceURI, getCache, getCachedDate, getGif, getImage, getImageURI, getInfoAsJson, getInfoAsXml, getPdf, getPdf, getRequestedWidth, getResourceURI, getURIPrefix, isInCache, redirectToFullImage, setImageURI, setInitializationException, setResourceURI, unescape

    Methods inherited from class de.unigoettingen.sub.commons.contentlib.servlet.rest.ContentServerResource

    checkMemoryOverflow, checkRequestOverflow, finishRequest, getNumCurrentFooterRequests, getNumCurrentImageRequests, getNumCurrentMetsPdfRequests, getNumCurrentRequests, getNumCurrentSinglePdfRequests, getRequestId, getStatus, remainingMemory, startRequest

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getMediaFileUrl

      public static URI getMediaFileUrl(Long userId) throws WebApplicationException
      Parameters:
      userId - database ID of the user
      Returns:
      URI
      Throws:
      WebApplicationException
    • getUserAvatarFolder

      public static Path getUserAvatarFolder()
    • getUserAvatarFile

      public static Optional<Path> getUserAvatarFile(Long userId) throws IOException
      Parameters:
      userId - database ID of the user
      Returns:
      Optional
      Throws:
      IOException
    • getAvatarFileSuffix

      public static String getAvatarFileSuffix(Long userId) throws IOException
      Throws:
      IOException
    • createResourceURI

      public void createResourceURI(HttpServletRequest request, String directory, String filename) throws de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
      Overrides:
      createResourceURI in class de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
    • redirectToCanonicalImageInfo

      @GET @Produces({"application/json","application/ld+json"}) public Response redirectToCanonicalImageInfo() throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Redirects to the canonical info.json url of this user's avatar image.
      Overrides:
      redirectToCanonicalImageInfo in class de.unigoettingen.sub.commons.contentlib.servlet.rest.ImageResource
      Returns:
      a 303 redirect response
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • uploadAvatarFile

      @POST @Consumes("multipart/form-data") @Produces("application/json") public Response uploadAvatarFile(@DefaultValue("true") boolean enabled, String uploadFilename, InputStream uploadedInputStream, org.glassfish.jersey.media.multipart.FormDataContentDisposition fileDetail)
      Uploads a new avatar image for the currently authenticated user.
      Parameters:
      enabled - accepted for compatibility with the request schema, but not evaluated by this endpoint
      uploadFilename - file name to store the avatar under; only its extension is used to derive the stored file name, so an upload with a different extension than the current avatar is stored alongside it rather than replacing it
      uploadedInputStream - avatar image file content
      fileDetail - multipart content disposition metadata of the file part
      Returns:
      a response indicating success, or the reason the upload was rejected
    • getAvatarFilePath

      public static Path getAvatarFilePath(String uploadFilename, Long userId)
    • removeFromImageCache

      public static void removeFromImageCache(Path file, de.unigoettingen.sub.commons.cache.ContentServerCacheManager cacheManager)