ResourceCollectionUtil.java
1.6 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Item
* javax.jcr.Node
* javax.jcr.NodeIterator
* javax.jcr.RepositoryException
* javax.jcr.Session
*/
package com.day.cq.workflow.collection;
import com.day.cq.workflow.collection.ResourceCollection;
import com.day.cq.workflow.collection.ResourceCollectionManager;
import javax.jcr.Item;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
public class ResourceCollectionUtil {
public static ResourceCollection getResourceCollection(Node node, ResourceCollectionManager manager) throws RepositoryException {
if (!node.isNodeType("vlt:PackageDefinition")) {
NodeIterator itr = node.getNodes();
while (itr.hasNext()) {
Node n = itr.nextNode();
ResourceCollection coll = ResourceCollectionUtil.getResourceCollection(n, manager);
if (coll == null) continue;
return coll;
}
} else {
return manager.createCollection(node);
}
return null;
}
public static Node getContainingPage(ResourceCollection collection, Session session) throws RepositoryException {
if (collection.getPath().indexOf("jcr:content") > 0) {
Node node = (Node)session.getItem(collection.getPath());
while (!node.getName().equals("jcr:content")) {
node = node.getParent();
}
return node.getParent();
}
return (Node)session.getItem(collection.getPath());
}
}