org.jasig.portal.layout.dlm
Class DistributedLayoutManager

java.lang.Object
  extended by org.jasig.portal.layout.dlm.DistributedLayoutManager
All Implemented Interfaces:
IFolderLocalNameResolver, IUserLayoutManager

public class DistributedLayoutManager
extends Object
implements IUserLayoutManager, IFolderLocalNameResolver

A layout manager that provides layout control through layout fragments that are derived from regular portal user accounts.

Since:
uPortal 2.5
Version:
1.0 $Revision: 21847 $ $Date: 2010-10-01 15:25:47 -0500 (Fri, 01 Oct 2010) $
Author:
Mark Boyd

Field Summary
protected  String cacheKey
           
protected  ILayoutCachingService layoutCachingService
           
protected  Set<LayoutEventListener> listeners
           
protected  IPerson owner
           
protected  UserProfile profile
           
static String RCS_ID
           
protected static Random rnd
           
protected  String rootNodeId
           
protected  RDBMDistributedLayoutStore store
           
 
Constructor Summary
DistributedLayoutManager(IPerson owner, UserProfile profile, IUserLayoutStore store)
           
 
Method Summary
 boolean addLayoutEventListener(LayoutEventListener l)
          Register a layout event listener
 IUserLayoutNodeDescription addNode(IUserLayoutNodeDescription node, String parentId, String nextSiblingId)
          Add a new node to a current user layout.
protected  boolean canAddNode(IUserLayoutNodeDescription node, IUserLayoutNodeDescription parent, String nextSiblingId)
           
 boolean canAddNode(IUserLayoutNodeDescription node, String parentId, String nextSiblingId)
          Test if a particular node can be added at a given location.
protected  boolean canDeleteNode(IUserLayoutNodeDescription node)
          Returns true if the node exists in the underlying DOM model and it does not contain a 'deleteAllowed' attribute with a value of 'false'.
 boolean canDeleteNode(String nodeId)
          Tests if a particular node can be deleted.
protected  boolean canMoveNode(IUserLayoutNodeDescription node, IUserLayoutNodeDescription parent, String nextSiblingId)
           
 boolean canMoveNode(String nodeId, String parentId, String nextSiblingId)
          Test if a particular node can be moved to a given location.
 boolean canUpdateNode(IUserLayoutNodeDescription node)
          Returns true if we are dealing with a fragment layout or if editing of attributes is allowed, or the node is a channel since ad-hoc parameters can always be added.
 boolean canUpdateNode(String nodeId)
           
 IUserLayoutNodeDescription createNodeDescription(Element node)
           
 IUserLayoutNodeDescription createNodeDescription(int nodeType)
          A factory method to create an empty IUserLayoutNodeDescription instance
 boolean deleteNode(String nodeId)
          Delete a node (folder or a channel) from a user layout.
 String getCacheKey()
          Return a cache key, uniqly corresponding to the composition and the structure of the user layout.
 Map getChannelFunctionalNameMap()
          Return a map of channel identifiers to functional names, for those channels that have functional names.
 Enumeration<String> getChildIds(String nodeId)
          Returns a list of child node Ids for a given node.
 int getDepth(String nodeId)
          Returns the depth of a node in the layout tree.
 String getFolderLabel(String nodeId)
          Returns the localized name of a folder node or null if none is available.
 IFolderLocalNameResolver getFolderNameResolver()
          Returns a resolver for local names.
 int getLayoutId()
          Returns a layout Id associated with this manager/
protected  IUserLayoutStore getLayoutStore()
           
 String getNextSiblingId(String nodeId)
          Determine an Id of a next sibling node.
 IUserLayoutNodeDescription getNode(String nodeId)
          Obtain a description of a node (channel or a folder) in a given user layout.
 String getParentId(String nodeId)
          Returns an Id of a parent user layout node.
 String getPreviousSiblingId(String nodeId)
          Determine an Id of a previous sibling node.
 String getRootFolderId()
          Returns an id of the root folder.
 String getSubscribeId(String fname)
          Returns the subscribe ID of a channel having the passed in functional name or null if it can't find such a channel in the layout.
 IUserLayout getUserLayout()
          Gets a user layout (with appropriate markings).
 void getUserLayout(ContentHandler ch)
          Output user layout (with appropriate markings) into a ContentHandler
protected  void getUserLayout(Node n, ContentHandler ch)
           
 void getUserLayout(String nodeId, ContentHandler ch)
          Output subtree of a user layout (with appropriate markings) defined by a particular node into a ContentHandler
 Document getUserLayoutDOM()
          Deprecated.  
 void loadUserLayout()
          Calls IUserLayoutManager.loadUserLayout(boolean) passing false.
 void loadUserLayout(boolean reload)
          Signal manager to load a user layout.
 void markAddTargets(IUserLayoutNodeDescription node)
          Unsupported operation in DLM.
 void markMoveTargets(String nodeId)
          Unsupported operation in DLM.
 boolean moveNode(String nodeId, String parentId, String nextSiblingId)
          Move a node (channel or folder) from one location to another.
 void processLayoutParameters(IPerson person, UserPreferences userPrefs, HttpServletRequest req)
          Handle layout specific parameters posted with the request.
 boolean removeLayoutEventListener(LayoutEventListener l)
          Remove a registered layout event listener.
 boolean resetLayout(String loginId)
          Resets the layout of the user with the specified user id if the current user is an administrator or a member of any administrative sub-group.
 void saveUserLayout()
          Signal manager to persist user layout to a database
 void setLayoutStore(IUserLayoutStore store)
          Set a user layout store implementation.
 void setUserLayout(IUserLayout userLayout)
          Sets a user layout (with appropriate markings).
 boolean updateNode(IUserLayoutNodeDescription node)
          Handles pushing changes made to the passed-in node into the user's layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RCS_ID

public static final String RCS_ID
See Also:
Constant Field Values

owner

protected final IPerson owner

profile

protected final UserProfile profile

layoutCachingService

protected final ILayoutCachingService layoutCachingService

store

protected RDBMDistributedLayoutStore store

listeners

protected Set<LayoutEventListener> listeners

rnd

protected static Random rnd

cacheKey

protected String cacheKey

rootNodeId

protected String rootNodeId
Constructor Detail

DistributedLayoutManager

public DistributedLayoutManager(IPerson owner,
                                UserProfile profile,
                                IUserLayoutStore store)
                         throws PortalException
Throws:
PortalException
Method Detail

getUserLayoutDOM

@Deprecated
public Document getUserLayoutDOM()
                          throws PortalException
Deprecated. 

Specified by:
getUserLayoutDOM in interface IUserLayoutManager
Returns:
Throws:
PortalException

getUserLayout

public void getUserLayout(ContentHandler ch)
                   throws PortalException
Description copied from interface: IUserLayoutManager
Output user layout (with appropriate markings) into a ContentHandler

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

getUserLayout

public void getUserLayout(String nodeId,
                          ContentHandler ch)
                   throws PortalException
Description copied from interface: IUserLayoutManager
Output subtree of a user layout (with appropriate markings) defined by a particular node into a ContentHandler

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

getUserLayout

protected void getUserLayout(Node n,
                             ContentHandler ch)
                      throws PortalException
Throws:
PortalException

setLayoutStore

public void setLayoutStore(IUserLayoutStore store)
Description copied from interface: IUserLayoutManager
Set a user layout store implementation.

Specified by:
setLayoutStore in interface IUserLayoutManager
Parameters:
store - an IUserLayoutStore value

getLayoutStore

protected IUserLayoutStore getLayoutStore()

loadUserLayout

public void loadUserLayout()
                    throws PortalException
Description copied from interface: IUserLayoutManager
Calls IUserLayoutManager.loadUserLayout(boolean) passing false.

Specified by:
loadUserLayout in interface IUserLayoutManager
Throws:
PortalException

loadUserLayout

public void loadUserLayout(boolean reload)
                    throws PortalException
Description copied from interface: IUserLayoutManager
Signal manager to load a user layout.

Specified by:
loadUserLayout in interface IUserLayoutManager
Parameters:
reload - If true the reload will be forced, purging any cached data.
Throws:
PortalException - PortalException if an error occurs

saveUserLayout

public void saveUserLayout()
                    throws PortalException
Description copied from interface: IUserLayoutManager
Signal manager to persist user layout to a database

Specified by:
saveUserLayout in interface IUserLayoutManager
Throws:
PortalException - if an error occurs

getNode

public IUserLayoutNodeDescription getNode(String nodeId)
                                   throws PortalException
Description copied from interface: IUserLayoutManager
Obtain a description of a node (channel or a folder) in a given user layout.

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

addNode

public IUserLayoutNodeDescription addNode(IUserLayoutNodeDescription node,
                                          String parentId,
                                          String nextSiblingId)
                                   throws PortalException
Description copied from interface: IUserLayoutManager
Add a new node to a current user layout.

Specified by:
addNode in interface IUserLayoutManager
Parameters:
node - an UserLayoutNodeDescription value of a node to be added (Id doesn't have to be set)
parentId - a String id of a folder to which the new node (channel or folder) should be added.
nextSiblingId - a String an id of a sibling node (channel or folder) prior to which the new node should be inserted.
Returns:
an UserLayoutNodeDescription value with a newly determined Id.
Throws:
PortalException - if an error occurs

moveNode

public boolean moveNode(String nodeId,
                        String parentId,
                        String nextSiblingId)
                 throws PortalException
Description copied from interface: IUserLayoutManager
Move a node (channel or folder) from one location to another.

Specified by:
moveNode in interface IUserLayoutManager
Parameters:
nodeId - a String value of a node Id.
parentId - a String id of a folder to which the node should be moved.
nextSiblingId - a String id of a sibling node (folder or channel) prior to which the node should be placed. (null to append at the end)
Returns:
a boolean value noting if the operation was successful
Throws:
PortalException - if an error occurs

deleteNode

public boolean deleteNode(String nodeId)
                   throws PortalException
Description copied from interface: IUserLayoutManager
Delete a node (folder or a channel) from a user layout.

Specified by:
deleteNode in interface IUserLayoutManager
Parameters:
nodeId - a String id (channel subscribe id or folder id)
Returns:
a boolean value noting if the operation was successful
Throws:
PortalException - if an error occurs

updateNode

public boolean updateNode(IUserLayoutNodeDescription node)
                   throws PortalException
Handles pushing changes made to the passed-in node into the user's layout. If the node is an ILF node then the change is recorded via directives in the PLF if such changes are allowed by the owning fragment. If the node is a user owned node then the changes are applied directly to the corresponding node in the PLF.

Specified by:
updateNode in interface IUserLayoutManager
Parameters:
node - an UserLayoutNodeDescription value with a valid id.
Returns:
a boolean value noting if the operation was successful
Throws:
PortalException - if an error occurs

canAddNode

public boolean canAddNode(IUserLayoutNodeDescription node,
                          String parentId,
                          String nextSiblingId)
                   throws PortalException
Description copied from interface: IUserLayoutManager
Test if a particular node can be added at a given location.

Specified by:
canAddNode in interface IUserLayoutManager
Parameters:
node - an UserLayoutNodeDescription value describing the node to be added.
parentId - a String id of a parent to which the node to be added.
nextSiblingId - a String id of a sibling prior to which the node to be inserted. (null to append at the end)
Returns:
a boolean value
Throws:
PortalException - if an error occurs

canAddNode

protected boolean canAddNode(IUserLayoutNodeDescription node,
                             IUserLayoutNodeDescription parent,
                             String nextSiblingId)
                      throws PortalException
Throws:
PortalException

canMoveNode

public boolean canMoveNode(String nodeId,
                           String parentId,
                           String nextSiblingId)
                    throws PortalException
Description copied from interface: IUserLayoutManager
Test if a particular node can be moved to a given location.

Specified by:
canMoveNode in interface IUserLayoutManager
Parameters:
nodeId - a String id of a node to be moved.
parentId - a String id of a parent to which the node to be moved.
nextSiblingId - a String id of a sibling prior to which the node is to be inserted (null to append at the end)
Returns:
a boolean value
Throws:
PortalException - if an error occurs

canMoveNode

protected boolean canMoveNode(IUserLayoutNodeDescription node,
                              IUserLayoutNodeDescription parent,
                              String nextSiblingId)
                       throws PortalException
Throws:
PortalException

canDeleteNode

public boolean canDeleteNode(String nodeId)
                      throws PortalException
Description copied from interface: IUserLayoutManager
Tests if a particular node can be deleted.

Specified by:
canDeleteNode in interface IUserLayoutManager
Parameters:
nodeId - a String node id.
Returns:
a boolean value
Throws:
PortalException - if an error occurs

canDeleteNode

protected boolean canDeleteNode(IUserLayoutNodeDescription node)
                         throws PortalException
Returns true if the node exists in the underlying DOM model and it does not contain a 'deleteAllowed' attribute with a value of 'false'.

Throws:
PortalException

canUpdateNode

public boolean canUpdateNode(String nodeId)
                      throws PortalException
Throws:
PortalException

canUpdateNode

public boolean canUpdateNode(IUserLayoutNodeDescription node)
Returns true if we are dealing with a fragment layout or if editing of attributes is allowed, or the node is a channel since ad-hoc parameters can always be added.

Specified by:
canUpdateNode in interface IUserLayoutManager
Parameters:
node - a IUserLayoutNodeDescription node id.
Returns:
a boolean value

markAddTargets

public void markAddTargets(IUserLayoutNodeDescription node)
Unsupported operation in DLM. This feature is handled by pluggable processors in the DLM processing pipe. See properties/dlmContext.xml.

Specified by:
markAddTargets in interface IUserLayoutManager
Parameters:
node - an UserLayoutNodeDescription value or null to stop outputting add markings.

markMoveTargets

public void markMoveTargets(String nodeId)
                     throws PortalException
Unsupported operation in DLM. This feature is handled by pluggable processors in the DLM processing pipe. See properties/dlmContext.xml.

Specified by:
markMoveTargets in interface IUserLayoutManager
Parameters:
nodeId - a String value or null to stop outputting move markings.
Throws:
PortalException - if an error occurs

getParentId

public String getParentId(String nodeId)
                   throws PortalException
Description copied from interface: IUserLayoutManager
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 IUserLayoutManager
Parameters:
nodeId - a String value
Returns:
a String value
Throws:
PortalException - if an error occurs

getNextSiblingId

public String getNextSiblingId(String nodeId)
                        throws PortalException
Description copied from interface: IUserLayoutManager
Determine an Id of a next sibling node.

Specified by:
getNextSiblingId in interface IUserLayoutManager
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 String getPreviousSiblingId(String nodeId)
                            throws PortalException
Description copied from interface: IUserLayoutManager
Determine an Id of a previous sibling node.

Specified by:
getPreviousSiblingId in interface IUserLayoutManager
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

getChildIds

public Enumeration<String> getChildIds(String nodeId)
                                throws PortalException
Description copied from interface: IUserLayoutManager
Returns a list of child node Ids for a given node.

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

getCacheKey

public String getCacheKey()
Description copied from interface: IUserLayoutManager
Return a cache key, uniqly corresponding to the composition and the structure of the user layout.

Specified by:
getCacheKey in interface IUserLayoutManager
Returns:
a String value

getLayoutId

public int getLayoutId()
Description copied from interface: IUserLayoutManager
Returns a layout Id associated with this manager/

Specified by:
getLayoutId in interface IUserLayoutManager
Returns:
an int layout Id value;

getSubscribeId

public String getSubscribeId(String fname)
Returns the subscribe ID of a channel having the passed in functional name or null if it can't find such a channel in the layout.

Specified by:
getSubscribeId in interface IUserLayoutManager
Parameters:
fname - the functional name to lookup
Returns:
a String subscription id

addLayoutEventListener

public boolean addLayoutEventListener(LayoutEventListener l)
Description copied from interface: IUserLayoutManager
Register a layout event listener

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

removeLayoutEventListener

public boolean removeLayoutEventListener(LayoutEventListener l)
Description copied from interface: IUserLayoutManager
Remove a registered layout event listener.

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

getUserLayout

public IUserLayout getUserLayout()
                          throws PortalException
Description copied from interface: IUserLayoutManager
Gets a user layout (with appropriate markings).

Specified by:
getUserLayout in interface IUserLayoutManager
Returns:
the user layout
Throws:
PortalException - if an error occurs

setUserLayout

public void setUserLayout(IUserLayout userLayout)
                   throws PortalException
Description copied from interface: IUserLayoutManager
Sets a user layout (with appropriate markings).

Specified by:
setUserLayout in interface IUserLayoutManager
Parameters:
userLayout - the user layout
Throws:
PortalException - if an error occurs

getRootFolderId

public String getRootFolderId()
Description copied from interface: IUserLayoutManager
Returns an id of the root folder.

Specified by:
getRootFolderId in interface IUserLayoutManager
Returns:
a String value

getDepth

public int getDepth(String nodeId)
             throws PortalException
Description copied from interface: IUserLayoutManager
Returns the depth of a node in the layout tree.

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

createNodeDescription

public IUserLayoutNodeDescription createNodeDescription(int nodeType)
                                                 throws PortalException
Description copied from interface: IUserLayoutManager
A factory method to create an empty IUserLayoutNodeDescription instance

Specified by:
createNodeDescription in interface IUserLayoutManager
Parameters:
nodeType - a node type constant from IUserLayoutNodeDescription interface
Returns:
an IUserLayoutNodeDescription instance
Throws:
PortalException - if the error occurs.

processLayoutParameters

public void processLayoutParameters(IPerson person,
                                    UserPreferences userPrefs,
                                    HttpServletRequest req)
                             throws PortalException
Handle layout specific parameters posted with the request.

Specified by:
processLayoutParameters in interface IUserLayoutManager
Throws:
PortalException

resetLayout

public boolean resetLayout(String loginId)
Resets the layout of the user with the specified user id if the current user is an administrator or a member of any administrative sub-group. Has no effect if these requirements are not met.

Parameters:
loginId -
Returns:
true if layout was reset, false otherwise.

createNodeDescription

public IUserLayoutNodeDescription createNodeDescription(Element node)
                                                 throws PortalException
Throws:
PortalException

getChannelFunctionalNameMap

public Map getChannelFunctionalNameMap()
                                throws PortalException
Return a map of channel identifiers to functional names, for those channels that have functional names.

Throws:
PortalException

getFolderNameResolver

public IFolderLocalNameResolver getFolderNameResolver()
Returns a resolver for local names. This layout manager supports this feature itself and hence returns itself as the interface.

Returns:

getFolderLabel

public String getFolderLabel(String nodeId)
Returns the localized name of a folder node or null if none is available. This method also implements enforcement of user label overrides to fragment folders purging those overrides if they are no longer allowed or needed.

Specified by:
getFolderLabel in interface IFolderLocalNameResolver
Returns:


Copyright © 2010 Jasig. All Rights Reserved.