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