001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/file/types/CmsResourceTypeFolder.java,v $
003: * Date : $Date: 2008-02-27 12:05:45 $
004: * Version: $Revision: 1.27 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.file.types;
033:
034: import org.opencms.configuration.CmsConfigurationException;
035: import org.opencms.main.OpenCms;
036: import org.opencms.util.CmsStringUtil;
037: import org.opencms.workplace.explorer.CmsNewResourceFolder;
038:
039: import java.util.Map;
040: import java.util.TreeMap;
041:
042: /**
043: * Resource type descriptor for the type "folder".<p>
044: *
045: * @author Alexander Kandzior
046: *
047: * @version $Revision: 1.27 $
048: *
049: * @since 6.0.0
050: */
051: public class CmsResourceTypeFolder extends A_CmsResourceTypeFolderBase {
052:
053: /** Configuration key for the optional list of resource types to show as available index page types. */
054: public static final String CONFIGURATION_INDEX_PAGE_TYPE = CmsNewResourceFolder.PROPERTY_RESTYPES_INDEXPAGE;
055:
056: /** The type id of this resource. */
057: public static final int RESOURCE_TYPE_ID = 0;
058:
059: /** The name of this resource type. */
060: public static final String RESOURCE_TYPE_NAME = "folder";
061:
062: /** Indicates that the static configuration of the resource type has been frozen. */
063: private static boolean m_staticFrozen;
064:
065: /** The static type id of this resource type. */
066: private static int m_staticTypeId;
067:
068: /** The configured list of resource types to show as available index page types. */
069: private String m_indexPageTypes;
070:
071: /**
072: * Default constructor, used to initialize member variables.<p>
073: */
074: public CmsResourceTypeFolder() {
075:
076: super ();
077: m_typeId = RESOURCE_TYPE_ID;
078: m_typeName = RESOURCE_TYPE_NAME;
079: }
080:
081: /**
082: * Returns the static type id of this (default) resource type.<p>
083: *
084: * @return the static type id of this (default) resource type
085: */
086: public static int getStaticTypeId() {
087:
088: return m_staticTypeId;
089: }
090:
091: /**
092: * Returns the static type name of this (default) resource type.<p>
093: *
094: * @return the static type name of this (default) resource type
095: */
096: public static String getStaticTypeName() {
097:
098: return RESOURCE_TYPE_NAME;
099: }
100:
101: /**
102: * @see org.opencms.file.types.A_CmsResourceType#addConfigurationParameter(java.lang.String, java.lang.String)
103: */
104: public void addConfigurationParameter(String paramName,
105: String paramValue) {
106:
107: super .addConfigurationParameter(paramName, paramValue);
108: if (CmsStringUtil.isNotEmpty(paramName)
109: && CmsStringUtil.isNotEmpty(paramValue)) {
110: if (CONFIGURATION_INDEX_PAGE_TYPE
111: .equalsIgnoreCase(paramName)) {
112: m_indexPageTypes = paramValue.trim();
113: }
114: }
115: }
116:
117: /**
118: * @see org.opencms.file.types.A_CmsResourceType#getConfiguration()
119: */
120: public Map getConfiguration() {
121:
122: Map result = new TreeMap();
123: if (CmsStringUtil.isNotEmpty(getIndexPageTypes())) {
124: result.put(CONFIGURATION_INDEX_PAGE_TYPE,
125: getIndexPageTypes());
126: }
127: Map additional = super .getConfiguration();
128: if ((additional != null) && (additional.size() > 0)) {
129: result.putAll(additional);
130: }
131: return result;
132: }
133:
134: /**
135: * Returns the indexPageTypes.<p>
136: *
137: * @return the indexPageTypes
138: */
139: public String getIndexPageTypes() {
140:
141: return m_indexPageTypes;
142: }
143:
144: /**
145: * @see org.opencms.file.types.A_CmsResourceType#initConfiguration(java.lang.String, java.lang.String, String)
146: */
147: public void initConfiguration(String name, String id,
148: String className) throws CmsConfigurationException {
149:
150: if ((OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING)
151: && m_staticFrozen) {
152: // configuration already frozen
153: throw new CmsConfigurationException(Messages.get()
154: .container(Messages.ERR_CONFIG_FROZEN_3,
155: this .getClass().getName(),
156: getStaticTypeName(),
157: new Integer(getStaticTypeId())));
158: }
159:
160: if (!RESOURCE_TYPE_NAME.equals(name)) {
161: // default resource type MUST have default name
162: throw new CmsConfigurationException(Messages.get()
163: .container(
164: Messages.ERR_INVALID_RESTYPE_CONFIG_NAME_3,
165: this .getClass().getName(),
166: RESOURCE_TYPE_NAME, name));
167: }
168:
169: // freeze the configuration
170: m_staticFrozen = true;
171:
172: super .initConfiguration(RESOURCE_TYPE_NAME, id, className);
173: // set static members with values from the configuration
174: m_staticTypeId = m_typeId;
175: }
176: }
|