ScaffoldingUtils.java
1.85 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.text.Text
* javax.jcr.Node
* javax.jcr.NodeIterator
* javax.jcr.Property
* javax.jcr.RepositoryException
*/
package com.day.cq.wcm.core.utils;
import com.day.text.Text;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
public class ScaffoldingUtils {
public static String CONTEXT_RESOURCE_ATTR_NAME = "com.day.cq.wcm.scaffolding.resource";
public static String findScaffoldByTemplate(Node node, String template) throws RepositoryException {
String tt;
if (node.hasProperty("jcr:content/cq:targetTemplate") && (tt = node.getProperty("jcr:content/cq:targetTemplate").getString()).equals(template)) {
return node.getPath();
}
NodeIterator iter = node.getNodes();
String scaffold = null;
while (scaffold == null && iter.hasNext()) {
Node child = iter.nextNode();
if (child.getName().equals("jcr:content")) continue;
scaffold = ScaffoldingUtils.findScaffoldByTemplate(child, template);
}
return scaffold;
}
public static String findScaffoldByPath(Node node, String path) throws RepositoryException {
String tt;
if (node.hasProperty("jcr:content/cq:targetPath") && Text.isDescendantOrEqual((String)(tt = node.getProperty("jcr:content/cq:targetPath").getString()), (String)path)) {
return node.getPath();
}
NodeIterator iter = node.getNodes();
String scaffold = null;
while (scaffold == null && iter.hasNext()) {
Node child = iter.nextNode();
if (child.getName().equals("jcr:content")) continue;
scaffold = ScaffoldingUtils.findScaffoldByPath(child, path);
}
return scaffold;
}
}