IsPageNodePredicate.java
1.67 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.commons.predicate.AbstractNodePredicate
* javax.jcr.Node
* javax.jcr.RepositoryException
* javax.jcr.nodetype.NodeType
* org.apache.commons.collections.Predicate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Properties
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Service
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.wcm.api;
import com.day.cq.commons.predicate.AbstractNodePredicate;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.nodetype.NodeType;
import org.apache.commons.collections.Predicate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=0)
@Service(value={Predicate.class})
@Properties(value={@Property(name="predicate.name", value={"page"})})
public class IsPageNodePredicate
extends AbstractNodePredicate
implements Predicate {
private final Logger log = LoggerFactory.getLogger(IsPageNodePredicate.class);
public boolean evaluate(Node node) throws RepositoryException {
String primaryName = node.getPrimaryNodeType().getName();
if (primaryName.equals("cq:Page")) {
return true;
}
if (primaryName.equals("nt:folder") || primaryName.equals("sling:Folder") || primaryName.equals("sling:OrderedFolder")) {
return node.hasNodes();
}
return false;
}
}