FilePassivationHandler.java
2.09 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
51
52
53
54
55
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemfd.docmanager.internal.passivation;
import com.adobe.aemfd.docmanager.passivation.AbstractPassivationHandler;
import com.adobe.aemfd.docmanager.passivation.PassivationConnection;
import com.adobe.aemfd.docmanager.passivation.PassivationType;
import com.adobe.aemfd.docmanager.source.DocumentSourceHandler;
import com.adobe.aemfd.docmanager.source.FileSourceHandler;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FilePassivationHandler
extends AbstractPassivationHandler {
private static final Logger logger = LoggerFactory.getLogger(FilePassivationHandler.class);
private File file;
private boolean ownFile;
public FilePassivationHandler(File file, boolean ownFile) {
super(false, true, false);
this.file = file;
this.ownFile = ownFile;
}
public PassivationConnection openConnectionForPassivation() throws IOException {
FileInputStream fis = new FileInputStream(this.file);
String ct = URLConnection.guessContentTypeFromName(this.file.getName());
return new PassivationConnection(fis, this.file.length(), ct);
}
protected DocumentSourceHandler doPassivate(byte[] preBuffer, PassivationConnection conn, long length) throws IOException {
return new FileSourceHandler(this.file, conn.getContentType(), this.ownFile);
}
public void release(boolean passivated, PassivationType pType) {
if (this.ownFile && (!passivated || pType.equals((Object)PassivationType.INLINED))) {
String path = this.file.getAbsolutePath();
if (!this.file.delete()) {
logger.warn("Failed to delete managed file at location " + path + ". Please ensure that files passed to Document objects " + "for management do not have existing open handles.");
}
}
this.file = null;
}
}