com.ibm.portal
Interface ModelController<T,M extends Modifiable>

Type Parameters:
T - the type of node the controller exposes
M - the type of modifiable node the controller exposes
All Superinterfaces:
Controller
All Known Subinterfaces:
ContentModelController<T,M>, LayoutModelController<T,M>, ListModelController<T,M>, OrderedListModelController<T,M>, PortletModelController, SearchableTreeModelController<T,M>, TreeModelController<T,M>

public interface ModelController<T,M extends Modifiable>
extends Controller

This interface provides a controller for models. Updates are scoped to the controller and appear in the model the controller bases on only after it is successfully committed (see Committable.commit()). The modifiable nodes the controller exposes are part of the model and can be used as input to the read-only model methods of the controller.

Modifiable nodes implement only interfaces for which the corresponding resource may be modified with regards to the programming model. If such interface is implemented, the corresponding resource may still not be modifiable due to other constraints, e.g. access control. To determine if a certain modification is possible the appropriate methods on the modifiable interfaces can be used, which are prefixed 'confirm'.

For symmetry reasons, the method to delete nodes from a model (a method called delete(...)) is available on the controller interface which also provides the appropriate insert(...) method - as is the case for TreeModelController and ListModelController.

Since:
6.1.0

Method Summary
 boolean confirmCreate(java.lang.Class aNodeClass, CreationContext aContext)
          Indicates if a modifiable node of the specified class and with the specified creation context may be created.
 M create(java.lang.Class aNodeClass, CreationContext aContext)
          Creates a modifiable node.
 M getModifiableNode(T aNode)
          Returns a modifiable instance of the specified node.
 T resolve(java.lang.Object aNode)
          Resolves the specified node of the model to its most recent representation.
 

Method Detail

create

M create(java.lang.Class aNodeClass,
         CreationContext aContext)
                            throws CannotInstantiateModifiableNodeException
Creates a modifiable node. The created node can be inserted into the model controller using an appropriate insert method defined on a subinterface of this interface. The node will not appear in the model unless it is inserted.

Parameters:
aNodeClass - interface class of node to insert
aContext - a context specifying information about the node to create, may be null
Returns:
a modifiable node;
Throws:
CannotInstantiateModifiableNodeException - in case the modifiable node cannot be instantiated

getModifiableNode

M getModifiableNode(T aNode)
                                       throws CannotInstantiateModifiableNodeException
Returns a modifiable instance of the specified node. In case a modifiable node has been requested for the specified node before, that instance is returned; otherwise a new modifiable instance is returned.

Parameters:
aNode - node to retrieve a modifiable node for
Returns:
a modifiable node
Throws:
CannotInstantiateModifiableNodeException - in case the modifiable node cannot be instantiated

resolve

T resolve(java.lang.Object aNode)
Resolves the specified node of the model to its most recent representation. Invoke this method to ensure that the reference of the node exposes modifications applied to it.

Parameters:
aNode - node to resolve
Returns:
up-to-date representation of the specified node or null, if the node cannot be resolved, e.g if the specified node is not contained in, or has been deleted from the model.

confirmCreate

boolean confirmCreate(java.lang.Class aNodeClass,
                      CreationContext aContext)
Indicates if a modifiable node of the specified class and with the specified creation context may be created.

Parameters:
aNodeClass - interface class for which to indicate if the creation of a node can be performed
aContext - creation context for which to indicate if the creation of a node can be performed, may be null.
Returns:
true if the creation can be performed, false otherwise