// Path: src/main/java/danta/aem/services/ContentModelFactoryService.java
// public interface ContentModelFactoryService {
// 
//     /**
//      * @param request This is a SlingHttpServletRequest
//      * @param response This is a SlingHttpServletResponse
//      * @return contentModel The Content Model of a resource
//      */
//     public ContentModel getContentModel(final SlingHttpServletRequest request, final SlingHttpServletResponse response);
// 
// }
// 
// Path: src/main/java/danta/aem/templating/TemplateContentModelImpl.java
// public class TemplateContentModelImpl
//         extends AbstractTemplateContentModelImpl {
// 
//     private final SlingHttpServletRequest request;
//     private final SlingHttpServletResponse response;
// 
//     public TemplateContentModelImpl(final SlingHttpServletRequest request, final SlingHttpServletResponse response) {
//         this(request, response, new JSONObject());
//     }
// 
//     public TemplateContentModelImpl(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final Map<String, Object> initialModelData) {
//         super(initialModelData);
//         getRootContext().data(SLING_HTTP_REQUEST, request);
// 
//         this.request = request;
//         this.response = response;
//     }
// 
//     public SlingHttpServletRequest request()
//             throws Exception {
//         return (has(SLING_HTTP_REQUEST)) ? getAs(SLING_HTTP_REQUEST, SlingHttpServletRequest.class) : null;
//     }
// 
//     final HttpServletResponse response()
//             throws Exception {
//         return response;
//     }
// }
// 
// Path: src/main/java/danta/aem/Constants.java
// public static final String SLING_HTTP_REQUEST = PRIVATE_AN_PREFIX + "sling_http_request";


import static danta.Constants.ENGINE_RESOURCE;
import static danta.aem.Constants.SLING_HTTP_REQUEST;
import danta.aem.services.ContentModelFactoryService;
import danta.aem.templating.TemplateContentModelImpl;
import danta.api.ContentModel;
import danta.api.ContextProcessorEngine;
import danta.core.execution.ExecutionContextImpl;
import org.apache.felix.scr.annotations.*;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Danta AEM Bundle
 *
 * Copyright (C) 2017 Tikal Technologies, Inc. All rights reserved.
 *
 * Licensed under GNU Affero General Public License, Version v3.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.gnu.org/licenses/agpl-3.0.txt
 *
 * 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;
 * without even the implied warranty of MERCHANTABILITY.
 * See the License for more details.
 */

package danta.aem.services.impl;



/**
 * The Content Model Factory Service implementer
 *
 * @author      Danta Team
 * @version     1.0.0
 * @since       2014-03-12
 */
@Component
@Service(ContentModelFactoryService.class)
public class ContentModelFactoryServiceImpl
        implements ContentModelFactoryService {

    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC)
    protected ContextProcessorEngine contextProcessorEngine;

    private final Logger LOG = LoggerFactory.getLogger(this.getClass());

    /**
     * This method gets the Content Model of a resource.
     *
     * @param request This is a SlingHttpServletRequest
     * @param response This is a SlingHttpServletResponse
     * @return contentModel The Content Model of a resource
     */
    @Override
// Path: src/main/java/danta/aem/services/ContentModelFactoryService.java
// public interface ContentModelFactoryService {
// 
//     /**
//      * @param request This is a SlingHttpServletRequest
//      * @param response This is a SlingHttpServletResponse
//      * @return contentModel The Content Model of a resource
//      */
//     public ContentModel getContentModel(final SlingHttpServletRequest request, final SlingHttpServletResponse response);
// 
// }
// 
// Path: src/main/java/danta/aem/templating/TemplateContentModelImpl.java
// public class TemplateContentModelImpl
//         extends AbstractTemplateContentModelImpl {
// 
//     private final SlingHttpServletRequest request;
//     private final SlingHttpServletResponse response;
// 
//     public TemplateContentModelImpl(final SlingHttpServletRequest request, final SlingHttpServletResponse response) {
//         this(request, response, new JSONObject());
//     }
// 
//     public TemplateContentModelImpl(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final Map<String, Object> initialModelData) {
//         super(initialModelData);
//         getRootContext().data(SLING_HTTP_REQUEST, request);
// 
//         this.request = request;
//         this.response = response;
//     }
// 
//     public SlingHttpServletRequest request()
//             throws Exception {
//         return (has(SLING_HTTP_REQUEST)) ? getAs(SLING_HTTP_REQUEST, SlingHttpServletRequest.class) : null;
//     }
// 
//     final HttpServletResponse response()
//             throws Exception {
//         return response;
//     }
// }
// 
// Path: src/main/java/danta/aem/Constants.java
// public static final String SLING_HTTP_REQUEST = PRIVATE_AN_PREFIX + "sling_http_request";


// Path: src/main/java/danta/aem/services/impl/ContentModelFactoryServiceImpl.java
import static danta.Constants.ENGINE_RESOURCE;
import static danta.aem.Constants.SLING_HTTP_REQUEST;
import danta.aem.services.ContentModelFactoryService;
import danta.aem.templating.TemplateContentModelImpl;
import danta.api.ContentModel;
import danta.api.ContextProcessorEngine;
import danta.core.execution.ExecutionContextImpl;
import org.apache.felix.scr.annotations.*;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Danta AEM Bundle
 *
 * Copyright (C) 2017 Tikal Technologies, Inc. All rights reserved.
 *
 * Licensed under GNU Affero General Public License, Version v3.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.gnu.org/licenses/agpl-3.0.txt
 *
 * 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;
 * without even the implied warranty of MERCHANTABILITY.
 * See the License for more details.
 */

package danta.aem.services.impl;



/**
 * The Content Model Factory Service implementer
 *
 * @author      Danta Team
 * @version     1.0.0
 * @since       2014-03-12
 */
@Component
@Service(ContentModelFactoryService.class)
public class ContentModelFactoryServiceImpl
        implements ContentModelFactoryService {

    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC)
    protected ContextProcessorEngine contextProcessorEngine;

    private final Logger LOG = LoggerFactory.getLogger(this.getClass());

    /**
     * This method gets the Content Model of a resource.
     *
     * @param request This is a SlingHttpServletRequest
     * @param response This is a SlingHttpServletResponse
     * @return contentModel The Content Model of a resource
     */
    @Override
    public ContentModel getContentModel (final SlingHttpServletRequest request, final SlingHttpServletResponse response) {