亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cmscompatiblecheck.java

?? cms是開源的框架
?? JAVA
字號:
/*
 * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/importexport/CmsCompatibleCheck.java,v $
 * Date   : $Date: 2006/03/27 14:52:54 $
 * Version: $Revision: 1.17 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (c) 2005 Alkacon Software GmbH (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 GmbH, 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.types.CmsResourceTypeFolder;
import org.opencms.file.types.CmsResourceTypePlain;
import org.opencms.workplace.CmsWorkplace;

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 Alexander Kandzior 
 * @author Thomas Weckert  
 * 
 * @version $Revision: 1.17 $ 
 * 
 * @since 6.0.0 
 */
public class CmsCompatibleCheck {

    /** Parameter for content body folder. */
    public static final String VFS_PATH_BODIES = "/system/bodies/";
    
    /** Parameter for default module. */
    public static final String VFS_PATH_DEFAULTMODULE = CmsWorkplace.VFS_PATH_MODULES + "default/";
    
    /** Path to content templates folder. */
    public static final String VFS_PATH_DEFAULT_TEMPLATES = VFS_PATH_DEFAULTMODULE + CmsWorkplace.VFS_DIR_TEMPLATES;
    
    /** Default class for templates. */
    public static final String XML_CONTROL_DEFAULT_CLASS = "com.opencms.template.CmsXmlTemplate";

    /**
     * Constructor, does nothing.<p> 
     */
    public CmsCompatibleCheck() {

        // nothing to do here 
    }

    /**
     * Checks if the resource path information fulfills the rules for template and body paths.<p>
     *
     * @param name the absolute path of the resource in the VFS
     * @param content the content of the resource.
     * @param type the resource type
     * @return true if the resource is ok
     */
    public boolean isTemplateCompatible(String name, byte[] content, String type) {

        // dont check folders
        if (CmsResourceTypeFolder.RESOURCE_TYPE_NAME.equals(type)) {
            return true;
        }
        if (name == null) {
            return false;
        }
        if (name.startsWith(CmsCompatibleCheck.VFS_PATH_BODIES)) {
            // this is a body file
            if (!CmsResourceTypePlain.getStaticTypeName().equals(type)) {
                // only plain files allowed in content/bodys
                return false;
            }
            // to check the rest we have to parse the content
            try {
                Document xmlDoc = DocumentHelper.parseText(new String(content));
                for (Node n = (Node)xmlDoc.content().get(0); n != null; n = treeWalker(xmlDoc, n)) {
                    short ntype = n.getNodeType();
                    if (((ntype > Node.CDATA_SECTION_NODE) && ntype < Node.DOCUMENT_TYPE_NODE)
                        || (ntype == Node.ATTRIBUTE_NODE)) {
                        return false;
                    }
                    if (n.getNodeType() == Node.ELEMENT_NODE) {
                        String tagName = n.getName();
                        if (!("template".equalsIgnoreCase(tagName) || "xmltemplate".equalsIgnoreCase(tagName))) {
                            return false;
                        }
                    }
                }
            } catch (Exception e) {
                return false;
            }

        } else if (name.startsWith(CmsCompatibleCheck.VFS_PATH_DEFAULT_TEMPLATES)
            || (name.startsWith(CmsWorkplace.VFS_PATH_MODULES) && name.indexOf("/" + CmsWorkplace.VFS_DIR_TEMPLATES) > -1)) {
            // this is a template file
            if (!CmsResourceTypePlain.getStaticTypeName().equals(type)) {
                // only plain templates are allowed
                return false;
            }
            // to check the rest we have to parse the content
            try {
                Document xmlDoc = DocumentHelper.parseText(new String(content));

                // we check the sub nodes from <xmltemplate>
                // there should be the two elementdefs, one template and some empty text nodes
                List list = xmlDoc.getRootElement().content();
                list = ((Element)list.get(0)).content();
                int counterEldefs = 0;
                int counterTeplate = 0;
                for (int i = 0; i < list.size(); i++) {
                    Node n = (Node)list.get(i);
                    short nodeType = n.getNodeType();
                    if (nodeType == Node.ELEMENT_NODE) {
                        // allowed is the Elementdef or the template tag
                        String nodeName = n.getName();
                        if ("elementdef".equalsIgnoreCase(nodeName)) {
                            // check the rules for the elementdefinitions
                            if (!checkElementDefOk((Element)n)) {
                                return false;
                            }
                            counterEldefs++;
                        } else if ("template".equalsIgnoreCase(nodeName)) {
                            // check if the template node is ok.
                            if (!checkTemplateTagOk((Element)n)) {
                                return false;
                            }
                            counterTeplate++;
                        } else {
                            //this name is not allowed
                            return false;
                        }

                    } else if (nodeType == Node.TEXT_NODE) {
                        // text node is only allowed if the value is empty
                        String nodeValue = n.getText();
                        if ((nodeValue != null) && (nodeValue.trim().length() > 0)) {
                            return false;
                        }
                    } else {
                        // this nodeType is not allowed
                        return false;
                    }
                }
                if (counterEldefs != 2 || counterTeplate != 1) {
                    // there have to be exactly two elementdefs and one template tag
                    return false;
                }

            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }

    /**
     * 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 (!CmsCompatibleCheck.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>
     * 
     * @param el the Element to check
     * @return true if the template is ok
     */
    private boolean checkTemplateTagOk(Element el) {

        List list = el.elements();
        if (list.size() > 3) {
            // only the one template tag allowed (and the two empty text nodes)
            return false;
        }
        for (int i = 0; i < list.size(); i++) {
            Node n = (Node)list.get(i);
            short ntype = n.getNodeType();
            if (ntype == Node.TEXT_NODE) {
                String nodeValue = n.getText();
                if ((nodeValue != null) && (nodeValue.trim().length() > 0)) {
                    return false;
                }
            } else if (ntype == Node.ELEMENT_NODE) {
                // this should be <ELEMENT name="frametemplate"/>
                if (!"element".equalsIgnoreCase(n.getName())) {
                    return false;
                }
                if (!"frametemplate".equals(((Element)n).attribute("name").getText())) {
                    return false;
                }
            } else {
                return false;
            }
        }
        return true;
    }

    /**
     * Returns the next sibling of a node.<p>
     * 
     * @param node the node
     * @return the next sibling, or null
     */
    private Node getNextSibling(Node node) {

        Node sibling = null;
        List content = null;
        int i = 0;

        Node parent = node.getParent();
        if (parent != null) {
            content = ((Element)parent).content();
            i = content.indexOf(node);
            if (i < content.size() - 1) {
                sibling = (Node)content.get(i + 1);
            }
        }

        return sibling;
    }

    /**
     * Help method to walk through the DOM document tree.<p>
     *
     * @param root the root Node
     * @param n a Node representing the current position in the tree
     * @return next node
     */
    private Node treeWalker(Node root, Node n) {

        Node nextnode = null;
        if (n.hasContent()) {
            // child has child notes itself
            // process these first in the next loop
            nextnode = (Node)((Element)n).content().get(0);
        } else {
            // child has no subchild.
            // so we take the next sibling
            nextnode = treeWalkerBreadth(root, n);
        }
        return nextnode;
    }

    /**
     * Help method to walk through the document tree by a breadth-first-order.<p>
     * 
     * @param root the root Node
     * @param n a Node representing the current position in the tree
     * @return next node
     */
    private Node treeWalkerBreadth(Node root, Node n) {

        if (n == root) {
            return null;
        }
        Node nextnode = null;
        Node parent = null;
        nextnode = getNextSibling(n);
        parent = n.getParent();
        while (nextnode == null && parent != null && parent != root) {
            // child has sibling
            // last chance: we take our parent's sibling
            // (or our grandparent's sibling...)
            nextnode = getNextSibling(parent);
            parent = parent.getParent();
        }
        return nextnode;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品成人综合色在线婷婷 | 成人av电影观看| 全国精品久久少妇| 午夜电影一区二区| 日本中文字幕一区| 日韩黄色一级片| 日韩黄色免费网站| 日韩中文欧美在线| 日本亚洲视频在线| 精品一区二区三区不卡| 欧美aⅴ一区二区三区视频| 免费人成精品欧美精品| 青青草原综合久久大伊人精品优势| 蜜桃精品在线观看| 国产真实精品久久二三区| 国产乱码一区二区三区| 国产老女人精品毛片久久| 成人午夜碰碰视频| 色欧美乱欧美15图片| 欧美日韩三级在线| 日韩精品一区国产麻豆| 国产色爱av资源综合区| 亚洲欧美日韩综合aⅴ视频| 亚洲人成影院在线观看| 亚洲成人av中文| 国产精品伊人色| 99re亚洲国产精品| 日韩一级二级三级| 国产午夜亚洲精品羞羞网站| 亚洲人成网站色在线观看| 日韩电影在线一区二区三区| 国产东北露脸精品视频| 欧美日韩视频在线一区二区| 久久亚洲精品小早川怜子| 国产精品久久福利| 日韩成人一级片| 不卡大黄网站免费看| 91精品黄色片免费大全| 国产精品久久午夜夜伦鲁鲁| 婷婷中文字幕综合| av中文字幕一区| 91精品国产综合久久精品图片| 国产情人综合久久777777| 亚洲一级二级三级在线免费观看| 蜜桃av噜噜一区二区三区小说| 成人一区二区三区中文字幕| 欧美日韩精品二区第二页| 欧美精彩视频一区二区三区| 亚洲一区二区三区四区的| 成人免费av网站| 精品久久久三级丝袜| 亚洲一区在线观看视频| 国产成人精品影视| 欧美一区二区啪啪| 亚洲曰韩产成在线| av激情亚洲男人天堂| 久久久蜜桃精品| 免费在线观看成人| 欧美妇女性影城| 亚洲一区二区三区在线| hitomi一区二区三区精品| 26uuu久久天堂性欧美| 天堂在线亚洲视频| 欧美日韩一级视频| 亚洲色图色小说| 成人激情综合网站| 欧美极品少妇xxxxⅹ高跟鞋| 免费欧美在线视频| 91精品国模一区二区三区| 视频一区视频二区中文| 欧美精品在欧美一区二区少妇| 亚洲人午夜精品天堂一二香蕉| 国产aⅴ综合色| 国产亚洲精品精华液| 国产精品一区二区91| 久久久久久久国产精品影院| 激情成人午夜视频| xfplay精品久久| 国产在线精品一区二区不卡了| 日韩欧美一级二级| 久久99精品国产.久久久久| 精品少妇一区二区三区在线视频| 麻豆成人久久精品二区三区小说| 欧美一区二区黄| 久久不见久久见免费视频7| 精品国产伦一区二区三区免费| 久久精品国产澳门| 久久精品一区二区三区不卡牛牛| 国内精品国产三级国产a久久| 精品成a人在线观看| 国产成人精品一区二| 国产精品高潮久久久久无| 91亚洲精品一区二区乱码| 亚洲综合精品久久| 欧美一激情一区二区三区| 国产一本一道久久香蕉| 日韩一区中文字幕| 在线免费观看日本欧美| 日韩国产欧美一区二区三区| 日韩欧美视频在线| av成人免费在线观看| 亚洲一区二区影院| 欧美成人猛片aaaaaaa| 不卡一卡二卡三乱码免费网站| 亚洲色图视频网站| 日韩欧美在线网站| 成人97人人超碰人人99| 亚洲va欧美va人人爽午夜| 精品国产自在久精品国产| 91看片淫黄大片一级在线观看| 亚洲一区二区av在线| 日韩精品一区二区三区四区视频| 国产剧情一区二区| 夜夜嗨av一区二区三区网页| 精品久久久久久综合日本欧美| 成人黄色电影在线 | 欧美久久一二三四区| 国产一区在线观看视频| 亚洲综合视频在线观看| 欧美精品一区二区三区久久久| 波多野结衣精品在线| 蜜臀久久99精品久久久久宅男 | 岛国一区二区在线观看| 亚洲v日本v欧美v久久精品| 国产亚洲欧美一区在线观看| 欧美电影在线免费观看| 99re6这里只有精品视频在线观看| 石原莉奈一区二区三区在线观看| 国产精品免费aⅴ片在线观看| 51精品久久久久久久蜜臀| 色综合中文字幕| 国产成人精品aa毛片| 麻豆91在线播放| 亚洲高清在线视频| 亚洲精品免费在线播放| 国产视频一区二区在线| 精品久久国产字幕高潮| 欧美日韩在线播放三区| 色悠悠亚洲一区二区| 成人高清视频免费观看| 国产一区二区三区免费| 精品一区二区免费视频| 蜜臀精品一区二区三区在线观看| 一区二区三区四区乱视频| 国产精品久久看| 国产精品日韩成人| 国产午夜精品一区二区三区嫩草| 日韩一级二级三级精品视频| 欧美日韩国产中文| 欧美日韩综合不卡| 欧美三级韩国三级日本三斤| 91久久精品日日躁夜夜躁欧美| yourporn久久国产精品| 99久久精品国产观看| 99久久精品国产观看| 色婷婷精品大在线视频| 欧洲亚洲国产日韩| 精品视频在线免费看| 欧美日韩三级一区| 欧美一区二区三区电影| 精品乱人伦一区二区三区| 337p日本欧洲亚洲大胆色噜噜| 精品国产在天天线2019| 国产丝袜欧美中文另类| 国产精品国产精品国产专区不片| 国产精品全国免费观看高清 | 日韩欧美第一区| 日韩一级免费观看| 国产日韩欧美精品在线| 日韩一区在线看| 亚洲成va人在线观看| 麻豆成人91精品二区三区| 国产精品羞羞答答xxdd| 国产91高潮流白浆在线麻豆| 波多野结衣一区二区三区| 色噜噜狠狠成人中文综合| 欧美日韩午夜在线| xnxx国产精品| 亚洲老妇xxxxxx| 日韩中文字幕亚洲一区二区va在线| 老司机精品视频在线| 岛国精品在线观看| 欧美色中文字幕| 精品久久久久久久久久久久久久久 | 99久久精品国产网站| 欧美久久一区二区| 欧美国产日韩一二三区| 一区二区三区四区蜜桃| 极品少妇一区二区| 91看片淫黄大片一级| 欧美刺激午夜性久久久久久久| 欧美国产精品v| 日韩国产欧美在线观看| 成人aaaa免费全部观看| 日韩欧美成人激情| 亚洲自拍偷拍欧美| 福利一区在线观看| 91精品国产91久久综合桃花| 国产精品盗摄一区二区三区| 日本三级韩国三级欧美三级|