DocUtil.java
2.32 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemfd.docmanager.Document
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemfd.watchfolder.util;
import com.adobe.aemfd.docmanager.Document;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class DocUtil {
private static final Logger logger = LoggerFactory.getLogger(DocUtil.class);
public static Map<String, Document> pruneForDisposal(Map<String, Document> docs, Map<String, Document> liveDocs) {
if (docs == null) {
return null;
}
if (liveDocs == null) {
return docs;
}
HashMap<String, Document> result = new HashMap<String, Document>(docs.size());
for (Map.Entry<String, Document> de : docs.entrySet()) {
String dName = de.getKey();
Document d = de.getValue();
if (liveDocs.containsValue((Object)d)) {
logger.warn("Skipping document " + dName + " for disposal since it is still live!");
continue;
}
result.put(dName, d);
}
return result;
}
public static void disposeAll(Map<String, Document> docs) {
if (docs != null) {
ArrayList<Document> disposed = new ArrayList<Document>();
for (Map.Entry<String, Document> de : docs.entrySet()) {
Document d = de.getValue();
if (d == null || !(d instanceof Document)) continue;
try {
Document doc = d;
if (!disposed.contains((Object)doc)) {
doc.dispose();
disposed.add(doc);
logger.info("Disposed document " + de.getKey());
continue;
}
logger.info("Document " + de.getKey() + " already disposed, ignoring...");
}
catch (Exception e) {
logger.warn("Error disposing document object " + de.getKey(), (Throwable)e);
}
}
disposed.clear();
}
}
}