/*  Copyright (c) 2000, 2002 by Oracle Corporation. All Rights Reserved. */
 
package oracle.portal.provider.v1.http; 
import oracle.portal.provider.v1.NameValuePersonalizationObject; 
import oracle.portal.provider.v1.PortletReference; 
import oracle.portal.provider.v1.PortletParameter; 
import oracle.portal.provider.v1.PortletRenderRequest;

/**
 * <p>Class for holding personalization details of URLPortlet.
 * Holds customization information for portlet title and portlet paramters.</p>
 *
 */
public class URLPersonalizationObject extends NameValuePersonalizationObject 
{ 
   
    // Key to retrieve the customized Portlet Parameter value.
    public static final String PORTLET_PARAMETER_VALUE = "portletparamvalue"; 
    
    //Key to store information whether to qualify parameters.
    public static final String QUALIFY_PARAMETERS = "qualifyparams"; 

    /**
     * Sets default values in the customization object.
     */
    public void setDefaultValues(PortletRenderRequest pr)
    {
        // Call super class method to set the default title for this portlet.
        setPortletTitle(pr.getPortlet().getTitle(pr.getLocale()));

        //Put default values for customization parameters.
        PortletParameter params[] = pr.getPortlet().getInputParameters(); 
        if (params != null) 
        { 
            for (int i = 0; i < params.length; i++) 
            { 
                this.putString(PORTLET_PARAMETER_VALUE + (i + 1),""); 
            } 
        } 
        putString(QUALIFY_PARAMETERS,UrlServicesUtils.FALSE); 
    }
    
    
    /**
     * Override the init method to provide default values for the items we wish
     * to customize.
     */
    public void init(PortletReference pr) 
    { 
        // Always be sure to call super.init() first.
        super.init(pr); 

        //Put default values for customization parameters.
        PortletParameter params[] = pr.getPortlet().getInputParameters(); 
        if (params != null) 
        { 
            for (int i = 0; i < params.length; i++) 
            { 
                this.putString(PORTLET_PARAMETER_VALUE + (i + 1),""); 
            } 
        } 
        putString(QUALIFY_PARAMETERS,UrlServicesUtils.FALSE); 
    } 
} 