34
34
import java .util .List ;
35
35
import java .util .Locale ;
36
36
import java .util .Map ;
37
+ import java .util .logging .Level ;
38
+ import java .util .logging .Logger ;
37
39
import java .util .stream .Collectors ;
38
40
import org .opengrok .indexer .configuration .PathAccepter ;
39
41
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
40
42
import org .opengrok .indexer .history .HistoryException ;
41
43
import org .opengrok .indexer .history .HistoryGuru ;
44
+ import org .opengrok .indexer .logger .LoggerFactory ;
42
45
import org .opengrok .indexer .search .DirectoryEntry ;
43
46
import org .opengrok .indexer .search .FileExtra ;
44
47
import org .opengrok .indexer .web .EftarFileReader ;
49
52
*/
50
53
public class DirectoryListing {
51
54
55
+ private static final Logger LOGGER = LoggerFactory .getLogger (DirectoryListing .class );
56
+
52
57
protected static final String DIRECTORY_SIZE_PLACEHOLDER = "-" ;
53
58
private final EftarFileReader desc ;
54
59
private final long now ;
@@ -135,14 +140,12 @@ private static String getSimplifiedPath(File dir) {
135
140
* @throws HistoryException history exception
136
141
* @throws IOException I/O exception
137
142
*/
138
- public List <String > listTo (String contextPath , File dir , Writer out ,
139
- String path , List <String > files )
140
- throws HistoryException , IOException {
143
+ public List <String > listTo (String contextPath , File dir , Writer out , String path , List <String > files )
144
+ throws IOException , HistoryException {
141
145
List <DirectoryEntry > filesExtra = null ;
142
146
if (files != null ) {
143
147
filesExtra = files .stream ().map (f ->
144
- new DirectoryEntry (new File (dir , f ), null )).collect (
145
- Collectors .toList ());
148
+ new DirectoryEntry (new File (dir , f ), null )).collect (Collectors .toList ());
146
149
}
147
150
return extraListTo (contextPath , dir , out , path , filesExtra );
148
151
}
@@ -159,22 +162,21 @@ public List<String> listTo(String contextPath, File dir, Writer out,
159
162
* but filtered by {@link PathAccepter}.
160
163
* @return a possible empty list of README files included in the written
161
164
* listing.
162
- * @throws org.opengrok.indexer.history.HistoryException when we cannot
163
- * get result from SCM
164
- *
165
- * @throws java.io.IOException when any I/O problem
166
- * @throws NullPointerException if a parameter except <var>files</var>
167
- * is {@code null}
165
+ * @throws IOException when cannot write to the {@code out} parameter
166
+ * @throws HistoryException when failed to get last modified time for files in directory
168
167
*/
169
168
public List <String > extraListTo (String contextPath , File dir , Writer out ,
170
- String path , List <DirectoryEntry > entries )
171
- throws HistoryException , IOException {
169
+ String path , List <DirectoryEntry > entries ) throws IOException , HistoryException {
172
170
// TODO this belongs to a jsp, not here
173
171
ArrayList <String > readMes = new ArrayList <>();
174
172
int offset = -1 ;
175
173
EftarFileReader .FNode parentFNode = null ;
176
174
if (desc != null ) {
177
- parentFNode = desc .getNode (path );
175
+ try {
176
+ parentFNode = desc .getNode (path );
177
+ } catch (IOException e ) {
178
+ LOGGER .log (Level .WARNING , String .format ("cannot get Eftar node for path ''%s''" , path ), e );
179
+ }
178
180
if (parentFNode != null ) {
179
181
offset = parentFNode .getChildOffset ();
180
182
}
0 commit comments