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.PdfStreamingOutputNested classes/interfaces inherited from class de.unigoettingen.sub.commons.contentlib.servlet.rest.ContentServerResource
de.unigoettingen.sub.commons.contentlib.servlet.rest.ContentServerResource.ResourceStatus -
Field Summary
FieldsFields 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_REPLACEMENTFields 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
ConstructorsConstructorDescriptionUserAvatarResource(ContainerRequestContext context, HttpServletRequest request, HttpServletResponse response, Long userId, de.unigoettingen.sub.commons.cache.ContentServerCacheManager cacheManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateResourceURI(HttpServletRequest request, String directory, String filename) static PathgetAvatarFilePath(String uploadFilename, Long userId) static StringgetAvatarFileSuffix(Long userId) static URIgetMediaFileUrl(Long userId) getUserAvatarFile(Long userId) static PathRedirects to the canonicalinfo.jsonurl of this user's avatar image.static voidremoveFromImageCache(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, unescapeMethods inherited from class de.unigoettingen.sub.commons.contentlib.servlet.rest.ContentServerResource
checkMemoryOverflow, checkRequestOverflow, finishRequest, getNumCurrentFooterRequests, getNumCurrentImageRequests, getNumCurrentMetsPdfRequests, getNumCurrentRequests, getNumCurrentSinglePdfRequests, getRequestId, getStatus, remainingMemory, startRequest
-
Field Details
-
servletRequest
-
servletResponse
-
-
Constructor Details
-
UserAvatarResource
public UserAvatarResource(@Context ContainerRequestContext context, @Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("userId") Long userId, @Context de.unigoettingen.sub.commons.cache.ContentServerCacheManager cacheManager) throws WebApplicationException, ViewerConfigurationException
-
-
Method Details
-
getMediaFileUrl
- Parameters:
userId- database ID of the user- Returns:
URI- Throws:
WebApplicationException
-
getUserAvatarFolder
-
getUserAvatarFile
- Parameters:
userId- database ID of the user- Returns:
- Optional
- Throws:
IOException
-
getAvatarFileSuffix
- Throws:
IOException
-
createResourceURI
public void createResourceURI(HttpServletRequest request, String directory, String filename) throws de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException - Overrides:
createResourceURIin classde.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.ContentLibExceptionRedirects to the canonicalinfo.jsonurl of this user's avatar image.- Overrides:
redirectToCanonicalImageInfoin classde.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 endpointuploadFilename- 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 ituploadedInputStream- avatar image file contentfileDetail- multipart content disposition metadata of the file part- Returns:
- a response indicating success, or the reason the upload was rejected
-
getAvatarFilePath
-
removeFromImageCache
public static void removeFromImageCache(Path file, de.unigoettingen.sub.commons.cache.ContentServerCacheManager cacheManager)
-