com.caucho.portal.generic
Class HttpPortletConnection

java.lang.Object
  extended by com.caucho.portal.generic.PortletConnection
      extended by com.caucho.portal.generic.HttpPortletConnection

public class HttpPortletConnection
extends PortletConnection

A connection to an HttpServletRequest and HttpServletResponse.


Field Summary
static java.lang.String HTTP_SERVLET_REQUEST
          request attribute for the HttpServletRequest
static java.lang.String HTTP_SERVLET_RESPONSE
          request attribute for the HttpServletResponse
 
Fields inherited from class com.caucho.portal.generic.PortletConnection
log, PORTLET_CONNECTION
 
Constructor Summary
HttpPortletConnection()
           
 
Method Summary
 void addProperty(java.lang.String name, java.lang.String value)
          Add a value to a property to be returned to the client.
 boolean canGuaranteeConfidentiality()
          Return true if the connection can guarantee confidentiality (preventing reading while in transit).
 boolean canGuaranteeIntegrity()
          Return true if the connection can guarantee integrity (preventing data tampering in the communication process).
 java.lang.String encodeURL(java.lang.String location)
          A path with a schem is encoded only.
 void finish()
           
 void flushBuffer()
           
 java.lang.Object getAttribute(java.lang.String name)
          Attributes for the connection are HttpServletRequest attributes.
 java.util.Enumeration getAttributeNames()
          Attributes for the connection are HttpServletRequest attributes.
 java.lang.String getAuthType()
          Return the authentication scheme used for the current request.
 int getBufferSize()
           
 java.lang.String getCharacterEncoding()
           
 java.util.Set<java.lang.String> getClientCharacterEncodings()
          Get the character encodings acceptable to the client.
 java.util.Set<java.lang.String> getClientContentTypes()
          Get the content types acceptable to the client.
 java.util.Set<java.util.Locale> getClientLocales()
          Get the locales acceptable to the client.
 java.lang.String getContentType()
          Return the content type established with setContentType(), or null if setContentType() has not been called.
 java.lang.String getContextPath()
          Return the path to the portal portion of the url that was used to make the request.
 HttpServletRequest getHttpRequest()
           
static HttpServletRequest getHttpRequest(PortletRequest request)
           
 HttpServletResponse getHttpResponse()
           
static HttpServletResponse getHttpResponse(PortletRequest request)
           
 java.util.Locale getLocale()
          Return the Locale established with setLocale(), or null if setLocale() has not been called.
 java.io.OutputStream getOutputStream()
           
 PortletSession getPortletSession(boolean create)
          Return a PortletSession for the current client, or null if one is not available.
 java.util.Enumeration getProperties(java.lang.String propertyName)
          Return the values of the specified connection property as an array of Strings, null if the property was not provided by the request from the client.
 java.lang.String getProperty(java.lang.String propertyName)
          Return the value of the specified connection property as a String, null if the property was not provided by the request from the client.
 java.util.Enumeration getPropertyNames()
          Return the names of available properties for the connection.
 java.lang.String getRemoteUser()
          Return the identity of the remote user, null if the identity has not been established.
 java.lang.String getRequestedSessionId()
          Return the session id that was supplied by the client for the current request.
 java.lang.String getScheme()
          Return the scheme portion of the url that was used to make the request.
 java.lang.String getServerName()
          Return the host name portion of the url that was used to make the request.
 int getServerPort()
          Return the port portion of the url that was used to make the request.
 java.lang.String getSubmitCharacterEncoding()
          Return the name of the character encoding that will be used by the Reader obtained using #getReader, null if none.
 int getSubmitContentLength()
          Return the length of of the data supplied as the "body" of the request, -1 if not known.
 java.lang.String getSubmitContentType()
          Return the MIME type of the data supplied as the "body" of the request, null if not known.
 java.io.InputStream getSubmitInputStream()
          Return the binary body of the current request.
 java.io.BufferedReader getSubmitReader()
           
 java.security.Principal getUserPrincipal()
          Return a Principal that contains the identity of the remote user, null if the identity has not been established.
 java.io.PrintWriter getWriter()
           
 boolean handleConstraintFailure(Constraint constraint, int failureCode)
          Handle a constraint failure by sending some response to the client.
 boolean handleException(java.lang.Exception exception)
          Handle an exception by sending some response to the client.
 boolean isCommitted()
           
 boolean isRequestedSessionIdValid()
          Return true the session id that was supplied by the client for the current request is valid.
 boolean isSecure()
          Return true if the connection for the current request is secure, for example it uses HTTPS.
 boolean isUserInRole(java.lang.String role)
          Return true if the identity of remote user has been established and the user has been assigned the role.
protected  java.lang.String makeServletUrl(HttpServletRequest request)
           
 void removeAttribute(java.lang.String name)
          Attributes for the connection are HttpServletRequest attributes.
 void reset()
           
 void resetBuffer()
           
 java.lang.String resolveURL(java.lang.String url)
          Resolve a url so that it makes a request to the portal
 java.lang.String resolveURL(java.lang.String url, boolean secure)
          Resolve the url with the given security level and encode it.
 void sendRedirect(java.lang.String location)
           
 void setAttribute(java.lang.String name, java.lang.Object o)
          Attributes for the connection are HttpServletRequest attributes.
 void setBufferSize(int size)
           
 void setCharacterEncoding(java.lang.String enc)
           
 void setContentType(java.lang.String contentType)
          Set the content type to use for the response.
 void setLocale(java.util.Locale locale)
          Set the locale to use for the response.
 void setProperty(java.lang.String name, java.lang.String value)
          Set a property to be returned to the client.
 void setSubmitCharacterEncoding(java.lang.String enc)
          Override the character encoding used by the Reader obtained using #getReader.
 void start(Portal portal, PortletContext portletContext, HttpServletRequest httpRequest, HttpServletResponse httpResponse, boolean useParameters)
           
 void start(Portal portal, PortletContext portletContext, HttpServletRequest httpRequest, HttpServletResponse httpResponse, InvocationFactory invocationFactory)
           
 
Methods inherited from class com.caucho.portal.generic.PortletConnection
checkForFailure, getAction, getAction, getConnection, getCurrentAction, getCurrentRender, getExpirationCache, getId, getPortal, getPortal, getRender, getRender, isConnectionFailed, isPrivate, setConnectionFailed, setConnectionFailed, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_SERVLET_REQUEST

public static final java.lang.String HTTP_SERVLET_REQUEST
request attribute for the HttpServletRequest

See Also:
Constant Field Values

HTTP_SERVLET_RESPONSE

public static final java.lang.String HTTP_SERVLET_RESPONSE
request attribute for the HttpServletResponse

See Also:
Constant Field Values
Constructor Detail

HttpPortletConnection

public HttpPortletConnection()
Method Detail

getHttpRequest

public static HttpServletRequest getHttpRequest(PortletRequest request)

getHttpResponse

public static HttpServletResponse getHttpResponse(PortletRequest request)

start

public void start(Portal portal,
                  PortletContext portletContext,
                  HttpServletRequest httpRequest,
                  HttpServletResponse httpResponse,
                  boolean useParameters)

start

public void start(Portal portal,
                  PortletContext portletContext,
                  HttpServletRequest httpRequest,
                  HttpServletResponse httpResponse,
                  InvocationFactory invocationFactory)

makeServletUrl

protected java.lang.String makeServletUrl(HttpServletRequest request)

finish

public void finish()
Overrides:
finish in class PortletConnection

getHttpRequest

public HttpServletRequest getHttpRequest()

getHttpResponse

public HttpServletResponse getHttpResponse()

getClientContentTypes

public java.util.Set<java.lang.String> getClientContentTypes()
Get the content types acceptable to the client. The returned Set is ordered, the most preferrable content types appear before the least preferred. This implementation returns the content types that appear in the String returned by getProperty("Accept") in the order they appear in the string.

Specified by:
getClientContentTypes in class PortletConnection
Returns:
the Set, null if client content types cannot be determined

getClientLocales

public java.util.Set<java.util.Locale> getClientLocales()
Get the locales acceptable to the client. The returned Set is ordered, the most preferrable locale appears before the least preferred. If the client supports all locales, then a Locale("","","") will be present in the returned Set. This implementation returns the locales that appear in the String returned by getProperty("Accept-Language") in the order they appear in the string. If the "*" element is present in the header, then a new Locale("","","") is present in the set.

Specified by:
getClientLocales in class PortletConnection
Returns:
the Set, null if client locales cannot be determined

getClientCharacterEncodings

public java.util.Set<java.lang.String> getClientCharacterEncodings()
Get the character encodings acceptable to the client. The returned Set is order, the most preferrable character encoding appears before the least preferred. This implementation returns the character encodings that appear in the String returned by getProperty("Accept-Charset") in the order they appear in the string.

Specified by:
getClientCharacterEncodings in class PortletConnection
Returns:
the Set, null if client character encodings cannot be determined

resolveURL

public java.lang.String resolveURL(java.lang.String url)
Description copied from class: PortletConnection
Resolve a url so that it makes a request to the portal

Specified by:
resolveURL in class PortletConnection

resolveURL

public java.lang.String resolveURL(java.lang.String url,
                                   boolean secure)
                            throws PortletSecurityException
Resolve the url with the given security level and encode it. This implementation calls resolveURL(String) if secure is false. If secure is true, the prefix set with setSecureUrlPrefix() is prepended.

Specified by:
resolveURL in class PortletConnection
Throws:
PortletSecurityException - if secure is true but the url cannot be made secure because setSecureUrlPrefix() has not been called.

handleConstraintFailure

public boolean handleConstraintFailure(Constraint constraint,
                                       int failureCode)
                                throws java.io.IOException
Description copied from class: PortletConnection
Handle a constraint failure by sending some response to the client.

Specified by:
handleConstraintFailure in class PortletConnection
Returns:
false if the connection cannot handle the constraint failure.
Throws:
java.io.IOException

handleException

public boolean handleException(java.lang.Exception exception)
Description copied from class: PortletConnection
Handle an exception by sending some response to the client.

Specified by:
handleException in class PortletConnection
Returns:
false if the connection cannot handle the constraint failure.

canGuaranteeIntegrity

public boolean canGuaranteeIntegrity()
Return true if the connection can guarantee integrity (preventing data tampering in the communication process).

Specified by:
canGuaranteeIntegrity in class PortletConnection

canGuaranteeConfidentiality

public boolean canGuaranteeConfidentiality()
Return true if the connection can guarantee confidentiality (preventing reading while in transit).

Specified by:
canGuaranteeConfidentiality in class PortletConnection

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Attributes for the connection are HttpServletRequest attributes.

Specified by:
getAttribute in class PortletConnection

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object o)
Attributes for the connection are HttpServletRequest attributes.

Specified by:
setAttribute in class PortletConnection

removeAttribute

public void removeAttribute(java.lang.String name)
Attributes for the connection are HttpServletRequest attributes.

Specified by:
removeAttribute in class PortletConnection

getAttributeNames

public java.util.Enumeration getAttributeNames()
Attributes for the connection are HttpServletRequest attributes.

Specified by:
getAttributeNames in class PortletConnection
Returns:
an Enumeration of String

getPortletSession

public PortletSession getPortletSession(boolean create)
Description copied from class: PortletConnection
Return a PortletSession for the current client, or null if one is not available. A PortletSession once established will be consistently returned for a client on subsequent requests. Different clients will never have the same PortletSession.

Specified by:
getPortletSession in class PortletConnection

getScheme

public java.lang.String getScheme()
Description copied from class: PortletConnection
Return the scheme portion of the url that was used to make the request.

Specified by:
getScheme in class PortletConnection
See Also:
javax.portlet.PortletRequest#getScheme

getServerName

public java.lang.String getServerName()
Description copied from class: PortletConnection
Return the host name portion of the url that was used to make the request.

Specified by:
getServerName in class PortletConnection
See Also:
javax.portlet.PortletRequest#getServerName

getServerPort

public int getServerPort()
Description copied from class: PortletConnection
Return the port portion of the url that was used to make the request.

Specified by:
getServerPort in class PortletConnection
See Also:
javax.portlet.PortletRequest#getServerPort

getContextPath

public java.lang.String getContextPath()
Description copied from class: PortletConnection
Return the path to the portal portion of the url that was used to make the request.

Specified by:
getContextPath in class PortletConnection
See Also:
javax.portlet.PortletRequest#getContextPath

getAuthType

public java.lang.String getAuthType()
Description copied from class: PortletConnection
Return the authentication scheme used for the current request.

Specified by:
getAuthType in class PortletConnection
Returns:
PortletRequest.BASIC_AUTH, PortletRequest.CLIENT_CERT_AUTH, PortletRequest.DIGEST_AUTH, PortletRequest.FORM_AUTH, or a custom method.
See Also:
javax.portlet.PortletRequest#getAuthType

isSecure

public boolean isSecure()
Description copied from class: PortletConnection
Return true if the connection for the current request is secure, for example it uses HTTPS.

Specified by:
isSecure in class PortletConnection
See Also:
javax.portlet.PortletRequest#isSecure

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Description copied from class: PortletConnection
Return the session id that was supplied by the client for the current request.

Specified by:
getRequestedSessionId in class PortletConnection
See Also:
javax.portlet.PortletRequest#getRequestedSessionId

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Description copied from class: PortletConnection
Return true the session id that was supplied by the client for the current request is valid.

Specified by:
isRequestedSessionIdValid in class PortletConnection
See Also:
javax.portlet.PortletRequest#isRequestedSessionIdValid

getRemoteUser

public java.lang.String getRemoteUser()
Description copied from class: PortletConnection
Return the identity of the remote user, null if the identity has not been established.

Specified by:
getRemoteUser in class PortletConnection
See Also:
javax.portlet.PortletRequest#getRemoteUser

getUserPrincipal

public java.security.Principal getUserPrincipal()
Description copied from class: PortletConnection
Return a Principal that contains the identity of the remote user, null if the identity has not been established.

Specified by:
getUserPrincipal in class PortletConnection
See Also:
javax.portlet.PortletRequest#getUserPrincipal

isUserInRole

public boolean isUserInRole(java.lang.String role)
Description copied from class: PortletConnection
Return true if the identity of remote user has been established and the user has been assigned the role.

Specified by:
isUserInRole in class PortletConnection
See Also:
javax.portlet.PortletRequest#isUserInRole

getProperty

public java.lang.String getProperty(java.lang.String propertyName)
Description copied from class: PortletConnection
Return the value of the specified connection property as a String, null if the property was not provided by the request from the client. "properties" correspond to HTTP headers in the request for HTTP connections.

Specified by:
getProperty in class PortletConnection
See Also:
javax.portlet.PortletRequest#getProperty

getProperties

public java.util.Enumeration getProperties(java.lang.String propertyName)
Description copied from class: PortletConnection
Return the values of the specified connection property as an array of Strings, null if the property was not provided by the request from the client. "properties" correspond to HTTP headers in the request for HTTP connections.

Specified by:
getProperties in class PortletConnection
Returns:
an Enumeration of String
See Also:
javax.portlet.PortletRequest#getProperties

getPropertyNames

public java.util.Enumeration getPropertyNames()
Description copied from class: PortletConnection
Return the names of available properties for the connection. "properties" correspond to HTTP headers in the request for HTTP connections.

Specified by:
getPropertyNames in class PortletConnection
Returns:
an Enumeration of String
See Also:
javax.portlet.PortletRequest#getPropertyNames

getSubmitContentType

public java.lang.String getSubmitContentType()
Description copied from class: PortletConnection
Return the MIME type of the data supplied as the "body" of the request, null if not known.

Specified by:
getSubmitContentType in class PortletConnection
See Also:
javax.portlet.ActionRequest#getContentType

getSubmitContentLength

public int getSubmitContentLength()
Description copied from class: PortletConnection
Return the length of of the data supplied as the "body" of the request, -1 if not known.

Specified by:
getSubmitContentLength in class PortletConnection
See Also:
javax.portlet.ActionRequest#getContentLength

getSubmitInputStream

public java.io.InputStream getSubmitInputStream()
                                         throws java.io.IOException
Description copied from class: PortletConnection
Return the binary body of the current request.

Specified by:
getSubmitInputStream in class PortletConnection
Throws:
java.io.IOException
See Also:
javax.portlet.ActionRequest#getPortletInputStream

setSubmitCharacterEncoding

public void setSubmitCharacterEncoding(java.lang.String enc)
                                throws java.io.UnsupportedEncodingException,
                                       java.lang.IllegalStateException
Description copied from class: PortletConnection
Override the character encoding used by the Reader obtained using #getReader. This method must be called prior to reading input using #getReader or #getPortletInputStream.

Specified by:
setSubmitCharacterEncoding in class PortletConnection
Throws:
java.io.UnsupportedEncodingException
java.lang.IllegalStateException - if getReader() has already been called for this connection.
See Also:
javax.portlet.ActionRequest#setCharacterEncoding

getSubmitCharacterEncoding

public java.lang.String getSubmitCharacterEncoding()
Description copied from class: PortletConnection
Return the name of the character encoding that will be used by the Reader obtained using #getReader, null if none.

Specified by:
getSubmitCharacterEncoding in class PortletConnection
See Also:
javax.portlet.ActionRequest#getCharacterEncoding

getSubmitReader

public java.io.BufferedReader getSubmitReader()
                                       throws java.io.UnsupportedEncodingException,
                                              java.io.IOException
Specified by:
getSubmitReader in class PortletConnection
Throws:
java.io.UnsupportedEncodingException
java.io.IOException

encodeURL

public java.lang.String encodeURL(java.lang.String location)
A path with a schem is encoded only. A relative location (does not start with slash) is resolved relative to the servlet path and then encoded. An absolute url (begins with slash) is resolved relative to the context path and then encoded.

Specified by:
encodeURL in class PortletConnection

sendRedirect

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException
Specified by:
sendRedirect in class PortletConnection
Throws:
java.io.IOException

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Description copied from class: PortletConnection
Set a property to be returned to the client. "properties" correspond to HTTP headers in the response for HTTP connections.

Specified by:
setProperty in class PortletConnection
See Also:
javax.portlet.PortletResponse#setProperty

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)
Description copied from class: PortletConnection
Add a value to a property to be returned to the client. "properties" correspond to HTTP headers in the response for HTTP connections.

Specified by:
addProperty in class PortletConnection
See Also:
javax.portlet.PortletResponse#addProperty

setContentType

public void setContentType(java.lang.String contentType)
Description copied from class: PortletConnection
Set the content type to use for the response.

Specified by:
setContentType in class PortletConnection

getContentType

public java.lang.String getContentType()
Return the content type established with setContentType(), or null if setContentType() has not been called.

Specified by:
getContentType in class PortletConnection

setLocale

public void setLocale(java.util.Locale locale)
Description copied from class: PortletConnection
Set the locale to use for the response.

Specified by:
setLocale in class PortletConnection

getLocale

public java.util.Locale getLocale()
Return the Locale established with setLocale(), or null if setLocale() has not been called.

Specified by:
getLocale in class PortletConnection

setBufferSize

public void setBufferSize(int size)
Specified by:
setBufferSize in class PortletConnection

getBufferSize

public int getBufferSize()
Specified by:
getBufferSize in class PortletConnection

flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Specified by:
flushBuffer in class PortletConnection
Throws:
java.io.IOException

resetBuffer

public void resetBuffer()
Specified by:
resetBuffer in class PortletConnection

reset

public void reset()
Specified by:
reset in class PortletConnection

isCommitted

public boolean isCommitted()
Specified by:
isCommitted in class PortletConnection

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Specified by:
getOutputStream in class PortletConnection
Throws:
java.io.IOException

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Specified by:
getCharacterEncoding in class PortletConnection

setCharacterEncoding

public void setCharacterEncoding(java.lang.String enc)
                          throws java.io.UnsupportedEncodingException
Specified by:
setCharacterEncoding in class PortletConnection
Throws:
java.io.UnsupportedEncodingException

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Specified by:
getWriter in class PortletConnection
Throws:
java.io.IOException