org.jasig.portal
Class ChannelManager

java.lang.Object
  extended by org.jasig.portal.ChannelManager
All Implemented Interfaces:
java.util.EventListener, LayoutEventListener

public class ChannelManager
extends java.lang.Object
implements LayoutEventListener

ChannelManager shall have the burden of squeezing content out of channels.

Validation and timeouts, these two are needed for smooth operation of the portal sometimes channels will timeout with information retreival then the content should be skipped.

Version:
$Revision: 1.124.2.12 $
Author:
Peter Kharchenko, pkharchenko@unicon.net

Field Summary
private  IAuthorizationPrincipal ap
           
private  BrowserInfo binfo
           
private  boolean ccaching
           
private static IChannelRendererFactory cChannelRendererFactory
          Factory used to build all channel renderer objects.
static java.lang.String channelAddressingPathElement
           
private  java.util.Map channelCacheTable
           
private  javax.naming.Context channelContext
           
private  java.util.Hashtable channelTable
           
private  java.lang.String channelTarget
           
private  boolean groupedRendering
           
private  java.util.HashMap iccListeners
           
private  java.util.HashMap iccTalkers
           
private  LocaleManager lm
           
private static org.apache.commons.logging.Log log
           
private  PortalControlStructures pcs
           
private  java.util.Set pendingChannels
           
private  javax.naming.Context portalContext
           
private  java.util.Hashtable rendererTable
           
private  java.util.Set repeatRenderings
           
static int SYSTEM_CHANNEL_CACHE_MIN_SIZE
           
static java.util.Map systemCache
           
private  java.util.Hashtable targetParams
           
 UPFileSpec uPElement
           
private  IUserPreferencesManager upm
           
private static boolean useAnchors
           
 
Constructor Summary
ChannelManager()
           
ChannelManager(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, IUserPreferencesManager manager, UPFileSpec uPElement)
          Creates a new ChannelManager instance.
ChannelManager(IUserPreferencesManager manager)
          Creates a new ChannelManager instance.
 
Method Summary
 void channelAdded(LayoutEvent ev)
           
 void channelDeleted(LayoutMoveEvent ev)
           
 void channelMoved(LayoutMoveEvent ev)
           
 void channelUpdated(LayoutEvent ev)
           
private  void clearRepeatedRenderings()
          Clear information about repeated rendering attempts.
 void commitToRenderingChannelSet()
          A method to notify ChannelManager that the channel set for the current rendering cycle is complete.
private  IChannel feedPortalControlStructuresToChannel(IChannel chObj, PortalControlStructures pcs)
           
private  IChannel feedRuntimeDataToChannel(IChannel chObj, javax.servlet.http.HttpServletRequest req)
           
 void finishedRenderingCycle()
          Clean up after a rendering round.
 void finishedSession()
          Handle end-of-session cleanup
 void folderAdded(LayoutEvent ev)
           
 void folderDeleted(LayoutMoveEvent ev)
           
 void folderMoved(LayoutMoveEvent ev)
           
 void folderUpdated(LayoutEvent ev)
           
 IChannel getChannelInstance(java.lang.String channelSubscribeId)
          Obtain an instance of a channel.
private static javax.naming.Context getChannelJndiContext(javax.naming.Context portalContext, java.lang.String sessionId, java.lang.String userId, java.lang.String layoutId)
          getChannelContext generates a JNDI context that will be passed to the regular channels.
 java.lang.String getChannelTarget()
           
 java.lang.String getChannelTitle(java.lang.String channelSubscribeId)
          Get the dynamic channel title for a given channelSubscribeID.
private  java.util.Set getListeningChannels(java.lang.String talkerChannelSubscribeId)
           
private static javax.naming.Context getPortalContext()
          Get the uPortal JNDI context
private  void handleRenderingError(java.lang.String channelSubscribeId, org.xml.sax.ContentHandler contentHandler, java.lang.Throwable t, int renderingStatus, java.lang.String commonMessage, java.lang.String technicalMessage, boolean partialOutput)
          Handles rendering output errors by replacing a channel instance with that of an error channel.
private  boolean hasListeningChannels(java.lang.String talkerChannelSubscribeId)
           
private  IChannel instantiateChannel(IUserLayoutChannelDescription cd)
           
 IChannel instantiateChannel(java.lang.String channelSubscribeId)
          Instantiates a channel given just the channel subscribe Id.
 boolean isCharacterCaching()
          Specifies if this particular rendering cycle is using character caching.
private  boolean isListeningToChannels(java.lang.String listenerChannelSubscribeId)
           
private  boolean isRepeatedRenderingAttempt(java.lang.String channelSubscribeId)
          Check if repeated rendering has been attempted for a given channel.
static boolean isUseAnchors()
          Determines whether or not anchors should be inserted at the end of URLS within channels.
 void layoutLoaded()
           
 void layoutSaved()
           
 void outputChannel(java.lang.String channelSubscribeId, org.xml.sax.ContentHandler contentHandler)
          Outputs a channel in to a given content handler.
 void passPortalEvent(java.lang.String channelSubscribeId, PortalEvent le)
          Passes a layout-level event to a channel.
private  void processRequestChannelParameters(javax.servlet.http.HttpServletRequest req)
          Determine target channel and pass corresponding actions/params to that channel
(package private)  void registerChannelDependency(java.lang.String listenerChannelSubscribeId, java.lang.String talkerChannelSubscribeId)
           
 void removeChannel(java.lang.String channelSubscribeId)
          Removes channel instance from the internal caches.
(package private)  void removeChannelDependency(java.lang.String listenerChannelSubscribeId, java.lang.String talkerChannelSubscribeId)
           
private  IChannel replaceWithErrorChannel(java.lang.String channelSubscribeId, ErrorCode errorCode, java.lang.Throwable t, java.lang.String message, boolean setRuntimeData)
          A helper method to replace all occurences of a given channel instance with that of an error channel.
private  IChannel replaceWithSecureInfoChannel(java.lang.String channelSubscribeId, boolean setRuntimeData)
          A helper method to replace all occurences of a secure channel instance with that of a secure information channel.
 void setChannelInstance(java.lang.String channelSubscribeId, IChannel channelInstance)
          Directly places a channel instance into the hashtable of active channels.
 void setCharacterCaching(boolean setting)
          Specify that the current rendering cycle should be using (or not) character caching.
 void setLocaleManager(LocaleManager lm)
           
private  void setRepeatedRenderingAttempt(java.lang.String channelSubscribeId)
          Register a repeated rendering attempt for a particular channel.
 void setUPElement(UPFileSpec uPElement)
          Specify UPFileSpec object that will be used to construct file portion of the context path in the auto-generated URLs, also known as the baseActionURL.
 void setUserPreferencesManager(IUserPreferencesManager m)
          Specify IUserPreferencesManager to use.
 IChannelRenderer startChannelRendering(java.lang.String channelSubscribeId)
          Initiate channel rendering cycle.
private  IChannelRenderer startChannelRendering(java.lang.String channelSubscribeId, boolean noTimeout)
          Initiate channel rendering cycle, possibly disabling timeout.
 void startRenderingCycle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, UPFileSpec uPElement)
          Signals the start of a new rendering cycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

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

upm

private IUserPreferencesManager upm

pcs

private PortalControlStructures pcs

channelTable

private java.util.Hashtable channelTable

rendererTable

private java.util.Hashtable rendererTable

channelCacheTable

private java.util.Map channelCacheTable

channelTarget

private java.lang.String channelTarget

targetParams

private java.util.Hashtable targetParams

binfo

private BrowserInfo binfo

lm

private LocaleManager lm

portalContext

private javax.naming.Context portalContext

channelContext

private javax.naming.Context channelContext

iccTalkers

private java.util.HashMap iccTalkers

iccListeners

private java.util.HashMap iccListeners

pendingChannels

private java.util.Set pendingChannels

groupedRendering

private boolean groupedRendering

ap

private IAuthorizationPrincipal ap

cChannelRendererFactory

private static final IChannelRendererFactory cChannelRendererFactory
Factory used to build all channel renderer objects.


uPElement

public UPFileSpec uPElement

SYSTEM_CHANNEL_CACHE_MIN_SIZE

public static final int SYSTEM_CHANNEL_CACHE_MIN_SIZE
See Also:
Constant Field Values

systemCache

public static final java.util.Map systemCache

channelAddressingPathElement

public static final java.lang.String channelAddressingPathElement
See Also:
Constant Field Values

useAnchors

private static boolean useAnchors

repeatRenderings

private java.util.Set repeatRenderings

ccaching

private boolean ccaching
Constructor Detail

ChannelManager

public ChannelManager()

ChannelManager

public ChannelManager(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      IUserPreferencesManager manager,
                      UPFileSpec uPElement)
Creates a new ChannelManager instance.

Parameters:
request - a HttpServletRequest value
response - a HttpServletResponse value
manager - an IUserPreferencesManager value
uPElement - an UPFileSpec that includes a tag number.

ChannelManager

public ChannelManager(IUserPreferencesManager manager)
Creates a new ChannelManager instance.

Parameters:
manager - an IUserPreferencesManager value
Method Detail

setChannelInstance

public void setChannelInstance(java.lang.String channelSubscribeId,
                               IChannel channelInstance)
Directly places a channel instance into the hashtable of active channels. This is designed to be used by the error channel only.


commitToRenderingChannelSet

public void commitToRenderingChannelSet()
A method to notify ChannelManager that the channel set for the current rendering cycle is complete. Note: This information is used to identify relevant channel communication dependencies


finishedRenderingCycle

public void finishedRenderingCycle()
Clean up after a rendering round.


finishedSession

public void finishedSession()
Handle end-of-session cleanup


outputChannel

public void outputChannel(java.lang.String channelSubscribeId,
                          org.xml.sax.ContentHandler contentHandler)
Outputs a channel in to a given content handler. If the current rendering cycle is targeting character cache output, and the content handler passed to the method is an instance of CachingSerializer, the method will take care of character cache compilation and store cache in the tables.

Parameters:
channelSubscribeId - a String value
contentHandler - a ContentHandler value

isRepeatedRenderingAttempt

private boolean isRepeatedRenderingAttempt(java.lang.String channelSubscribeId)
Check if repeated rendering has been attempted for a given channel.

Parameters:
channelSubscribeId - a String value
Returns:
a boolean value

setRepeatedRenderingAttempt

private void setRepeatedRenderingAttempt(java.lang.String channelSubscribeId)
Register a repeated rendering attempt for a particular channel.

Parameters:
channelSubscribeId - a String value

clearRepeatedRenderings

private void clearRepeatedRenderings()
Clear information about repeated rendering attempts.


handleRenderingError

private void handleRenderingError(java.lang.String channelSubscribeId,
                                  org.xml.sax.ContentHandler contentHandler,
                                  java.lang.Throwable t,
                                  int renderingStatus,
                                  java.lang.String commonMessage,
                                  java.lang.String technicalMessage,
                                  boolean partialOutput)
Handles rendering output errors by replacing a channel instance with that of an error channel. (or giving up if the error channel is failing as well)

Parameters:
channelSubscribeId - a String value
contentHandler - a ContentHandler value
t - a Throwable value
renderingStatus - an int value
commonMessage - a String value
technicalMessage - a String value
partialOutput - a boolean value

replaceWithErrorChannel

private IChannel replaceWithErrorChannel(java.lang.String channelSubscribeId,
                                         ErrorCode errorCode,
                                         java.lang.Throwable t,
                                         java.lang.String message,
                                         boolean setRuntimeData)
A helper method to replace all occurences of a given channel instance with that of an error channel.

Parameters:
channelSubscribeId - a String value
errorCode - an ErrorCode
t - a Throwable an exception that caused the problem
message - a String an optional message to pass to the error channel
setRuntimeData - a boolean wether the method should also set the ChannelRuntimeData for the newly instantiated error channel
Returns:
an IChannel value of an error channel instance

replaceWithSecureInfoChannel

private IChannel replaceWithSecureInfoChannel(java.lang.String channelSubscribeId,
                                              boolean setRuntimeData)
A helper method to replace all occurences of a secure channel instance with that of a secure information channel.

Parameters:
channelSubscribeId - a String value
setRuntimeData - a boolean wether the method should also set the ChannelRuntimeData for the newly instantiated secure info channel
Returns:
an IChannel value of a secure info channel instance

getChannelJndiContext

private static javax.naming.Context getChannelJndiContext(javax.naming.Context portalContext,
                                                          java.lang.String sessionId,
                                                          java.lang.String userId,
                                                          java.lang.String layoutId)
                                                   throws javax.naming.NamingException
getChannelContext generates a JNDI context that will be passed to the regular channels. The context is pieced together from the parts of the global portal context.

Parameters:
portalContext - uPortal JNDI context
sessionId - current session id
userId - id of a current user
layoutId - id of the layout used by the user
Returns:
a channel InitialContext value
Throws:
javax.naming.NamingException

getPortalContext

private static javax.naming.Context getPortalContext()
                                              throws javax.naming.NamingException
Get the uPortal JNDI context

Returns:
uPortal initial JNDI context
Throws:
javax.naming.NamingException

instantiateChannel

public IChannel instantiateChannel(java.lang.String channelSubscribeId)
                            throws PortalException
Instantiates a channel given just the channel subscribe Id.

Parameters:
channelSubscribeId - a channel instance Id in the userLayout
Returns:
an IChannel object
Throws:
PortalException

instantiateChannel

private IChannel instantiateChannel(IUserLayoutChannelDescription cd)
                             throws PortalException
Throws:
PortalException

passPortalEvent

public void passPortalEvent(java.lang.String channelSubscribeId,
                            PortalEvent le)
Passes a layout-level event to a channel.

Parameters:
channelSubscribeId - the channel subscribe id
le - the portal event

processRequestChannelParameters

private void processRequestChannelParameters(javax.servlet.http.HttpServletRequest req)
Determine target channel and pass corresponding actions/params to that channel

Parameters:
req - the HttpServletRequest

feedPortalControlStructuresToChannel

private IChannel feedPortalControlStructuresToChannel(IChannel chObj,
                                                      PortalControlStructures pcs)

feedRuntimeDataToChannel

private IChannel feedRuntimeDataToChannel(IChannel chObj,
                                          javax.servlet.http.HttpServletRequest req)

getChannelInstance

public IChannel getChannelInstance(java.lang.String channelSubscribeId)
Obtain an instance of a channel.

Parameters:
channelSubscribeId - a String value
Returns:
an IChannel object

removeChannel

public void removeChannel(java.lang.String channelSubscribeId)
Removes channel instance from the internal caches.

Parameters:
channelSubscribeId - a String value

startRenderingCycle

public void startRenderingCycle(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                UPFileSpec uPElement)
Signals the start of a new rendering cycle.

Parameters:
request - a HttpServletRequest value
response - a HttpServletResponse value
uPElement - an UPFileSpec value

isCharacterCaching

public boolean isCharacterCaching()
Specifies if this particular rendering cycle is using character caching.

Returns:
a boolean value

setCharacterCaching

public void setCharacterCaching(boolean setting)
Specify that the current rendering cycle should be using (or not) character caching.

Parameters:
setting - a boolean value

setUPElement

public void setUPElement(UPFileSpec uPElement)
Specify UPFileSpec object that will be used to construct file portion of the context path in the auto-generated URLs, also known as the baseActionURL.

Parameters:
uPElement - an UPFileSpec value

setUserPreferencesManager

public void setUserPreferencesManager(IUserPreferencesManager m)
Specify IUserPreferencesManager to use.

Parameters:
m - an IUserPreferencesManager value

startChannelRendering

public IChannelRenderer startChannelRendering(java.lang.String channelSubscribeId)
                                       throws PortalException
Initiate channel rendering cycle.

Parameters:
channelSubscribeId - a String value
Returns:
a IChannelRenderer value
Throws:
PortalException - if an error occurs

startChannelRendering

private IChannelRenderer startChannelRendering(java.lang.String channelSubscribeId,
                                               boolean noTimeout)
                                        throws PortalException
Initiate channel rendering cycle, possibly disabling timeout.

Parameters:
channelSubscribeId - a String value
noTimeout - a boolean value specifying if the time out rendering control should be disabled.
Returns:
a IChannelRenderer value
Throws:
PortalException - if an error occurs

registerChannelDependency

void registerChannelDependency(java.lang.String listenerChannelSubscribeId,
                               java.lang.String talkerChannelSubscribeId)

getListeningChannels

private java.util.Set getListeningChannels(java.lang.String talkerChannelSubscribeId)

isListeningToChannels

private boolean isListeningToChannels(java.lang.String listenerChannelSubscribeId)

hasListeningChannels

private boolean hasListeningChannels(java.lang.String talkerChannelSubscribeId)

removeChannelDependency

void removeChannelDependency(java.lang.String listenerChannelSubscribeId,
                             java.lang.String talkerChannelSubscribeId)

isUseAnchors

public static boolean isUseAnchors()
Determines whether or not anchors should be inserted at the end of URLS within channels. These anchors typically tell a browser to position itself with the channel in-view after a link is clicked or a form is submitted.

Returns:
true if use of anchors is enabled, otherwise false

getChannelTarget

public java.lang.String getChannelTarget()

channelAdded

public void channelAdded(LayoutEvent ev)
Specified by:
channelAdded in interface LayoutEventListener

channelUpdated

public void channelUpdated(LayoutEvent ev)
Specified by:
channelUpdated in interface LayoutEventListener

channelMoved

public void channelMoved(LayoutMoveEvent ev)
Specified by:
channelMoved in interface LayoutEventListener

channelDeleted

public void channelDeleted(LayoutMoveEvent ev)
Specified by:
channelDeleted in interface LayoutEventListener

folderAdded

public void folderAdded(LayoutEvent ev)
Specified by:
folderAdded in interface LayoutEventListener

folderUpdated

public void folderUpdated(LayoutEvent ev)
Specified by:
folderUpdated in interface LayoutEventListener

folderMoved

public void folderMoved(LayoutMoveEvent ev)
Specified by:
folderMoved in interface LayoutEventListener

folderDeleted

public void folderDeleted(LayoutMoveEvent ev)
Specified by:
folderDeleted in interface LayoutEventListener

layoutLoaded

public void layoutLoaded()
Specified by:
layoutLoaded in interface LayoutEventListener

layoutSaved

public void layoutSaved()
Specified by:
layoutSaved in interface LayoutEventListener

setLocaleManager

public void setLocaleManager(LocaleManager lm)

getChannelTitle

public java.lang.String getChannelTitle(java.lang.String channelSubscribeId)
Get the dynamic channel title for a given channelSubscribeID. Returns null if no dynamic channel (the rendering infrastructure calling this method should fall back on a default title when this method returns null).

Parameters:
channelSubscribeId -
Throws:
java.lang.IllegalArgumentException - if channelSubcribeId is null
java.lang.IllegalStateException - if