|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.caucho.portal.generic.PortletConnection
public abstract class PortletConnection
A PortletConnection is used to obtain Action and Render
objects.
For implementations that support only one portlet for each connection,
the pattern of use is:
Window window = ...;
Portlet portlet = ...;
Action action = connection.getAction(window);
if (action != null) {
try {
if (action.isTarget())
action.processAction(portlet);
}
finally {
action.finish();
}
}
Render render = connection.getRender(window);
if (render != null) {
try {
render.render(portlet);
}
finally {
render.finish();
}
}
For implementations that support more than one portlet for each connection,
each portlet is identified with a namespace. An optional Renderer is
specified, it is used to obtain a Writer or OutputStream when the portlet
requests it.
Window window = ...;
Portlet portlet = ...;
String namespace = "...";
Action action = connection.getAction(window, namespace);
if (action != null) {
try {
if (action.isTarget())
action.processAction(portlet);
}
finally {
action.finish();
}
}
Render render = connection.getRender(window, namespace);
if (render != null) {
try {
render.render(portlet);
}
finally {
render.finish();
}
}
getAction(PortletRequest),
getRender(PortletRequest),
Action,
Render| Field Summary | |
|---|---|
static java.util.logging.Logger |
log
|
static java.lang.String |
PORTLET_CONNECTION
Name of the request attribute that stores the connection |
| Constructor Summary | |
|---|---|
protected |
PortletConnection()
|
| Method Summary | |
|---|---|
abstract void |
addProperty(java.lang.String name,
java.lang.String value)
Add a value to a property to be returned to the client. |
abstract boolean |
canGuaranteeConfidentiality()
Return true if the connection can guarantee confidentiality (preventing reading while in transit). |
abstract boolean |
canGuaranteeIntegrity()
Return true if the connection can guarantee integrity (preventing data tampering in the communication process). |
void |
checkForFailure()
Throw an exception if an error was encountered when using this conneciton. |
abstract java.lang.String |
encodeURL(java.lang.String path)
Encode a url with any special encoding needed by the protocol, for example by adding a sesison id. |
void |
finish()
|
abstract void |
flushBuffer()
|
static Action |
getAction(PortletRequest portletRequest)
Return the Action that corresponds to the PortletRequest, or null if there is not a current Action or Connection. |
Action |
getAction(Window window,
java.lang.String namespace)
Get an Action for a namespace. |
abstract java.lang.Object |
getAttribute(java.lang.String name)
Get an attribute for the current connection. |
abstract java.util.Enumeration |
getAttributeNames()
Get a list of all attributes for the current connection. |
abstract java.lang.String |
getAuthType()
Return the authentication scheme used for the current request. |
abstract int |
getBufferSize()
|
abstract java.lang.String |
getCharacterEncoding()
|
abstract java.util.Set<java.lang.String> |
getClientCharacterEncodings()
Get the character encodings acceptable to the client. |
abstract java.util.Set<java.lang.String> |
getClientContentTypes()
Get the content types acceptable to the client. |
abstract java.util.Set<java.util.Locale> |
getClientLocales()
Get the locales acceptable to the client. |
static PortletConnection |
getConnection(PortletRequest portletRequest)
Return the connection that corresponds to the PortletRequest |
abstract java.lang.String |
getContentType()
Return the content type established with setContentType(), or null if setContentType() has not been called. |
abstract java.lang.String |
getContextPath()
Return the path to the portal portion of the url that was used to make the request. |
Action |
getCurrentAction()
Get the current Action object, established from a call to getRender(). |
Render |
getCurrentRender()
Get the current Render object, established from a call to getRender(). |
protected int |
getExpirationCache()
Used in derived classes during finish() to determine the maximum expires time for the connection, derived classes use this value to send an expires timeout to the client. |
java.lang.String |
getId()
A unique identifier for this connection object, used for debugging |
abstract java.util.Locale |
getLocale()
Return the Locale established with setLocale(), or null if setLocale() has not been called. |
abstract java.io.OutputStream |
getOutputStream()
|
Portal |
getPortal()
|
static Portal |
getPortal(PortletRequest portletRequest)
Return the Portal that corresponds to the PortletRequest, or null if there is not a current Portal or Connection. |
abstract PortletSession |
getPortletSession(boolean create)
Return a PortletSession for the current client, or null if one is
not available. |
abstract 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. |
abstract 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. |
abstract java.util.Enumeration |
getPropertyNames()
Return the names of available properties for the connection. |
abstract java.lang.String |
getRemoteUser()
Return the identity of the remote user, null if the identity has not been established. |
static Render |
getRender(PortletRequest portletRequest)
Return the Render that corresponds to the PortletRequest, or null if there is not a current Render or Connection. |
Render |
getRender(Window window,
java.lang.String namespace)
Get a Render for a namespace. |
abstract java.lang.String |
getRequestedSessionId()
Return the session id that was supplied by the client for the current request. |
abstract java.lang.String |
getScheme()
Return the scheme portion of the url that was used to make the request. |
abstract java.lang.String |
getServerName()
Return the host name portion of the url that was used to make the request. |
abstract int |
getServerPort()
Return the port portion of the url that was used to make the request. |
abstract java.lang.String |
getSubmitCharacterEncoding()
Return the name of the character encoding that will be used by the Reader obtained using #getReader, null if none. |
abstract int |
getSubmitContentLength()
Return the length of of the data supplied as the "body" of the request, -1 if not known. |
abstract java.lang.String |
getSubmitContentType()
Return the MIME type of the data supplied as the "body" of the request, null if not known. |
abstract java.io.InputStream |
getSubmitInputStream()
Return the binary body of the current request. |
abstract java.io.BufferedReader |
getSubmitReader()
|
abstract java.security.Principal |
getUserPrincipal()
Return a Principal that contains the identity of
the remote user, null if the identity has not been established. |
abstract java.io.PrintWriter |
getWriter()
|
abstract boolean |
handleConstraintFailure(Constraint constraint,
int failureCode)
Handle a constraint failure by sending some response to the client. |
abstract boolean |
handleException(java.lang.Exception exception)
Handle an exception by sending some response to the client. |
abstract boolean |
isCommitted()
|
boolean |
isConnectionFailed()
A connection fails if an unrecoverable error occurs. |
protected boolean |
isPrivate()
Used in derived classes during finish() to determine if the response is private |
abstract boolean |
isRequestedSessionIdValid()
Return true the session id that was supplied by the client for the current request is valid. |
abstract boolean |
isSecure()
Return true if the connection for the current request is secure, for example it uses HTTPS. |
abstract 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. |
abstract void |
removeAttribute(java.lang.String name)
Remove an attribute for the current connection. |
abstract void |
reset()
|
abstract void |
resetBuffer()
|
abstract java.lang.String |
resolveURL(java.lang.String partialUrl)
Resolve a url so that it makes a request to the portal |
abstract java.lang.String |
resolveURL(java.lang.String partialUrl,
boolean isSecure)
Resolve a url so that it makes a request to the portal with the specified level of security. |
abstract void |
sendRedirect(java.lang.String location)
|
abstract void |
setAttribute(java.lang.String name,
java.lang.Object o)
Set an attribute for the current connection. |
abstract void |
setBufferSize(int size)
|
abstract void |
setCharacterEncoding(java.lang.String enc)
|
void |
setConnectionFailed()
Used to indicate that the connection has failed. |
void |
setConnectionFailed(java.lang.Exception ex)
Used to indicate that the connection has failed. |
abstract void |
setContentType(java.lang.String contentType)
Set the content type to use for the response. |
abstract void |
setLocale(java.util.Locale locale)
Set the locale to use for the response. |
abstract void |
setProperty(java.lang.String name,
java.lang.String value)
Set a property to be returned to the client. |
abstract void |
setSubmitCharacterEncoding(java.lang.String enc)
Override the character encoding used by the Reader obtained using #getReader. |
void |
start(Portal portal,
InvocationFactory invocationFactory)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PORTLET_CONNECTION
public static final java.util.logging.Logger log
| Constructor Detail |
|---|
protected PortletConnection()
| Method Detail |
|---|
public static PortletConnection getConnection(PortletRequest portletRequest)
public static Portal getPortal(PortletRequest portletRequest)
public static Action getAction(PortletRequest portletRequest)
public static Render getRender(PortletRequest portletRequest)
public java.lang.String getId()
public void start(Portal portal,
InvocationFactory invocationFactory)
public void finish()
public Portal getPortal()
public void setConnectionFailed()
public void setConnectionFailed(java.lang.Exception ex)
public boolean isConnectionFailed()
public abstract boolean handleConstraintFailure(Constraint constraint,
int failureCode)
throws java.io.IOException
java.io.IOExceptionpublic abstract boolean handleException(java.lang.Exception exception)
public abstract boolean canGuaranteeIntegrity()
public abstract boolean canGuaranteeConfidentiality()
public abstract void setAttribute(java.lang.String name,
java.lang.Object o)
public abstract java.lang.Object getAttribute(java.lang.String name)
public abstract void removeAttribute(java.lang.String name)
public abstract java.util.Enumeration getAttributeNames()
public abstract PortletSession getPortletSession(boolean create)
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.
create, - if true create a new session if one does not already exist
for the client.public abstract java.lang.String getScheme()
javax.portlet.PortletRequest#getSchemepublic abstract java.lang.String getServerName()
javax.portlet.PortletRequest#getServerNamepublic abstract int getServerPort()
javax.portlet.PortletRequest#getServerPortpublic abstract java.lang.String getContextPath()
javax.portlet.PortletRequest#getContextPathpublic abstract java.lang.String getAuthType()
javax.portlet.PortletRequest#getAuthTypepublic abstract boolean isSecure()
javax.portlet.PortletRequest#isSecurepublic abstract java.lang.String getRequestedSessionId()
javax.portlet.PortletRequest#getRequestedSessionIdpublic abstract boolean isRequestedSessionIdValid()
javax.portlet.PortletRequest#isRequestedSessionIdValidpublic abstract java.lang.String getRemoteUser()
javax.portlet.PortletRequest#getRemoteUserpublic abstract java.security.Principal getUserPrincipal()
Principal that contains the identity of
the remote user, null if the identity has not been established.
javax.portlet.PortletRequest#getUserPrincipalpublic abstract boolean isUserInRole(java.lang.String role)
javax.portlet.PortletRequest#isUserInRolepublic abstract java.lang.String getProperty(java.lang.String propertyName)
javax.portlet.PortletRequest#getPropertypublic abstract java.util.Enumeration getProperties(java.lang.String propertyName)
javax.portlet.PortletRequest#getPropertiespublic abstract java.util.Enumeration getPropertyNames()
javax.portlet.PortletRequest#getPropertyNamespublic abstract java.util.Set<java.lang.String> getClientContentTypes()
public abstract java.util.Set<java.util.Locale> getClientLocales()
public abstract java.util.Set<java.lang.String> getClientCharacterEncodings()
public abstract java.lang.String getSubmitContentType()
javax.portlet.ActionRequest#getContentTypepublic abstract int getSubmitContentLength()
javax.portlet.ActionRequest#getContentLength
public abstract java.io.InputStream getSubmitInputStream()
throws java.io.IOException,
java.lang.IllegalStateException
java.lang.IllegalStateException - if getReader() has already been
called for this connection.
java.io.IOExceptionjavax.portlet.ActionRequest#getPortletInputStream
public abstract void setSubmitCharacterEncoding(java.lang.String enc)
throws java.io.UnsupportedEncodingException,
java.lang.IllegalStateException
#getReader. This method must be called prior to reading
input using #getReader or #getPortletInputStream.
java.io.UnsupportedEncodingException
java.lang.IllegalStateException - if getReader() has already been called for
this connection.javax.portlet.ActionRequest#setCharacterEncodingpublic abstract java.lang.String getSubmitCharacterEncoding()
#getReader, null if none.
javax.portlet.ActionRequest#getCharacterEncoding
public abstract java.io.BufferedReader getSubmitReader()
throws java.io.UnsupportedEncodingException,
java.io.IOException
java.io.UnsupportedEncodingException
java.io.IOExceptionpublic abstract java.lang.String encodeURL(java.lang.String path)
public abstract java.lang.String resolveURL(java.lang.String partialUrl)
public abstract java.lang.String resolveURL(java.lang.String partialUrl,
boolean isSecure)
throws PortletSecurityException
PortletSecurityException
public abstract void sendRedirect(java.lang.String location)
throws java.lang.IllegalStateException,
java.io.IOException
java.lang.IllegalStateException
java.io.IOException
public abstract void setProperty(java.lang.String name,
java.lang.String value)
javax.portlet.PortletResponse#setProperty
public abstract void addProperty(java.lang.String name,
java.lang.String value)
javax.portlet.PortletResponse#addPropertypublic abstract void setContentType(java.lang.String contentType)
public abstract java.lang.String getContentType()
public abstract void setLocale(java.util.Locale locale)
public abstract java.util.Locale getLocale()
public abstract void setBufferSize(int size)
public abstract int getBufferSize()
public abstract void flushBuffer()
throws java.io.IOException
java.io.IOExceptionpublic abstract void resetBuffer()
public abstract void reset()
public abstract boolean isCommitted()
public abstract java.io.OutputStream getOutputStream()
throws java.io.IOException
IllegalStatementException - if the content type has not been set
with setContentType.
java.io.IOExceptionpublic abstract java.lang.String getCharacterEncoding()
public abstract void setCharacterEncoding(java.lang.String enc)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public abstract java.io.PrintWriter getWriter()
throws java.io.IOException
IllegalStatementException - if the content type has not been set
with setContentType.
java.io.IOException
public Action getAction(Window window,
java.lang.String namespace)
throws PortletException,
java.io.IOException
PortletException - if the namespace has already been seen in the
actionstagephase of this connection
java.io.IOExceptionpublic Action getCurrentAction()
public Render getRender(Window window,
java.lang.String namespace)
throws PortletException,
java.io.IOException
PortletException - if the namespace has already been seen in the
render phase of this connection
java.io.IOExceptionpublic Render getCurrentRender()
public void checkForFailure()
throws PortletException
PortletExceptionprotected boolean isPrivate()
protected int getExpirationCache()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||