info.magnolia.cms.core
Class DefaultHierarchyManager

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

public class DefaultHierarchyManager
extends java.lang.Object
implements HierarchyManager, java.io.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(java.lang.String userId, javax.jcr.Session jcrSession, AccessManager aManager)
           
 
Method Summary
 void copyTo(java.lang.String source, java.lang.String destination)
          copy content to the specified location.
 Content createContent(java.lang.String path, java.lang.String label, java.lang.String contentType)
          Creates contentNode of type contentType.
 void delete(java.lang.String path)
          removes specified path, it can be either node or property.
 AccessManager getAccessManager()
          Get access manager.
 Content getContent(java.lang.String path)
          get content object of the requested URI.
 Content getContent(java.lang.String path, boolean create, ItemType type)
          Like getContent() but creates the node if not yet existing.
 Content getContentByUUID(java.lang.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.
 java.lang.String getName()
           
 NodeData getNodeData(java.lang.String path)
          get NodeData object of the requested URI.
 Content getPage(java.lang.String path, java.lang.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(java.lang.String path)
          check is either the node or property exists with the specified path and user has access to it.
 boolean isGranted(java.lang.String path, long permissions)
          Checks for the allowed access rights.
 boolean isNodeData(java.lang.String path)
          checks if the requested resource is an NodeData (Property).
 boolean isNodeType(java.lang.String path, ItemType type)
          Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)
 boolean isNodeType(java.lang.String path, java.lang.String type)
          Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)
 boolean isPage(java.lang.String path)
          Deprecated. since 4.0 - use getContent().isNodeType() instead. (not used currently)
 void moveTo(java.lang.String source, java.lang.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(java.lang.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(java.lang.String path,
                             java.lang.String label,
                             java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String path,
                                  java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String path,
                                     java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String source,
                   java.lang.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(java.lang.String source,
                   java.lang.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 java.lang.String getName()
Specified by:
getName in interface HierarchyManager


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