/*************************************************************************
* *
* SignServer: The OpenSource Automated Signing Server *
* *
* This software is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or any later version. *
* *
* See terms of license at gnu.org. *
* *
*************************************************************************/
package org.signserver.web;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Dispatches or forwards or redirects requests to the old ValidationWS
* path /signserver/validationws/validationws to the new
* /signserver/ValidationWSService/ValidationWS.
*
* @author Markus KilÄs
* @version $Id: Validation31Dispatcher.java 1533 2010-12-25 17:21:15Z netmackan $
*/
public class Validation31Dispatcher extends HttpServlet {
/** The new WS endpoint URL **/
private static final String NEW_URL
= "/signserver/ValidationWSService/ValidationWS";
/**
* Processes requests for both HTTP GET
and POST
methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException,
IOException {
final StringBuilder newUrl = new StringBuilder();
newUrl.append(NEW_URL);
final String query = request.getQueryString();
if (query != null) {
newUrl.append("?");
newUrl.append(query);
}
response.sendRedirect(response.encodeRedirectURL(newUrl.toString()));
}
//
/**
* Handles the HTTP GET
method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP POST
method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}//
}