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.file.types;
029
030import org.opencms.configuration.CmsParameterConfiguration;
031import org.opencms.util.CmsStringUtil;
032
033/**
034 * Resource type descriptor for extended folder types (like for example the workplace galleries).<p>
035 *
036 * This type extends a folder but has a configurable type id and type name.
037 * Optionally, a workplace class name for the type and a parameter String can be provided.<p>
038 *
039 * @since 6.0.0
040 */
041public class CmsResourceTypeFolderExtended extends A_CmsResourceTypeFolderBase {
042
043    /** Configuration key for the optional folder class name. */
044    public static final String CONFIGURATION_FOLDER_CLASS = "folder.class";
045
046    /** Configuration key for the optional folder class parameters. */
047    public static final String CONFIGURATION_FOLDER_CLASS_PARAMS = "folder.class.params";
048
049    /** The serial version id. */
050    private static final long serialVersionUID = -3354434293847996599L;
051
052    /** The configured folder class name for this folder type. */
053    private String m_folderClassName;
054
055    /** The configured folder parameters for this folder type. */
056    private String m_folderClassParams;
057
058    /**
059     * @see org.opencms.file.types.A_CmsResourceType#addConfigurationParameter(java.lang.String, java.lang.String)
060     */
061    @Override
062    public void addConfigurationParameter(String paramName, String paramValue) {
063
064        super.addConfigurationParameter(paramName, paramValue);
065        if (CmsStringUtil.isNotEmpty(paramName) && CmsStringUtil.isNotEmpty(paramValue)) {
066            if (CONFIGURATION_FOLDER_CLASS.equalsIgnoreCase(paramName)) {
067                m_folderClassName = paramValue.trim();
068            }
069            if (CONFIGURATION_FOLDER_CLASS_PARAMS.equalsIgnoreCase(paramName)) {
070                m_folderClassParams = paramValue.trim();
071            }
072        }
073    }
074
075    /**
076     * @see org.opencms.file.types.A_CmsResourceType#getConfiguration()
077     */
078    @Override
079    public CmsParameterConfiguration getConfiguration() {
080
081        CmsParameterConfiguration result = new CmsParameterConfiguration();
082        CmsParameterConfiguration additional = super.getConfiguration();
083        if ((additional != null) && (additional.size() > 0)) {
084            result.putAll(additional);
085        }
086        if (CmsStringUtil.isNotEmpty(getFolderClassName())) {
087            result.put(CONFIGURATION_FOLDER_CLASS, getFolderClassName());
088        }
089        if (CmsStringUtil.isNotEmpty(getFolderClassParams())) {
090            result.put(CONFIGURATION_FOLDER_CLASS_PARAMS, getFolderClassParams());
091        }
092        return result;
093    }
094
095    /**
096     * Returns the (optional) configured folder class name for this folder.<p>
097     *
098     * @return the (optional) configured folder class name for this folder
099     */
100    public String getFolderClassName() {
101
102        return m_folderClassName;
103    }
104
105    /**
106     * Returns the (optional) configured folder class parameters name for this folder.<p>
107     *
108     * @return the (optional) configured folder class parameters for this folder
109     */
110    public String getFolderClassParams() {
111
112        return m_folderClassParams;
113    }
114}