juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [12/51] [partial] incubator-juneau-website git commit: Javadoc updates.
Date Sat, 01 Apr 2017 23:58:00 GMT
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/5aed2f48/content/site/apidocs/src-html/org/apache/juneau/microservice/resources/LogsResource.FileResource.html
----------------------------------------------------------------------
diff --git a/content/site/apidocs/src-html/org/apache/juneau/microservice/resources/LogsResource.FileResource.html b/content/site/apidocs/src-html/org/apache/juneau/microservice/resources/LogsResource.FileResource.html
index 5cd598c..1dd44a8 100644
--- a/content/site/apidocs/src-html/org/apache/juneau/microservice/resources/LogsResource.FileResource.html
+++ b/content/site/apidocs/src-html/org/apache/juneau/microservice/resources/LogsResource.FileResource.html
@@ -40,284 +40,287 @@
 <span class="sourceLineNo">032</span>import org.apache.juneau.rest.annotation.Properties;<a name="line.32"></a>
 <span class="sourceLineNo">033</span>import org.apache.juneau.rest.converters.*;<a name="line.33"></a>
 <span class="sourceLineNo">034</span>import org.apache.juneau.transforms.*;<a name="line.34"></a>
-<span class="sourceLineNo">035</span><a name="line.35"></a>
-<span class="sourceLineNo">036</span>/**<a name="line.36"></a>
-<span class="sourceLineNo">037</span> * REST resource for viewing and accessing log files.<a name="line.37"></a>
-<span class="sourceLineNo">038</span> */<a name="line.38"></a>
-<span class="sourceLineNo">039</span>@RestResource(<a name="line.39"></a>
-<span class="sourceLineNo">040</span>   path="/logs",<a name="line.40"></a>
-<span class="sourceLineNo">041</span>   title="Log files",<a name="line.41"></a>
-<span class="sourceLineNo">042</span>   description="Log files from this service",<a name="line.42"></a>
-<span class="sourceLineNo">043</span>   properties={<a name="line.43"></a>
-<span class="sourceLineNo">044</span>      @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),<a name="line.44"></a>
-<span class="sourceLineNo">045</span>      @Property(name=REST_allowMethodParam, value="true")<a name="line.45"></a>
-<span class="sourceLineNo">046</span>   },<a name="line.46"></a>
-<span class="sourceLineNo">047</span>   pojoSwaps={<a name="line.47"></a>
-<span class="sourceLineNo">048</span>      IteratorSwap.class,       // Allows Iterators and Iterables to be serialized.<a name="line.48"></a>
-<span class="sourceLineNo">049</span>      DateSwap.ISO8601DT.class  // Serialize Date objects as ISO8601 strings.<a name="line.49"></a>
-<span class="sourceLineNo">050</span>   }<a name="line.50"></a>
-<span class="sourceLineNo">051</span>)<a name="line.51"></a>
-<span class="sourceLineNo">052</span>@SuppressWarnings("nls")<a name="line.52"></a>
-<span class="sourceLineNo">053</span>public class LogsResource extends Resource {<a name="line.53"></a>
-<span class="sourceLineNo">054</span>   private static final long serialVersionUID = 1L;<a name="line.54"></a>
-<span class="sourceLineNo">055</span><a name="line.55"></a>
-<span class="sourceLineNo">056</span>   private File logDir;<a name="line.56"></a>
-<span class="sourceLineNo">057</span>   private LogEntryFormatter leFormatter;<a name="line.57"></a>
-<span class="sourceLineNo">058</span><a name="line.58"></a>
-<span class="sourceLineNo">059</span>   private final FileFilter filter = new FileFilter() {<a name="line.59"></a>
-<span class="sourceLineNo">060</span>      @Override /* FileFilter */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>      public boolean accept(File f) {<a name="line.61"></a>
-<span class="sourceLineNo">062</span>         return f.isDirectory() || f.getName().endsWith(".log");<a name="line.62"></a>
-<span class="sourceLineNo">063</span>      }<a name="line.63"></a>
-<span class="sourceLineNo">064</span>   };<a name="line.64"></a>
-<span class="sourceLineNo">065</span>   <a name="line.65"></a>
-<span class="sourceLineNo">066</span>   @Override /* RestServlet */<a name="line.66"></a>
-<span class="sourceLineNo">067</span>   public synchronized void init(RestConfig config) throws Exception {<a name="line.67"></a>
-<span class="sourceLineNo">068</span>      super.init(config);<a name="line.68"></a>
-<span class="sourceLineNo">069</span>      ConfigFile cf = config.getConfigFile();<a name="line.69"></a>
-<span class="sourceLineNo">070</span>      <a name="line.70"></a>
-<span class="sourceLineNo">071</span>      logDir = new File(cf.getString("Logging/logDir", "."));<a name="line.71"></a>
-<span class="sourceLineNo">072</span>      leFormatter = new LogEntryFormatter(<a name="line.72"></a>
-<span class="sourceLineNo">073</span>         cf.getString("Logging/format", "[{date} {level}] {msg}%n"),<a name="line.73"></a>
-<span class="sourceLineNo">074</span>         cf.getString("Logging/dateFormat", "yyyy.MM.dd hh:mm:ss"),<a name="line.74"></a>
-<span class="sourceLineNo">075</span>         cf.getBoolean("Logging/useStackTraceHashes")<a name="line.75"></a>
-<span class="sourceLineNo">076</span>      );<a name="line.76"></a>
-<span class="sourceLineNo">077</span>   }<a name="line.77"></a>
-<span class="sourceLineNo">078</span><a name="line.78"></a>
-<span class="sourceLineNo">079</span>   /**<a name="line.79"></a>
-<span class="sourceLineNo">080</span>    * [GET /*] - Get file details or directory listing.<a name="line.80"></a>
-<span class="sourceLineNo">081</span>    *<a name="line.81"></a>
-<span class="sourceLineNo">082</span>    * @param req The HTTP request<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    * @param properties The writable properties for setting the descriptions.<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    * @param path The log file path.<a name="line.84"></a>
-<span class="sourceLineNo">085</span>    * @return The log file.<a name="line.85"></a>
-<span class="sourceLineNo">086</span>    * @throws Exception<a name="line.86"></a>
-<span class="sourceLineNo">087</span>    */<a name="line.87"></a>
-<span class="sourceLineNo">088</span>   @RestMethod(name="GET", path="/*", responses={@Response(200),@Response(404)})<a name="line.88"></a>
-<span class="sourceLineNo">089</span>   public Object getFileOrDirectory(RestRequest req, @Properties ObjectMap properties, @PathRemainder String path) throws Exception {<a name="line.89"></a>
-<span class="sourceLineNo">090</span><a name="line.90"></a>
-<span class="sourceLineNo">091</span>      File f = getFile(path);<a name="line.91"></a>
+<span class="sourceLineNo">035</span>import org.apache.juneau.utils.*;<a name="line.35"></a>
+<span class="sourceLineNo">036</span><a name="line.36"></a>
+<span class="sourceLineNo">037</span>/**<a name="line.37"></a>
+<span class="sourceLineNo">038</span> * REST resource for viewing and accessing log files.<a name="line.38"></a>
+<span class="sourceLineNo">039</span> */<a name="line.39"></a>
+<span class="sourceLineNo">040</span>@RestResource(<a name="line.40"></a>
+<span class="sourceLineNo">041</span>   path="/logs",<a name="line.41"></a>
+<span class="sourceLineNo">042</span>   title="Log files",<a name="line.42"></a>
+<span class="sourceLineNo">043</span>   description="Log files from this service",<a name="line.43"></a>
+<span class="sourceLineNo">044</span>   properties={<a name="line.44"></a>
+<span class="sourceLineNo">045</span>      @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),<a name="line.45"></a>
+<span class="sourceLineNo">046</span>      @Property(name=REST_allowMethodParam, value="true")<a name="line.46"></a>
+<span class="sourceLineNo">047</span>   },<a name="line.47"></a>
+<span class="sourceLineNo">048</span>   pojoSwaps={<a name="line.48"></a>
+<span class="sourceLineNo">049</span>      IteratorSwap.class,       // Allows Iterators and Iterables to be serialized.<a name="line.49"></a>
+<span class="sourceLineNo">050</span>      DateSwap.ISO8601DT.class  // Serialize Date objects as ISO8601 strings.<a name="line.50"></a>
+<span class="sourceLineNo">051</span>   }<a name="line.51"></a>
+<span class="sourceLineNo">052</span>)<a name="line.52"></a>
+<span class="sourceLineNo">053</span>@SuppressWarnings("nls")<a name="line.53"></a>
+<span class="sourceLineNo">054</span>public class LogsResource extends Resource {<a name="line.54"></a>
+<span class="sourceLineNo">055</span>   private static final long serialVersionUID = 1L;<a name="line.55"></a>
+<span class="sourceLineNo">056</span><a name="line.56"></a>
+<span class="sourceLineNo">057</span>   private File logDir;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>   private LogEntryFormatter leFormatter;<a name="line.58"></a>
+<span class="sourceLineNo">059</span><a name="line.59"></a>
+<span class="sourceLineNo">060</span>   private final FileFilter filter = new FileFilter() {<a name="line.60"></a>
+<span class="sourceLineNo">061</span>      @Override /* FileFilter */<a name="line.61"></a>
+<span class="sourceLineNo">062</span>      public boolean accept(File f) {<a name="line.62"></a>
+<span class="sourceLineNo">063</span>         return f.isDirectory() || f.getName().endsWith(".log");<a name="line.63"></a>
+<span class="sourceLineNo">064</span>      }<a name="line.64"></a>
+<span class="sourceLineNo">065</span>   };<a name="line.65"></a>
+<span class="sourceLineNo">066</span>   <a name="line.66"></a>
+<span class="sourceLineNo">067</span>   @Override /* RestServlet */<a name="line.67"></a>
+<span class="sourceLineNo">068</span>   public synchronized void init(RestConfig config) throws Exception {<a name="line.68"></a>
+<span class="sourceLineNo">069</span>      super.init(config);<a name="line.69"></a>
+<span class="sourceLineNo">070</span>      ConfigFile cf = config.getConfigFile();<a name="line.70"></a>
+<span class="sourceLineNo">071</span>      <a name="line.71"></a>
+<span class="sourceLineNo">072</span>      logDir = new File(cf.getString("Logging/logDir", "."));<a name="line.72"></a>
+<span class="sourceLineNo">073</span>      leFormatter = new LogEntryFormatter(<a name="line.73"></a>
+<span class="sourceLineNo">074</span>         cf.getString("Logging/format", "[{date} {level}] {msg}%n"),<a name="line.74"></a>
+<span class="sourceLineNo">075</span>         cf.getString("Logging/dateFormat", "yyyy.MM.dd hh:mm:ss"),<a name="line.75"></a>
+<span class="sourceLineNo">076</span>         cf.getBoolean("Logging/useStackTraceHashes")<a name="line.76"></a>
+<span class="sourceLineNo">077</span>      );<a name="line.77"></a>
+<span class="sourceLineNo">078</span>   }<a name="line.78"></a>
+<span class="sourceLineNo">079</span><a name="line.79"></a>
+<span class="sourceLineNo">080</span>   /**<a name="line.80"></a>
+<span class="sourceLineNo">081</span>    * [GET /*] - Get file details or directory listing.<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    *<a name="line.82"></a>
+<span class="sourceLineNo">083</span>    * @param req The HTTP request<a name="line.83"></a>
+<span class="sourceLineNo">084</span>    * @param res The HTTP response<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    * @param properties The writable properties for setting the descriptions.<a name="line.85"></a>
+<span class="sourceLineNo">086</span>    * @param path The log file path.<a name="line.86"></a>
+<span class="sourceLineNo">087</span>    * @return The log file.<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    * @throws Exception<a name="line.88"></a>
+<span class="sourceLineNo">089</span>    */<a name="line.89"></a>
+<span class="sourceLineNo">090</span>   @RestMethod(name="GET", path="/*", responses={@Response(200),@Response(404)})<a name="line.90"></a>
+<span class="sourceLineNo">091</span>   public Object getFileOrDirectory(RestRequest req, RestResponse res, @Properties ObjectMap properties, @PathRemainder String path) throws Exception {<a name="line.91"></a>
 <span class="sourceLineNo">092</span><a name="line.92"></a>
-<span class="sourceLineNo">093</span>      if (f.isDirectory()) {<a name="line.93"></a>
-<span class="sourceLineNo">094</span>         Set&lt;FileResource&gt; l = new TreeSet&lt;FileResource&gt;(new FileResourceComparator());<a name="line.94"></a>
-<span class="sourceLineNo">095</span>         File[] files = f.listFiles(filter);<a name="line.95"></a>
-<span class="sourceLineNo">096</span>         if (files != null) {<a name="line.96"></a>
-<span class="sourceLineNo">097</span>            for (File fc : files) {<a name="line.97"></a>
-<span class="sourceLineNo">098</span>               URL fUrl = new URL(req.getTrimmedRequestURL().append('/').append(fc.getName()).toString());<a name="line.98"></a>
-<span class="sourceLineNo">099</span>               l.add(new FileResource(fc, fUrl));<a name="line.99"></a>
-<span class="sourceLineNo">100</span>            }<a name="line.100"></a>
-<span class="sourceLineNo">101</span>         }<a name="line.101"></a>
-<span class="sourceLineNo">102</span>         properties.put(HTMLDOC_description, "Contents of " + f.getAbsolutePath());<a name="line.102"></a>
-<span class="sourceLineNo">103</span>         return l;<a name="line.103"></a>
-<span class="sourceLineNo">104</span>      }<a name="line.104"></a>
-<span class="sourceLineNo">105</span><a name="line.105"></a>
-<span class="sourceLineNo">106</span>      properties.put(HTMLDOC_description, "File details on " + f.getAbsolutePath());<a name="line.106"></a>
-<span class="sourceLineNo">107</span>      return new FileResource(f, new URL(req.getTrimmedRequestURL().toString()));<a name="line.107"></a>
-<span class="sourceLineNo">108</span>   }<a name="line.108"></a>
-<span class="sourceLineNo">109</span><a name="line.109"></a>
-<span class="sourceLineNo">110</span>   /**<a name="line.110"></a>
-<span class="sourceLineNo">111</span>    * [VIEW /*] - Retrieve the contents of a log file.<a name="line.111"></a>
-<span class="sourceLineNo">112</span>    *<a name="line.112"></a>
-<span class="sourceLineNo">113</span>    * @param req The HTTP request.<a name="line.113"></a>
-<span class="sourceLineNo">114</span>    * @param res The HTTP response.<a name="line.114"></a>
-<span class="sourceLineNo">115</span>    * @param path The log file path.<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    * @param properties The writable properties for setting the descriptions.<a name="line.116"></a>
-<span class="sourceLineNo">117</span>    * @param highlight If &lt;code&gt;true&lt;/code&gt;, add color highlighting based on severity.<a name="line.117"></a>
-<span class="sourceLineNo">118</span>    * @param start Optional start timestamp.  Don't print lines logged before the specified timestamp.  Example:  "&amp;amp;start=2014-01-23 11:25:47".<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    * @param end Optional end timestamp.  Don't print lines logged after the specified timestamp.  Example:  "&amp;amp;end=2014-01-23 11:25:47".<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    * @param thread Optional thread name filter.  Only show log entries with the specified thread name.  Example: "&amp;amp;thread=pool-33-thread-1".<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    * @param loggers Optional logger filter.  Only show log entries if they were produced by one of the specified loggers (simple class name).  Example: "&amp;amp;loggers=(LinkIndexService,LinkIndexRestService)".<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    * @param severity Optional severity filter.  Only show log entries with the specified severity.  Example: "&amp;amp;severity=(ERROR,WARN)".<a name="line.122"></a>
-<span class="sourceLineNo">123</span>    * @throws Exception<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    */<a name="line.124"></a>
-<span class="sourceLineNo">125</span>   @RestMethod(name="VIEW", path="/*", responses={@Response(200),@Response(404)})<a name="line.125"></a>
-<span class="sourceLineNo">126</span>   @SuppressWarnings("nls")<a name="line.126"></a>
-<span class="sourceLineNo">127</span>   public void viewFile(RestRequest req, RestResponse res, @PathRemainder String path, @Properties ObjectMap properties, @Query("highlight") boolean highlight, @Query("start") String start, @Query("end") String end, @Query("thread") String thread, @Query("loggers") String[] loggers, @Query("severity") String[] severity) throws Exception {<a name="line.127"></a>
-<span class="sourceLineNo">128</span><a name="line.128"></a>
-<span class="sourceLineNo">129</span>      File f = getFile(path);<a name="line.129"></a>
-<span class="sourceLineNo">130</span>      if (f.isDirectory())<a name="line.130"></a>
-<span class="sourceLineNo">131</span>         throw new RestException(SC_METHOD_NOT_ALLOWED, "View not available on directories");<a name="line.131"></a>
-<span class="sourceLineNo">132</span><a name="line.132"></a>
-<span class="sourceLineNo">133</span>      Date startDate = StringUtils.parseISO8601Date(start), endDate = StringUtils.parseISO8601Date(end);<a name="line.133"></a>
-<span class="sourceLineNo">134</span><a name="line.134"></a>
-<span class="sourceLineNo">135</span>      if (! highlight) {<a name="line.135"></a>
-<span class="sourceLineNo">136</span>         Object o = getReader(f, startDate, endDate, thread, loggers, severity);<a name="line.136"></a>
-<span class="sourceLineNo">137</span>         res.setContentType("text/plain");<a name="line.137"></a>
-<span class="sourceLineNo">138</span>         if (o instanceof Reader)<a name="line.138"></a>
-<span class="sourceLineNo">139</span>            res.setOutput(o);<a name="line.139"></a>
-<span class="sourceLineNo">140</span>         else {<a name="line.140"></a>
-<span class="sourceLineNo">141</span>            LogParser p = (LogParser)o;<a name="line.141"></a>
-<span class="sourceLineNo">142</span>            Writer w = res.getNegotiatedWriter();<a name="line.142"></a>
-<span class="sourceLineNo">143</span>            try {<a name="line.143"></a>
-<span class="sourceLineNo">144</span>               p.writeTo(w);<a name="line.144"></a>
-<span class="sourceLineNo">145</span>            } finally {<a name="line.145"></a>
-<span class="sourceLineNo">146</span>               w.flush();<a name="line.146"></a>
-<span class="sourceLineNo">147</span>               w.close();<a name="line.147"></a>
-<span class="sourceLineNo">148</span>            }<a name="line.148"></a>
-<span class="sourceLineNo">149</span>         }<a name="line.149"></a>
-<span class="sourceLineNo">150</span>         return;<a name="line.150"></a>
-<span class="sourceLineNo">151</span>      }<a name="line.151"></a>
-<span class="sourceLineNo">152</span><a name="line.152"></a>
-<span class="sourceLineNo">153</span>      res.setContentType("text/html");<a name="line.153"></a>
-<span class="sourceLineNo">154</span>      PrintWriter w = res.getNegotiatedWriter();<a name="line.154"></a>
-<span class="sourceLineNo">155</span>      try {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>         w.println("&lt;html&gt;&lt;body style='font-family:monospace;font-size:8pt;white-space:pre;'&gt;");<a name="line.156"></a>
-<span class="sourceLineNo">157</span>         LogParser lp = getLogParser(f, startDate, endDate, thread, loggers, severity);<a name="line.157"></a>
-<span class="sourceLineNo">158</span>         try {<a name="line.158"></a>
-<span class="sourceLineNo">159</span>            if (! lp.hasNext())<a name="line.159"></a>
-<span class="sourceLineNo">160</span>               w.append("&lt;span style='color:gray'&gt;[EMPTY]&lt;/span&gt;");<a name="line.160"></a>
-<span class="sourceLineNo">161</span>            else for (LogParser.Entry le : lp) {<a name="line.161"></a>
-<span class="sourceLineNo">162</span>               char s = le.severity.charAt(0);<a name="line.162"></a>
-<span class="sourceLineNo">163</span>               String color = "black";<a name="line.163"></a>
-<span class="sourceLineNo">164</span>               //SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST<a name="line.164"></a>
-<span class="sourceLineNo">165</span>               if (s == 'I')<a name="line.165"></a>
-<span class="sourceLineNo">166</span>                  color = "#006400";<a name="line.166"></a>
-<span class="sourceLineNo">167</span>               else if (s == 'W')<a name="line.167"></a>
-<span class="sourceLineNo">168</span>                  color = "#CC8400";<a name="line.168"></a>
-<span class="sourceLineNo">169</span>               else if (s == 'E' || s == 'S')<a name="line.169"></a>
-<span class="sourceLineNo">170</span>                  color = "#DD0000";<a name="line.170"></a>
-<span class="sourceLineNo">171</span>               else if (s == 'D' || s == 'F' || s == 'T')<a name="line.171"></a>
-<span class="sourceLineNo">172</span>                  color = "#000064";<a name="line.172"></a>
-<span class="sourceLineNo">173</span>               w.append("&lt;span style='color:").append(color).append("'&gt;");<a name="line.173"></a>
-<span class="sourceLineNo">174</span>               le.appendHtml(w).append("&lt;/span&gt;");<a name="line.174"></a>
-<span class="sourceLineNo">175</span>            }<a name="line.175"></a>
-<span class="sourceLineNo">176</span>            w.append("&lt;/body&gt;&lt;/html&gt;");<a name="line.176"></a>
-<span class="sourceLineNo">177</span>         } finally {<a name="line.177"></a>
-<span class="sourceLineNo">178</span>            lp.close();<a name="line.178"></a>
-<span class="sourceLineNo">179</span>         }<a name="line.179"></a>
-<span class="sourceLineNo">180</span>      } finally {<a name="line.180"></a>
-<span class="sourceLineNo">181</span>         w.close();<a name="line.181"></a>
-<span class="sourceLineNo">182</span>      }<a name="line.182"></a>
-<span class="sourceLineNo">183</span>   }<a name="line.183"></a>
-<span class="sourceLineNo">184</span><a name="line.184"></a>
-<span class="sourceLineNo">185</span>   /**<a name="line.185"></a>
-<span class="sourceLineNo">186</span>    * [VIEW /*] - Retrieve the contents of a log file as parsed entries.<a name="line.186"></a>
-<span class="sourceLineNo">187</span>    *<a name="line.187"></a>
-<span class="sourceLineNo">188</span>    * @param req The HTTP request.<a name="line.188"></a>
-<span class="sourceLineNo">189</span>    * @param path The log file path.<a name="line.189"></a>
-<span class="sourceLineNo">190</span>    * @param start Optional start timestamp.  Don't print lines logged before the specified timestamp.  Example:  "&amp;amp;start=2014-01-23 11:25:47".<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    * @param end Optional end timestamp.  Don't print lines logged after the specified timestamp.  Example:  "&amp;amp;end=2014-01-23 11:25:47".<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    * @param thread Optional thread name filter.  Only show log entries with the specified thread name.  Example: "&amp;amp;thread=pool-33-thread-1".<a name="line.192"></a>
-<span class="sourceLineNo">193</span>    * @param loggers Optional logger filter.  Only show log entries if they were produced by one of the specified loggers (simple class name).  Example: "&amp;amp;loggers=(LinkIndexService,LinkIndexRestService)".<a name="line.193"></a>
-<span class="sourceLineNo">194</span>    * @param severity Optional severity filter.  Only show log entries with the specified severity.  Example: "&amp;amp;severity=(ERROR,WARN)".<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    * @return The parsed contents of the log file.<a name="line.195"></a>
-<span class="sourceLineNo">196</span>    * @throws Exception<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    */<a name="line.197"></a>
-<span class="sourceLineNo">198</span>   @RestMethod(name="PARSE", path="/*", converters=Queryable.class, responses={@Response(200),@Response(404)})<a name="line.198"></a>
-<span class="sourceLineNo">199</span>   public LogParser viewParsedEntries(RestRequest req, @PathRemainder String path, @Query("start") String start, @Query("end") String end, @Query("thread") String thread, @Query("loggers") String[] loggers, @Query("severity") String[] severity) throws Exception {<a name="line.199"></a>
-<span class="sourceLineNo">200</span><a name="line.200"></a>
-<span class="sourceLineNo">201</span>      File f = getFile(path);<a name="line.201"></a>
-<span class="sourceLineNo">202</span>      Date startDate = StringUtils.parseISO8601Date(start), endDate = StringUtils.parseISO8601Date(end);<a name="line.202"></a>
+<span class="sourceLineNo">093</span>      File f = getFile(path);<a name="line.93"></a>
+<span class="sourceLineNo">094</span><a name="line.94"></a>
+<span class="sourceLineNo">095</span>      if (f.isDirectory()) {<a name="line.95"></a>
+<span class="sourceLineNo">096</span>         Set&lt;FileResource&gt; l = new TreeSet&lt;FileResource&gt;(new FileResourceComparator());<a name="line.96"></a>
+<span class="sourceLineNo">097</span>         File[] files = f.listFiles(filter);<a name="line.97"></a>
+<span class="sourceLineNo">098</span>         if (files != null) {<a name="line.98"></a>
+<span class="sourceLineNo">099</span>            for (File fc : files) {<a name="line.99"></a>
+<span class="sourceLineNo">100</span>               URL fUrl = new URL(req.getTrimmedRequestURL().append('/').append(fc.getName()).toString());<a name="line.100"></a>
+<span class="sourceLineNo">101</span>               l.add(new FileResource(fc, fUrl));<a name="line.101"></a>
+<span class="sourceLineNo">102</span>            }<a name="line.102"></a>
+<span class="sourceLineNo">103</span>         }<a name="line.103"></a>
+<span class="sourceLineNo">104</span>         res.setPageText(new StringMessage("Contents of {0}", f.getAbsolutePath()));<a name="line.104"></a>
+<span class="sourceLineNo">105</span>         properties.put(HTMLDOC_text, "Contents of " + f.getAbsolutePath());<a name="line.105"></a>
+<span class="sourceLineNo">106</span>         return l;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      }<a name="line.107"></a>
+<span class="sourceLineNo">108</span><a name="line.108"></a>
+<span class="sourceLineNo">109</span>      res.setPageText(new StringMessage("File details on {0}", f.getAbsolutePath()));<a name="line.109"></a>
+<span class="sourceLineNo">110</span>      return new FileResource(f, new URL(req.getTrimmedRequestURL().toString()));<a name="line.110"></a>
+<span class="sourceLineNo">111</span>   }<a name="line.111"></a>
+<span class="sourceLineNo">112</span><a name="line.112"></a>
+<span class="sourceLineNo">113</span>   /**<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    * [VIEW /*] - Retrieve the contents of a log file.<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    *<a name="line.115"></a>
+<span class="sourceLineNo">116</span>    * @param req The HTTP request.<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    * @param res The HTTP response.<a name="line.117"></a>
+<span class="sourceLineNo">118</span>    * @param path The log file path.<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    * @param properties The writable properties for setting the descriptions.<a name="line.119"></a>
+<span class="sourceLineNo">120</span>    * @param highlight If &lt;code&gt;true&lt;/code&gt;, add color highlighting based on severity.<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    * @param start Optional start timestamp.  Don't print lines logged before the specified timestamp.  Example:  "&amp;amp;start=2014-01-23 11:25:47".<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    * @param end Optional end timestamp.  Don't print lines logged after the specified timestamp.  Example:  "&amp;amp;end=2014-01-23 11:25:47".<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    * @param thread Optional thread name filter.  Only show log entries with the specified thread name.  Example: "&amp;amp;thread=pool-33-thread-1".<a name="line.123"></a>
+<span class="sourceLineNo">124</span>    * @param loggers Optional logger filter.  Only show log entries if they were produced by one of the specified loggers (simple class name).  Example: "&amp;amp;loggers=(LinkIndexService,LinkIndexRestService)".<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    * @param severity Optional severity filter.  Only show log entries with the specified severity.  Example: "&amp;amp;severity=(ERROR,WARN)".<a name="line.125"></a>
+<span class="sourceLineNo">126</span>    * @throws Exception<a name="line.126"></a>
+<span class="sourceLineNo">127</span>    */<a name="line.127"></a>
+<span class="sourceLineNo">128</span>   @RestMethod(name="VIEW", path="/*", responses={@Response(200),@Response(404)})<a name="line.128"></a>
+<span class="sourceLineNo">129</span>   @SuppressWarnings("nls")<a name="line.129"></a>
+<span class="sourceLineNo">130</span>   public void viewFile(RestRequest req, RestResponse res, @PathRemainder String path, @Properties ObjectMap properties, @Query("highlight") boolean highlight, @Query("start") String start, @Query("end") String end, @Query("thread") String thread, @Query("loggers") String[] loggers, @Query("severity") String[] severity) throws Exception {<a name="line.130"></a>
+<span class="sourceLineNo">131</span><a name="line.131"></a>
+<span class="sourceLineNo">132</span>      File f = getFile(path);<a name="line.132"></a>
+<span class="sourceLineNo">133</span>      if (f.isDirectory())<a name="line.133"></a>
+<span class="sourceLineNo">134</span>         throw new RestException(SC_METHOD_NOT_ALLOWED, "View not available on directories");<a name="line.134"></a>
+<span class="sourceLineNo">135</span><a name="line.135"></a>
+<span class="sourceLineNo">136</span>      Date startDate = StringUtils.parseISO8601Date(start), endDate = StringUtils.parseISO8601Date(end);<a name="line.136"></a>
+<span class="sourceLineNo">137</span><a name="line.137"></a>
+<span class="sourceLineNo">138</span>      if (! highlight) {<a name="line.138"></a>
+<span class="sourceLineNo">139</span>         Object o = getReader(f, startDate, endDate, thread, loggers, severity);<a name="line.139"></a>
+<span class="sourceLineNo">140</span>         res.setContentType("text/plain");<a name="line.140"></a>
+<span class="sourceLineNo">141</span>         if (o instanceof Reader)<a name="line.141"></a>
+<span class="sourceLineNo">142</span>            res.setOutput(o);<a name="line.142"></a>
+<span class="sourceLineNo">143</span>         else {<a name="line.143"></a>
+<span class="sourceLineNo">144</span>            LogParser p = (LogParser)o;<a name="line.144"></a>
+<span class="sourceLineNo">145</span>            Writer w = res.getNegotiatedWriter();<a name="line.145"></a>
+<span class="sourceLineNo">146</span>            try {<a name="line.146"></a>
+<span class="sourceLineNo">147</span>               p.writeTo(w);<a name="line.147"></a>
+<span class="sourceLineNo">148</span>            } finally {<a name="line.148"></a>
+<span class="sourceLineNo">149</span>               w.flush();<a name="line.149"></a>
+<span class="sourceLineNo">150</span>               w.close();<a name="line.150"></a>
+<span class="sourceLineNo">151</span>            }<a name="line.151"></a>
+<span class="sourceLineNo">152</span>         }<a name="line.152"></a>
+<span class="sourceLineNo">153</span>         return;<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      }<a name="line.154"></a>
+<span class="sourceLineNo">155</span><a name="line.155"></a>
+<span class="sourceLineNo">156</span>      res.setContentType("text/html");<a name="line.156"></a>
+<span class="sourceLineNo">157</span>      PrintWriter w = res.getNegotiatedWriter();<a name="line.157"></a>
+<span class="sourceLineNo">158</span>      try {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>         w.println("&lt;html&gt;&lt;body style='font-family:monospace;font-size:8pt;white-space:pre;'&gt;");<a name="line.159"></a>
+<span class="sourceLineNo">160</span>         LogParser lp = getLogParser(f, startDate, endDate, thread, loggers, severity);<a name="line.160"></a>
+<span class="sourceLineNo">161</span>         try {<a name="line.161"></a>
+<span class="sourceLineNo">162</span>            if (! lp.hasNext())<a name="line.162"></a>
+<span class="sourceLineNo">163</span>               w.append("&lt;span style='color:gray'&gt;[EMPTY]&lt;/span&gt;");<a name="line.163"></a>
+<span class="sourceLineNo">164</span>            else for (LogParser.Entry le : lp) {<a name="line.164"></a>
+<span class="sourceLineNo">165</span>               char s = le.severity.charAt(0);<a name="line.165"></a>
+<span class="sourceLineNo">166</span>               String color = "black";<a name="line.166"></a>
+<span class="sourceLineNo">167</span>               //SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST<a name="line.167"></a>
+<span class="sourceLineNo">168</span>               if (s == 'I')<a name="line.168"></a>
+<span class="sourceLineNo">169</span>                  color = "#006400";<a name="line.169"></a>
+<span class="sourceLineNo">170</span>               else if (s == 'W')<a name="line.170"></a>
+<span class="sourceLineNo">171</span>                  color = "#CC8400";<a name="line.171"></a>
+<span class="sourceLineNo">172</span>               else if (s == 'E' || s == 'S')<a name="line.172"></a>
+<span class="sourceLineNo">173</span>                  color = "#DD0000";<a name="line.173"></a>
+<span class="sourceLineNo">174</span>               else if (s == 'D' || s == 'F' || s == 'T')<a name="line.174"></a>
+<span class="sourceLineNo">175</span>                  color = "#000064";<a name="line.175"></a>
+<span class="sourceLineNo">176</span>               w.append("&lt;span style='color:").append(color).append("'&gt;");<a name="line.176"></a>
+<span class="sourceLineNo">177</span>               le.appendHtml(w).append("&lt;/span&gt;");<a name="line.177"></a>
+<span class="sourceLineNo">178</span>            }<a name="line.178"></a>
+<span class="sourceLineNo">179</span>            w.append("&lt;/body&gt;&lt;/html&gt;");<a name="line.179"></a>
+<span class="sourceLineNo">180</span>         } finally {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>            lp.close();<a name="line.181"></a>
+<span class="sourceLineNo">182</span>         }<a name="line.182"></a>
+<span class="sourceLineNo">183</span>      } finally {<a name="line.183"></a>
+<span class="sourceLineNo">184</span>         w.close();<a name="line.184"></a>
+<span class="sourceLineNo">185</span>      }<a name="line.185"></a>
+<span class="sourceLineNo">186</span>   }<a name="line.186"></a>
+<span class="sourceLineNo">187</span><a name="line.187"></a>
+<span class="sourceLineNo">188</span>   /**<a name="line.188"></a>
+<span class="sourceLineNo">189</span>    * [VIEW /*] - Retrieve the contents of a log file as parsed entries.<a name="line.189"></a>
+<span class="sourceLineNo">190</span>    *<a name="line.190"></a>
+<span class="sourceLineNo">191</span>    * @param req The HTTP request.<a name="line.191"></a>
+<span class="sourceLineNo">192</span>    * @param path The log file path.<a name="line.192"></a>
+<span class="sourceLineNo">193</span>    * @param start Optional start timestamp.  Don't print lines logged before the specified timestamp.  Example:  "&amp;amp;start=2014-01-23 11:25:47".<a name="line.193"></a>
+<span class="sourceLineNo">194</span>    * @param end Optional end timestamp.  Don't print lines logged after the specified timestamp.  Example:  "&amp;amp;end=2014-01-23 11:25:47".<a name="line.194"></a>
+<span class="sourceLineNo">195</span>    * @param thread Optional thread name filter.  Only show log entries with the specified thread name.  Example: "&amp;amp;thread=pool-33-thread-1".<a name="line.195"></a>
+<span class="sourceLineNo">196</span>    * @param loggers Optional logger filter.  Only show log entries if they were produced by one of the specified loggers (simple class name).  Example: "&amp;amp;loggers=(LinkIndexService,LinkIndexRestService)".<a name="line.196"></a>
+<span class="sourceLineNo">197</span>    * @param severity Optional severity filter.  Only show log entries with the specified severity.  Example: "&amp;amp;severity=(ERROR,WARN)".<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    * @return The parsed contents of the log file.<a name="line.198"></a>
+<span class="sourceLineNo">199</span>    * @throws Exception<a name="line.199"></a>
+<span class="sourceLineNo">200</span>    */<a name="line.200"></a>
+<span class="sourceLineNo">201</span>   @RestMethod(name="PARSE", path="/*", converters=Queryable.class, responses={@Response(200),@Response(404)})<a name="line.201"></a>
+<span class="sourceLineNo">202</span>   public LogParser viewParsedEntries(RestRequest req, @PathRemainder String path, @Query("start") String start, @Query("end") String end, @Query("thread") String thread, @Query("loggers") String[] loggers, @Query("severity") String[] severity) throws Exception {<a name="line.202"></a>
 <span class="sourceLineNo">203</span><a name="line.203"></a>
-<span class="sourceLineNo">204</span>      if (f.isDirectory())<a name="line.204"></a>
-<span class="sourceLineNo">205</span>         throw new RestException(SC_METHOD_NOT_ALLOWED, "View not available on directories");<a name="line.205"></a>
+<span class="sourceLineNo">204</span>      File f = getFile(path);<a name="line.204"></a>
+<span class="sourceLineNo">205</span>      Date startDate = StringUtils.parseISO8601Date(start), endDate = StringUtils.parseISO8601Date(end);<a name="line.205"></a>
 <span class="sourceLineNo">206</span><a name="line.206"></a>
-<span class="sourceLineNo">207</span>      return getLogParser(f, startDate, endDate, thread, loggers, severity);<a name="line.207"></a>
-<span class="sourceLineNo">208</span>   }<a name="line.208"></a>
+<span class="sourceLineNo">207</span>      if (f.isDirectory())<a name="line.207"></a>
+<span class="sourceLineNo">208</span>         throw new RestException(SC_METHOD_NOT_ALLOWED, "View not available on directories");<a name="line.208"></a>
 <span class="sourceLineNo">209</span><a name="line.209"></a>
-<span class="sourceLineNo">210</span>   /**<a name="line.210"></a>
-<span class="sourceLineNo">211</span>    * [DOWNLOAD /*] - Download file.<a name="line.211"></a>
-<span class="sourceLineNo">212</span>    *<a name="line.212"></a>
-<span class="sourceLineNo">213</span>    * @param res The HTTP response.<a name="line.213"></a>
-<span class="sourceLineNo">214</span>    * @param path The log file path.<a name="line.214"></a>
-<span class="sourceLineNo">215</span>    * @return The contents of the log file.<a name="line.215"></a>
-<span class="sourceLineNo">216</span>    * @throws Exception<a name="line.216"></a>
-<span class="sourceLineNo">217</span>    */<a name="line.217"></a>
-<span class="sourceLineNo">218</span>   @RestMethod(name="DOWNLOAD", path="/*", responses={@Response(200),@Response(404)})<a name="line.218"></a>
-<span class="sourceLineNo">219</span>   public Object downloadFile(RestResponse res, @PathRemainder String path) throws Exception {<a name="line.219"></a>
-<span class="sourceLineNo">220</span><a name="line.220"></a>
-<span class="sourceLineNo">221</span>      File f = getFile(path);<a name="line.221"></a>
-<span class="sourceLineNo">222</span><a name="line.222"></a>
-<span class="sourceLineNo">223</span>      if (f.isDirectory())<a name="line.223"></a>
-<span class="sourceLineNo">224</span>         throw new RestException(SC_METHOD_NOT_ALLOWED, "Download not available on directories");<a name="line.224"></a>
+<span class="sourceLineNo">210</span>      return getLogParser(f, startDate, endDate, thread, loggers, severity);<a name="line.210"></a>
+<span class="sourceLineNo">211</span>   }<a name="line.211"></a>
+<span class="sourceLineNo">212</span><a name="line.212"></a>
+<span class="sourceLineNo">213</span>   /**<a name="line.213"></a>
+<span class="sourceLineNo">214</span>    * [DOWNLOAD /*] - Download file.<a name="line.214"></a>
+<span class="sourceLineNo">215</span>    *<a name="line.215"></a>
+<span class="sourceLineNo">216</span>    * @param res The HTTP response.<a name="line.216"></a>
+<span class="sourceLineNo">217</span>    * @param path The log file path.<a name="line.217"></a>
+<span class="sourceLineNo">218</span>    * @return The contents of the log file.<a name="line.218"></a>
+<span class="sourceLineNo">219</span>    * @throws Exception<a name="line.219"></a>
+<span class="sourceLineNo">220</span>    */<a name="line.220"></a>
+<span class="sourceLineNo">221</span>   @RestMethod(name="DOWNLOAD", path="/*", responses={@Response(200),@Response(404)})<a name="line.221"></a>
+<span class="sourceLineNo">222</span>   public Object downloadFile(RestResponse res, @PathRemainder String path) throws Exception {<a name="line.222"></a>
+<span class="sourceLineNo">223</span><a name="line.223"></a>
+<span class="sourceLineNo">224</span>      File f = getFile(path);<a name="line.224"></a>
 <span class="sourceLineNo">225</span><a name="line.225"></a>
-<span class="sourceLineNo">226</span>      res.setContentType("application/octet-stream"); //$NON-NLS-1$<a name="line.226"></a>
-<span class="sourceLineNo">227</span>      res.setContentLength((int)f.length());<a name="line.227"></a>
-<span class="sourceLineNo">228</span>      return new FileInputStream(f);<a name="line.228"></a>
-<span class="sourceLineNo">229</span>   }<a name="line.229"></a>
-<span class="sourceLineNo">230</span><a name="line.230"></a>
-<span class="sourceLineNo">231</span>   /**<a name="line.231"></a>
-<span class="sourceLineNo">232</span>    * [DELETE /*] - Delete a file.<a name="line.232"></a>
-<span class="sourceLineNo">233</span>    *<a name="line.233"></a>
-<span class="sourceLineNo">234</span>    * @param path The log file path.<a name="line.234"></a>
-<span class="sourceLineNo">235</span>    * @return A redirect object to the root.<a name="line.235"></a>
-<span class="sourceLineNo">236</span>    * @throws Exception<a name="line.236"></a>
-<span class="sourceLineNo">237</span>    */<a name="line.237"></a>
-<span class="sourceLineNo">238</span>   @RestMethod(name="DELETE", path="/*", responses={@Response(200),@Response(404)})<a name="line.238"></a>
-<span class="sourceLineNo">239</span>   public Object deleteFile(@PathRemainder String path) throws Exception {<a name="line.239"></a>
-<span class="sourceLineNo">240</span><a name="line.240"></a>
-<span class="sourceLineNo">241</span>      File f = getFile(path);<a name="line.241"></a>
-<span class="sourceLineNo">242</span><a name="line.242"></a>
-<span class="sourceLineNo">243</span>      if (f.isDirectory())<a name="line.243"></a>
-<span class="sourceLineNo">244</span>         throw new RestException(SC_BAD_REQUEST, "Delete not available on directories.");<a name="line.244"></a>
+<span class="sourceLineNo">226</span>      if (f.isDirectory())<a name="line.226"></a>
+<span class="sourceLineNo">227</span>         throw new RestException(SC_METHOD_NOT_ALLOWED, "Download not available on directories");<a name="line.227"></a>
+<span class="sourceLineNo">228</span><a name="line.228"></a>
+<span class="sourceLineNo">229</span>      res.setContentType("application/octet-stream"); //$NON-NLS-1$<a name="line.229"></a>
+<span class="sourceLineNo">230</span>      res.setContentLength((int)f.length());<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      return new FileInputStream(f);<a name="line.231"></a>
+<span class="sourceLineNo">232</span>   }<a name="line.232"></a>
+<span class="sourceLineNo">233</span><a name="line.233"></a>
+<span class="sourceLineNo">234</span>   /**<a name="line.234"></a>
+<span class="sourceLineNo">235</span>    * [DELETE /*] - Delete a file.<a name="line.235"></a>
+<span class="sourceLineNo">236</span>    *<a name="line.236"></a>
+<span class="sourceLineNo">237</span>    * @param path The log file path.<a name="line.237"></a>
+<span class="sourceLineNo">238</span>    * @return A redirect object to the root.<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    * @throws Exception<a name="line.239"></a>
+<span class="sourceLineNo">240</span>    */<a name="line.240"></a>
+<span class="sourceLineNo">241</span>   @RestMethod(name="DELETE", path="/*", responses={@Response(200),@Response(404)})<a name="line.241"></a>
+<span class="sourceLineNo">242</span>   public Object deleteFile(@PathRemainder String path) throws Exception {<a name="line.242"></a>
+<span class="sourceLineNo">243</span><a name="line.243"></a>
+<span class="sourceLineNo">244</span>      File f = getFile(path);<a name="line.244"></a>
 <span class="sourceLineNo">245</span><a name="line.245"></a>
-<span class="sourceLineNo">246</span>      if (f.canWrite())<a name="line.246"></a>
-<span class="sourceLineNo">247</span>         if (! f.delete())<a name="line.247"></a>
-<span class="sourceLineNo">248</span>            throw new RestException(SC_FORBIDDEN, "Could not delete file.");<a name="line.248"></a>
-<span class="sourceLineNo">249</span><a name="line.249"></a>
-<span class="sourceLineNo">250</span>      return new Redirect(path + "/.."); //$NON-NLS-1$<a name="line.250"></a>
-<span class="sourceLineNo">251</span>   }<a name="line.251"></a>
+<span class="sourceLineNo">246</span>      if (f.isDirectory())<a name="line.246"></a>
+<span class="sourceLineNo">247</span>         throw new RestException(SC_BAD_REQUEST, "Delete not available on directories.");<a name="line.247"></a>
+<span class="sourceLineNo">248</span><a name="line.248"></a>
+<span class="sourceLineNo">249</span>      if (f.canWrite())<a name="line.249"></a>
+<span class="sourceLineNo">250</span>         if (! f.delete())<a name="line.250"></a>
+<span class="sourceLineNo">251</span>            throw new RestException(SC_FORBIDDEN, "Could not delete file.");<a name="line.251"></a>
 <span class="sourceLineNo">252</span><a name="line.252"></a>
-<span class="sourceLineNo">253</span>   private static BufferedReader getReader(File f) throws IOException {<a name="line.253"></a>
-<span class="sourceLineNo">254</span>      return new BufferedReader(new InputStreamReader(new FileInputStream(f), Charset.defaultCharset()));<a name="line.254"></a>
-<span class="sourceLineNo">255</span>   }<a name="line.255"></a>
-<span class="sourceLineNo">256</span><a name="line.256"></a>
-<span class="sourceLineNo">257</span>   private File getFile(String path) {<a name="line.257"></a>
-<span class="sourceLineNo">258</span>      if (path != null &amp;&amp; path.indexOf("..") != -1)<a name="line.258"></a>
-<span class="sourceLineNo">259</span>         throw new RestException(SC_NOT_FOUND, "File not found.");<a name="line.259"></a>
-<span class="sourceLineNo">260</span>      File f = (path == null ? logDir : new File(logDir.getAbsolutePath() + '/' + path));<a name="line.260"></a>
-<span class="sourceLineNo">261</span>      if (filter.accept(f))<a name="line.261"></a>
-<span class="sourceLineNo">262</span>         return f;<a name="line.262"></a>
-<span class="sourceLineNo">263</span>      throw new RestException(SC_NOT_FOUND, "File not found.");<a name="line.263"></a>
-<span class="sourceLineNo">264</span>   }<a name="line.264"></a>
-<span class="sourceLineNo">265</span><a name="line.265"></a>
-<span class="sourceLineNo">266</span>   /**<a name="line.266"></a>
-<span class="sourceLineNo">267</span>    * File bean.<a name="line.267"></a>
-<span class="sourceLineNo">268</span>    */<a name="line.268"></a>
-<span class="sourceLineNo">269</span>   @SuppressWarnings("javadoc")<a name="line.269"></a>
-<span class="sourceLineNo">270</span>   public static class FileResource {<a name="line.270"></a>
-<span class="sourceLineNo">271</span>      private File f;<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      public String type;<a name="line.272"></a>
-<span class="sourceLineNo">273</span>      public Object name;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>      public Long size;<a name="line.274"></a>
-<span class="sourceLineNo">275</span>      @BeanProperty(swap=DateSwap.DateTimeMedium.class) public Date lastModified;<a name="line.275"></a>
-<span class="sourceLineNo">276</span>      public URL view, highlighted, parsed, download, delete;<a name="line.276"></a>
-<span class="sourceLineNo">277</span><a name="line.277"></a>
-<span class="sourceLineNo">278</span>      public FileResource(File f, URL url) throws IOException {<a name="line.278"></a>
-<span class="sourceLineNo">279</span>         this.f = f;<a name="line.279"></a>
-<span class="sourceLineNo">280</span>         this.type = (f.isDirectory() ? "dir" : "file");<a name="line.280"></a>
-<span class="sourceLineNo">281</span>         this.name = f.isDirectory() ? new Link(f.getName(), url.toString()) : f.getName();<a name="line.281"></a>
-<span class="sourceLineNo">282</span>         this.size = f.isDirectory() ? null : f.length();<a name="line.282"></a>
-<span class="sourceLineNo">283</span>         this.lastModified = new Date(f.lastModified());<a name="line.283"></a>
-<span class="sourceLineNo">284</span>         if (f.canRead() &amp;&amp; ! f.isDirectory()) {<a name="line.284"></a>
-<span class="sourceLineNo">285</span>            this.view = new URL(url + "?method=VIEW");<a name="line.285"></a>
-<span class="sourceLineNo">286</span>            this.highlighted = new URL(url + "?method=VIEW&amp;highlight=true");<a name="line.286"></a>
-<span class="sourceLineNo">287</span>            this.parsed = new URL(url + "?method=PARSE");<a name="line.287"></a>
-<span class="sourceLineNo">288</span>            this.download = new URL(url + "?method=DOWNLOAD");<a name="line.288"></a>
-<span class="sourceLineNo">289</span>            this.delete = new URL(url + "?method=DELETE");<a name="line.289"></a>
-<span class="sourceLineNo">290</span>         }<a name="line.290"></a>
-<span class="sourceLineNo">291</span>      }<a name="line.291"></a>
-<span class="sourceLineNo">292</span>   }<a name="line.292"></a>
-<span class="sourceLineNo">293</span><a name="line.293"></a>
-<span class="sourceLineNo">294</span>   private static class FileResourceComparator implements Comparator&lt;FileResource&gt;, Serializable {<a name="line.294"></a>
-<span class="sourceLineNo">295</span>      private static final long serialVersionUID = 1L;<a name="line.295"></a>
-<span class="sourceLineNo">296</span>      @Override /* Comparator */<a name="line.296"></a>
-<span class="sourceLineNo">297</span>      public int compare(FileResource o1, FileResource o2) {<a name="line.297"></a>
-<span class="sourceLineNo">298</span>         int c = o1.type.compareTo(o2.type);<a name="line.298"></a>
-<span class="sourceLineNo">299</span>         return c != 0 ? c : o1.f.getName().compareTo(o2.f.getName());<a name="line.299"></a>
-<span class="sourceLineNo">300</span>      }<a name="line.300"></a>
-<span class="sourceLineNo">301</span>   }<a name="line.301"></a>
-<span class="sourceLineNo">302</span><a name="line.302"></a>
-<span class="sourceLineNo">303</span>   private Object getReader(File f, final Date start, final Date end, final String thread, final String[] loggers, final String[] severity) throws IOException {<a name="line.303"></a>
-<span class="sourceLineNo">304</span>      if (start == null &amp;&amp; end == null &amp;&amp; thread == null &amp;&amp; loggers == null)<a name="line.304"></a>
-<span class="sourceLineNo">305</span>         return getReader(f);<a name="line.305"></a>
-<span class="sourceLineNo">306</span>      return getLogParser(f, start, end, thread, loggers, severity);<a name="line.306"></a>
-<span class="sourceLineNo">307</span>   }<a name="line.307"></a>
-<span class="sourceLineNo">308</span><a name="line.308"></a>
-<span class="sourceLineNo">309</span>   private LogParser getLogParser(File f, final Date start, final Date end, final String thread, final String[] loggers, final String[] severity) throws IOException {<a name="line.309"></a>
-<span class="sourceLineNo">310</span>      return new LogParser(leFormatter, f, start, end, thread, loggers, severity);<a name="line.310"></a>
-<span class="sourceLineNo">311</span>   }<a name="line.311"></a>
-<span class="sourceLineNo">312</span>}<a name="line.312"></a>
+<span class="sourceLineNo">253</span>      return new Redirect(path + "/.."); //$NON-NLS-1$<a name="line.253"></a>
+<span class="sourceLineNo">254</span>   }<a name="line.254"></a>
+<span class="sourceLineNo">255</span><a name="line.255"></a>
+<span class="sourceLineNo">256</span>   private static BufferedReader getReader(File f) throws IOException {<a name="line.256"></a>
+<span class="sourceLineNo">257</span>      return new BufferedReader(new InputStreamReader(new FileInputStream(f), Charset.defaultCharset()));<a name="line.257"></a>
+<span class="sourceLineNo">258</span>   }<a name="line.258"></a>
+<span class="sourceLineNo">259</span><a name="line.259"></a>
+<span class="sourceLineNo">260</span>   private File getFile(String path) {<a name="line.260"></a>
+<span class="sourceLineNo">261</span>      if (path != null &amp;&amp; path.indexOf("..") != -1)<a name="line.261"></a>
+<span class="sourceLineNo">262</span>         throw new RestException(SC_NOT_FOUND, "File not found.");<a name="line.262"></a>
+<span class="sourceLineNo">263</span>      File f = (path == null ? logDir : new File(logDir.getAbsolutePath() + '/' + path));<a name="line.263"></a>
+<span class="sourceLineNo">264</span>      if (filter.accept(f))<a name="line.264"></a>
+<span class="sourceLineNo">265</span>         return f;<a name="line.265"></a>
+<span class="sourceLineNo">266</span>      throw new RestException(SC_NOT_FOUND, "File not found.");<a name="line.266"></a>
+<span class="sourceLineNo">267</span>   }<a name="line.267"></a>
+<span class="sourceLineNo">268</span><a name="line.268"></a>
+<span class="sourceLineNo">269</span>   /**<a name="line.269"></a>
+<span class="sourceLineNo">270</span>    * File bean.<a name="line.270"></a>
+<span class="sourceLineNo">271</span>    */<a name="line.271"></a>
+<span class="sourceLineNo">272</span>   @SuppressWarnings("javadoc")<a name="line.272"></a>
+<span class="sourceLineNo">273</span>   public static class FileResource {<a name="line.273"></a>
+<span class="sourceLineNo">274</span>      private File f;<a name="line.274"></a>
+<span class="sourceLineNo">275</span>      public String type;<a name="line.275"></a>
+<span class="sourceLineNo">276</span>      public Object name;<a name="line.276"></a>
+<span class="sourceLineNo">277</span>      public Long size;<a name="line.277"></a>
+<span class="sourceLineNo">278</span>      @BeanProperty(swap=DateSwap.DateTimeMedium.class) public Date lastModified;<a name="line.278"></a>
+<span class="sourceLineNo">279</span>      public URL view, highlighted, parsed, download, delete;<a name="line.279"></a>
+<span class="sourceLineNo">280</span><a name="line.280"></a>
+<span class="sourceLineNo">281</span>      public FileResource(File f, URL url) throws IOException {<a name="line.281"></a>
+<span class="sourceLineNo">282</span>         this.f = f;<a name="line.282"></a>
+<span class="sourceLineNo">283</span>         this.type = (f.isDirectory() ? "dir" : "file");<a name="line.283"></a>
+<span class="sourceLineNo">284</span>         this.name = f.isDirectory() ? new Link(f.getName(), url.toString()) : f.getName();<a name="line.284"></a>
+<span class="sourceLineNo">285</span>         this.size = f.isDirectory() ? null : f.length();<a name="line.285"></a>
+<span class="sourceLineNo">286</span>         this.lastModified = new Date(f.lastModified());<a name="line.286"></a>
+<span class="sourceLineNo">287</span>         if (f.canRead() &amp;&amp; ! f.isDirectory()) {<a name="line.287"></a>
+<span class="sourceLineNo">288</span>            this.view = new URL(url + "?method=VIEW");<a name="line.288"></a>
+<span class="sourceLineNo">289</span>            this.highlighted = new URL(url + "?method=VIEW&amp;highlight=true");<a name="line.289"></a>
+<span class="sourceLineNo">290</span>            this.parsed = new URL(url + "?method=PARSE");<a name="line.290"></a>
+<span class="sourceLineNo">291</span>            this.download = new URL(url + "?method=DOWNLOAD");<a name="line.291"></a>
+<span class="sourceLineNo">292</span>            this.delete = new URL(url + "?method=DELETE");<a name="line.292"></a>
+<span class="sourceLineNo">293</span>         }<a name="line.293"></a>
+<span class="sourceLineNo">294</span>      }<a name="line.294"></a>
+<span class="sourceLineNo">295</span>   }<a name="line.295"></a>
+<span class="sourceLineNo">296</span><a name="line.296"></a>
+<span class="sourceLineNo">297</span>   private static class FileResourceComparator implements Comparator&lt;FileResource&gt;, Serializable {<a name="line.297"></a>
+<span class="sourceLineNo">298</span>      private static final long serialVersionUID = 1L;<a name="line.298"></a>
+<span class="sourceLineNo">299</span>      @Override /* Comparator */<a name="line.299"></a>
+<span class="sourceLineNo">300</span>      public int compare(FileResource o1, FileResource o2) {<a name="line.300"></a>
+<span class="sourceLineNo">301</span>         int c = o1.type.compareTo(o2.type);<a name="line.301"></a>
+<span class="sourceLineNo">302</span>         return c != 0 ? c : o1.f.getName().compareTo(o2.f.getName());<a name="line.302"></a>
+<span class="sourceLineNo">303</span>      }<a name="line.303"></a>
+<span class="sourceLineNo">304</span>   }<a name="line.304"></a>
+<span class="sourceLineNo">305</span><a name="line.305"></a>
+<span class="sourceLineNo">306</span>   private Object getReader(File f, final Date start, final Date end, final String thread, final String[] loggers, final String[] severity) throws IOException {<a name="line.306"></a>
+<span class="sourceLineNo">307</span>      if (start == null &amp;&amp; end == null &amp;&amp; thread == null &amp;&amp; loggers == null)<a name="line.307"></a>
+<span class="sourceLineNo">308</span>         return getReader(f);<a name="line.308"></a>
+<span class="sourceLineNo">309</span>      return getLogParser(f, start, end, thread, loggers, severity);<a name="line.309"></a>
+<span class="sourceLineNo">310</span>   }<a name="line.310"></a>
+<span class="sourceLineNo">311</span><a name="line.311"></a>
+<span class="sourceLineNo">312</span>   private LogParser getLogParser(File f, final Date start, final Date end, final String thread, final String[] loggers, final String[] severity) throws IOException {<a name="line.312"></a>
+<span class="sourceLineNo">313</span>      return new LogParser(leFormatter, f, start, end, thread, loggers, severity);<a name="line.313"></a>
+<span class="sourceLineNo">314</span>   }<a name="line.314"></a>
+<span class="sourceLineNo">315</span>}<a name="line.315"></a>
 
 
 


Mime
View raw message