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, 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.file.types;
029
030import org.opencms.configuration.CmsConfigurationCopyResource;
031import org.opencms.file.CmsObject;
032import org.opencms.util.CmsMacroResolver;
033
034import java.util.Arrays;
035import java.util.List;
036
037/**
038 * Content type class for subsitemap content folders.
039 *
040 * <p>Has special handling for copy resources.
041 */
042public class CmsResourceTypeSubsitemapContentFolder extends CmsResourceTypeFolderExtended {
043
044    /** Serial version id. */
045    private static final long serialVersionUID = -4763516920316525304L;
046
047    /** The default value for the config file copy source. */
048    public static final String DEFAULT_CONFIG_SOURCE = "/system/modules/org.opencms.base/copyresources/sitemap.config";
049
050    /** True if the 'use formatter keys' option should be enabled by default in newly created sitemap configurations. */
051    private static boolean m_enableNewPageFormatByDefault = true;
052
053    /**
054     * Checks if the 'use formatter keys' option should be enabled by default in generated sitemap configurations.
055     *
056     * @return true if the 'use formatter keys' option should be enabled by default
057     */
058    public static boolean isEnableNewPageFormatByDefault() {
059
060        return m_enableNewPageFormatByDefault;
061    }
062
063    /**
064     * Enables / disables the default value to use for 'use formatter keys' option in generated sitemap configurations.
065     *
066     * @param enabled the default value for the 'use formatter keys' option
067     */
068    public static void setEnableNewPageFormatByDefault(boolean enabled) {
069
070        m_enableNewPageFormatByDefault = enabled;
071    }
072
073    /**
074     * @see org.opencms.file.types.A_CmsResourceType#getCopyResources(org.opencms.file.CmsObject, java.lang.String, org.opencms.util.CmsMacroResolver)
075     */
076    @Override
077    protected List<CmsConfigurationCopyResource> getCopyResources(
078        CmsObject cms,
079        String resourcename,
080        CmsMacroResolver resolver) {
081
082        String source = DEFAULT_CONFIG_SOURCE;
083        if (!m_enableNewPageFormatByDefault) {
084            source = source + ".nokeys";
085        }
086        CmsConfigurationCopyResource res = new CmsConfigurationCopyResource(
087            source,
088            "${resource.folder.path}/.config",
089            "new");
090        return Arrays.asList(res);
091    }
092
093}