FileSourceHandler.java
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemfd.docmanager.source;
import com.adobe.aemfd.docmanager.source.AbstractSourceHandler;
import com.adobe.aemfd.docmanager.source.FileBasedDocumentSourceHandler;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FileSourceHandler
extends AbstractSourceHandler
implements FileBasedDocumentSourceHandler {
private static final Logger logger = LoggerFactory.getLogger(FileSourceHandler.class);
private File file;
private boolean deleteOnDispose = false;
public FileSourceHandler(File file, String contentType, boolean deleteOnDispose) {
super(file.length(), contentType);
this.file = file;
this.deleteOnDispose = deleteOnDispose;
}
public InputStream getInputStream() throws IOException {
return new FileInputStream(this.file);
}
protected void doDispose() {
if (this.deleteOnDispose) {
String path = this.file.getAbsolutePath();
if (!this.file.delete()) {
logger.warn("Failed to delete managed file at location " + path + ". Please ensure that all input-streams created from Document " + "objects are closed properly before the documents are disposed.");
}
}
this.file = null;
}
public File getSourceFile() {
return this.file;
}
}