All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.wink.server.internal.handlers.CreateRequestWithParamsHandler Maven / Gradle / Ivy

/*******************************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *  
 *******************************************************************************/
package org.apache.wink.server.internal.handlers;

//import java.util.Collections;
//import java.util.Enumeration;
//import java.util.HashMap;
//import java.util.Map;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletRequestWrapper;

import org.apache.wink.server.handlers.AbstractHandler;
import org.apache.wink.server.handlers.MessageContext;

/**
 * In case the searchMethodState contains request parameters, the handler adds
 * these parameters to the request by creating wrapper of the request. Currently
 * this functionality is used by aliases to provide "path to parameter"
 * functionality: /defect/critical to
 * /defects?severity=critical
 */
public class CreateRequestWithParamsHandler extends AbstractHandler {

    public void handleRequest(MessageContext context) throws Throwable {

        // TODO: fix me (see javadoc of handler)

        // SearchResult searchResult = context.getSearchResult();
        // add the request parameters
        // Map reqParameters = searchResult.getReqParameters();
        // if (reqParameters != null) {
        // RequestWithParameters servletRequestWrapper = new
        // RequestWithParameters(
        // enhancedRequest.getBaseServletRequest(), reqParameters);
        // enhancedRequest.setBaseServletRequest(servletRequestWrapper);
        // }
    }

    // private static class RequestWithParameters extends
    // HttpServletRequestWrapper {
    //
    // private Map requestParameters;
    //
    // private RequestWithParameters(HttpServletRequest httpServletRequest,
    // Map requestParameters) {
    // super(httpServletRequest);
    //
    // // because of legacy API
    // @SuppressWarnings("unchecked")
    // HashMap paramHashMap = new HashMap(
    // super.getParameterMap());
    // for (Map.Entry requestParameter :
    // requestParameters.entrySet()) {
    // paramHashMap.put(requestParameter.getKey(),
    // new String[] { requestParameter.getValue() });
    // }
    // this.requestParameters = paramHashMap;
    // }
    //
    // @Override
    // public String getParameter(String parameter) {
    // String[] value = requestParameters.get(parameter);
    // if (value != null) {
    // return value[0];
    // } else {
    // return null;
    // }
    // }
    //
    // @Override
    // public Map getParameterMap() {
    // return requestParameters;
    // }
    //
    // @Override
    // public Enumeration getParameterNames() {
    // return Collections.enumeration(requestParameters.keySet());
    // }
    //
    // @Override
    // public String[] getParameterValues(String parameter) {
    // return requestParameters.get(parameter);
    // }
    //
    // } // class RequestWithParameters

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy