JcrResourceProvider.java
1.35 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.Property
* javax.jcr.RepositoryException
* javax.jcr.Session
*/
package com.adobe.granite.ui.clientlibs.impl;
import com.adobe.granite.ui.clientlibs.impl.JcrPropertyResource;
import com.adobe.granite.ui.clientlibs.script.ScriptResource;
import com.adobe.granite.ui.clientlibs.script.ScriptResourceProvider;
import java.io.IOException;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
public class JcrResourceProvider
implements ScriptResourceProvider {
private final Session session;
public JcrResourceProvider(Session session) {
this.session = session;
}
@Override
public ScriptResource getResource(String path) throws IOException {
try {
String propPath = path + "/jcr:content/jcr:data";
if (this.session.propertyExists(propPath)) {
Property p = this.session.getProperty(propPath);
return new JcrPropertyResource(p, p.getParent().getParent().getPath());
}
return null;
}
catch (RepositoryException e) {
IOException io = new IOException("Unable to read resource at " + path);
io.initCause((Throwable)e);
throw io;
}
}
}