mirror of
https://github.com/sismics/docs.git
synced 2024-11-23 22:37:55 +01:00
Close all PDDocument
This commit is contained in:
parent
2c7083aa43
commit
2289f523c4
@ -153,12 +153,17 @@ public class FileUtil {
|
|||||||
image = ImageIO.read(originalFile);
|
image = ImageIO.read(originalFile);
|
||||||
} else if(file.getMimeType().equals(MimeType.APPLICATION_PDF)) {
|
} else if(file.getMimeType().equals(MimeType.APPLICATION_PDF)) {
|
||||||
// Generate preview from the first page of the PDF
|
// Generate preview from the first page of the PDF
|
||||||
PDDocument pdfDocument = PDDocument.load(originalFile.getAbsolutePath(), true);
|
PDDocument pdfDocument = null;
|
||||||
@SuppressWarnings("unchecked")
|
try {
|
||||||
List<PDPage> pageList = pdfDocument.getDocumentCatalog().getAllPages();
|
pdfDocument = PDDocument.load(originalFile.getAbsolutePath(), true);
|
||||||
if (pageList.size() > 0) {
|
@SuppressWarnings("unchecked")
|
||||||
PDPage page = pageList.get(0);
|
List<PDPage> pageList = pdfDocument.getDocumentCatalog().getAllPages();
|
||||||
image = page.convertToImage();
|
if (pageList.size() > 0) {
|
||||||
|
PDPage page = pageList.get(0);
|
||||||
|
image = page.convertToImage();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
pdfDocument.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,15 +251,15 @@ public class DocumentResource extends BaseResource {
|
|||||||
if (params[1].length() == 10) {
|
if (params[1].length() == 10) {
|
||||||
DateTime date = dayFormatter.parseDateTime(params[1]);
|
DateTime date = dayFormatter.parseDateTime(params[1]);
|
||||||
documentCriteria.setCreateDateMin(date.toDate());
|
documentCriteria.setCreateDateMin(date.toDate());
|
||||||
documentCriteria.setCreateDateMax(date.plusDays(1).toDate());
|
documentCriteria.setCreateDateMax(date.plusDays(1).minusSeconds(1).toDate());
|
||||||
} else if (params[1].length() == 7) {
|
} else if (params[1].length() == 7) {
|
||||||
DateTime date = monthFormatter.parseDateTime(params[1]);
|
DateTime date = monthFormatter.parseDateTime(params[1]);
|
||||||
documentCriteria.setCreateDateMin(date.toDate());
|
documentCriteria.setCreateDateMin(date.toDate());
|
||||||
documentCriteria.setCreateDateMax(date.plusMonths(1).toDate());
|
documentCriteria.setCreateDateMax(date.plusMonths(1).minusSeconds(1).toDate());
|
||||||
} else if (params[1].length() == 4) {
|
} else if (params[1].length() == 4) {
|
||||||
DateTime date = yearFormatter.parseDateTime(params[1]);
|
DateTime date = yearFormatter.parseDateTime(params[1]);
|
||||||
documentCriteria.setCreateDateMin(date.toDate());
|
documentCriteria.setCreateDateMin(date.toDate());
|
||||||
documentCriteria.setCreateDateMax(date.plusYears(1).toDate());
|
documentCriteria.setCreateDateMax(date.plusYears(1).minusSeconds(1).toDate());
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// NOP
|
// NOP
|
||||||
|
@ -2,4 +2,5 @@ log4j.rootCategory=WARN, MEMORY
|
|||||||
log4j.appender.MEMORY=com.sismics.util.log4j.MemoryAppender
|
log4j.appender.MEMORY=com.sismics.util.log4j.MemoryAppender
|
||||||
log4j.appender.MEMORY.size=1000
|
log4j.appender.MEMORY.size=1000
|
||||||
|
|
||||||
log4j.logger.com.sismics=INFO
|
log4j.logger.com.sismics=INFO
|
||||||
|
log4j.logger.org.apache.pdfbox=ERROR
|
Loading…
Reference in New Issue
Block a user