Revision 4e7b8a39 src/gr/ebs/gss/server/rest/FilesHandler.java
b/src/gr/ebs/gss/server/rest/FilesHandler.java | ||
---|---|---|
404 | 404 |
|
405 | 405 |
// Find content type. |
406 | 406 |
String contentType = null; |
407 |
boolean isFolderPublic = false;
|
|
407 |
boolean isContentHtml = false;
|
|
408 | 408 |
|
409 | 409 |
if (file != null) { |
410 | 410 |
contentType = version>0 ? oldBody.getMimeType() : file.getMimeType(); |
... | ... | |
412 | 412 |
contentType = context.getMimeType(file.getName()); |
413 | 413 |
file.setMimeType(contentType); |
414 | 414 |
} |
415 |
} |
|
416 |
else if (req.getHeader("Accept").contains("text/html")) |
|
417 |
if(folder != null && folder.isReadForAll()){ |
|
418 |
contentType = "text/html;charset=UTF-8"; |
|
419 |
isFolderPublic = true; |
|
420 |
} |
|
421 |
else |
|
422 |
contentType = "application/json;charset=UTF-8"; |
|
423 |
else |
|
424 |
contentType = "application/json;charset=UTF-8"; |
|
415 |
} else { // folder != null |
|
416 |
String accept = req.getHeader("Accept"); |
|
417 |
// The order in this conditional pessimizes the common API case, |
|
418 |
// but is important for backwards compatibility with existing |
|
419 |
// clients who send no accept header and expect a JSON response. |
|
420 |
if (accept != null && accept.contains("text/html")) { |
|
421 |
contentType = "text/html;charset=UTF-8"; |
|
422 |
isContentHtml = true; |
|
423 |
} else |
|
424 |
contentType = "application/json;charset=UTF-8"; |
|
425 |
} |
|
425 | 426 |
|
426 | 427 |
|
427 | 428 |
ArrayList ranges = null; |
... | ... | |
499 | 500 |
InputStream renderResult = null; |
500 | 501 |
if (content) |
501 | 502 |
// Serve the directory browser for a public folder |
502 |
if (isFolderPublic)
|
|
503 |
if (isContentHtml)
|
|
503 | 504 |
renderResult = renderHtml(req.getContextPath(), path, folder,user); |
504 | 505 |
// Serve the directory for an ordinary folder |
505 | 506 |
else |
Also available in: Unified diff