// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java
// public interface GeometrixxMediaContentType {
// 
//     JSONObject getJson();
// 
//     SolrInputDocument getSolrDoc();
// 
// }
// 
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java
// @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class})
// public class GeometrixxMediaPage implements GeometrixxMediaContentType{
// 
//     private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class);
// 
//     private GeometrixxMediaPageContent pageContent;
// 
//     @Inject @Named("jcr:content")
//     private Resource jcrResource;
// 
//     @PostConstruct
//     public void init() throws SlingModelsException {
// 
//         pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class);
// 
//     }
// 
//     public GeometrixxMediaPage(Resource resource) throws SlingModelsException {
// 
//         if (null == resource) {
//             LOG.debug("resource is null");
//             throw new SlingModelsException("Resource is null");
//         }
// 
//         if (ResourceUtil.isNonExistingResource(resource)) {
//             LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath());
//             throw new SlingModelsException(
//                 "Can't adapt non existent resource." + resource.getPath());
//         }
// 
//     }
// 
//     @Override
//     public String toString() {
// 
//         final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{");
//         if(null != pageContent){
//             sb.append(pageContent.toString());
//         }
//         sb.append('}');
//         return sb.toString();
//     }
// 
//     @Override
//     public JSONObject getJson() {
// 
//         return pageContent != null ? pageContent.getJson() : new JSONObject();
//     }
// 
//     @Override
//     public SolrInputDocument getSolrDoc() {
// 
//         return pageContent != null ? pageContent.getSolrDoc() : null;
//     }
// }


import com.day.cq.replication.ReplicationAction;
import com.day.cq.wcm.api.PageEvent;
import com.day.cq.wcm.api.PageModification;
import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType;
import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage;
import org.apache.felix.scr.annotations.*;
import org.apache.sling.api.resource.*;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Iterator;
import java.util.Map;
                LOG.info("Page '{}' is in observed path '{}'", pagePath, observedPath);
                return true;
            }
        }

        return false;
    }

    protected boolean pageIsNotInObservedPath(String pagePath) {
        return !pageIsInObservedPath(pagePath);
    }

    protected void addOrUpdatePage(PageModification modification) {

        // We need to add the correct page for the add/update. On page moves, we need to use the destination.
        final String modificationPath = (modification.getType() == PageModification.ModificationType.MOVED)
            ? modification.getDestination()
            : modification.getPath();

        if (null == resourceResolver) {
            LOG.warn("Can't perform indexing operation for '{}'", modificationPath);
            return;
        }

        final Resource resource = resourceResolver.getResource(modificationPath);
        if (ResourceUtil.isNonExistingResource(resource)) {
            LOG.warn("Can't perform indexing operation for '{}'. Resource does not exist.", modificationPath);
            return;
        }

// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaContentType.java
// public interface GeometrixxMediaContentType {
// 
//     JSONObject getJson();
// 
//     SolrInputDocument getSolrDoc();
// 
// }
// 
// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/model/GeometrixxMediaPage.java
// @Model(adaptables = Resource.class, adapters = {GeometrixxMediaContentType.class, GeometrixxMediaPage.class})
// public class GeometrixxMediaPage implements GeometrixxMediaContentType{
// 
//     private static final Logger LOG = LoggerFactory.getLogger(GeometrixxMediaPage.class);
// 
//     private GeometrixxMediaPageContent pageContent;
// 
//     @Inject @Named("jcr:content")
//     private Resource jcrResource;
// 
//     @PostConstruct
//     public void init() throws SlingModelsException {
// 
//         pageContent = jcrResource.adaptTo(GeometrixxMediaPageContent.class);
// 
//     }
// 
//     public GeometrixxMediaPage(Resource resource) throws SlingModelsException {
// 
//         if (null == resource) {
//             LOG.debug("resource is null");
//             throw new SlingModelsException("Resource is null");
//         }
// 
//         if (ResourceUtil.isNonExistingResource(resource)) {
//             LOG.warn("Can't adapt non existent resource: '{}'", resource.getPath());
//             throw new SlingModelsException(
//                 "Can't adapt non existent resource." + resource.getPath());
//         }
// 
//     }
// 
//     @Override
//     public String toString() {
// 
//         final StringBuilder sb = new StringBuilder("GeometrixxMediaPage{");
//         if(null != pageContent){
//             sb.append(pageContent.toString());
//         }
//         sb.append('}');
//         return sb.toString();
//     }
// 
//     @Override
//     public JSONObject getJson() {
// 
//         return pageContent != null ? pageContent.getJson() : new JSONObject();
//     }
// 
//     @Override
//     public SolrInputDocument getSolrDoc() {
// 
//         return pageContent != null ? pageContent.getSolrDoc() : null;
//     }
// }


// Path: aemsolrsearch-geometrixx-media-sample/src/main/java/com/headwire/aemsolrsearch/geometrixxmedia/solr/index/DefaultSolrIndexListenerService.java
import com.day.cq.replication.ReplicationAction;
import com.day.cq.wcm.api.PageEvent;
import com.day.cq.wcm.api.PageModification;
import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaContentType;
import com.headwire.aemsolrsearch.geometrixxmedia.model.GeometrixxMediaPage;
import org.apache.felix.scr.annotations.*;
import org.apache.sling.api.resource.*;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Iterator;
import java.util.Map;

                LOG.info("Page '{}' is in observed path '{}'", pagePath, observedPath);
                return true;
            }
        }

        return false;
    }

    protected boolean pageIsNotInObservedPath(String pagePath) {
        return !pageIsInObservedPath(pagePath);
    }

    protected void addOrUpdatePage(PageModification modification) {

        // We need to add the correct page for the add/update. On page moves, we need to use the destination.
        final String modificationPath = (modification.getType() == PageModification.ModificationType.MOVED)
            ? modification.getDestination()
            : modification.getPath();

        if (null == resourceResolver) {
            LOG.warn("Can't perform indexing operation for '{}'", modificationPath);
            return;
        }

        final Resource resource = resourceResolver.getResource(modificationPath);
        if (ResourceUtil.isNonExistingResource(resource)) {
            LOG.warn("Can't perform indexing operation for '{}'. Resource does not exist.", modificationPath);
            return;
        }

        GeometrixxMediaContentType contentPage = resource.adaptTo(GeometrixxMediaPage.class);