PersistenceUtils.java
1.58 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemfd.docmanager.internal.persistence;
import com.adobe.aemfd.docmanager.io.IOUtils;
import com.adobe.aemfd.docmanager.passivation.PassivationConnection;
import com.adobe.aemfd.docmanager.source.DocumentSourceHandler;
import com.adobe.aemfd.docmanager.source.FileSourceHandler;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class PersistenceUtils {
private static final Logger logger = LoggerFactory.getLogger(PersistenceUtils.class);
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public static DocumentSourceHandler passivatePersistently(byte[] preBuffer, PassivationConnection conn) throws IOException {
File tmp = IOUtils.createTempFile(null);
FileOutputStream fos = new FileOutputStream(tmp);
try {
if (preBuffer != null) {
IOUtils.copy(new ByteArrayInputStream(preBuffer), fos);
}
IOUtils.copy(conn.getContentStream(), fos);
}
finally {
try {
fos.close();
}
catch (IOException e) {
logger.warn("Error closing output stream for file " + tmp.getAbsolutePath(), (Throwable)e);
}
}
return new FileSourceHandler(tmp, conn.getContentType(), true);
}
}