org.jasig.portal.layout.alm
Class AggregatedLayout

java.lang.Object
  extended by org.jasig.portal.layout.alm.AggregatedLayout
All Implemented Interfaces:
IAggregatedLayout, IUserLayout
Direct Known Subclasses:
ALFragment

public class AggregatedLayout
extends java.lang.Object
implements IAggregatedLayout

The aggregated user layout implementation. Prior to uPortal 2.5, this class existed in the package org.jasig.portal.layout. It was moved to its present package to reflect that it is part of Aggregated Layouts.

Version:
$Revision: 1.2.2.8 $
Author:
Michael Ivanov

Field Summary
private  java.lang.String cacheKey
           
private static GuidGenerator guid
           
private  java.util.Hashtable layout
           
private  java.lang.String layoutId
           
private  IAggregatedUserLayoutManager layoutManager
           
private static org.apache.commons.logging.Log LOG
           
 
Fields inherited from interface org.jasig.portal.layout.alm.IAggregatedLayout
ADD_TARGET, CHANNEL, FOLDER, FRAGMENT, LAYOUT, MOVE_TARGET, PARAMETER, RESTRICTION
 
Fields inherited from interface org.jasig.portal.layout.IUserLayout
ROOT_NODE_NAME
 
Constructor Summary
AggregatedLayout(java.lang.String layoutId)
           
AggregatedLayout(java.lang.String layoutId, IAggregatedUserLayoutManager layoutManager)
           
 
Method Summary
 boolean addLayoutEventListener(LayoutEventListener l)
          Register a layout event listener
private  void appendDescendants(org.w3c.dom.Document domLayout, org.w3c.dom.Node node, java.lang.String nodeId)
          Build the DOM consistent of folders and channels using the internal representation
private  void bindRestrictions(IALNodeDescription nodeDesc, org.xml.sax.ContentHandler contentHandler)
           
private  void createMarkingLeaf(org.xml.sax.ContentHandler contentHandler, java.lang.String leafName, java.lang.String parentNodeId, java.lang.String nextNodeId)
           
private  void createMarkingLeaf(org.w3c.dom.Document document, java.lang.String leafName, java.lang.String parentNodeId, java.lang.String nextNodeId, org.w3c.dom.Node node)
           
 java.lang.String getCacheKey()
          Return a cache key, uniqly corresponding to the composition and the structure of the user layout.
 java.util.Enumeration getChildIds(java.lang.String nodeId)
          Returns a list of child node Ids for a given node.
 int getDepth(java.lang.String nodeId)
          Gets the tree depth for a given node
 ALNode getFirstSiblingNode(java.lang.String nodeId)
           
 java.lang.String getFragmentId(java.lang.String nodeId)
          Returns an fragment Id for a given node.
 java.util.Set getFragmentIds()
          Returns a list of fragment Ids existing in the layout.
 java.lang.String getFragmentRootId(java.lang.String fragmentId)
          Returns an fragment root Id for a given fragment.
 java.lang.String getId()
          Returns a layout Id associated with this manager/
 ALNode getLastSiblingNode(java.lang.String nodeId)
           
 java.util.Hashtable getLayoutData()
           
 ALFolder getLayoutFolder(java.lang.String folderId)
          Returns the folder by a given folder ID.
 ALNode getLayoutNode(java.lang.String nodeId)
          Returns the node by a given node ID.
 java.lang.String getNextSiblingId(java.lang.String nodeId)
          Determine an Id of a next sibling node.
 ALNode getNode(java.lang.String nodeId)
          Returns a node specified by a node ID.
 IUserLayoutNodeDescription getNodeDescription(java.lang.String nodeId)
          Obtain a description of a node (channel or a folder) in a given user layout.
 java.lang.String getNodeId(java.lang.String fname)
          Returns a node id associated with the supplied functional name.
 java.util.Enumeration getNodeIds()
          Returns a list of node Ids in the layout.
 java.lang.String getParentId(java.lang.String nodeId)
          Returns an Id of a parent user layout node.
 java.lang.String getPreviousSiblingId(java.lang.String nodeId)
          Determine an Id of a previous sibling node.
 java.lang.String getRootId()
          Returns an id of the root node.
 boolean removeLayoutEventListener(LayoutEventListener l)
          Remove a registered layout event listener.
 void setLayoutData(java.util.Hashtable layout)
           
 void setLayoutManager(IAggregatedUserLayoutManager layoutManager)
           
private  void updateCacheKey()
           
 void writeTo(org.xml.sax.ContentHandler ch)
          Writes user layout content (with appropriate markings) into a ContentHandler
 void writeTo(org.w3c.dom.Document document)
          Writes user layout content (with appropriate markings) into a Document object
 void writeTo(java.lang.String nodeId, org.xml.sax.ContentHandler contentHandler)
          Writes subtree of a user layout (with appropriate markings) defined by a particular node into a ContentHandler
 void writeTo(java.lang.String nodeId, org.w3c.dom.Document document)
          Writes subtree of a user layout (with appropriate markings) defined by a particular node into a Document
 
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

layout

private java.util.Hashtable layout

layoutId

private java.lang.String layoutId

layoutManager

private IAggregatedUserLayoutManager layoutManager

guid

private static GuidGenerator guid

cacheKey

private java.lang.String cacheKey
Constructor Detail

AggregatedLayout

public AggregatedLayout(java.lang.String layoutId,
                        IAggregatedUserLayoutManager layoutManager)
                 throws PortalException
Throws:
PortalException

AggregatedLayout

public AggregatedLayout(java.lang.String layoutId)
                 throws PortalException
Throws:
PortalException
Method Detail

setLayoutManager

public void setLayoutManager(IAggregatedUserLayoutManager layoutManager)

setLayoutData

public void setLayoutData(java.util.Hashtable layout)
                   throws PortalException
Throws:
PortalException

getLayoutData

public java.util.Hashtable getLayoutData()
                                  throws PortalException
Throws:
PortalException

updateCacheKey

private void updateCacheKey()

bindRestrictions

private void bindRestrictions(IALNodeDescription nodeDesc,
                              org.xml.sax.ContentHandler contentHandler)
                       throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

getLayoutNode

public ALNode getLayoutNode(java.lang.String nodeId)
Description copied from interface: IAggregatedLayout
Returns the node by a given node ID.

Specified by:
getLayoutNode in interface IAggregatedLayout
Parameters:
nodeId - a String value
Returns:
a ALNode instance

getLayoutFolder

public ALFolder getLayoutFolder(java.lang.String folderId)
Description copied from interface: IAggregatedLayout
Returns the folder by a given folder ID.

Specified by:
getLayoutFolder in interface IAggregatedLayout
Parameters:
folderId - a String value
Returns:
a ALFolder instance

getLastSiblingNode

public ALNode getLastSiblingNode(java.lang.String nodeId)

getFirstSiblingNode

public ALNode getFirstSiblingNode(java.lang.String nodeId)

getDepth

public int getDepth(java.lang.String nodeId)
             throws PortalException
Gets the tree depth for a given node

Specified by:
getDepth in interface IAggregatedLayout
Parameters:
nodeId - a String node ID
Returns:
a depth value
Throws:
PortalException - if an error occurs

createMarkingLeaf

private void createMarkingLeaf(org.xml.sax.ContentHandler contentHandler,
                               java.lang.String leafName,
                               java.lang.String parentNodeId,
                               java.lang.String nextNodeId)
                        throws PortalException
Throws:
PortalException

createMarkingLeaf

private void createMarkingLeaf(org.w3c.dom.Document document,
                               java.lang.String leafName,
                               java.lang.String parentNodeId,
                               java.lang.String nextNodeId,
                               org.w3c.dom.Node node)
                        throws PortalException
Throws:
PortalException

appendDescendants

private void appendDescendants(org.w3c.dom.Document domLayout,
                               org.w3c.dom.Node node,
                               java.lang.String nodeId)
                        throws PortalException
Build the DOM consistent of folders and channels using the internal representation

Parameters:
domLayout - a Document a user layout document.
node - a Element a node that will be used as a root for the tree construction
nodeId - a String a nodeId from the user layout internal representation
Throws:
PortalException - if an error occurs

getFragmentIds

public java.util.Set getFragmentIds()
                             throws PortalException
Returns a list of fragment Ids existing in the layout.

Specified by:
getFragmentIds in interface IAggregatedLayout
Returns:
a Set of String fragment Ids.
Throws:
PortalException - if an error occurs

getFragmentId

public java.lang.String getFragmentId(java.lang.String nodeId)
                               throws PortalException
Returns an fragment Id for a given node. Returns null if the node is not part of any fragments.

Specified by:
getFragmentId in interface IAggregatedLayout
Parameters:
nodeId - a String value
Returns:
a String fragment Id
Throws:
PortalException - if an error occurs

getFragmentRootId

public java.lang.String getFragmentRootId(java.lang.String fragmentId)
                                   throws PortalException
Returns an fragment root Id for a given fragment.

Specified by:
getFragmentRootId in interface IAggregatedLayout
Parameters:
fragmentId - a String value
Returns:
a String fragment root Id
Throws:
PortalException - if an error occurs

writeTo

public void writeTo(org.xml.sax.ContentHandler ch)
             throws PortalException
Writes user layout content (with appropriate markings) into a ContentHandler

Specified by:
writeTo in interface IUserLayout
Parameters:
ch - a ContentHandler value
Throws:
PortalException - if an error occurs

writeTo

public void writeTo(java.lang.String nodeId,
                    org.xml.sax.ContentHandler contentHandler)
             throws PortalException
Writes subtree of a user layout (with appropriate markings) defined by a particular node into a ContentHandler

Specified by:
writeTo in interface IUserLayout
Parameters:
nodeId - a String a node determining a user layout subtree.
contentHandler - a ContentHandler value
Throws:
PortalException - if an error occurs

writeTo

public void writeTo(org.w3c.dom.Document document)
             throws PortalException
Writes user layout content (with appropriate markings) into a Document object

Specified by:
writeTo in interface IUserLayout
Parameters:
document - a Document value
Throws:
PortalException - if an error occurs

writeTo

public void writeTo(java.lang.String nodeId,
                    org.w3c.dom.Document document)
             throws PortalException
Writes subtree of a user layout (with appropriate markings) defined by a particular node into a Document

Specified by:
writeTo in interface IUserLayout
Parameters:
nodeId - a String a node determining a user layout subtree.
document - a Document object
Throws:
PortalException - if an error occurs

getNodeDescription

public IUserLayoutNodeDescription getNodeDescription(java.lang.String nodeId)
                                              throws PortalException
Obtain a description of a node (channel or a folder) in a given user layout.

Specified by:
getNodeDescription in interface IUserLayout
Parameters:
nodeId - a String channel subscribe id or folder id.
Returns:
an UserLayoutNodeDescription value
Throws:
PortalException - if an error occurs

getNode

public ALNode getNode(java.lang.String nodeId)
               throws PortalException
Returns a node specified by a node ID.

Parameters:
nodeId - a String value
Returns:
a ALNode object
Throws:
PortalException - if an error occurs

getParentId

public java.lang.String getParentId(java.lang.String nodeId)
                             throws PortalException
Returns an Id of a parent user layout node. The user layout root node always has ID=IUserLayout#ROOT_NODE_NAME

Specified by:
getParentId in interface IUserLayout
Parameters:
nodeId - a String value
Returns:
a String value
Throws:
PortalException - if an error occurs

getChildIds

public java.util.Enumeration getChildIds(java.lang.String nodeId)
                                  throws PortalException
Returns a list of child node Ids for a given node.

Specified by:
getChildIds in interface IUserLayout
Parameters:
nodeId - a String value
Returns:
a Enumeration of String child node Ids.
Throws:
PortalException - if an error occurs

getNextSiblingId

public java.lang.String getNextSiblingId(java.lang.String nodeId)
                                  throws PortalException
Determine an Id of a next sibling node.

Specified by:
getNextSiblingId in interface IUserLayout
Parameters:
nodeId - a String value
Returns:
a String Id value of a next sibling node, or null if this is the last sibling.
Throws:
PortalException - if an error occurs

getPreviousSiblingId

public java.lang.String getPreviousSiblingId(java.lang.String nodeId)
                                      throws PortalException
Determine an Id of a previous sibling node.

Specified by:
getPreviousSiblingId in interface IUserLayout
Parameters:
nodeId - a String value
Returns:
a String Id value of a previous sibling node, or null if this is the first sibling.
Throws:
PortalException - if an error occurs

getCacheKey

public java.lang.String getCacheKey()
                             throws PortalException
Return a cache key, uniqly corresponding to the composition and the structure of the user layout.

Specified by:
getCacheKey in interface IUserLayout
Returns:
a String value
Throws:
PortalException - if an error occurs

addLayoutEventListener

public boolean addLayoutEventListener(LayoutEventListener l)
Register a layout event listener

Specified by:
addLayoutEventListener in interface IUserLayout
Parameters:
l - a LayoutEventListener object
Returns:
a boolean success status

removeLayoutEventListener

public boolean removeLayoutEventListener(LayoutEventListener l)
Remove a registered layout event listener.

Specified by:
removeLayoutEventListener in interface IUserLayout
Parameters:
l - a LayoutEventListener object
Returns:
a boolean success status

getId

public java.lang.String getId()
Returns a layout Id associated with this manager/

Specified by:
getId in interface IUserLayout
Returns:
an String layout Id value;

getNodeId

public java.lang.String getNodeId(java.lang.String fname)
                           throws PortalException
Returns a node id associated with the supplied functional name.

Specified by:
getNodeId in interface IUserLayout
Parameters:
fname - the functional name to lookup
Returns:
a String subscription id
Throws:
PortalException - if an error occurs

getNodeIds

public java.util.Enumeration getNodeIds()
                                 throws PortalException
Returns a list of node Ids in the layout.

Specified by:
getNodeIds in interface IUserLayout
Returns:
a Enumeration of node Ids
Throws:
PortalException - if an error occurs

getRootId

public java.lang.String getRootId()
Returns an id of the root node.

Specified by:
getRootId in interface IUserLayout
Returns:
a String value