📄 wcsdispatcher.java
字号:
* logic for the class.
*
* @param request The servlet request object.
* @param response The servlet response object.
*
* @throws ServletException For any servlet problems.
* @throws IOException For any io problems.
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int targetRequest = 0;
// Examine the incoming request and create appropriate server objects
// to deal with each request
// try {
final String queryString = request.getQueryString();
if (queryString != null) {
Map kvPairs = KvpRequestReader.parseKvpSet(queryString);
targetRequest = DispatcherKvpReader.getRequestType(kvPairs);
} else {
targetRequest = UNKNOWN;
//throw exception
}
doResponse(null, request, response, targetRequest);
}
/**
* Does the actual response, creates the appropriate servlet to handle the
* detected request. Note that the requestReader is a bit of a hack, if
* it is null then it is from a get Request, if not then that means the
* request is being stored as a file, and needs to be read with this
* particular reader.
*
* <p>
* This does have the downside of forcing us to have doGet and doPost
* methods of AbstractService be public, perhaps there is a good pattern
* for handling this. Or we could try to re-write Dispatcher to extend
* AbstractService, but it may be tricky.
* </p>
*
* @param requestReader The reader of a file that contains the request,
* null if from a get request.
* @param request The http request that was made.
* @param response The response to be returned.
* @param req_type The request type.
*
* @throws ServletException for any problems.
* @throws IOException If anything goes wrong reading or writing.
*/
protected void doResponse(Reader requestReader, HttpServletRequest request,
HttpServletResponse response, int req_type) throws ServletException, IOException {
AbstractService dispatched;
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info(new StringBuffer("req_type is ").append(req_type).toString());
}
// switch (req_type) {
// case GET_CAPABILITIES_REQUEST:
// dispatched = new Capabilities();
//
// break;
//
// case DESCRIBE_COVERAGE_REQUEST:
// dispatched = new Describe();
//
// break;
//
// case GET_COVERAGE_REQUEST:
// dispatched = new Coverage();
//
// break;
//
// default:
// dispatched = null;
// }
//
// if ((dispatched != null)) {
// dispatched.init(servletConfig); //only really needed for init
//
// if (requestReader == null) {
// dispatched.doGet(request, response);
// } else {
// dispatched.doPost(request, response, requestReader);
// }
// } else {
// String message;
//
// if (requestReader == null) {
// message = "No request recognized. The REQUEST parameter"
// + " must be one of GetCoverage or DescribeCoverage.";
// } else {
// message = "The proper request could not be extracted from the"
// + "the xml posted. Make sure the case is correct. The "
// + "request must be one of GetCoverage or DescribeCoverage.";
// }
// HttpSession session = request.getSession();
// ServletContext context = session.getServletContext();
// GeoServer geoServer = (GeoServer) context.getAttribute(GeoServer.WEB_CONTAINER_KEY);
//
// WcsException wcse = new WcsException(message);
// String tempResponse = wcse.getXmlResponse(geoServer.isVerboseExceptions(), request);
//
// response.setContentType(geoServer.getCharSet().toString());
// response.getWriter().write(tempResponse);
// }
}
// /**
// * Gets the request encoding by taking a couple guesses. First it tries
// * to get the encoding specified in the actual XML sent, which is likely
// * the most accurate. We are willing to take the speed hit to be more
// * sure of the right encoding. If that is not present we take a shot
// * at the encoding used to send the http request. If that is not found
// * then we just go ahead with the default encoding. Thanks to Artie Konin
// * for this work, it's right on.
// *
// * @param request The http request object to guess the encoding of.
// * @return A string of the best guess of the encoding of the request.
// */
// protected String guessRequestEncoding(HttpServletRequest request) {
// String defaultEncoding = DEFAULT_ENCODING;
// String encoding = getXmlEncoding();
// if (encoding == null) {
// encoding = request.getHeader(ENCODING_HEADER_ARG);
// if (encoding == null) {
// encoding = defaultEncoding;
// } else {
// if (encoding.indexOf("=") == -1) {
// encoding = defaultEncoding;
// } else {
// int encodingIndex = encoding.lastIndexOf("=") + 1;
// encoding = encoding.substring(encodingIndex).trim();
// }
// }
// }
// return encoding;
// }
//
// /**
// * Gets the encoding of the xml request made to the dispatcher. This
// * works by reading the temp file where we are storing the request,
// * looking to match the header specified encoding that should be present
// * on all xml files. This call should only be made after the temp file
// * has been set. If no encoding is found, or if an IOError is encountered
// * then null shall be returned.
// *
// * @return The encoding specified in the xml header of the file stored
// * in 'temp'.
// */
// protected String getXmlEncoding() {
// try {
// StringWriter sw = new StringWriter(60);
// BufferedReader in = new BufferedReader(new FileReader(temp));
//
// int c;
// while ((-1 != (c = in.read())) && (0x3E != c)) {
// sw.write(c);
// }
// in.close();
//
// Matcher m = ENCODING_PATTERN.matcher(sw.toString());
// if (m.find()) {
// String result = m.group(1);
// LOGGER.info("got match: " + result);
// return result;
// //return m.toMatchResult().group(1);
// } else {
// return null;
// }
// } catch (IOException e) {
// return null;
// }
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -