<commit_before>/*
 * File   : $Source: /alkacon/cvs/opencms/src/com/opencms/template/Attic/CmsRootTemplate.java,v $
 * Date   : $Date: 2000/02/21 22:24:13 $
 * Version: $Revision: 1.10 $
 *
 * Copyright (C) 2000  The OpenCms Group 
 * 
 * This File is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * For further information about OpenCms, please see the
 * OpenCms Website: http://www.opencms.com
 * 
 * You should have received a copy of the GNU General Public License
 * long with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package com.opencms.template;

import com.opencms.core.*;
import com.opencms.launcher.*;
import com.opencms.file.*;
import javax.servlet.http.*;
import java.util.*;

/**
 * Represents an "empty" page or screen that should be filled with
 * the content of a master template.
 * <P>
 * Every launcher uses this canonical root the invoke the output
 * generation of the master template class to be used.
 * 
 * @author <NAME>
 * @version $Revision: 1.10 $ $Date: 2000/02/21 22:24:13 $
 */
public class CmsRootTemplate implements I_CmsLogChannels {
    
    /**
     * Gets the processed content of the requested master template by calling
     * the given template class.
     * <P>
     * If the result is cacheable, the complete output will be stored
     * in the template cache for later re-use.
     * 
     * @param cms A_CmsObject object for accessing system resources.
     * @param templateClass Instance of the template class to be called.
     * @param masterTemplate CmsFile object of the master template file.
     * @param cache templateCache to be used.
     * @param parameters Hashtable with all template class parameters.
     * 
     * @return Byte array containing the results of the master template.
     */
    public byte[] getMasterTemplate(A_CmsObject cms, I_CmsTemplate templateClass, CmsFile masterTemplate,
            com.opencms.launcher.I_CmsTemplateCache cache, Hashtable parameters) throws CmsException {
        
        long timer=System.currentTimeMillis();
        
        byte[] result;
        //String cacheKey = cms.getUrl();
        Object cacheKey = templateClass.getKey(cms, masterTemplate.getAbsolutePath(), parameters, null);
    
        if(A_OpenCms.isLogging()) {
            A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsRootTemplate] Caching key for " + masterTemplate.getName() + " is: " + cacheKey);            
            A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsRootTemplate] isCacheable: " + templateClass.isCacheable(cms, masterTemplate.getAbsolutePath(), null, parameters, null));
            A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsRootTemplate] Cache has  : " + cache.has(cacheKey));
            A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsRootTemplate] should reload: " + templateClass.shouldReload(cms, masterTemplate.getAbsolutePath(), null, parameters, null));
        }                
        
        if(templateClass.isCacheable(cms, masterTemplate.getAbsolutePath(), null, parameters, null)
                && cache.has(cacheKey) 
                && ! templateClass.shouldReload(cms, masterTemplate.getAbsolutePath(), null, parameters, null)) {
            result = cache.get(cacheKey);
            if(A_OpenCms.isLogging()) {
                A_OpenCms.log(C_OPENCMS_INFO, "[CmsRootTemplate] page " + masterTemplate.getAbsolutePath() + " was read from cache.");                                                                 
            }
        } else {
            try {
                result = templateClass.getContent(cms, masterTemplate.getAbsolutePath(), null, parameters);
          } catch(CmsException e) {
                cache.clearCache(cacheKey);
                if(A_OpenCms.isLogging()) {
                    A_OpenCms.log(C_OPENCMS_INFO, "[CmsRootTemplate] Could not get contents of master template " + masterTemplate.getName());
                }
                throw e;
            }
            if(templateClass.isCacheable(cms, masterTemplate.getAbsolutePath(), null, parameters, null)) {
                cache.put(cacheKey, result);
            }
       }         <commit_msg>no message<commit_after>/*
 * File   : $Source: /alkacon/cvs/opencms/src/com/opencms/template/Attic/CmsRootTemplate.java,v $
 * Date   : $Date: 2000/02/21 22:30:00 $
 * Version: $Revision: 1.11 $
 *
 * Copyright (C) 2000  The OpenCms Group 
 * 
 * This File is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * For further information about OpenCms, please see the
 * OpenCms Website: http://www.opencms.com
 * 
 * You should have received a copy of the GNU General Public License
 * long with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package com.opencms.template;

import com.opencms.core.*;
import com.opencms.launcher.*;
import com.opencms.file.*;
import javax.servlet.http.*;
import java.util.*;

/**
 * Represents an "empty" page or screen that should be filled with
 * the content of a master template.
 * <P>
 * Every launcher uses this canonical root the invoke the output
 * generation of the master template class to be used.
 * 
 * @author <NAME>
 * @version $Revision: 1.11 $ $Date: 2000/02/21 22:30:00 $
 */
public class CmsRootTemplate implements I_CmsLogChannels {
    
    /**
     * Gets the processed content of the requested master template by calling
     * the given template class.
     * <P>
     * If the result is cacheable, the complete output will be stored
     * in the template cache for later re-use.
     * 
     * @param cms A_CmsObject object for accessing system resources.
     * @param templateClass Instance of the template class to be called.
     * @param masterTemplate CmsFile object of the master template file.
     * @param cache templateCache to be used.
     * @param parameters Hashtable with all template class parameters.
     * 
     * @return Byte array containing the results of the master template.
     */
    public byte[] getMasterTemplate(A_CmsObject cms, I_CmsTemplate templateClass, CmsFile masterTemplate,
            com.opencms.launcher.I_CmsTemplateCache cache, Hashtable parameters) throws CmsException {
        
        long timer=System.currentTimeMillis();
        
        byte[] result;
        //String cacheKey = cms.getUrl();
        Object cacheKey = templateClass.getKey(cms, masterTemplate.getAbsolutePath(), parameters, "root");
    
        if(A_OpenCms.isLogging()) {
            A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsRootTemplate] Caching key for " + masterTemplate.getName() + " is: " + cacheKey);            
            A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsRootTemplate] isCacheable: " + templateClass.isCacheable(cms, masterTemplate.getAbsolutePath(), null, parameters, "root"));
            A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsRootTemplate] Cache has  : " + cache.has(cacheKey));
            A_OpenCms.log(C_OPENCMS_DEBUG, "[CmsRootTemplate] should reload: " + templateClass.shouldReload(cms, masterTemplate.getAbsolutePath(), null, parameters, "root"));
        }                
        
        if(templateClass.isCacheable(cms, masterTemplate.getAbsolutePath(), null, parameters, "root")
                && cache.has(cacheKey) 
                && ! templateClass.shouldReload(cms, masterTemplate.getAbsolutePath(), null, parameters, "root")) {
            result = cache.get(cacheKey);
            if(A_OpenCms.isLogging()) {
                A_OpenCms.log(C_OPENCMS_INFO, "[CmsRootTemplate] page " + masterTemplate.getAbsolutePath() + " was read from cache.");                                                                 
            }
        } else {
            try {
                result = templateClass.getContent(cms, masterTemplate.getAbsolutePath(), null, parameters, "root");
          } catch(CmsException e) {
                cache.clearCache(cacheKey);
                if(A_OpenCms.isLogging()) {
                    A_OpenCms.log(C_OPENCMS_INFO, "[CmsRootTemplate] Could not get contents of master template " + masterTemplate.getName());
                }
                throw e;
            }
            if(templateClass.isCacheable(cms, masterTemplate.getAbsolutePath(), null, parameters, "root")) {
                cache.put(cacheKey, result);
            }
       }         
{'fraction_non_alphanumeric': 0.09379325029277122, 'fraction_numerical': 0.011284999467688704, 'mean_word_length': 2.6795926361143754, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2549861', 'n_tokens_mistral': 2691, 'n_tokens_neox': 2558, 'n_words': 822}