org.hippoecm.hst.content.beans.manager.workflow
Class WorkflowPersistenceManagerImpl

java.lang.Object
  extended by org.hippoecm.hst.content.beans.manager.ObjectBeanManagerImpl
      extended by org.hippoecm.hst.content.beans.manager.workflow.WorkflowPersistenceManagerImpl
All Implemented Interfaces:
ObjectBeanManager, ObjectBeanPersistenceManager, WorkflowPersistenceManager

public class WorkflowPersistenceManagerImpl
extends ObjectBeanManagerImpl
implements WorkflowPersistenceManager

An implementation for WorkflowPersistenceManager interface with Hippo Repository Workflow API.

This implementation does not provide automatic bindings from content object to JCR node(s). So, client codes should provide custom binders for their own node types. These custom binders map can be given by a constructor argument, or a custom binder can be given by an argument of update(Object, ContentNodeBinder) method.

Another useful option is to make a content POJO object implement ContentNodeBinder interface. When client codes invoke update(Object) method, this implementation will look up the custom binder from the internal map at first. If there's nothing found, then this implementation will check if the content POJO object is an instance of ContentNodeBinder. If it is, this implementation will use the content POJO object itself as a ContentNodeBinder.

If this implementation cannot find any ContentNodeBinder, it will do updating the content without any bindings.


Field Summary
protected  Map<String,ContentNodeBinder> contentNodeBinders
          Custom content node binders map, which is used to look up a custom binder for a node type.
protected  String defaultWorkflowCategory
          The workflow category name to localize the new document
protected  String documentAdditionWorkflowCategory
          The workflow category name to add a new document.
protected  String documentNodeWorkflowCategory
          The workflow category name to get a document workflow.
protected  String folderAdditionWorkflowCategory
          The workflow category name to add a new folder.
protected  String folderNodeTypeName
          Hippo Repository specific predefined folder node type name
protected  String folderNodeWorkflowCategory
          The workflow category name to get a folder workflow.
protected  org.hippoecm.repository.api.StringCodec uriEncoding
          The codec which is used for the node names
protected  WorkflowCallbackHandler workflowCallbackHandler
          Workflow callback handler
 
Fields inherited from class org.hippoecm.hst.content.beans.manager.ObjectBeanManagerImpl
objectConverter, session
 
Constructor Summary
WorkflowPersistenceManagerImpl(javax.jcr.Session session, ObjectConverter objectConverter)
          Constructor
WorkflowPersistenceManagerImpl(javax.jcr.Session session, ObjectConverter objectConverter, Map<String,ContentNodeBinder> contentNodeBinders)
          Constructor
 
Method Summary
 void create(String absPath, String nodeTypeName, String name)
          Deprecated. the name of the created node can differ from the passed name. Use createAndReturn(String absPath, String nodeTypeName, String name, boolean autoCreateFolders) to get the absolute path of the created node.
 void create(String absPath, String nodeTypeName, String name, boolean autoCreateFolders)
          Deprecated. the name of the created node can differ from the passed name. Use createAndReturn(String absPath, String nodeTypeName, String name, boolean autoCreateFolders) to get the absolute path of the created node.
 String createAndReturn(String absPath, String nodeTypeName, String name, boolean autoCreateFolders)
          Creates content node(s) with the specified node type at the specified absolute path.
protected  javax.jcr.Node createMissingFolders(String absPath)
           
protected  String createNodeByWorkflow(javax.jcr.Node folderNode, String nodeTypeName, String name)
           
 String getDocumentAdditionWorkflowCategory()
          Gets the workflow category name used to add a document.
 String getDocumentNodeWorkflowCategory()
          Gets the workflow category name used to get a document workflow.
 String getFolderAdditionWorkflowCategory()
          Gets the workflow category name used to add a folder.
 String getFolderNodeTypeName()
          Gets the folder node type name which is used to create folders.
 String getFolderNodeWorkflowCategory()
          Gets the workflow category name used to get a folder workflow.
 org.hippoecm.repository.api.Workflow getWorkflow(String category, org.hippoecm.repository.api.Document document)
           
 org.hippoecm.repository.api.Workflow getWorkflow(String category, javax.jcr.Node node)
           
 void refresh()
          Invokes Session.refresh(boolean) with false parameter.
 void refresh(boolean keepChanges)
          Invokes Session.refresh(boolean).
 void remove(Object content)
          Removes the content node which is mapped to the object.
 void save()
          Saves all pending changes.
 void setDocumentAdditionWorkflowCategory(String documentAdditionWorkflowCategory)
          Sets the workflow category name used to add a document.
 void setDocumentNodeWorkflowCategory(String documentNodeWorkflowCategory)
          Sets the workflow category name used to get a document workflow.
 void setFolderAdditionWorkflowCategory(String folderAdditionWorkflowCategory)
          Sets the workflow category name used to add a folder.
 void setFolderNodeTypeName(String folderNodeTypeName)
          Sets the folder node type name which is used to create folders.
 void setFolderNodeWorkflowCategory(String folderNodeWorkflowCategory)
          Sets the workflow category name used to get a folder workflow.
 void setWorkflowCallbackHandler(WorkflowCallbackHandler<? extends org.hippoecm.repository.api.Workflow> workflowCallbackHandler)
           
 void update(Object content)
          Updates the content node which is mapped to the object.
 void update(Object content, ContentNodeBinder customContentNodeBinder)
          Updates the content node which is mapped to the object by the customContentNodeBinder provided by client.
 
Methods inherited from class org.hippoecm.hst.content.beans.manager.ObjectBeanManagerImpl
getObject, getObjectByUuid, getSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hippoecm.hst.content.beans.manager.ObjectBeanManager
getObject, getObjectByUuid, getSession
 

Field Detail

contentNodeBinders

protected Map<String,ContentNodeBinder> contentNodeBinders
Custom content node binders map, which is used to look up a custom binder for a node type.


folderNodeTypeName

protected String folderNodeTypeName
Hippo Repository specific predefined folder node type name


folderNodeWorkflowCategory

protected String folderNodeWorkflowCategory
The workflow category name to get a folder workflow. We use threepane as this is the same as the CMS uses


documentNodeWorkflowCategory

protected String documentNodeWorkflowCategory
The workflow category name to get a document workflow.


documentAdditionWorkflowCategory

protected String documentAdditionWorkflowCategory
The workflow category name to add a new document.


folderAdditionWorkflowCategory

protected String folderAdditionWorkflowCategory
The workflow category name to add a new folder.


workflowCallbackHandler

protected WorkflowCallbackHandler workflowCallbackHandler
Workflow callback handler


uriEncoding

protected org.hippoecm.repository.api.StringCodec uriEncoding
The codec which is used for the node names


defaultWorkflowCategory

protected String defaultWorkflowCategory
The workflow category name to localize the new document

Constructor Detail

WorkflowPersistenceManagerImpl

public WorkflowPersistenceManagerImpl(javax.jcr.Session session,
                                      ObjectConverter objectConverter)
Constructor

Parameters:
session - the session for this manager context
objectConverter - the object converter to do mapping from JCR nodes to content POJO objects

WorkflowPersistenceManagerImpl

public WorkflowPersistenceManagerImpl(javax.jcr.Session session,
                                      ObjectConverter objectConverter,
                                      Map<String,ContentNodeBinder> contentNodeBinders)
Constructor

Parameters:
session - the session for this manager context
objectConverter - the object converter to do mapping from JCR nodes to content POJO objects
contentNodeBinders - the predefined content node binders map which item is node type name key and custom binder object value.
Method Detail

create

@Deprecated
public void create(String absPath,
                              String nodeTypeName,
                              String name)
            throws ObjectBeanPersistenceException
Deprecated. the name of the created node can differ from the passed name. Use createAndReturn(String absPath, String nodeTypeName, String name, boolean autoCreateFolders) to get the absolute path of the created node.

Creates content node(s) with the specified node type at the specified absolute path.

The absolute path could be regarded differently according to physical implementations. For example, an implementation can regard the path as a simple one to create a simple JCR node. On the other hand, a sophisticated implementation can regard the path as an input for a workflow-enabled document/folder path.

Specified by:
create in interface ObjectBeanPersistenceManager
Parameters:
absPath - the absolute node path
nodeTypeName - the node type name of the content object
name - the content node name
Throws:
ObjectBeanPersistenceException

create

@Deprecated
public void create(String absPath,
                              String nodeTypeName,
                              String name,
                              boolean autoCreateFolders)
            throws ObjectBeanPersistenceException
Deprecated. the name of the created node can differ from the passed name. Use createAndReturn(String absPath, String nodeTypeName, String name, boolean autoCreateFolders) to get the absolute path of the created node.

Creates content node(s) with the specified node type at the specified absolute path.

The absolute path could be regarded differently according to physical implementations. For example, an implementation can regard the path as a simple one to create a simple JCR node. On the other hand, a sophisticated implementation can regard the path as an input for a workflow-enabled document/folder path.

If autoCreateFolders is true, then folders will be automatically created.

Specified by:
create in interface ObjectBeanPersistenceManager
Parameters:
absPath - the absolute node path
nodeTypeName - the node type name of the content object
name - the content node name
autoCreateFolders - the flag to create folders
Throws:
ObjectBeanPersistenceException

createAndReturn

public String createAndReturn(String absPath,
                              String nodeTypeName,
                              String name,
                              boolean autoCreateFolders)
                       throws ObjectBeanPersistenceException
Creates content node(s) with the specified node type at the specified absolute path.

The absolute path could be regarded differently according to physical implementations. For example, an implementation can regard the path as a simple one to create a simple JCR node. On the other hand, a sophisticated implementation can regard the path as an input for a workflow-enabled document/folder path.

If autoCreateFolders is true, then folders will be automatically created.

Specified by:
createAndReturn in interface ObjectBeanPersistenceManager
Parameters:
absPath - the absolute node path
nodeTypeName - the node type name of the content object
name - the content node name
autoCreateFolders - the flag to create folders
Returns:
the absolute path of the created node
Throws:
ObjectBeanPersistenceException

createMissingFolders

protected javax.jcr.Node createMissingFolders(String absPath)
                                       throws ObjectBeanPersistenceException
Throws:
ObjectBeanPersistenceException

createNodeByWorkflow

protected String createNodeByWorkflow(javax.jcr.Node folderNode,
                                      String nodeTypeName,
                                      String name)
                               throws ObjectBeanPersistenceException
Throws:
ObjectBeanPersistenceException

update

public void update(Object content)
            throws ObjectBeanPersistenceException
Updates the content node which is mapped to the object.

This will look up a propery custom content node binder from the internal map. (contentNodeBinders). If it is not found there, this implementation will check if the content object is an instance of ContentNodeBinder interface. If so, the content object will be used as a custom binder.

If there's no content node binder found, then this implementation will do updating only without any bindings.

Specified by:
update in interface ObjectBeanPersistenceManager
Parameters:
content -
Throws:
ObjectBeanPersistenceException

update

public void update(Object content,
                   ContentNodeBinder customContentNodeBinder)
            throws ObjectBeanPersistenceException
Updates the content node which is mapped to the object by the customContentNodeBinder provided by client.

Unlike update(Object), the implementation should not try to do automatic or predefined bindings. Instead, it should invoke customContentNodeBinder to do bindings.

Therefore, if a developer wants to customize the bindings, the developer should provide a customContentNodeBinder.

Specified by:
update in interface ObjectBeanPersistenceManager
Parameters:
content -
customContentNodeBinder -
Throws:
ObjectBeanPersistenceException

remove

public void remove(Object content)
            throws ObjectBeanPersistenceException
Removes the content node which is mapped to the object.

Specified by:
remove in interface ObjectBeanPersistenceManager
Parameters:
content -
Throws:
ObjectBeanPersistenceException

save

public void save()
          throws ObjectBeanPersistenceException
Saves all pending changes.

Specified by:
save in interface ObjectBeanPersistenceManager
Throws:
ObjectBeanPersistenceException

refresh

public void refresh()
             throws ObjectBeanPersistenceException
Invokes Session.refresh(boolean) with false parameter.

Specified by:
refresh in interface ObjectBeanPersistenceManager
Throws:
ObjectBeanPersistenceException

refresh

public void refresh(boolean keepChanges)
             throws ObjectBeanPersistenceException
Invokes Session.refresh(boolean).

Specified by:
refresh in interface ObjectBeanPersistenceManager
Parameters:
keepChanges -
Throws:
ObjectBeanPersistenceException

setFolderNodeTypeName

public void setFolderNodeTypeName(String folderNodeTypeName)
Sets the folder node type name which is used to create folders.

Parameters:
folderNodeTypeName -

getFolderNodeTypeName

public String getFolderNodeTypeName()
Gets the folder node type name which is used to create folders.

Returns:

getFolderNodeWorkflowCategory

public String getFolderNodeWorkflowCategory()
Gets the workflow category name used to get a folder workflow.

Returns:

setFolderNodeWorkflowCategory

public void setFolderNodeWorkflowCategory(String folderNodeWorkflowCategory)
Sets the workflow category name used to get a folder workflow.

Parameters:
folderNodeWorkflowCategory -

getDocumentNodeWorkflowCategory

public String getDocumentNodeWorkflowCategory()
Gets the workflow category name used to get a document workflow.

Returns:

setDocumentNodeWorkflowCategory

public void setDocumentNodeWorkflowCategory(String documentNodeWorkflowCategory)
Sets the workflow category name used to get a document workflow.

Parameters:
documentNodeWorkflowCategory -

getFolderAdditionWorkflowCategory

public String getFolderAdditionWorkflowCategory()
Gets the workflow category name used to add a folder.

Returns:

setFolderAdditionWorkflowCategory

public void setFolderAdditionWorkflowCategory(String folderAdditionWorkflowCategory)
Sets the workflow category name used to add a folder.

Parameters:
folderAdditionWorkflowCategory -

getDocumentAdditionWorkflowCategory

public String getDocumentAdditionWorkflowCategory()
Gets the workflow category name used to add a document.

Returns:

setDocumentAdditionWorkflowCategory

public void setDocumentAdditionWorkflowCategory(String documentAdditionWorkflowCategory)
Sets the workflow category name used to add a document.

Parameters:
documentAdditionWorkflowCategory -

setWorkflowCallbackHandler

public void setWorkflowCallbackHandler(WorkflowCallbackHandler<? extends org.hippoecm.repository.api.Workflow> workflowCallbackHandler)
Specified by:
setWorkflowCallbackHandler in interface WorkflowPersistenceManager

getWorkflow

public org.hippoecm.repository.api.Workflow getWorkflow(String category,
                                                        javax.jcr.Node node)
                                                 throws javax.jcr.RepositoryException
Specified by:
getWorkflow in interface WorkflowPersistenceManager
Throws:
javax.jcr.RepositoryException

getWorkflow

public org.hippoecm.repository.api.Workflow getWorkflow(String category,
                                                        org.hippoecm.repository.api.Document document)
                                                 throws javax.jcr.RepositoryException
Specified by:
getWorkflow in interface WorkflowPersistenceManager
Throws:
javax.jcr.RepositoryException


Copyright © 2008-2012 Hippo. All Rights Reserved.