public abstract class AbstractImageServlet extends SlingSafeMethodsServlet
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractImageServlet.ImageContext
Convenience class that holds useful stuff needed for image generation
|
| Constructor and Description |
|---|
AbstractImageServlet() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
applyDiff(Layer layer,
AbstractImageServlet.ImageContext c)
Default behavior that applies diff information to the layer
|
protected boolean |
checkModifiedSince(SlingHttpServletRequest req,
SlingHttpServletResponse resp)
Checks if the request contains a if-last-modified-since header and if the
node has a jcr:lastModified property.
|
protected ImageResource |
createImageResource(Resource resource)
Creates an image resource based on the resource in the image context.
|
protected abstract Layer |
createLayer(AbstractImageServlet.ImageContext c)
Creates the image layer.
|
protected void |
doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response)
Handles a GET request and created the desired image.
|
protected double |
getImageQuality()
Returns the image quality.
|
protected java.lang.String |
getImageType()
Returns the image type.
|
protected java.lang.String |
getImageType(java.lang.String ext)
Returns the image type for the given extension.
|
protected boolean |
isModifiedDiff(AbstractImageServlet.ImageContext c)
Calculates if the underlying image was modified in respect to the versioned
diff.
|
protected void |
writeLayer(SlingHttpServletRequest request,
SlingHttpServletResponse response,
AbstractImageServlet.ImageContext context,
Layer layer)
Writes the layer to the response.
|
protected void |
writeLayer(SlingHttpServletRequest request,
SlingHttpServletResponse response,
AbstractImageServlet.ImageContext context,
Layer layer,
double quality)
Writes the layer to the response at the specified quality.
|
doGeneric, doHead, doOptions, doTrace, getAllowedRequestMethods, getServletInfo, handleMethodNotImplemented, mayService, service, serviceprotected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, java.io.IOException
checkModifiedSince(SlingHttpServletRequest, SlingHttpServletResponse)
createLayer(ImageContext)
writeLayer(SlingHttpServletRequest, SlingHttpServletResponse, ImageContext, Layer)
getImageType(String), a 404 is responded.doGet in class SlingSafeMethodsServletrequest - The HTTP requestresponse - The HTTP responseServletException - Not thrown by this implementation.java.io.IOException - If the error status cannot be reported back to the
client.protected void writeLayer(SlingHttpServletRequest request, SlingHttpServletResponse response, AbstractImageServlet.ImageContext context, Layer layer) throws java.io.IOException, RepositoryException
request - servlet requestresponse - servlet responsecontext - the contextlayer - layerjava.io.IOException - if an I/O error occurs.RepositoryException - if an repository error occurs.protected void writeLayer(SlingHttpServletRequest request, SlingHttpServletResponse response, AbstractImageServlet.ImageContext context, Layer layer, double quality) throws java.io.IOException, RepositoryException
request - servlet requestresponse - servlet responsecontext - the contextlayer - layerquality - image qualityjava.io.IOException - if an I/O error occurs.RepositoryException - if an repository error occurs.protected java.lang.String getImageType()
protected java.lang.String getImageType(java.lang.String ext)
ext - the extensionnull.protected double getImageQuality()
protected boolean checkModifiedSince(SlingHttpServletRequest req, SlingHttpServletResponse resp)
req - the requestresp - the responsetrue if the response was sentprotected abstract Layer createLayer(AbstractImageServlet.ImageContext c) throws RepositoryException, java.io.IOException
c - the convenience contextRepositoryException - if an error occurs.java.io.IOException - if an I/O error occursprotected boolean applyDiff(Layer layer, AbstractImageServlet.ImageContext c)
layer - the layerc - the contexttrue if the layer was modified.protected ImageResource createImageResource(Resource resource)
resource - the resourceprotected boolean isModifiedDiff(AbstractImageServlet.ImageContext c)
c - the image contexttrue if modified