it.openutils.mgnltasks
Class ConditionalTask

java.lang.Object
  extended by info.magnolia.module.delta.AbstractTask
      extended by it.openutils.mgnltasks.ConditionalTask
All Implemented Interfaces:
info.magnolia.module.delta.Task

public abstract class ConditionalTask
extends info.magnolia.module.delta.AbstractTask

Base abstract task that executes a list of other tasks only if a specific node/nodedata doesn't already exists in the repository. Subclasses must implement the verifyCondition method.

Version:
$Id: ConditionalTask.java 1830 2010-02-07 10:16:00Z fgiust $
Author:
molaschi

Field Summary
protected  String handle
          Handle to check.
protected  List<info.magnolia.module.delta.Task> tasks
          Subtasks that will be executed if the node doesn't exists.
protected  String workspace
          Workspace to check.
 
Fields inherited from class info.magnolia.module.delta.AbstractTask
log
 
Constructor Summary
ConditionalTask(String workspace, String handle, List<info.magnolia.module.delta.Task> tasks)
           
 
Method Summary
 void execute(info.magnolia.module.InstallContext installContext)
          
 boolean existsNode(info.magnolia.cms.core.HierarchyManager hm, String handle)
          Check if a node exists.
 boolean existsNodedata(info.magnolia.cms.core.HierarchyManager hm, String handle, String nodedata)
          Check if a nodedata exists.
 boolean nodeDataEquals(info.magnolia.cms.core.HierarchyManager hm, String handle, String nodedata, Object value)
          Check if a nodedata exists with a specific value.
abstract  boolean verifyCondition(info.magnolia.cms.core.HierarchyManager hm, String handle)
           
 
Methods inherited from class info.magnolia.module.delta.AbstractTask
getDescription, getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

workspace

protected String workspace
Workspace to check.


handle

protected String handle
Handle to check.


tasks

protected List<info.magnolia.module.delta.Task> tasks
Subtasks that will be executed if the node doesn't exists.

Constructor Detail

ConditionalTask

public ConditionalTask(String workspace,
                       String handle,
                       List<info.magnolia.module.delta.Task> tasks)
Parameters:
taskName -
taskDescription -
Method Detail

execute

public void execute(info.magnolia.module.InstallContext installContext)
             throws info.magnolia.module.delta.TaskExecutionException

Throws:
info.magnolia.module.delta.TaskExecutionException

existsNode

public boolean existsNode(info.magnolia.cms.core.HierarchyManager hm,
                          String handle)
Check if a node exists.

Parameters:
hm - HieararchyManager
handle - node handle
Returns:
true if node exists

existsNodedata

public boolean existsNodedata(info.magnolia.cms.core.HierarchyManager hm,
                              String handle,
                              String nodedata)
                       throws javax.jcr.RepositoryException
Check if a nodedata exists.

Parameters:
hm - HieararchyManager
handle - node handle
nodedata - nodedata name
Returns:
true if nodedata exists
Throws:
javax.jcr.RepositoryException - exceptions while checking content

nodeDataEquals

public boolean nodeDataEquals(info.magnolia.cms.core.HierarchyManager hm,
                              String handle,
                              String nodedata,
                              Object value)
                       throws javax.jcr.RepositoryException
Check if a nodedata exists with a specific value.

Parameters:
hm - HieararchyManager
handle - node handle
nodedata - nodedata name
value - expected value for nodeData
Returns:
true if nodedata has the same value
Throws:
javax.jcr.RepositoryException - exceptions while checking content

verifyCondition

public abstract boolean verifyCondition(info.magnolia.cms.core.HierarchyManager hm,
                                        String handle)
                                 throws javax.jcr.RepositoryException
Parameters:
hm - HieararchyManager
handle - node handle
Returns:
true if the task must be executed
Throws:
javax.jcr.RepositoryException - exceptions while checking content


Copyright © 2008-2010 Openmind. All Rights Reserved.