info.magnolia.cms.core
Class DefaultHierarchyManager

java.lang.Object
  extended by info.magnolia.cms.core.DefaultHierarchyManager
All Implemented Interfaces:
HierarchyManager, Serializable

public class DefaultHierarchyManager
extends Object
implements HierarchyManager, Serializable

Default JCR-based implementation of HierarchyManager.

Author:
Sameer Charles $Id:HierarchyManager.java 2719 2006-04-27 14:38:44Z scharles $
See Also:
Serialized Form

Constructor Summary
protected DefaultHierarchyManager()
           
  DefaultHierarchyManager(String userId, javax.jcr.Session jcrSession, AccessManager aManager)
           
 
Method Summary
 void copyTo(String source, String destination)
          copy content to the specified location.
 Content createContent(String path, String label, String contentType)
          Creates contentNode of type contentType.
 void delete(String path)
          removes specified path, it can be either node or property.
 AccessManager getAccessManager()
          Get access manager.
 Content getContent(String path)
          get content object of the requested URI.
 Content getContent(String path, boolean create, ItemType type)
          Like getContent() but creates the node if not yet existing.
 Content getContentByUUID(String uuid)
          This method can be used to retrieve Content which has UUID assigned to it, in other words only those nodes which has mixin type mix:referenceable.
 String getName()
           
 NodeData getNodeData(String path)
          get NodeData object of the requested URI.
 Content getPage(String path, String templateName)
          Deprecated. since 4.0 - only used by taglibs - should go/move.
 QueryManager getQueryManager()
           
 Content getRoot()
           
 javax.jcr.Workspace getWorkspace()
          gets currently used workspace for this hierarchy manager.
 boolean hasPendingChanges()
          Returns true if the session has pending (unsaved) changes.
 boolean isExist(String path)
          check is either the node or property exists with the specified path and user has access to it.
 boolean isGranted(String path, long permissions)
          Checks for the allowed access rights.
 boolean isNodeData(String path)
          checks if the requested resource is an NodeData (Property).
 boolean isNodeType(String path, ItemType type)
          Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)
 boolean isNodeType(String path, String type)
          Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)
 boolean isPage(String path)
          Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)
 void moveTo(String source, String destination)
          move content to the specified location.
 void refresh(boolean keepChanges)
          Refreshes this session.
 void save()
          Persists all changes to the repository if validation succeeds.
protected  void setAccessManager(AccessManager accessManager)
          Set access manager for this hierarchy.
protected  void setMetaData(MetaData md)
          Helper method to set page properties, create page calls this method.
protected  void setQueryManager(QueryManager queryManager)
          Set query manager for this hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHierarchyManager

protected DefaultHierarchyManager()

DefaultHierarchyManager

public DefaultHierarchyManager(String userId,
                               javax.jcr.Session jcrSession,
                               AccessManager aManager)
                        throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException
Method Detail

setAccessManager

protected void setAccessManager(AccessManager accessManager)
Set access manager for this hierarchy.

Parameters:
accessManager -

getAccessManager

public AccessManager getAccessManager()
Get access manager.

Specified by:
getAccessManager in interface HierarchyManager
Returns:
accessmanager attached to this hierarchy

setQueryManager

protected void setQueryManager(QueryManager queryManager)
Set query manager for this hierarchy.

Parameters:
queryManager -

getQueryManager

public QueryManager getQueryManager()
Specified by:
getQueryManager in interface HierarchyManager

createContent

public Content createContent(String path,
                             String label,
                             String contentType)
                      throws javax.jcr.PathNotFoundException,
                             javax.jcr.RepositoryException,
                             AccessDeniedException
Creates contentNode of type contentType. contentType must be defined in item type definition of Magnolia as well as JCR implementation.

Specified by:
createContent in interface HierarchyManager
Parameters:
path - absolute (primary) path to this Node
label - page name
contentType - , JCR node type as configured
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

setMetaData

protected void setMetaData(MetaData md)
                    throws javax.jcr.RepositoryException,
                           AccessDeniedException
Helper method to set page properties, create page calls this method. you could call this method anytime to create working page properties.

Throws:
javax.jcr.RepositoryException
AccessDeniedException

getContent

public Content getContent(String path)
                   throws javax.jcr.PathNotFoundException,
                          javax.jcr.RepositoryException,
                          AccessDeniedException
get content object of the requested URI.

Specified by:
getContent in interface HierarchyManager
Parameters:
path - of the content to be initialized
Returns:
Content
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

getContent

public Content getContent(String path,
                          boolean create,
                          ItemType type)
                   throws AccessDeniedException,
                          javax.jcr.RepositoryException
Like getContent() but creates the node if not yet existing. Attention save is not called!

Specified by:
getContent in interface HierarchyManager
Parameters:
path - the path of the node
create - true if the node should get created
type - the node type of the created node
Returns:
the node
Throws:
AccessDeniedException
javax.jcr.RepositoryException

getNodeData

public NodeData getNodeData(String path)
                     throws javax.jcr.PathNotFoundException,
                            javax.jcr.RepositoryException,
                            AccessDeniedException
get NodeData object of the requested URI.

Specified by:
getNodeData in interface HierarchyManager
Parameters:
path - of the atom to be initialized
Returns:
NodeData
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

getPage

@Deprecated
public Content getPage(String path,
                                  String templateName)
                throws javax.jcr.PathNotFoundException,
                       javax.jcr.RepositoryException,
                       AccessDeniedException
Deprecated. since 4.0 - only used by taglibs - should go/move.

returns the first page with a given template name that is found in tree that starts from the page given py the path (including this page).

Specified by:
getPage in interface HierarchyManager
Parameters:
path - handle of the page from where the search should start
templateName - template name to search for
Returns:
first Content hierarchy node that has the specified template name assigned
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

delete

public void delete(String path)
            throws javax.jcr.PathNotFoundException,
                   javax.jcr.RepositoryException,
                   AccessDeniedException
removes specified path, it can be either node or property.

Specified by:
delete in interface HierarchyManager
Parameters:
path - to be removed
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

getRoot

public Content getRoot()
                throws javax.jcr.RepositoryException,
                       AccessDeniedException
Specified by:
getRoot in interface HierarchyManager
Returns:
rootNode of the current working repository-workspace
Throws:
javax.jcr.RepositoryException
AccessDeniedException

isPage

@Deprecated
public boolean isPage(String path)
               throws AccessDeniedException
Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)

Checks if the requested resource is a page (hierarchy Node).

Specified by:
isPage in interface HierarchyManager
Parameters:
path - of the requested content
Returns:
boolean true is the requested content is a Hierarchy Node todo remove this method, instead use (getContent(PATH) is NodeType)
Throws:
AccessDeniedException

isExist

public boolean isExist(String path)
check is either the node or property exists with the specified path and user has access to it. If at least READ permission is not granted or not running in SystemContext, the method will return false even if the node in question exists.

Specified by:
isExist in interface HierarchyManager
Parameters:
path -

isGranted

public boolean isGranted(String path,
                         long permissions)
Description copied from interface: HierarchyManager
Checks for the allowed access rights.

Specified by:
isGranted in interface HierarchyManager
Parameters:
path - path to content to be checked
permissions - permission mask
Returns:
true if the current user has access on the provided node path.

isNodeType

@Deprecated
public boolean isNodeType(String path,
                                     String type)
Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)

Evaluate primary node type of the node at the given path.

Specified by:
isNodeType in interface HierarchyManager

isNodeType

@Deprecated
public boolean isNodeType(String path,
                                     ItemType type)
Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)

Evaluate primary node type of the node at the given path.

Specified by:
isNodeType in interface HierarchyManager

isNodeData

public boolean isNodeData(String path)
                   throws AccessDeniedException
checks if the requested resource is an NodeData (Property).

Specified by:
isNodeData in interface HierarchyManager
Parameters:
path - of the requested NodeData
Returns:
boolean true is the requested content is an NodeData
Throws:
AccessDeniedException

getContentByUUID

public Content getContentByUUID(String uuid)
                         throws javax.jcr.ItemNotFoundException,
                                javax.jcr.RepositoryException,
                                AccessDeniedException
This method can be used to retrieve Content which has UUID assigned to it, in other words only those nodes which has mixin type mix:referenceable.

Specified by:
getContentByUUID in interface HierarchyManager
Parameters:
uuid -
Throws:
javax.jcr.ItemNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

getWorkspace

public javax.jcr.Workspace getWorkspace()
gets currently used workspace for this hierarchy manager.

Specified by:
getWorkspace in interface HierarchyManager

moveTo

public void moveTo(String source,
                   String destination)
            throws javax.jcr.PathNotFoundException,
                   javax.jcr.RepositoryException,
                   AccessDeniedException
move content to the specified location.

Specified by:
moveTo in interface HierarchyManager
Parameters:
source - source node path
destination - node where the node has to be moved
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

copyTo

public void copyTo(String source,
                   String destination)
            throws javax.jcr.PathNotFoundException,
                   javax.jcr.RepositoryException,
                   AccessDeniedException
copy content to the specified location.

Specified by:
copyTo in interface HierarchyManager
Parameters:
source - source node path
destination - node where the node has to be copied
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

save

public void save()
          throws javax.jcr.RepositoryException
Persists all changes to the repository if validation succeeds.

Specified by:
save in interface HierarchyManager
Throws:
javax.jcr.RepositoryException

hasPendingChanges

public boolean hasPendingChanges()
                          throws javax.jcr.RepositoryException
Returns true if the session has pending (unsaved) changes.

Specified by:
hasPendingChanges in interface HierarchyManager
Throws:
javax.jcr.RepositoryException

refresh

public void refresh(boolean keepChanges)
             throws javax.jcr.RepositoryException
Refreshes this session.

Specified by:
refresh in interface HierarchyManager
Parameters:
keepChanges -
Throws:
javax.jcr.RepositoryException
See Also:
Session.refresh(boolean)

getName

public String getName()
Specified by:
getName in interface HierarchyManager


Copyright © 2003-2011 Magnolia International Ltd.. All Rights Reserved.