com.sap.portal.admin.wizard.handlers
Interface IObjectTypeHandler

All Known Implementing Classes:
AbstractObjectTypeHandler

public interface IObjectTypeHandler

IObjectTypeHandler handles the object according to its type. Every type of object must be provided with a handler implementation in order to be supported by the toolkit with the new PCM API. The framework calls this interface along the creation process and after it according to the object's semantics. This API is called from the SavePane as follows:

 < get the handler from session > 
 // create new descriptor
 Object descriptor = createObjectDescriptor(typeHandler,context);
 < get the wizard instance >
 < get the attributes map >
 // finalize the descriptor (add the attributes)
 wizard.finalizeDescriptor(attributesMap, descriptor, context);
 // save the object
 typeHandler.saveObject(descriptor, context);
 // finalize the object
 wizard.finalizeObject(context);
 ...
 

The toolkit provides default handlers that can be re-used or extended: iView, Page, Layout, System and Producer(Global Portal). How to use the handler mechanism:

  1. The wizard uses one of the public handlers that are provided by the toolkit, does not need to implement a handler class. The only thing that needs to be verified, is that the toolkit knows which handler is used (explained in the next paragraph). If for any reason the object type parameter is not provided, a property must be defined, otherwise an exception is thrown.
  2. The wizard implements a handler that either extends one of the public handlers, extends AbstractObjectTypeHandler or implements this interface. In this case the implementing class can implement IService for re-use, and publish its key as a service in the portalapp.xml file, or be a core implementation for private use.
Note, that in the first case (when using a public handler that is provided by the toolkit), if the ObjectType parameter is known to be one of the implemented types, there is no need to set the property for the handler service, the toolkit finds it automatically.
Any time that one of the aforementioned properties is set, the toolkit gives it a higher priority. Defining both of them should be avoided; if they are both defined, the "handlerServiceKey" property is applied, and the "handlerClassName" property is disregarded.

See Also:
AbstractPCMWizard

Method Summary
 java.lang.Object createObjectDescriptor(java.lang.String targetId, com.sap.portal.pcm.CreateMethod method, IWizardContext context)
          Create a new object descriptor that is in charge of storing the object's data.
 void saveObject(java.lang.Object descriptor, IWizardContext context)
          Saves the object in the persistence.
 

Method Detail

createObjectDescriptor

public java.lang.Object createObjectDescriptor(java.lang.String targetId,
                                               com.sap.portal.pcm.CreateMethod method,
                                               IWizardContext context)
                                        throws DescriptorNotCreatedException
Create a new object descriptor that is in charge of storing the object's data. The PCM uses it to save the new object into the persistence.
Every handler generates implementation dependent descriptor that implements this interface.

Note: the implementation should deal only with the descriptor creation. Everything else should be would be implemented in AbstractPCMWizard.finalizeDescriptor(Map, Object, com.sapportals.admin.wizardframework.api.IWizardContext).

Parameters:
targetId - the target path.
method - creation method CreateMethod
context - the wizard context
Returns:
Object the newly created descriptor.
Throws:
DescriptorNotCreatedException - if the descriptor failed to be created.
See Also:
INewObjectDescriptor

saveObject

public void saveObject(java.lang.Object descriptor,
                       IWizardContext context)
                throws ObjectNotCreatedException
Saves the object in the persistence. Which method to use in order save the object is up to the wizard developer. The toolkit uses bind() as default.
Parameters:
descriptor - the object descriptor, ready for save.
context - wizard context.
Throws:
ObjectNotCreatedException - if the save has failed.
See Also:
AbstractObjectTypeHandler.saveObject(Object, IWizardContext), Context.bind(String, Object)