Package io.goobi.viewer.api.rest.v1.cms
Class CMSMediaResource
java.lang.Object
io.goobi.viewer.api.rest.v1.cms.CMSMediaResource
CMSMediaResource class.
- Author:
- Florian Alpers
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected jakarta.servlet.http.HttpServletRequestprotected jakarta.servlet.http.HttpServletResponse -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateMediaItem(Path filePath) createMediaItem.voidvoidList all uploaded media files.getAllMedia(String tags, Integer maxItems, Integer prioritySlots, Boolean random) getMediaByTag.static jakarta.ws.rs.core.StreamingOutputgetIcoContent(String filename, jakarta.servlet.http.HttpServletResponse response) getMediaItem(Long id) static StringgetMediaItemContent(String filename) getMediaItemContent.getMediaOfCategories(String tags, Integer maxItems, Integer prioritySlots, Boolean random) getMediaByTag.static jakarta.ws.rs.core.StreamingOutputgetPDFMediaItemContent(String filename, jakarta.servlet.http.HttpServletResponse response) getPDFMediaItemContent.static jakarta.ws.rs.core.StreamingOutputgetSvgContent(String filename, jakarta.servlet.http.HttpServletResponse response) static voidremoveFromImageCache(CMSMediaItem item, de.unigoettingen.sub.commons.cache.ContentServerCacheManager cacheManager) serveAudioContent(String filename) serveVideoContent(String filename) jakarta.ws.rs.core.ResponseuploadMediaFiles(boolean enabled, String filename, InputStream uploadedInputStream, org.glassfish.jersey.media.multipart.FormDataContentDisposition fileDetail) May receive a file from a multipart form and saves the file in the cms media folder.jakarta.ws.rs.core.ResponsevalidateUploadMediaFiles(String filename) Return the media item for the given filename.
-
Field Details
-
servletRequest
@Context protected jakarta.servlet.http.HttpServletRequest servletRequest -
servletResponse
@Context protected jakarta.servlet.http.HttpServletResponse servletResponse
-
-
Constructor Details
-
CMSMediaResource
public CMSMediaResource() -
CMSMediaResource
-
-
Method Details
-
getMediaOfCategories
@GET @Produces("application/json") @Path("/category/{tags}") public MediaList getMediaOfCategories(@PathParam("tags") String tags, @QueryParam("max") Integer maxItems, @QueryParam("prioritySlots") Integer prioritySlots, @QueryParam("random") Boolean random) throws DAOException getMediaByTag.
- Parameters:
tags- aStringobject.maxItems-prioritySlots-random-- Returns:
- a
MediaListobject. - Throws:
DAOException- if any.
-
getAllMedia
@GET @Produces("application/json") public MediaList getAllMedia(@QueryParam("tags") String tags, @QueryParam("max") Integer maxItems, @QueryParam("prioritySlots") Integer prioritySlots, @QueryParam("random") Boolean random) throws DAOException getMediaByTag.
- Parameters:
tags- aStringobject.maxItems-prioritySlots-random-- Returns:
- a
MediaListobject. - Throws:
DAOException- if any.
-
getMediaItem
@GET @Path("/{id: \\d+}") @Produces("application/json") public MediaItem getMediaItem(@PathParam("id") Long id) throws DAOException - Throws:
DAOException
-
getPDFMediaItemContent
@GET @Path("/files/{filename: (?i)[^\\/]*\\.(pdf)}") @Produces("application/pdf") public static jakarta.ws.rs.core.StreamingOutput getPDFMediaItemContent(@PathParam("filename") String filename, @Context jakarta.servlet.http.HttpServletResponse response) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException getPDFMediaItemContent.
- Parameters:
filename-response- aHttpServletResponseobject.- Returns:
- File contents as HTML
- Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException- if any.DAOException- if any.
-
getSvgContent
@GET @Path("/files/{filename: (?i)[^\\/]*\\.(svg)}") @Produces("image/svg+xml") public static jakarta.ws.rs.core.StreamingOutput getSvgContent(@PathParam("filename") String filename, @Context jakarta.servlet.http.HttpServletResponse response) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException
-
getIcoContent
@GET @Path("/files/{filename: (?i)[^\\/]*\\.(ico)}") @Produces("image/x-icon") public static jakarta.ws.rs.core.StreamingOutput getIcoContent(@PathParam("filename") String filename, @Context jakarta.servlet.http.HttpServletResponse response) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException
-
serveVideoContent
@GET @Path("/files/{filename: (?i).*\\.(mp4|mpeg4|avi|mov|wmv)}") public String serveVideoContent(@PathParam("filename") String filename) throws PresentationException, jakarta.ws.rs.WebApplicationException - Throws:
PresentationExceptionjakarta.ws.rs.WebApplicationException
-
serveAudioContent
@GET @Path("/files/{filename: (?i).*\\.(mp3|mpeg|wav|ogg|wma)}") public String serveAudioContent(@PathParam("filename") String filename) throws PresentationException, jakarta.ws.rs.WebApplicationException - Throws:
PresentationExceptionjakarta.ws.rs.WebApplicationException
-
getMediaItemContent
@GET @Path("/files/{filename: (?i)[^\\/]*\\.(html)}") @Produces("text/html") public static String getMediaItemContent(@PathParam("filename") String filename) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException getMediaItemContent.
- Parameters:
filename-- Returns:
- File contents as HTML
- Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException- if any.DAOException- if any.
-
validateUploadMediaFiles
@GET @Path("/{filename: [^\\/]*\\.\\w{1,4}}") @Produces("application/json") public jakarta.ws.rs.core.Response validateUploadMediaFiles(@PathParam("filename") String filename) throws DAOException Return the media item for the given filename. If no matching media item exists, return a not-found status code
- Parameters:
filename- aStringobject.- Returns:
- a
Responseobject. - Throws:
DAOException- if any.
-
getAllFiles
@GET @Path("/files") @Produces("application/json") public List<String> getAllFiles() throws PresentationExceptionList all uploaded media files.- Returns:
- List
of media file names - Throws:
PresentationException
-
deleteAllFiles
@DELETE @Path("/files") @Produces("application/json") public void deleteAllFiles() throws de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException- Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
-
deleteFile
@DELETE @Path("/files/{filename}") @Produces("application/json") public void deleteFile() throws de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException- Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
-
uploadMediaFiles
@POST @Path("/files") @Consumes("multipart/form-data") @Produces("application/json") public jakarta.ws.rs.core.Response uploadMediaFiles(@DefaultValue("true") boolean enabled, String filename, InputStream uploadedInputStream, org.glassfish.jersey.media.multipart.FormDataContentDisposition fileDetail) throws DAOException May receive a file from a multipart form and saves the file in the cms media folder.- Parameters:
enabled- a boolean.filename- aStringobject.uploadedInputStream- aInputStreamobject.fileDetail- aFormDataContentDispositionobject.- Returns:
- an ACCEPTED response if the upload was successful, a FORBIDDEN response if no user is registered in the html session or the user does not have rights to upload media, or a CONFLICT response if a file of the same name already exists in the cms media foler
- Throws:
DAOException- if any.
-
removeFromImageCache
public static void removeFromImageCache(CMSMediaItem item, de.unigoettingen.sub.commons.cache.ContentServerCacheManager cacheManager) - Parameters:
item-cacheManager-
-
createMediaItem
createMediaItem.
- Parameters:
filePath- aPathobject.- Returns:
- a
CMSMediaItemobject.
-