Package org.apache.juneau.examples.rest
Class PhotosResource
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.juneau.rest.servlet.RestServlet
org.apache.juneau.rest.servlet.BasicRestServlet
org.apache.juneau.examples.rest.PhotosResource
- All Implemented Interfaces:
jakarta.servlet.Servlet
,jakarta.servlet.ServletConfig
,Serializable
,BasicUniversalConfig
,DefaultConfig
,DefaultHtmlConfig
,BasicRestOperations
Sample resource that allows images to be uploaded and retrieved.
See Also:
- See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddPhoto
(int id, BufferedImage image) [HTTP PUT /photos/{id}] PUT request handler.deletePhoto
(int id) [HTTP DELETE /photos/{id}] DELETE request handler[HTTP GET /photos] GET request handler for list of all photos.getPhoto
(int id) [HTTP GET /photos/{id}] GET request handler for single photo.setPhoto
(BufferedImage image) [HTTP POST /photos] POST request handler.Methods inherited from class org.apache.juneau.rest.servlet.BasicRestServlet
error, getFavIcon, getHtdoc, getStats, getSwagger
Methods inherited from class org.apache.juneau.rest.servlet.RestServlet
destroy, doLog, getContext, getPath, getRequest, getResponse, init, log, log, service, setContext
Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
Methods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
PhotosResource
public PhotosResource()
-
-
Method Details
-
getAllPhotos
[HTTP GET /photos] GET request handler for list of all photos.- Returns:
- A list of photo beans.
-
getPhoto
[HTTP GET /photos/{id}] GET request handler for single photo.- Parameters:
id
- The photo ID.- Returns:
- The photo image.
- Throws:
NotFound
- If photo not found.
-
addPhoto
[HTTP PUT /photos/{id}] PUT request handler.- Parameters:
id
- The photo ID.image
- The photo image.- Returns:
- OK.
-
setPhoto
[HTTP POST /photos] POST request handler.- Parameters:
image
- The photo image.- Returns:
- The created photo bean.
-
deletePhoto
[HTTP DELETE /photos/{id}] DELETE request handler- Parameters:
id
- The photo ID.- Returns:
- OK.
- Throws:
NotFound
- If photo not found.
-