org.jasig.portal.channels.error
Class CError

java.lang.Object
  extended by org.jasig.portal.channels.BaseChannel
      extended by org.jasig.portal.channels.error.CError
All Implemented Interfaces:
ICacheable, IChannel, ICharacterChannel, IPrivileged, IPrivilegedChannel

public final class CError
extends BaseChannel
implements IPrivilegedChannel, ICacheable, ICharacterChannel

CError is the error channel, also known as the null channel; it is designed to render in place of other channels when something goes wrong.

Possible conditions when CError is invoked are:

Since:
uPortal 2.5. Prior to 2.5, CError existed only as org.jasig.portal.channels.CError.
Version:
$Revision: 1.7.2.2 $ $Date: 2005/09/09 16:12:09 $
Author:
Peter Kharchenko, pkharchenko@interactivebusiness.com, andrew.petro@yale.edu

Nested Class Summary
private  class CError.RefreshPolicy
          Class to represent policy about whether channel refresh and reinstantiation is allowed.
 
Field Summary
private  ErrorDocument errorDocument
          An ErrorDocument representing the error about which we are reporting and providing a source for XML to be rendered by our XSLT.
private static org.apache.commons.logging.Log log
           
private static MediaManager MEDIAMANAGER
           
private  boolean placeHolder
          CError is a placeholder when it is taking the place of a channel that no longer exists or that the user doesn't have permission to render.
private  PortalControlStructures portcs
           
private  boolean showStackTrace
          True if we should display the stack trace of the stored Throwable, if any, at rendering.
private static java.lang.String sslLocation
          The location of our our .ssl file.
private  java.lang.String ssTitle
          The title of the stylesheet we should use to render.
private  IChannel the_channel
          The channel instance that failed.
 
Fields inherited from class org.jasig.portal.channels.BaseChannel
runtimeData, staticData
 
Constructor Summary
CError()
          Construct an uninitialized instance of the CError channel.
CError(ErrorCode errorCode, java.lang.String message, java.lang.String channelSubscribeId, IChannel channelInstance)
          Instantiate a CError representing a particular channel's failure, including a message and errorCode, but not a Throwable.
CError(ErrorCode errorCode, java.lang.Throwable throwable, java.lang.String channelSubscribeId, IChannel channelInstance)
          Construct an instance of the Error channel representing a failure to render of a particular subscribed channel for reason of having thrown a Throwable.
CError(ErrorCode errorCode, java.lang.Throwable exception, java.lang.String channelSubscribeId, IChannel channelInstance, java.lang.String message)
          Instantiate a CError instance representing the failure of some particular channel, including an error code, message, and the Throwable.
 
Method Summary
private  CError.RefreshPolicy computeRefreshPolicy()
          Compute the refresh policy.
 ChannelCacheKey generateKey()
          Requests the channel to generate a key uniqly describing it's current state, and a description of key usage.
 ErrorDocument getErrorDocument()
           
 boolean isCacheValid(java.lang.Object validity)
          Requests the channel to verify validity of the retreived cache based on the validator object.
(package private)  boolean isPlaceHolder()
          Returns true iff this CError instance is acting as a placeholder.
private  void localRenderXML(org.xml.sax.ContentHandler out)
           
 void receiveEvent(PortalEvent ev)
          Passes an outside event to a channel.
 void renderCharacters(java.io.PrintWriter out)
          Asks the channel to render its content as characters.
 void renderXML(org.xml.sax.ContentHandler out)
          Ask channel to render its content.
private  void resetCError(ErrorCode errorCode, java.lang.Throwable throwable, java.lang.String channelSubscribeId, IChannel channelInstance, java.lang.String message)
          Resets internal state of CError.
 void setErrorDocument(ErrorDocument errorDocument)
           
(package private)  void setPlaceHolder(boolean placeHolder)
          Configure this CError instance to act as a placeholder.
 void setPortalControlStructures(PortalControlStructures pcs)
          Passes portal control structure to the channel.
 void setStaticData(ChannelStaticData sd)
          Passes ChannelStaticData to the channel.
 java.lang.String toString()
           
 
Methods inherited from class org.jasig.portal.channels.BaseChannel
getRuntimeProperties, setRuntimeData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jasig.portal.IChannel
getRuntimeProperties, setRuntimeData
 
Methods inherited from interface org.jasig.portal.IChannel
getRuntimeProperties, setRuntimeData
 

Field Detail

log

private static final org.apache.commons.logging.Log log

errorDocument

private ErrorDocument errorDocument
An ErrorDocument representing the error about which we are reporting and providing a source for XML to be rendered by our XSLT.


the_channel

private IChannel the_channel
The channel instance that failed.


placeHolder

private boolean placeHolder
CError is a placeholder when it is taking the place of a channel that no longer exists or that the user doesn't have permission to render. CError is not a placeholder when it represents the failure of a channel that actually tried to render.


showStackTrace

private boolean showStackTrace
True if we should display the stack trace of the stored Throwable, if any, at rendering.


ssTitle

private java.lang.String ssTitle
The title of the stylesheet we should use to render.


portcs

private PortalControlStructures portcs

sslLocation

private static final java.lang.String sslLocation
The location of our our .ssl file.

See Also:
Constant Field Values

MEDIAMANAGER

private static final MediaManager MEDIAMANAGER
Constructor Detail

CError

public CError()
Construct an uninitialized instance of the CError channel.


CError

public CError(ErrorCode errorCode,
              java.lang.Throwable throwable,
              java.lang.String channelSubscribeId,
              IChannel channelInstance)
Construct an instance of the Error channel representing a failure to render of a particular subscribed channel for reason of having thrown a Throwable.

Parameters:
errorCode - - one of the static error codes of this class
throwable - - cause of failed channel's failure
channelSubscribeId - - identifies the failed channel
channelInstance - - the failed channel

CError

public CError(ErrorCode errorCode,
              java.lang.String message,
              java.lang.String channelSubscribeId,
              IChannel channelInstance)
Instantiate a CError representing a particular channel's failure, including a message and errorCode, but not a Throwable.

Parameters:
errorCode - - one of the static error codes of this class
message - - describes error
channelSubscribeId - - identifies failed channel
channelInstance - - failed channel

CError

public CError(ErrorCode errorCode,
              java.lang.Throwable exception,
              java.lang.String channelSubscribeId,
              IChannel channelInstance,
              java.lang.String message)
Instantiate a CError instance representing the failure of some particular channel, including an error code, message, and the Throwable.

Parameters:
errorCode - - one of the static error codes of this class
exception - - thrown by the failed channel
channelSubscribeId - - identifies failed channel
channelInstance - - the failed channel instance
message - - message describing failure
Method Detail

resetCError

private void resetCError(ErrorCode errorCode,
                         java.lang.Throwable throwable,
                         java.lang.String channelSubscribeId,
                         IChannel channelInstance,
                         java.lang.String message)
Resets internal state of CError.

Parameters:
errorCode - - new errorCode value
throwable - - new stored Throwable
channelSubscribeId - - new channelSubscribeId
channelInstance - - new failed channel
message - - new failure message

setPortalControlStructures

public void setPortalControlStructures(PortalControlStructures pcs)
Description copied from interface: IPrivileged
Passes portal control structure to the channel.

Specified by:
setPortalControlStructures in interface IPrivileged
See Also:
PortalControlStructures

receiveEvent

public void receiveEvent(PortalEvent ev)
Description copied from interface: IChannel
Passes an outside event to a channel. Events should normally come from the LayoutBean.

Specified by:
receiveEvent in interface IChannel
Overrides:
receiveEvent in class BaseChannel
Parameters:
ev - PortalEvent object
See Also:
PortalEvent

setStaticData

public void setStaticData(ChannelStaticData sd)
Description copied from interface: IChannel
Passes ChannelStaticData to the channel. This is done during channel instantiation time. see org.jasig.portal.ChannelStaticData

Specified by:
setStaticData in interface IChannel
Overrides:
setStaticData in class BaseChannel
Parameters:
sd - channel static data
See Also:
ChannelStaticData

renderXML

public void renderXML(org.xml.sax.ContentHandler out)
Description copied from interface: IChannel
Ask channel to render its content.

Specified by:
renderXML in interface IChannel
Overrides:
renderXML in class BaseChannel
Parameters:
out - the SAX ContentHandler to output content to

localRenderXML

private void localRenderXML(org.xml.sax.ContentHandler out)

generateKey

public ChannelCacheKey generateKey()
Description copied from interface: ICacheable
Requests the channel to generate a key uniqly describing it's current state, and a description of key usage.

Specified by:
generateKey in interface ICacheable

isCacheValid

public boolean isCacheValid(java.lang.Object validity)
Description copied from interface: ICacheable
Requests the channel to verify validity of the retreived cache based on the validator object.

Specified by:
isCacheValid in interface ICacheable

renderCharacters

public void renderCharacters(java.io.PrintWriter out)
                      throws PortalException
Description copied from interface: ICharacterChannel
Asks the channel to render its content as characters. The method has the same call precedence as the IChannel.renderXML() method. (i.e. if the channel also supports ICacheable, portal will try to find a cache entry prior calling this method)

Specified by:
renderCharacters in interface ICharacterChannel
Parameters:
out - a PrintWriter value into which the character output should be directed
Throws:
PortalException - if an error occurs

computeRefreshPolicy

private CError.RefreshPolicy computeRefreshPolicy()
Compute the refresh policy. Assumes channel subcribe ID is not null, since in that case there is no question about the policy - you cannot reinstantiate or refresh unknown channels.

Returns:
a RefreshPolicy suitable to our state.

getErrorDocument

public ErrorDocument getErrorDocument()
Returns:
Returns the errorDocument.

setErrorDocument

public void setErrorDocument(ErrorDocument errorDocument)
Parameters:
errorDocument - The errorDocument to set.

isPlaceHolder

boolean isPlaceHolder()
Returns true iff this CError instance is acting as a placeholder.

Returns:
Returns true iff this CError instance is acting as a placeholder.

setPlaceHolder

void setPlaceHolder(boolean placeHolder)
Configure this CError instance to act as a placeholder. In placeholder mode, we do not present refresh and restart controls. Instead, we display a message about why we have taken the place of a channel - perhaps because the user is not authorized to view the channel or because the channel no longer exists.

Parameters:
placeHolder - true to suppress refresh and renew controls, false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class BaseChannel