ProvidedJcrURLPassivationHandler.java
3.37 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.resourceresolverhelper.ResourceResolverHelper
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.References
* org.apache.sling.api.resource.ResourceResolver
*/
package com.adobe.aemfd.docmanager.internal.passivation.jcr;
import com.adobe.aemfd.docmanager.internal.passivation.jcr.JcrURLPassivationHandler;
import com.adobe.aemfd.docmanager.internal.source.ProvidedJcrURLSourceHandler;
import com.adobe.aemfd.docmanager.passivation.PassivationConnection;
import com.adobe.aemfd.docmanager.passivation.PassivationType;
import com.adobe.aemfd.docmanager.source.DocumentSourceHandler;
import com.adobe.granite.resourceresolverhelper.ResourceResolverHelper;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.Callable;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.References;
import org.apache.sling.api.resource.ResourceResolver;
@Component(immediate=1)
@References(value={@Reference(name="resourceResolverHelper", referenceInterface=ResourceResolverHelper.class)})
public class ProvidedJcrURLPassivationHandler
extends JcrURLPassivationHandler {
private static ResourceResolverHelper resourceResolverHelper;
private ResourceResolver resourceResolver;
private boolean managed;
public ProvidedJcrURLPassivationHandler() {
super(null);
}
public ProvidedJcrURLPassivationHandler(String jcrPath, ResourceResolver resourceResolver, boolean managed) {
super(jcrPath);
this.resourceResolver = resourceResolver;
this.managed = managed;
}
public void bindResourceResolverHelper(ResourceResolverHelper rrh) {
resourceResolverHelper = rrh;
}
public void unbindResourceResolverHelper(ResourceResolverHelper rrh) {
resourceResolverHelper = null;
}
public PassivationConnection openConnectionForPassivation() throws IOException {
try {
return (PassivationConnection)resourceResolverHelper.callWith(this.resourceResolver, (Callable)new Callable<PassivationConnection>(){
@Override
public PassivationConnection call() throws Exception {
return ProvidedJcrURLPassivationHandler.this.openConnectionForPassivation();
}
});
}
catch (IOException e) {
throw e;
}
catch (RuntimeException e) {
throw e;
}
catch (Exception e) {
throw new RuntimeException("Unexpected error occurred while opening connection to node " + this.jcrPath, e);
}
}
protected DocumentSourceHandler doPassivate(byte[] preBuffer, PassivationConnection conn, long length) throws IOException {
URL url = (URL)conn.getPayload();
return new ProvidedJcrURLSourceHandler(url, length, conn.getContentType(), resourceResolverHelper, this.resourceResolver, this.managed);
}
public void release(boolean passivated, PassivationType pType) {
if (this.managed && (!passivated || pType.equals((Object)PassivationType.INLINED))) {
this.resourceResolver.close();
}
this.resourceResolver = null;
super.release(passivated, pType);
}
}