1 13 package info.magnolia.cms.util; 14 15 import info.magnolia.cms.core.Content; 16 17 import javax.jcr.RepositoryException; 18 19 import org.slf4j.Logger; 20 import org.slf4j.LoggerFactory; 21 22 23 27 public class RuleBasedContentFilter implements Content.ContentFilter { 28 29 32 private static Logger log = LoggerFactory.getLogger(RuleBasedContentFilter.class); 33 34 37 private Rule rule; 38 39 42 public RuleBasedContentFilter(Rule rule) { 43 this.rule = rule; 44 } 45 46 51 public boolean accept(Content content) { 52 String nodeType = ""; 53 try { 54 nodeType = content.getNodeTypeName(); 55 } 56 catch (RepositoryException re) { 57 if (log.isDebugEnabled()) { 58 log.debug("failed to retrieve node type : " + re.getMessage(), re); 59 } 60 } 61 return this.rule.isAllowed(nodeType); 62 } 63 64 } 65 | Popular Tags |