org.mmbase.applications.vprowizards.spring.action
Class AbstractNodeAction

java.lang.Object
  extended by org.mmbase.applications.vprowizards.spring.action.Action
      extended by org.mmbase.applications.vprowizards.spring.action.AbstractNodeAction
Direct Known Subclasses:
AbstractRelationAction, CreateNodeAction, UpdateNodeAction

public abstract class AbstractNodeAction
extends Action

this is a template class for the 'real' node actions Is it more or less a redo of org.mmbase.datatypes.handler.html

Author:
ebunders
Javadoc:
Why?

Field Summary
protected  String securityContext
           
 
Constructor Summary
AbstractNodeAction()
           
 
Method Summary
protected  void addCachFlushHint(CacheFlushHint hint)
           
protected  void addFieldError(String field, String key)
          Create a field error for this action, using a key without place holder values
protected  void addFieldError(String field, String key, String[] placeholderValues)
          Creates a field error for this action
protected  void addFieldErrorTypeMessage(String field, String message)
          Creates a field error for this action, where there is some sort of error when setting the field.
protected  void addFieldErrorTypeMessage(String field, Throwable e)
           
protected  void addFieldErrorTypeValue(String field, String value)
          Creates a field error for this action, where the value set on some field is invalid.
protected  void addGlobalError(String key)
          Creates a global error for this action.
protected  void addGlobalError(String key, String[] placeholderValues)
          Creates a global error for this action.
protected  void addGlobalError(String key, String[] placeholderValues, Throwable t)
           
protected  void addNodeParam(String name)
           
protected  void addParam(String name, String value)
           
protected abstract  void createCacheFlushHints()
          This template method is called when the node to edit is changed.
protected abstract  Node createNode(Transaction transaction, Map<String,Node> idMap, HttpServletRequest request)
          This template method is called to obtain the node for this action.
 Map<String,DateTime> getDateFields()
           
 Map<String,String> getFields()
           
 org.springframework.web.multipart.MultipartFile getFile()
           
 String getId()
           
protected  Locale getLocale()
           
protected  Node getNode()
           
protected  boolean hasChanged()
           
protected  boolean hasErrors()
           
protected  boolean isNodeNullIllegal()
          This template method determines if it is an error when the node is null.
protected  boolean mayCreate(NodeManager nodeManager)
          can the current owner create a node of this type? set global error when fail.
protected  boolean mayDelete(Node node)
          can the current owner delete this node? set global error when fail.
protected  boolean mayWrite(NodeManager nodeManager)
          can the current owner create a node of this type? set global error when fail.
 void process(ResultContainer resultContainer)
          This final method calls the different template methods, that are either abstract or have a default implementation.
protected  void processNode(Transaction transaction)
          This template method is called after the values that have been injected in this action in the fields and datefields collections, as well as the file field have been set on the node.
protected  void setChanged()
          call this method to set the changed flag on this node
 void setDateFields(Map<String,DateTime> dateFields)
           
 void setFields(Map<String,String> fields)
           
 void setFile(org.springframework.web.multipart.MultipartFile file)
           
 void setHtmlField(String htmlField)
           
 void setId(String id)
           
 void setSecurityContext(String c)
           
protected  boolean shouldProcess(Node node)
          this template method is called before any changes are made to the node to edit.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

securityContext

protected String securityContext
Constructor Detail

AbstractNodeAction

public AbstractNodeAction()
Method Detail

process

public final void process(ResultContainer resultContainer)
This final method calls the different template methods, that are either abstract or have a default implementation. When the id is set on this action, the node is added to the idmap.

Specified by:
process in class Action
Throws:
XNIException

setHtmlField

public void setHtmlField(String htmlField)

getDateFields

public Map<String,DateTime> getDateFields()

setDateFields

public void setDateFields(Map<String,DateTime> dateFields)

getFields

public Map<String,String> getFields()

setFields

public void setFields(Map<String,String> fields)

setSecurityContext

public void setSecurityContext(String c)

getFile

public org.springframework.web.multipart.MultipartFile getFile()

setFile

public void setFile(org.springframework.web.multipart.MultipartFile file)

getId

public String getId()

setId

public void setId(String id)

toString

public String toString()
Overrides:
toString in class Object

isNodeNullIllegal

protected boolean isNodeNullIllegal()
This template method determines if it is an error when the node is null. Override this for concrete actions that actually don't need a node always.

Returns:
true by default.

shouldProcess

protected boolean shouldProcess(Node node)
this template method is called before any changes are made to the node to edit. if it returns false, no more action will be taken. Use this if you want to use some kind of switch.

Parameters:
node - the current node.
Returns:
true if there is no reason not to process this node

createNode

protected abstract Node createNode(Transaction transaction,
                                   Map<String,Node> idMap,
                                   HttpServletRequest request)
This template method is called to obtain the node for this action. it is the responsibility of the implementation of this method to set a global error (using addGlobalError) when something goes wrong. In that case the action stops.

Parameters:
transaction - the mmmbase transaction
request -
Returns:
the node this action should handle or null if an error occurs

processNode

protected void processNode(Transaction transaction)
This template method is called after the values that have been injected in this action in the fields and datefields collections, as well as the file field have been set on the node. The default implementation does nothing

Parameters:
node -
resultContainer -

getLocale

protected final Locale getLocale()

getNode

protected final Node getNode()
Returns:
the node that is created for this node action.

setChanged

protected final void setChanged()
call this method to set the changed flag on this node


hasChanged

protected final boolean hasChanged()

addFieldError

protected final void addFieldError(String field,
                                   String key,
                                   String[] placeholderValues)
Creates a field error for this action

Parameters:
field -
key -
placeholderValues -

addFieldError

protected final void addFieldError(String field,
                                   String key)
Create a field error for this action, using a key without place holder values

Parameters:
field -
key -

addFieldErrorTypeMessage

protected final void addFieldErrorTypeMessage(String field,
                                              String message)
Creates a field error for this action, where there is some sort of error when setting the field. This version does not take the (offending) field value but the error message. This method uses it's own error message key.

Parameters:
field -
message -

addFieldErrorTypeMessage

protected final void addFieldErrorTypeMessage(String field,
                                              Throwable e)

addFieldErrorTypeValue

protected final void addFieldErrorTypeValue(String field,
                                            String value)
Creates a field error for this action, where the value set on some field is invalid. This method uses it's own error message key.

Parameters:
field -
value -

addGlobalError

protected final void addGlobalError(String key,
                                    String[] placeholderValues)
Creates a global error for this action. This is an example of exception reimplementation. This should all be dropped and actual exceptions should be used.

Parameters:
key -
placeholderValues -

addGlobalError

protected final void addGlobalError(String key,
                                    String[] placeholderValues,
                                    Throwable t)

addGlobalError

protected final void addGlobalError(String key)
Creates a global error for this action.

Parameters:
key -

addCachFlushHint

protected final void addCachFlushHint(CacheFlushHint hint)

createCacheFlushHints

protected abstract void createCacheFlushHints()
This template method is called when the node to edit is changed. custom cachflush hints can be set here. This class dous not know if the current node is updated or created, so it dousn't know what kind of events to create.


mayWrite

protected final boolean mayWrite(NodeManager nodeManager)
can the current owner create a node of this type? set global error when fail.

Parameters:
nodeManager -
Returns:
true when allowed.

mayCreate

protected final boolean mayCreate(NodeManager nodeManager)
can the current owner create a node of this type? set global error when fail.

Parameters:
nodeManager -
Returns:
true when allowed.

mayDelete

protected final boolean mayDelete(Node node)
can the current owner delete this node? set global error when fail.

Parameters:
nodeManager -
Returns:
true when allowed.

hasErrors

protected final boolean hasErrors()

addNodeParam

protected final void addNodeParam(String name)

addParam

protected final void addParam(String name,
                              String value)


MMBase 2.0-SNAPSHOT - null