01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.solr.handler;
17:
18: import java.io.IOException;
19: import java.util.ArrayList;
20:
21: import org.apache.commons.io.IOUtils;
22: import org.apache.solr.util.ContentStream;
23: import org.apache.solr.request.SolrQueryRequest;
24: import org.apache.solr.request.SolrQueryResponse;
25: import org.apache.solr.util.NamedList;
26: import org.apache.solr.util.SimpleOrderedMap;
27:
28: public class DumpRequestHandler extends RequestHandlerBase {
29: @Override
30: public void handleRequestBody(SolrQueryRequest req,
31: SolrQueryResponse rsp) throws IOException {
32: // Show params
33: rsp.add("params", req.getParams().toNamedList());
34:
35: // Write the streams...
36: if (req.getContentStreams() != null) {
37: ArrayList streams = new ArrayList();
38: // Cycle through each stream
39: for (ContentStream content : req.getContentStreams()) {
40: NamedList<Object> stream = new SimpleOrderedMap<Object>();
41: stream.add("name", content.getName());
42: stream.add("fieldName", content.getSourceInfo());
43: stream.add("size", content.getSize());
44: stream.add("contentType", content.getContentType());
45: stream.add("stream", IOUtils.toString(content
46: .getStream()));
47: streams.add(stream);
48: }
49: rsp.add("streams", streams);
50: }
51:
52: rsp.add("context", req.getContext());
53: }
54:
55: //////////////////////// SolrInfoMBeans methods //////////////////////
56:
57: @Override
58: public String getDescription() {
59: return "Dump handler (debug)";
60: }
61:
62: @Override
63: public String getVersion() {
64: return "$Revision: 523774 $";
65: }
66:
67: @Override
68: public String getSourceId() {
69: return "$Id: DumpRequestHandler.java 523774 2007-03-29 17:28:31Z yonik $";
70: }
71:
72: @Override
73: public String getSource() {
74: return "$URL: https://svn.apache.org/repos/asf/lucene/solr/branches/branch-1.2/src/java/org/apache/solr/handler/DumpRequestHandler.java $";
75: }
76: }
|