001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.setup.xml.v7;
029
030import org.opencms.configuration.CmsConfigurationManager;
031import org.opencms.configuration.CmsSystemConfiguration;
032import org.opencms.configuration.I_CmsXmlConfiguration;
033import org.opencms.setup.xml.A_CmsSetupXmlUpdate;
034
035import java.util.ArrayList;
036import java.util.List;
037
038/**
039 * Remove the old v6 resource handler classes, deprecated by version 7.0.x.<p>
040 *
041 * @since 7.0.3
042 */
043public class CmsXmlRemoveResourceHandlers extends A_CmsSetupXmlUpdate {
044
045    /** List of xpaths to update. */
046    private List<String> m_xpaths;
047
048    /**
049     * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getName()
050     */
051    public String getName() {
052
053        return "Remove old v6 resource handler classes";
054    }
055
056    /**
057     * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getXmlFilename()
058     */
059    public String getXmlFilename() {
060
061        return CmsSystemConfiguration.DEFAULT_XML_FILE_NAME;
062    }
063
064    /**
065     * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToRemove()
066     */
067    @Override
068    protected List<String> getXPathsToRemove() {
069
070        if (m_xpaths == null) {
071            // "/opencms/system/resourceinit/resourceinithandler[@class='...']";
072            StringBuffer xp = new StringBuffer(256);
073            xp.append("/").append(CmsConfigurationManager.N_ROOT);
074            xp.append("/").append(CmsSystemConfiguration.N_SYSTEM);
075            xp.append("/").append(CmsSystemConfiguration.N_RESOURCEINIT);
076            xp.append("/").append(CmsSystemConfiguration.N_RESOURCEINITHANDLER);
077            xp.append("[@").append(I_CmsXmlConfiguration.A_CLASS);
078            xp.append("='org.opencms.file.CmsBackupResourceHandler']");
079            m_xpaths = new ArrayList<String>();
080            m_xpaths.add(xp.toString());
081        }
082        return m_xpaths;
083    }
084
085}