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:
AdminPortletModelController, ClientListController<T,M>, CommittableListModelController<T,M>, CommittableTreeModelController<T,M>, CommonPortletModelController, ContentModelController<T,M>, LayoutModelController<T,M>, ListModelController<T,M>, MarkupListController<T,M>, OrderedListModelController<T,M>, OutboundConnectionModelController, PortletModelController, RatingModelController<R,M>, ResourceModelController<R,M>, SearchableListModelController<T,M>, SearchableTreeModelController<T,M>, SkinListController<T,M>, TagModelController<T,M>, ThemeListController<T,M>, TreeModelController<T,M>, VanityURLModelController<E,M>, WireModelController<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.
 boolean confirmGetModifiableNode(T aNode)
          Indicates if a modifiable node of the specified node 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

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

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

confirmGetModifiableNode

boolean confirmGetModifiableNode(T aNode)
Indicates if a modifiable node of the specified node may be created.

Parameters:
aNode - the node that shall be tested
Returns:
true if a modifiable instance can be created, false otherwise

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.