⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmscontentcheck.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * File   : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/content/check/CmsContentCheck.java,v $
 * Date   : $Date: 2006/03/27 14:52:54 $
 * Version: $Revision: 1.2 $
 *
 * 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.workplace.tools.content.check;

import org.opencms.file.CmsObject;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.report.I_CmsReport;
import org.opencms.util.CmsFileUtil;
import org.opencms.workplace.CmsWorkplace;
import org.opencms.workplace.tools.CmsToolManager;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;

import org.apache.commons.logging.Log;

/**
 * Main implementation of the content check. It maintains all configured content check
 * plugins and handles the check process.<p>
 * 
 *
 * @author  Michael Emmerich
 * 
 * @version $Revision: 1.2 $ 
 * 
 * @since 6.1.2 
 */
public class CmsContentCheck {

    /**  Path to the plugin folder. */
    public static final String VFS_PATH_PLUGIN_FOLDER = CmsWorkplace.VFS_PATH_WORKPLACE
        + "admin/contenttools/check/plugin/";

    /** The log object for this class. */
    private static final Log LOG = CmsLog.getLog(CmsContentCheck.class);

    /** The CmsObject. */
    private CmsObject m_cms;

    /** The list of paths to be processed. */
    private List m_paths;

    /** The list of all instantiated plugins. */
    private List m_plugins;

    /** The report for the output. */
    private I_CmsReport m_report;

    /** The map of resources to check. */
    private SortedMap m_resources;

    /** The content check result. */
    private CmsContentCheckResult m_result;

    /**
     * Constructor, creates a new CmsContentCheck. <p>
     * 
     * @param cms the CmsObject
     */
    public CmsContentCheck(CmsObject cms) {

        m_cms = cms;
        m_plugins = new ArrayList();
        m_paths = new ArrayList();
        m_result = new CmsContentCheckResult();

        try {
            init();
        } catch (CmsException e) {
            // TODO: do some errorhandling
        }
    }

    /**
     * Gets a list of all paths to be processed by the content check plugins.<p>
     * 
     * @return list of vfs paths
     */
    public List getPaths() {

        return m_paths;
    }

    /**
     * Gets a list of instances of all available content check plugins.<p>
     * 
     * @return list of plugin instances.
     */
    public List getPlugins() {

        return m_plugins;
    }

    /**
     * Gets the number of installed plugins.<p>
     * 
     * @return number of installed plugins
     */
    public int getPluginsCount() {

        return m_plugins.size();
    }

    /**
     * Gets the results of the content check.<p>
     * 
     * @return CmsContentCheckResult object containing all resources that collected an error or warning
     */
    public CmsContentCheckResult getResults() {

        return m_result;
    }

    /**
     * Sets the list of all paths to be processed by the content check plugins.<p>
     * @param paths list of vfs paths
     */
    public void setPaths(List paths) {

        m_paths = paths;
    }

    /**
     * Starts the content check.<p>
     * 
     * @param cms the CmsObject
     * @param report StringBuffer for reporting
     * @throws Exception if something goes wrong
     */
    public void startContentCheck(CmsObject cms, I_CmsReport report) throws Exception {

        m_report = report;
        m_report.println(Messages.get().container(Messages.RPT_CONTENT_CHECK_BEGIN_0), I_CmsReport.FORMAT_HEADLINE);

        // collect all resources
        m_report.print(Messages.get().container(Messages.RPT_CONTENT_COLLECT_BEGIN_0), I_CmsReport.FORMAT_HEADLINE);
        m_report.println(
            org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0),
            I_CmsReport.FORMAT_HEADLINE);
        m_resources = collectResources(cms);
        m_report.print(
            org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0),
            I_CmsReport.FORMAT_HEADLINE);
        m_report.println(
            Messages.get().container(Messages.RPT_CONTENT_COLLECT_END_1, new Integer(m_resources.size())),
            I_CmsReport.FORMAT_HEADLINE);

        // now process all resources
        m_report.print(Messages.get().container(Messages.RPT_CONTENT_PROCESS_BEGIN_0), I_CmsReport.FORMAT_HEADLINE);
        m_report.println(
            org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0),
            I_CmsReport.FORMAT_HEADLINE);
        int count = 1;
        Iterator i = m_resources.keySet().iterator();
        while (i.hasNext()) {
            String resourceName = (String)i.next();
            CmsContentCheckResource res = (CmsContentCheckResource)m_resources.get(resourceName);
            boolean errorWarning = false;
            m_report.print(Messages.get().container(
                Messages.RPT_CONTENT_PROCESS_2,
                new Integer(count++),
                new Integer(m_resources.size())), I_CmsReport.FORMAT_NOTE);
            m_report.print(
                Messages.get().container(Messages.RPT_CONTENT_PROCESS_RESOURCE_1, res.getResourceName()),
                I_CmsReport.FORMAT_DEFAULT);
            m_report.print(
                org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0),
                I_CmsReport.FORMAT_NOTE);

            // loop through all plugins and perform each content check
            Iterator j = getPlugins().iterator();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -