NodeUrlConnection.java
1.81 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.resourceresolverhelper.ResourceResolverHelper
* javax.jcr.Node
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceMetadata
* org.apache.sling.api.resource.ResourceResolver
*/
package com.adobe.aemds.datamanager.impl;
import com.adobe.aemds.datamanager.impl.NodeBasedUrlConnection;
import com.adobe.aemds.datamanager.impl.ServiceContainer;
import com.adobe.granite.resourceresolverhelper.ResourceResolverHelper;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.jcr.Node;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceMetadata;
import org.apache.sling.api.resource.ResourceResolver;
class NodeUrlConnection
extends NodeBasedUrlConnection {
protected Resource resource;
NodeUrlConnection(URL url, Node node) {
super(url, node);
}
protected Node getNode() throws Exception {
return this.node;
}
protected void doConnect() throws Exception {
Node n = this.getNode();
this.resource = ServiceContainer.resourceResolverHelper.getResourceResolver().getResource(n.getPath());
}
protected String doGetContentType() throws Exception {
return this.resource.getResourceMetadata().getContentType();
}
protected InputStream doGetInputStream() throws Exception {
InputStream res = (InputStream)this.resource.adaptTo(InputStream.class);
if (res == null) {
throw new IOException("The JCR node at location " + this.url.toExternalForm() + " has no content!");
}
return res;
}
protected long doGetContentLength() throws Exception {
return this.resource.getResourceMetadata().getContentLength();
}
}