/*
 * #%L
 * aem-docs-custom-predicate-evaluator
 * %%
 * Copyright (C) 2013 Adobe Research
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package com.adobe.aem.docs.search;

import org.apache.felix.scr.annotations.Component;

import com.day.cq.search.eval.AbstractPredicateEvaluator;

@Component(metatype = false, factory = "com.day.cq.search.eval.PredicateEvaluator/repli")
public class ReplicationPredicateEvaluator extends AbstractPredicateEvaluator {

}

@@ -747,16 +747,109 @@
 ponent;%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.day.cq.search.Predicate;
 %0Aimport 
@@ -898,16 +898,65 @@
 aluator;
+%0Aimport com.day.cq.search.eval.EvaluationContext;
 %0A%0A@Compo
@@ -1119,11 +1119,2104 @@
 uator %7B%0A
+%09static final String PE_NAME = %22replic%22;%0A    %0A    static final String PN_LAST_REPLICATED_BY = %22cq:lastReplicatedBy%22;%0A    static final String PN_LAST_REPLICATED = %22cq:lastReplicated%22;%0A    static final String PN_LAST_REPLICATED_ACTION = %22cq:lastReplicationAction%22;%0A %0A    static final String PREDICATE_BY = %22by%22;%0A    static final String PREDICATE_SINCE = %22since%22;%0A    static final String PREDICATE_SINCE_OP = %22 %3E= %22;%0A    static final String PREDICATE_ACTION = %22action%22;%0A %0A    Logger log = LoggerFactory.getLogger(getClass());%0A %0A    /**%0A     * Returns a XPath expression filtering by replication metadata.%0A     *%0A     * @see com.day.cq.search.eval.AbstractPredicateEvaluator#getXPathExpression(com.day.cq.search.Predicate,%0A     *      com.day.cq.search.eval.EvaluationContext)%0A     */%0A    @Override%0A    public String getXPathExpression(Predicate predicate,%0A            EvaluationContext context) %7B%0A %0A        log.debug(%22predicate %7B%7D%22, predicate);%0A %0A        String date = predicate.get(PREDICATE_SINCE);%0A        String user = predicate.get(PREDICATE_BY);%0A        String action = predicate.get(PREDICATE_ACTION);%0A         %0A        StringBuilder sb = new StringBuilder();%0A %0A        if (date != null) %7B%0A            sb.append(PN_LAST_REPLICATED).append(PREDICATE_SINCE_OP);%0A            sb.append(%22xs:dateTime('%22).append(date).append(%22')%22);%0A        %7D%0A        if (user != null) %7B%0A            addAndOperator(sb);%0A            sb.append(PN_LAST_REPLICATED_BY);%0A            sb.append(%22='%22).append(user).append(%22'%22);%0A        %7D%0A        if (action != null) %7B%0A            addAndOperator(sb);%0A            sb.append(PN_LAST_REPLICATED_ACTION);%0A            sb.append(%22='%22).append(action).append(%22'%22);%0A        %7D%0A        String xpath = sb.toString();%0A %0A        log.debug(%22xpath **%7B%7D**%22, xpath);%0A %0A        return xpath;%0A    %7D%0A %0A    /**%0A     * Add an and operator if the builder is not empty.%0A     *%0A     * @param sb a %7B@link StringBuilder%7D containing the query under construction%0A     */%0A    private void addAndOperator(StringBuilder sb) %7B%0A        if (sb.length() != 0) %7B%0A            sb.append(%22 and %22);%0A        %7D%0A    %7D
 %0A%7D%0A

Implement replication predicate evaluator logic