Log exception stack trace in presentation conversion classes using error scope.
This commit is contained in:
parent
dd82d95022
commit
424a3ffde6
@ -72,7 +72,7 @@ public class ImageToSwfSlide {
|
||||
try {
|
||||
FileUtils.copyFile(new File(BLANK_SLIDE), slide);
|
||||
} catch (IOException e) {
|
||||
log.error("IOException while copying blank slide.");
|
||||
log.error("IOException while copying blank slide.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class PdfToSwfSlide {
|
||||
try {
|
||||
FileUtils.copyFile(new File(BLANK_SLIDE), slide);
|
||||
} catch (IOException e) {
|
||||
log.error("IOException while copying blank slide.");
|
||||
log.error("IOException while copying blank slide.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,10 +136,8 @@ public class PresentationUrlDownloadService {
|
||||
try {
|
||||
FileUtils.copyFile(sourcePresentationFile, newPresentation);
|
||||
} catch (IOException e) {
|
||||
log.error("Could not copy presentation {} to {}",
|
||||
sourcePresentationFile.getAbsolutePath(),
|
||||
newPresentation.getAbsolutePath());
|
||||
e.printStackTrace();
|
||||
log.error("Could not copy presentation {} to {}", sourcePresentationFile.getAbsolutePath(),
|
||||
newPresentation.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,8 +177,7 @@ public class PresentationUrlDownloadService {
|
||||
try {
|
||||
presUrl = new URL(redirectUrl);
|
||||
} catch (MalformedURLException e) {
|
||||
log.error("Malformed url=[{}] for meeting=[{}]", redirectUrl,
|
||||
meetingId);
|
||||
log.error("Malformed url=[{}] for meeting=[{}]", redirectUrl, meetingId, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -210,8 +207,7 @@ public class PresentationUrlDownloadService {
|
||||
return redirectUrl;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("IOException for url=[{}] with meeting[{}]", redirectUrl,
|
||||
meetingId);
|
||||
log.error("IOException for url=[{}] with meeting[{}]", redirectUrl, meetingId, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -246,16 +242,16 @@ public class PresentationUrlDownloadService {
|
||||
File result = future.get();
|
||||
success = result.exists();
|
||||
} catch (java.lang.InterruptedException ex) {
|
||||
|
||||
log.error("InterruptedException while saving presentation", meetingId, ex);
|
||||
} catch (java.util.concurrent.ExecutionException ex) {
|
||||
|
||||
log.error("ExecutionException while saving presentation", meetingId, ex);
|
||||
} catch (java.io.FileNotFoundException ex) {
|
||||
|
||||
log.error("FileNotFoundException while saving presentation", meetingId, ex);
|
||||
} finally {
|
||||
try {
|
||||
httpclient.close();
|
||||
} catch (java.io.IOException ex) {
|
||||
|
||||
log.error("IOException while saving presentation", meetingId, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,5 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Pdf2PngPageConverterHandler extends AbstractCommandHandler {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(Pdf2PngPageConverterHandler.class);
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(Pdf2PngPageConverterHandler.class);
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public class Pdf2SwfPageConverterHandler extends AbstractCommandHandler {
|
||||
return Integer
|
||||
.parseInt(m.group(0).replace(PLACEMENT_OUTPUT, "").trim());
|
||||
} catch (Exception e) {
|
||||
log.error("Exception counting the number of placements", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -77,6 +78,7 @@ public class Pdf2SwfPageConverterHandler extends AbstractCommandHandler {
|
||||
m.find();
|
||||
return Integer.parseInt(m.group(0).replace(TEXT_TAG_OUTPUT, "").trim());
|
||||
} catch (Exception e) {
|
||||
log.error("Exception counting the number of text tags", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -97,6 +99,7 @@ public class Pdf2SwfPageConverterHandler extends AbstractCommandHandler {
|
||||
return Integer
|
||||
.parseInt(m.group(0).replace(IMAGE_TAG_OUTPUT, "").trim());
|
||||
} catch (Exception e) {
|
||||
log.error("Exception counting the number of iamge tags", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public class PdfPageCounterHandler extends AbstractCommandHandler {
|
||||
m.find();
|
||||
return Integer.parseInt(m.group(1).trim());
|
||||
} catch (Exception e) {
|
||||
log.error("Exception counting images", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,5 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Png2SwfPageConverterHandler extends AbstractCommandHandler {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(Png2SwfPageConverterHandler.class);
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(Png2SwfPageConverterHandler.class);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ public class SvgConversionHandler extends AbstractCommandHandler {
|
||||
m.find();
|
||||
return Integer.parseInt(m.group(0).replace(PATH_OUTPUT, "").trim());
|
||||
} catch (Exception e) {
|
||||
log.error("Exception counting the number of paths", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -46,6 +47,7 @@ public class SvgConversionHandler extends AbstractCommandHandler {
|
||||
m.find();
|
||||
return Integer.parseInt(m.group(0).replace(IMAGE_TAG_OUTPUT, "").trim());
|
||||
} catch (Exception e) {
|
||||
log.error("Exception counting the number of image tags", e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -118,14 +118,14 @@ public class ImageToSwfSlidesGenerationService {
|
||||
future = completionService.take();
|
||||
slide = future.get(timeLeft, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("InterruptedException while creating slide " + pres.getName());
|
||||
log.error("InterruptedException while creating slide {}", pres.getName(), e);
|
||||
} catch (ExecutionException e) {
|
||||
log.error("ExecutionException while creating slide " + pres.getName());
|
||||
log.error("ExecutionException while creating slide {}", pres.getName(), e);
|
||||
} catch (TimeoutException e) {
|
||||
log.error("TimeoutException while converting " + pres.getName());
|
||||
log.error("TimeoutException while converting {}", pres.getName(), e);
|
||||
} finally {
|
||||
if ((slide != null) && (! slide.isDone())){
|
||||
log.warn("Creating blank slide for " + slide.getPageNumber());
|
||||
log.warn("Creating blank slide for {}", slide.getPageNumber());
|
||||
future.cancel(true);
|
||||
slide.generateBlankSlide();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class Office2PdfPageConverter {
|
||||
logData.put("exception", e.getMessage());
|
||||
Gson gson = new Gson();
|
||||
String logStr = gson.toJson(logData);
|
||||
log.error("-- analytics -- " + logStr);
|
||||
log.error("-- analytics -- {}", logStr, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class OfficeDocumentValidator {
|
||||
logData.put("message", "Cannot open PPTX file " + pres.getName());
|
||||
Gson gson = new Gson();
|
||||
String logStr = gson.toJson(logData);
|
||||
log.error("-- analytics -- " + logStr);
|
||||
log.error("-- analytics -- {}", logStr, e);
|
||||
|
||||
valid = false;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public class OfficeToPdfConversionService {
|
||||
try {
|
||||
officeManager.start();
|
||||
} catch (OfficeException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("Could not start Office Manager", e);
|
||||
}
|
||||
|
||||
}
|
||||
@ -135,7 +135,7 @@ public class OfficeToPdfConversionService {
|
||||
try {
|
||||
officeManager.stop();
|
||||
} catch (OfficeException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("Could not stop Office Manager", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,16 +40,15 @@ import com.zaxxer.nuprocess.NuProcess;
|
||||
import com.zaxxer.nuprocess.NuProcessBuilder;
|
||||
|
||||
public class Pdf2SwfPageConverter implements PageConverter {
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(Pdf2SwfPageConverter.class);
|
||||
private static Logger log = LoggerFactory.getLogger(Pdf2SwfPageConverter.class);
|
||||
|
||||
private String SWFTOOLS_DIR;
|
||||
private String fontsDir;
|
||||
private long placementsThreshold;
|
||||
private long defineTextThreshold;
|
||||
private long imageTagThreshold;
|
||||
private String convTimeout = "7s";
|
||||
private int WAIT_FOR_SEC = 7;
|
||||
private String SWFTOOLS_DIR;
|
||||
private String fontsDir;
|
||||
private long placementsThreshold;
|
||||
private long defineTextThreshold;
|
||||
private long imageTagThreshold;
|
||||
private String convTimeout = "7s";
|
||||
private int WAIT_FOR_SEC = 7;
|
||||
|
||||
public boolean convert(File presentation, File output, int page,
|
||||
UploadedPresentation pres) {
|
||||
@ -77,7 +76,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
|
||||
try {
|
||||
process.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("InterruptedException while creating SWF {}", pres.getName(), e);
|
||||
}
|
||||
|
||||
long pdf2SwfEnd = System.currentTimeMillis();
|
||||
@ -134,7 +133,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
|
||||
logData.put("message", "Unable to create temporary files");
|
||||
gson = new Gson();
|
||||
logStr = gson.toJson(logData);
|
||||
log.error("-- analytics -- " + logStr);
|
||||
log.error("-- analytics -- {}", logStr, ioException);
|
||||
}
|
||||
|
||||
long pdfStart = System.currentTimeMillis();
|
||||
@ -153,7 +152,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
|
||||
try {
|
||||
processPng.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("InterruptedException while creating temporary PNG {}", pres.getName(), e);
|
||||
}
|
||||
|
||||
//long pdfEnd = System.currentTimeMillis();
|
||||
@ -173,7 +172,7 @@ public class Pdf2SwfPageConverter implements PageConverter {
|
||||
try {
|
||||
processSwf.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("InterruptedException while creating SWF {}", pres.getName(), e);
|
||||
}
|
||||
|
||||
//long png2swfEnd = System.currentTimeMillis();
|
||||
@ -215,23 +214,23 @@ public class Pdf2SwfPageConverter implements PageConverter {
|
||||
}
|
||||
}
|
||||
|
||||
public void setSwfToolsDir(String dir) {
|
||||
SWFTOOLS_DIR = dir;
|
||||
}
|
||||
public void setSwfToolsDir(String dir) {
|
||||
SWFTOOLS_DIR = dir;
|
||||
}
|
||||
|
||||
public void setFontsDir(String dir) {
|
||||
fontsDir = dir;
|
||||
}
|
||||
public void setFontsDir(String dir) {
|
||||
fontsDir = dir;
|
||||
}
|
||||
|
||||
public void setPlacementsThreshold(long threshold) {
|
||||
placementsThreshold = threshold;
|
||||
}
|
||||
public void setPlacementsThreshold(long threshold) {
|
||||
placementsThreshold = threshold;
|
||||
}
|
||||
|
||||
public void setDefineTextThreshold(long threshold) {
|
||||
defineTextThreshold = threshold;
|
||||
}
|
||||
public void setDefineTextThreshold(long threshold) {
|
||||
defineTextThreshold = threshold;
|
||||
}
|
||||
|
||||
public void setImageTagThreshold(long threshold) {
|
||||
imageTagThreshold = threshold;
|
||||
}
|
||||
public void setImageTagThreshold(long threshold) {
|
||||
imageTagThreshold = threshold;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class PdfPageCounter implements PageCounter {
|
||||
try {
|
||||
process.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("InterruptedException while counting PDF pages {}", presentationFile.getName(), e);
|
||||
}
|
||||
|
||||
numPages = pHandler.numberOfPages();
|
||||
|
@ -108,7 +108,7 @@ public class PdfToSwfSlidesGenerationService {
|
||||
logData.put("message", "Failed to determine number of pages.");
|
||||
Gson gson = new Gson();
|
||||
String logStr = gson.toJson(logData);
|
||||
log.warn("-- analytics -- " + logStr);
|
||||
log.error("-- analytics -- {}", logStr, e);
|
||||
|
||||
DocPageCountFailed progress = new DocPageCountFailed(pres.getMeetingId(),
|
||||
pres.getId(), pres.getId(),
|
||||
@ -203,9 +203,7 @@ public class PdfToSwfSlidesGenerationService {
|
||||
logData.put("message", "ExecutionException while converting page.");
|
||||
Gson gson = new Gson();
|
||||
String logStr = gson.toJson(logData);
|
||||
log.warn("-- analytics -- " + logStr);
|
||||
|
||||
log.error(e.getMessage());
|
||||
log.error("-- analytics -- {}", logStr, e);
|
||||
} catch (InterruptedException e) {
|
||||
Map<String, Object> logData = new HashMap<String, Object>();
|
||||
logData.put("meetingId", pres.getMeetingId());
|
||||
@ -215,7 +213,7 @@ public class PdfToSwfSlidesGenerationService {
|
||||
logData.put("message", "InterruptedException while converting page");
|
||||
Gson gson = new Gson();
|
||||
String logStr = gson.toJson(logData);
|
||||
log.warn("-- analytics -- " + logStr);
|
||||
log.error("-- analytics -- {}", logStr, e);
|
||||
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (TimeoutException e) {
|
||||
@ -227,7 +225,7 @@ public class PdfToSwfSlidesGenerationService {
|
||||
logData.put("message", "TimeoutException while converting page");
|
||||
Gson gson = new Gson();
|
||||
String logStr = gson.toJson(logData);
|
||||
log.warn("-- analytics -- " + logStr);
|
||||
log.error("-- analytics -- {}", logStr, e);
|
||||
|
||||
f.cancel(true);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class SvgImageCreatorImp implements SvgImageCreator {
|
||||
FileUtils.cleanDirectory(svgImagesPresentationDir);
|
||||
success = generateSvgImages(svgImagesPresentationDir, pres);
|
||||
} catch (Exception e) {
|
||||
log.warn("Interrupted Exception while generating images.");
|
||||
log.error("Interrupted Exception while generating images {}", pres.getName(), e);
|
||||
success = false;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class SvgImageCreatorImp implements SvgImageCreator {
|
||||
done = true;
|
||||
} catch (InterruptedException e) {
|
||||
done = false;
|
||||
log.error(e.getMessage());
|
||||
log.error("InterruptedException while converting to SVG {}", dest, e);
|
||||
}
|
||||
|
||||
source = imagePresentationDir.getAbsolutePath() + File.separator + "slide1.pdf";
|
||||
@ -96,7 +96,7 @@ public class SvgImageCreatorImp implements SvgImageCreator {
|
||||
process.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
|
||||
done = true;
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("Interrupted Exception while generating SVG slides {}", pres.getName(), e);
|
||||
}
|
||||
if (!done) {
|
||||
break;
|
||||
@ -141,7 +141,7 @@ public class SvgImageCreatorImp implements SvgImageCreator {
|
||||
logData.put("message", "Unable to create temporary files");
|
||||
gson = new Gson();
|
||||
logStr = gson.toJson(logData);
|
||||
log.error("-- analytics -- {}", logStr);
|
||||
log.error("-- analytics -- {}", logStr, ioException);
|
||||
}
|
||||
|
||||
// Step 1: Convert a PDF page to PNG using a raw pdftocairo
|
||||
@ -154,7 +154,7 @@ public class SvgImageCreatorImp implements SvgImageCreator {
|
||||
try {
|
||||
pngProcess.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("Interrupted Exception while generating PNG image {}", pres.getName(), e);
|
||||
}
|
||||
|
||||
// Step 2: Convert a PNG image to SVG
|
||||
@ -167,7 +167,7 @@ public class SvgImageCreatorImp implements SvgImageCreator {
|
||||
try {
|
||||
svgProcess.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("Interrupted Exception while generating SVG image {}", pres.getName(), e);
|
||||
}
|
||||
|
||||
done = svgHandler.isCommandSuccessful();
|
||||
@ -189,7 +189,7 @@ public class SvgImageCreatorImp implements SvgImageCreator {
|
||||
try {
|
||||
namespaceProcess.waitFor(WAIT_FOR_SEC, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("Interrupted Exception while adding SVG namespace {}", pres.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class TextFileCreatorImp implements TextFileCreator {
|
||||
try {
|
||||
success = generateTextFiles(textfilesDir, pres);
|
||||
} catch (InterruptedException e) {
|
||||
log.warn("Interrupted Exception while generating thumbnails.");
|
||||
log.error("Interrupted Exception while generating thumbnails {}", pres.getName(), e);
|
||||
success = false;
|
||||
}
|
||||
|
||||
@ -77,13 +77,13 @@ public class TextFileCreatorImp implements TextFileCreator {
|
||||
writer = new BufferedWriter(new FileWriter(file));
|
||||
writer.write(text);
|
||||
} catch (IOException e) {
|
||||
log.error("Error: " + e.getMessage());
|
||||
log.error("Error: ", e);
|
||||
success = false;
|
||||
} finally {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
log.error("Error: " + e.getMessage());
|
||||
log.error("Error: ", e);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class ThumbnailCreatorImp implements ThumbnailCreator {
|
||||
try {
|
||||
success = generateThumbnails(thumbsDir, pres);
|
||||
} catch (InterruptedException e) {
|
||||
log.warn("Interrupted Exception while generating thumbnails.");
|
||||
log.error("Interrupted Exception while generating thumbnails {}", pres.getName(), e);
|
||||
success = false;
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ public class ThumbnailCreatorImp implements ThumbnailCreator {
|
||||
try {
|
||||
FileUtils.copyFile(new File(BLANK_THUMBNAIL), thumb);
|
||||
} catch (IOException e) {
|
||||
log.error("IOException while copying blank thumbnail.");
|
||||
log.error("IOException while copying blank thumbnail.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user