1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.docstore.discovery.servlet;
17
18 import javax.servlet.ServletException;
19 import javax.servlet.ServletOutputStream;
20 import javax.servlet.http.HttpServlet;
21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpServletResponse;
23 import java.io.BufferedInputStream;
24 import java.io.File;
25 import java.io.FileInputStream;
26 import java.io.IOException;
27
28
29
30
31 public class DiscoveryConfigServlet extends HttpServlet {
32 private static final long serialVersionUID = 1L;
33
34
35
36
37 public DiscoveryConfigServlet() {
38 super();
39 }
40
41
42
43
44
45 protected void doPost(HttpServletRequest request,
46 HttpServletResponse response) throws ServletException, IOException {
47 ServletOutputStream outputStream = null;
48 BufferedInputStream inputStream = null;
49 try {
50 outputStream = response.getOutputStream();
51 String solrHome = System.getProperty("solr.solr.home");
52 File docSearchConfigFile = new File(solrHome + "/DocSearchConfig.xml");
53 response.setContentType("text/xml");
54 response.setContentLength((int) docSearchConfigFile.length());
55 FileInputStream input = new FileInputStream(docSearchConfigFile);
56 inputStream = new BufferedInputStream(input);
57 int readBytes;
58 while ((readBytes = inputStream.read()) != -1)
59 outputStream.write(readBytes);
60 } catch (IOException ioe) {
61 throw new ServletException(ioe.getMessage());
62 } finally {
63 if (outputStream != null)
64 outputStream.close();
65 if (inputStream != null)
66 inputStream.close();
67 }
68 }
69
70
71
72
73
74
75 protected void doGet(HttpServletRequest request,
76 HttpServletResponse response) throws ServletException, IOException {
77 doPost(request, response);
78 }
79 }