/*  Copyright (c) 2000 by Oracle Corporation. All Rights Reserved. */

package oracle.portal.provider.v1;

import org.w3c.dom.Node;

import oracle.portal.utils.xml.v1.*;

/**
 * This class contains methods for processing an XML provider registry.
 * The main entry point is processNode which recursively processes the XML 
 * nodes in the XML document. 
 */
public class ProviderNodeHandler extends DefaultNodeHandler
{
    public void invokePreInitialize(Object o, Object parent) throws NodeHandlerException
    {
        super.invokePreInitialize(o, parent);

        //if the object is a portlet then we call the init method from the
        //Portlet interface
        if (o instanceof Portlet)
        {
            if (!(parent instanceof Provider))
            {
                throw new NodeHandlerException("Parent of a Portlet must be a Provider");
            }
            ((Portlet)o).init((Provider)parent);
        }
        //if the object is a PersonalizationManager then call it's initInstance method
        if (o instanceof PortletPersonalizationManager)
        {
            if (!(parent instanceof Portlet))
            {
                throw new NodeHandlerException("Parent of a PortletPersonalizationManager must be a Portlet");
            }
            ((PortletPersonalizationManager)o).initInstance((Portlet)parent);
        }
    }
}

