88import com .ithit .webdav .server .deltav .AutoVersion ;
99import com .ithit .webdav .server .exceptions .DavException ;
1010import com .ithit .webdav .server .exceptions .WebDavStatus ;
11+ import org .apache .commons .io .FileUtils ;
1112
1213import javax .servlet .ServletConfig ;
1314import javax .servlet .ServletException ;
1415import javax .servlet .http .HttpServlet ;
1516import javax .servlet .http .HttpServletRequest ;
1617import javax .servlet .http .HttpServletResponse ;
1718import javax .servlet .http .HttpSession ;
18- import java .io .BufferedReader ;
19- import java .io .FileReader ;
20- import java .io .IOException ;
21- import java .io .PrintWriter ;
19+ import java .io .*;
20+ import java .nio .charset .StandardCharsets ;
2221import java .nio .file .Files ;
2322import java .nio .file .Path ;
2423import java .nio .file .Paths ;
@@ -38,27 +37,6 @@ public class WebDavServlet extends HttpServlet {
3837 private SearchFacade searchFacade ;
3938 static final String START_TIME = "" + System .currentTimeMillis ();
4039
41- /**
42- * Reads license file content.
43- *
44- * @param fileName License file location.
45- * @return String license content.
46- */
47- private static String getContents (String fileName ) {
48- StringBuilder contents = new StringBuilder ();
49-
50- try (BufferedReader input = new BufferedReader (new FileReader (fileName ))) {
51- String line ;
52- while ((line = input .readLine ()) != null ) {
53- contents .append (line );
54- contents .append (System .getProperty ("line.separator" ));
55- }
56- } catch (IOException ignored ) {
57- }
58-
59- return contents .toString ();
60- }
61-
6240 /**
6341 * Return path of servlet location in file system to load resources.
6442 *
@@ -100,7 +78,11 @@ public void init(ServletConfig servletConfig) throws ServletException {
10078 autoputUnderVersionControl = "true" .equals (servletConfig .getInitParameter ("autoPutUnderVersionControl" ));
10179 realPath = servletConfig .getServletContext ().getRealPath ("" );
10280 servletContext = servletConfig .getServletContext ().getContextPath ();
103- license = getContents (licenseFile );
81+ try {
82+ license = FileUtils .readFileToString (new File (licenseFile ), StandardCharsets .UTF_8 );
83+ } catch (IOException e ) {
84+ license = "" ;
85+ }
10486 WebDavEngine engine = new WebDavEngine (logger , license );
10587 DataAccess dataAccess = new DataAccess (engine );
10688 String indexLocalPath = createIndexPath ();
0 commit comments