Skip to content

Commit 4721191

Browse files
committed
增加文档上传并后台转换的例子
1 parent 6f40958 commit 4721191

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

docviewerapi/src/com/log4ic/DocViewer.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,27 @@ public static void destroy() throws Exception {
248248
OfficeConverter.stopService();
249249
}
250250

251-
private synchronized static void checkWorker(ConvertWorker worker) throws Exception {
251+
private synchronized static boolean checkWorker(ConvertWorker worker) throws Exception {
252252
worker.setOutputPath(OUTPUT_PATH);
253253
if (worker.getInFile() == null) {
254-
throw new Exception("input file is null");
254+
return false;
255255
}
256+
return true;
256257
}
257258

258259
public synchronized static void addConvertWorker(PDFConvertWorker worker) throws Exception {
259-
checkWorker(worker);
260+
if (!checkWorker(worker)) {
261+
return;
262+
}
260263
synchronized (pdfQueue) {
261264
pdfQueue.addWorker(worker);
262265
}
263266
}
264267

265268
public synchronized static void addConvertWorker(OfficeConvertWorker worker) throws Exception {
266-
checkWorker(worker);
269+
if (!checkWorker(worker)) {
270+
return;
271+
}
267272
synchronized (officeQueue) {
268273
officeQueue.addWorker(worker);
269274
}

docviewerapi/src/com/log4ic/utils/convert/OfficeConvertWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void run() {
3838
OfficeConverter converter = new OfficeConverter();
3939
try {
4040
in = converter.toPDF(in, dir.getPath());
41-
DocViewer.addConvertWorker(new PDFConvertWorker(0, in, out, splitePage));
41+
DocViewer.addConvertWorker(new PDFConvertWorker(this.getId(), in, out, splitePage));
4242
} catch (IOException e) {
4343
e.printStackTrace();
4444
} catch (Exception e) {

0 commit comments

Comments
 (0)