<commit_before>/*
 * File   : $Source: /alkacon/cvs/opencms/src/org/opencms/importexport/Attic/CmsCompatibleCheck.java,v $
 * Date   : $Date: 2004/02/17 11:40:29 $
 * Version: $Revision: 1.4 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (C) 2002 - 2003 Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.importexport;

import org.opencms.file.CmsResourceTypeFolder;
import org.opencms.file.CmsResourceTypePlain;
import org.opencms.main.I_CmsConstants;
import org.opencms.workplace.I_CmsWpConstants;

import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Node;

/**
 * Checks path information on vfs resources.<p>
 *
 * @author <NAME> (<EMAIL>)
 * @author <NAME> (<EMAIL>)
 * 
 * @version $Revision: 1.4 $
 */
public class CmsCompatibleCheck {

    /**
     * Constructor, does nothing.<p> 
     */
    public CmsCompatibleCheck() {
        // nothing to do here 
    }

    /**
     * Helper for checking the templates from C_VFS_PATH_BODIES.<p>
     * 
     * @param el the Element to check
     * @return true if the element definition is ok
     */
    private boolean checkElementDefOk(Element el) {
        // first the name
        String elementName = el.attribute("name").getText();
        if (!("contenttemplate".equalsIgnoreCase(elementName) || "frametemplate".equalsIgnoreCase(elementName))) {
            // no other elementdefinition allowed
            return false;
        }
        // now the templateclass only the standard class is allowed
        String elClass = CmsImport.getChildElementTextValue(el,"CLASS");
        if (!I_CmsConstants.C_XML_CONTROL_DEFAULT_CLASS.equals(elClass)) {
            return false;
        }
        String elTemplate = CmsImport.getChildElementTextValue(el,"TEMPLATE");
        if (elTemplate == null || elTemplate.indexOf(elementName) < 1) {
            // it must be in the path /content/"elementName"/ or in
            // the path /system/modules/"modulename"/"elementName"/
            return false;
        }
        return true;
    }

    /**
     * Helper for checking the templates from C_VFS_PATH_BODIES.<p>
     * <commit_msg>Improved formatting<commit_after>/*
 * File   : $Source: /alkacon/cvs/opencms/src/org/opencms/importexport/Attic/CmsCompatibleCheck.java,v $
 * Date   : $Date: 2004/02/17 11:48:02 $
 * Version: $Revision: 1.5 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (C) 2002 - 2003 Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.importexport;

import org.opencms.file.CmsResourceTypeFolder;
import org.opencms.file.CmsResourceTypePlain;
import org.opencms.main.I_CmsConstants;
import org.opencms.workplace.I_CmsWpConstants;

import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Node;

/**
 * Checks path information on vfs resources.<p>
 *
 * @author <NAME> (<EMAIL>)
 * @author <NAME> (<EMAIL>)
 * 
 * @version $Revision: 1.5 $
 */
public class CmsCompatibleCheck {

    /**
     * Constructor, does nothing.<p> 
     */
    public CmsCompatibleCheck() {
        // nothing to do here 
    }

    /**
     * Helper for checking the templates from C_VFS_PATH_BODIES.<p>
     * 
     * @param el the Element to check
     * @return true if the element definition is ok
     */
    private boolean checkElementDefOk(Element el) {
        // first the name
        String elementName = el.attribute("name").getText();
        if (!("contenttemplate".equalsIgnoreCase(elementName) || "frametemplate".equalsIgnoreCase(elementName))) {
            // no other elementdefinition allowed
            return false;
        }
        // now the templateclass only the standard class is allowed
        String elClass = CmsImport.getChildElementTextValue(el, "CLASS");
        if (!I_CmsConstants.C_XML_CONTROL_DEFAULT_CLASS.equals(elClass)) {
            return false;
        }
        String elTemplate = CmsImport.getChildElementTextValue(el, "TEMPLATE");
        if (elTemplate == null || elTemplate.indexOf(elementName) < 1) {
            // it must be in the path /content/"elementName"/ or in
            // the path /system/modules/"modulename"/"elementName"/
            return false;
        }
        return true;
    }

    /**
     * Helper for checking the templates from C_VFS_PATH_BODIES.<p>
     * 
{'fraction_non_alphanumeric': 0.09790428526743822, 'fraction_numerical': 0.014701282452299031, 'mean_word_length': 3.0423514538558787, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '525660', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1841, 'n_words': 609}