Package es.udc.myportal.portal.controller

Source Code of es.udc.myportal.portal.controller.MyPortalDefaultServiceController

/*
* $Header: /export/home/cvsroot/MyPersonalizerRepository/MyPortal/Sources/es/udc/myportal/portal/controller/MyPortalDefaultServiceController.java,v 1.1.1.1 2004/03/25 12:10:42 fbellas Exp $
* $Revision: 1.1.1.1 $
* $Date: 2004/03/25 12:10:42 $
*
* =============================================================================
*
* Copyright (c) 2003, The MyPersonalizer Development Group
* (http://www.tic.udc.es/~fbellas/mypersonalizer/index.html) at
* University Of A Coruna
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of source code must retain the above copyright notice,
*    this list of conditions and the following disclaimer.
*
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the documentation
*    and/or other materials provided with the distribution.
*
*  - Neither the name of the University Of A Coruna nor the names of its
*    contributors may be used to endorse or promote products derived from
*    this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

package es.udc.myportal.portal.controller;
import es.udc.mypersonalizer.kernel.util.exceptions.
    InternalErrorException;
import es.udc.mypersonalizer.kernel.model.repository.interfaces.
    ServiceButtonsState;   
import es.udc.mypersonalizer.kernel.model.repository.interfaces.
    ServiceProperty;
import es.udc.mypersonalizer.kernel.model.repository.interfaces.
    ServicePropertyKey;
import es.udc.mypersonalizer.kernel.model.repository.interfaces.
    ServiceConfigurationRegistrySingleton;
import es.udc.mypersonalizer.kernel.model.repository.interfaces.
    ServiceConfiguration;
import es.udc.mypersonalizer.kernel.model.editors.
    ServiceButtonsStateEditor;
import es.udc.mypersonalizer.kernel.model.editors.
    EditorFactory;
import es.udc.mypersonalizer.portal.controller.services.
    DefaultServiceController;
import es.udc.mypersonalizer.portal.controller.services.
    PersonalizedReplyRequest;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* A default <code>ServiceController</code> for MyPortal services. This
* controller gets the service context relative path from its configuration.
*
* @author Abel Iago Toral Quiroga
* @author Daniel F. Garrido
* @since 1.0
*/
public class MyPortalDefaultServiceController
         extends DefaultServiceController {
       
    /** Constant for the service context relative path configuration setting */
    private static final String CONTEXT_RELATIVE_PATH_CONFIG_PARAMETER =
        "serviceURL";

    protected PersonalizedReplyRequest getPersonalizedReplyRequest(
            HttpServletRequest request, HttpServletResponse response,
            ServicePropertyKey servicePropertyKey,
            ServiceProperty serviceProperty, ServiceButtonsState buttons)
            throws InternalErrorException {

        try {

            /* Get context relative path from service configuration */       
            String serviceIdentifier =
                servicePropertyKey.getServiceIdentifier();

            ServiceConfiguration serviceConfiguration =
                ServiceConfigurationRegistrySingleton.getInstance().
                    getServiceConfiguration(serviceIdentifier);

            String contextRelativePath =
                (String) serviceConfiguration.getParameters().get(
                    CONTEXT_RELATIVE_PATH_CONFIG_PARAMETER);
       
            /* Create parameters Map */
            Map serviceParameters = getServiceParameters(
                request, response, serviceProperty, buttons);
           
            /* Return personalized reply request. */
            return new PersonalizedReplyRequest(
                contextRelativePath, serviceParameters);


        } catch (InternalErrorException e) {
            throw e;
        } catch (Exception e) {
            throw new InternalErrorException(e);
        }
    }

    /**
     * Returns the service parameters. In general, this method will be redefined
     * by specific service controllers. The default implementation returns an
     * empty map of parameters.
     *
     * @param request the request.
     * @param response the response.
     * @param serviceProperty the user personalization for the service.
     * @param buttons the service buttons state
     * @throws <code>Exception</code> if an error eccured
     * @return a <code>Map</code> with the pairs parameter name and parameter
     *         values (as a <code>String[]</code>) for the service response
     *         request.
     */    
    protected Map getServiceParameters(
            HttpServletRequest request, HttpServletResponse response,
            ServiceProperty serviceProperty, ServiceButtonsState buttons)
            throws Exception {
               
        return new HashMap();
       
    }

}
TOP

Related Classes of es.udc.myportal.portal.controller.MyPortalDefaultServiceController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.