Class MimeResponseWrapper
- java.lang.Object
-
- jakarta.portlet.filter.PortletResponseWrapper
-
- jakarta.portlet.filter.MimeResponseWrapper
-
- All Implemented Interfaces:
MimeResponse,PortletResponse
- Direct Known Subclasses:
HeaderResponseWrapper,RenderResponseWrapper,ResourceResponseWrapper
public class MimeResponseWrapper extends PortletResponseWrapper implements MimeResponse
TheMimeResponseWrapperprovides a convenient implementation of theMimeResponseinterface that can be subclassed by developers. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.- Since:
- 3.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.portlet.MimeResponse
MimeResponse.Copy
-
-
Field Summary
-
Fields inherited from interface jakarta.portlet.MimeResponse
CACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT
-
-
Constructor Summary
Constructors Constructor Description MimeResponseWrapper(MimeResponse response)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends PortletURL & ActionURL>
TcreateActionURL()Creates an action URL targeting the portlet.ActionURLcreateActionURL(MimeResponse.Copy option)Creates an action URL targeting the portlet.<T extends PortletURL & RenderURL>
TcreateRenderURL()Creates a render URL targeting the portlet.RenderURLcreateRenderURL(MimeResponse.Copy option)Creates a render URL targeting the portlet.ResourceURLcreateResourceURL()Creates a resource URL targeting the portlet.voidflushBuffer()Forces any content in the buffer to be written to the underlying output stream.intgetBufferSize()Returns the actual buffer size used for the response.CacheControlgetCacheControl()Returns the cache control object allowing to set specific cache settings valid for the markup returned in this response.StringgetCharacterEncoding()Returns the name of the charset used for the MIME body sent in this response.StringgetContentType()Returns the MIME type that can be used to contribute markup to the render response.LocalegetLocale()Returns the locale assigned to the response.OutputStreamgetPortletOutputStream()Returns aOutputStreamsuitable for writing binary data in the response.MimeResponsegetResponse()Return the wrapped response object.PrintWritergetWriter()Returns a PrintWriter object that can send character text to the portal.booleanisCommitted()Returns a boolean indicating if the response has been committed.voidreset()Clears any data that exists in the buffer as well as the properties set.voidresetBuffer()Clears the content of the underlying buffer in the response without clearing properties set.voidsetBufferSize(int size)Sets the preferred buffer size for the body of the response.voidsetContentType(String type)Sets the MIME type for the response.voidsetResponse(MimeResponse response)Sets the response object being wrapped.-
Methods inherited from class jakarta.portlet.filter.PortletResponseWrapper
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty, setResponse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.portlet.PortletResponse
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty
-
-
-
-
Constructor Detail
-
MimeResponseWrapper
public MimeResponseWrapper(MimeResponse response)
- Parameters:
response- the wrapped response
-
-
Method Detail
-
getResponse
public MimeResponse getResponse()
Return the wrapped response object.- Overrides:
getResponsein classPortletResponseWrapper- Returns:
- the wrapped response
-
setResponse
public void setResponse(MimeResponse response)
Sets the response object being wrapped.- Parameters:
response- the response to set- Throws:
IllegalArgumentException- if the response is null.
-
flushBuffer
public void flushBuffer() throws IOExceptionDescription copied from interface:MimeResponseForces any content in the buffer to be written to the underlying output stream. A call to this method automatically commits the response.- Specified by:
flushBufferin interfaceMimeResponse- Throws:
IOException- if an error occurred when writing the output- See Also:
MimeResponse.setBufferSize(int),MimeResponse.getBufferSize(),MimeResponse.isCommitted(),MimeResponse.reset()
-
getBufferSize
public int getBufferSize()
Description copied from interface:MimeResponseReturns the actual buffer size used for the response. If no buffering is used, this method returns 0.- Specified by:
getBufferSizein interfaceMimeResponse- Returns:
- the actual buffer size used
- See Also:
MimeResponse.setBufferSize(int),MimeResponse.flushBuffer(),MimeResponse.isCommitted(),MimeResponse.reset()
-
getCharacterEncoding
public String getCharacterEncoding()
Description copied from interface:MimeResponseReturns the name of the charset used for the MIME body sent in this response.See RFC 2047 for more information about character encoding and MIME.
- Specified by:
getCharacterEncodingin interfaceMimeResponse- Returns:
- a
Stringspecifying the name of the charset, for example,ISO-8859-1
-
getContentType
public String getContentType()
Description copied from interface:MimeResponseReturns the MIME type that can be used to contribute markup to the render response.If no content type was set previously using the
MimeResponse.setContentType(java.lang.String)method this method returnsnull.- Specified by:
getContentTypein interfaceMimeResponse- Returns:
- the MIME type of the response, or
nullif no content type is set - See Also:
MimeResponse.setContentType(java.lang.String)
-
getLocale
public Locale getLocale()
Description copied from interface:MimeResponseReturns the locale assigned to the response.- Specified by:
getLocalein interfaceMimeResponse- Returns:
- Locale of this response
-
getPortletOutputStream
public OutputStream getPortletOutputStream() throws IOException
Description copied from interface:MimeResponseReturns aOutputStreamsuitable for writing binary data in the response. The portlet container does not encode the binary data.Before calling this method the content type of the render response must be set using the
MimeResponse.setContentType(java.lang.String)method.Calling
flush()on the OutputStream commits the response.Either this method or
MimeResponse.getWriter()may be called to write the body, not both.- Specified by:
getPortletOutputStreamin interfaceMimeResponse- Returns:
- a
OutputStreamfor writing binary data - Throws:
IOException- if an input or output exception occurred- See Also:
MimeResponse.setContentType(java.lang.String),MimeResponse.getWriter()
-
getWriter
public PrintWriter getWriter() throws IOException
Description copied from interface:MimeResponseReturns a PrintWriter object that can send character text to the portal.Before calling this method the content type of the render response should be set using the
MimeResponse.setContentType(java.lang.String)method.Either this method or
MimeResponse.getPortletOutputStream()may be called to write the body, not both.- Specified by:
getWriterin interfaceMimeResponse- Returns:
- a
PrintWriterobject that can return character data to the portal - Throws:
IOException- if an input or output exception occurred- See Also:
MimeResponse.setContentType(java.lang.String),MimeResponse.getPortletOutputStream()
-
isCommitted
public boolean isCommitted()
Description copied from interface:MimeResponseReturns a boolean indicating if the response has been committed.- Specified by:
isCommittedin interfaceMimeResponse- Returns:
- a boolean indicating if the response has been committed
- See Also:
MimeResponse.setBufferSize(int),MimeResponse.getBufferSize(),MimeResponse.flushBuffer(),MimeResponse.reset()
-
reset
public void reset()
Description copied from interface:MimeResponseClears any data that exists in the buffer as well as the properties set. If the response has been committed, this method throws anIllegalStateException.- Specified by:
resetin interfaceMimeResponse- See Also:
MimeResponse.setBufferSize(int),MimeResponse.getBufferSize(),MimeResponse.flushBuffer(),MimeResponse.isCommitted()
-
resetBuffer
public void resetBuffer()
Description copied from interface:MimeResponseClears the content of the underlying buffer in the response without clearing properties set. If the response has been committed, this method throws anIllegalStateException.- Specified by:
resetBufferin interfaceMimeResponse- See Also:
MimeResponse.setBufferSize(int),MimeResponse.getBufferSize(),MimeResponse.isCommitted(),MimeResponse.reset()
-
setBufferSize
public void setBufferSize(int size)
Description copied from interface:MimeResponseSets the preferred buffer size for the body of the response. The portlet container will use a buffer at least as large as the size requested.This method must be called before any response body content is written; if content has been written, or the portlet container does not support buffering, this method may throw an
IllegalStateException.- Specified by:
setBufferSizein interfaceMimeResponse- Parameters:
size- the preferred buffer size- See Also:
MimeResponse.getBufferSize(),MimeResponse.flushBuffer(),MimeResponse.isCommitted(),MimeResponse.reset()
-
getCacheControl
public CacheControl getCacheControl()
Description copied from interface:MimeResponseReturns the cache control object allowing to set specific cache settings valid for the markup returned in this response.- Specified by:
getCacheControlin interfaceMimeResponse- Returns:
- Cache control for the current response.
-
createActionURL
public <T extends PortletURL & ActionURL> T createActionURL() throws IllegalStateException
Description copied from interface:MimeResponseCreates an action URL targeting the portlet. Action URLs are used to create forms or links that, when triggered, update the render state in a non-idempotent manner.If a request is triggered by the URL, it results in an action request.
The returned action URL will not contain any private render parameters per default not contain any parameters from the current request.
The returned URL can be further extended by adding portlet-specific action parameters, portlet mode, and window state. If no additional portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.
Public render parameters do not need to be explicitly added to the returned action URL, unless the public render parameter value is to be changed. Any public render parameters associated with the portlet will automatically be available during action request processing resulting from activation of the URL.
If a public render parameter value is set or removed on an action URL, then the public render parameter will be set to the new value or removed when the URL is activated.
The effect of this method is the same as calling
MimeResponse.createRenderURL(Copy)with the parameter set to PUBLIC.- Specified by:
createActionURLin interfaceMimeResponse- Type Parameters:
T- the type of the URL, which must be a subtype of bothPortletURLandActionURL- Returns:
- a portlet action URL
- Throws:
IllegalStateException
-
createActionURL
public ActionURL createActionURL(MimeResponse.Copy option) throws IllegalStateException
Description copied from interface:MimeResponseCreates an action URL targeting the portlet. Action URLs are used to create forms or links that, when triggered, update the render state in a non-idempotent manner.If a request is triggered by the URL, it results in an action request.
The new action URL will contain render parameters from the current request as specified by the
optionparameter.- NONE
- All public and private parameters are removed from the URL.
- ALL
- The public and private parameters governing the current request are added to the URL.
- PUBLIC
- Only public parameters governing the current request are added to the URL.
The returned URL can be further extended by adding action parameters, portlet mode, and window state. If no additional portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.
If a public render parameter value is set or removed on an action URL, then the public render parameter will be set to the new value or removed when the URL is activated.
- Specified by:
createActionURLin interfaceMimeResponse- Parameters:
option- Specifies how current parameters are to be copied to the URL- Returns:
- a portlet action URL
- Throws:
IllegalStateException- See Also:
MimeResponse.Copy
-
createRenderURL
public <T extends PortletURL & RenderURL> T createRenderURL() throws IllegalStateException
Description copied from interface:MimeResponseCreates a render URL targeting the portlet. Render URLs cause idempotent requests that move the portlet to a new view state, for example, to view a different page of data.If a request is triggered by the URL, it results in a render request.
The returned render URL will not contain any private render parameters from the current request.
The created URL will per default not contain any parameters of the current render request.
The returned URL can be further extended by adding portlet-specific render parameters, portlet mode, and window state. If no portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.
Public render parameters do not need to be explicitly added to the returned render URL, unless the public render parameter value is to be changed. Any public render parameters associated with the portlet will automatically be available during render request processing resulting from activation of the URL.
If a public render parameter value is set or removed on a render URL, then the public render parameter will be set to the new value or removed when the URL is activated.
The effect of this method is the same as calling
MimeResponse.createRenderURL(Copy)with the parameter set to PUBLIC.- Specified by:
createRenderURLin interfaceMimeResponse- Type Parameters:
T- the type of the URL, which must be a subtype of bothPortletURLandRenderURL- Returns:
- a portlet render URL
- Throws:
IllegalStateException
-
createRenderURL
public RenderURL createRenderURL(MimeResponse.Copy option) throws IllegalStateException
Description copied from interface:MimeResponseCreates a render URL targeting the portlet. Render URLs cause idempotent requests that move the portlet to a new view state, for example, to view a different page of data.If a request is triggered by the URL, it results in a render request.
The new render URL will contain render parameters from the current request as specified by the
optionparameter.- NONE
- All public and private parameters are removed from the URL.
- ALL
- The public and private parameters governing the current request are added to the URL.
- PUBLIC
- Only public parameters governing the current request are added to the URL.
If a public render parameter value is set or removed on a render URL, then the public render parameter will be set to the new value or removed when the URL is activated.
- Specified by:
createRenderURLin interfaceMimeResponse- Parameters:
option- Specifies how current parameters are to be copied to the URL- Returns:
- a portlet render URL
- Throws:
IllegalStateException- See Also:
MimeResponse.Copy
-
createResourceURL
public ResourceURL createResourceURL() throws IllegalStateException
Description copied from interface:MimeResponseCreates a resource URL targeting the portlet. Resource URLs are used to trigger requests for content that applies to the current portlet view state.If a request is triggered by the
ResourceURL, it results in a serve resource request of theResourceServingPortletinterface.The security settings can be changed for the URL. If the security settings are not explicitly set, the values governing the current request are preserved. The current render parameters, portlet mode, and window state are preserved depending on the cacheability setting for the returned resource URL.
If cacheability is set to
PORTLETorPAGE, the values of the render parameters, portlet mode, and window state are preserved. Otherwise, they will not be preserved.If allowed by the cacheability setting, public and private render parameters are added to the URL with their current values. The render parameter values cannot be changed on the URL.
The URL can be further extended by adding portlet-specific resource parameters.
The URL will contain the current cacheability setting of the parent resource by default. If no parent resource is available,
PAGEis the default.If a request is triggered by the PortletURL, it results in a serve resource request of theResourceServingPortletinterface.The returned URL can be further extended by adding portlet-specific parameters .
The created URL will by default contain the current cacheability setting of the parent resource. If no parent resource is available,
PAGEis the default.- Specified by:
createResourceURLin interfaceMimeResponse- Returns:
- a portlet resource URL
- Throws:
IllegalStateException
-
setContentType
public void setContentType(String type)
Description copied from interface:MimeResponseSets the MIME type for the response. The portlet should set the content type before callingMimeResponse.getWriter()orMimeResponse.getPortletOutputStream(). If the content type is not set using this method, the preferred content type as returned byPortletRequest.getResponseContentType()is used.Calling
setContentTypeaftergetWriterorgetOutputStreamdoes not change the content type.- Specified by:
setContentTypein interfaceMimeResponse- Parameters:
type- the content MIME type- See Also:
PortletRequest.getResponseContentTypes(),MimeResponse.getContentType()
-
-