📄 cmsworkplacemanager.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsWorkplaceManager.java,v $
* Date : $Date: 2006/10/26 12:25:34 $
* Version: $Revision: 1.77 $
*
* 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;
import org.opencms.configuration.CmsDefaultUserSettings;
import org.opencms.db.CmsExportPoint;
import org.opencms.db.CmsUserSettings;
import org.opencms.db.I_CmsProjectDriver;
import org.opencms.file.CmsFolder;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsUser;
import org.opencms.file.types.CmsResourceTypeFolderExtended;
import org.opencms.file.types.I_CmsResourceType;
import org.opencms.i18n.CmsAcceptLanguageHeaderParser;
import org.opencms.i18n.CmsEncoder;
import org.opencms.i18n.CmsI18nInfo;
import org.opencms.i18n.CmsLocaleComparator;
import org.opencms.i18n.CmsLocaleManager;
import org.opencms.i18n.I_CmsLocaleHandler;
import org.opencms.main.CmsEvent;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.I_CmsEventListener;
import org.opencms.main.OpenCms;
import org.opencms.module.CmsModule;
import org.opencms.module.CmsModuleManager;
import org.opencms.security.CmsRole;
import org.opencms.security.CmsRoleViolationException;
import org.opencms.util.CmsRfsFileViewer;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.editors.CmsEditorDisplayOptions;
import org.opencms.workplace.editors.CmsEditorHandler;
import org.opencms.workplace.editors.CmsWorkplaceEditorManager;
import org.opencms.workplace.editors.I_CmsEditorActionHandler;
import org.opencms.workplace.editors.I_CmsEditorHandler;
import org.opencms.workplace.editors.directedit.CmsDirectEditDefaultProvider;
import org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider;
import org.opencms.workplace.explorer.CmsExplorerContextMenu;
import org.opencms.workplace.explorer.CmsExplorerTypeAccess;
import org.opencms.workplace.explorer.CmsExplorerTypeSettings;
import org.opencms.workplace.galleries.A_CmsGallery;
import org.opencms.workplace.tools.CmsToolManager;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
/**
* Manages the global OpenCms workplace settings for all users.<p>
*
* This class reads the settings from the "opencms.properties" and stores them in member variables.
* For each setting one or more get methods are provided.<p>
*
* @author Andreas Zahner
*
* @version $Revision: 1.77 $
*
* @since 6.0.0
*/
public final class CmsWorkplaceManager implements I_CmsLocaleHandler, I_CmsEventListener {
/** The default encoding for the workplace (UTF-8). */
public static final String DEFAULT_WORKPLACE_ENCODING = CmsEncoder.ENCODING_UTF_8;
/** The id of the "requestedResource" parameter for the OpenCms login form. */
public static final String PARAM_LOGIN_REQUESTED_RESOURCE = "requestedResource";
/** Key name for the session workplace settings. */
public static final String SESSION_WORKPLACE_SETTINGS = "__CmsWorkplace.WORKPLACE_SETTINGS";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(CmsWorkplaceManager.class);
/** Indicates if auto-locking of resources is enabled or disabled. */
private boolean m_autoLockResources;
/** The default acces for explorer types. */
private CmsExplorerTypeAccess m_defaultAccess;
/** The configured default locale of the workplace. */
private Locale m_defaultLocale;
/** The default property setting for setting new property values. */
private boolean m_defaultPropertiesOnStructure;
/** The default user seetings. */
private CmsDefaultUserSettings m_defaultUserSettings;
/** The configured dialog handlers. */
private Map m_dialogHandler;
/** The configured direct edit provider. */
private I_CmsDirectEditProvider m_directEditProvider;
/** The edit action handler. */
private I_CmsEditorActionHandler m_editorAction;
/** The workplace editor display options. */
private CmsEditorDisplayOptions m_editorDisplayOptions;
/** The editor handler. */
private I_CmsEditorHandler m_editorHandler;
/** The editor manager. */
private CmsWorkplaceEditorManager m_editorManager;
/** The flag if switching tabs in the advanced property dialog is enabled. */
private boolean m_enableAdvancedPropertyTabs;
/** The configured encoding of the workplace. */
private String m_encoding;
/** The explorer type settings. */
private List m_explorerTypeSettings;
/** The explorer type settings from the configured modules. */
private List m_explorerTypeSettingsFromModules;
/** The explorer type settings from the XML configuration. */
private List m_explorerTypeSettingsFromXml;
/** The explorer type settings as Map with resource type name as key. */
private Map m_explorerTypeSettingsMap;
/** The workplace export points. */
private Set m_exportPoints;
/** Maximum size of an upload file. */
private int m_fileMaxUploadSize;
/** The instance used for reading portions of lines of a file to choose. */
private CmsRfsFileViewer m_fileViewSettings;
/** The configured workplace galleries. */
private Map m_galleries;
/** Contains all folders that should be labled if siblings exist. */
private List m_labelSiteFolders;
/** List of installed workplace locales, soreted ascending. */
private List m_locales;
/** The configured list of localized workplace folders. */
private List m_localizedFolders;
/** The workplace localized messages (mapped to the locales). */
private Map m_messages;
/** The configured multi context menu. */
private CmsExplorerContextMenu m_multiContextMenu;
/** Indicates if the user managemet icon should be displayed in the workplace. */
private boolean m_showUserGroupIcon;
/** The temporary file project used by the editors. */
private CmsProject m_tempFileProject;
/** The tool manager. */
private CmsToolManager m_toolManager;
/** The configured workplace views. */
private List m_views;
/** The workflow settings. */
private boolean m_workflowMessage;
/**
* Creates a new instance for the workplace manager, will be called by the workplace configuration manager.<p>
*/
public CmsWorkplaceManager() {
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_INITIALIZE_START_0));
}
m_locales = new ArrayList();
m_labelSiteFolders = new ArrayList();
m_localizedFolders = new ArrayList();
m_autoLockResources = true;
m_showUserGroupIcon = true;
m_dialogHandler = new HashMap();
m_views = new ArrayList();
m_exportPoints = new HashSet();
m_editorHandler = new CmsEditorHandler();
m_fileMaxUploadSize = -1;
m_fileViewSettings = new CmsRfsFileViewer();
m_explorerTypeSettingsFromXml = new ArrayList();
m_explorerTypeSettingsFromModules = new ArrayList();
m_defaultPropertiesOnStructure = true;
m_enableAdvancedPropertyTabs = true;
m_defaultUserSettings = new CmsDefaultUserSettings();
m_defaultAccess = new CmsExplorerTypeAccess();
m_galleries = new HashMap();
m_messages = new HashMap();
m_workflowMessage = false;
m_multiContextMenu = new CmsExplorerContextMenu();
m_multiContextMenu.setMultiMenu(true);
// important to set this to null to avoid unneccessary overhead during configuration phase
m_explorerTypeSettings = null;
}
/**
* Returns true if the provided request was done by a Workplace user.<p>
*
* @param req the request to check
* @return true if the provided request was done by a Workplace user
*/
public static boolean isWorkplaceUser(HttpServletRequest req) {
HttpSession session = req.getSession(false);
if (session != null) {
// if a session is available, check for a workplace configuration
return null != session.getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS);
}
// no session means no workplace use
return false;
}
/**
* Adds a dialog handler instance to the list of configured dialog handlers.<p>
*
* @param clazz the instanciated dialog handler to add
*/
public void addDialogHandler(I_CmsDialogHandler clazz) {
m_dialogHandler.put(clazz.getDialogHandler(), clazz);
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(
Messages.INIT_ADD_DIALOG_HANDLER_2,
clazz.getDialogHandler(),
clazz.getClass().getName()));
}
}
/**
* Adds an explorer type setting object to the list of type settings.<p>
*
* @param settings the explorer type settings
*/
public void addExplorerTypeSetting(CmsExplorerTypeSettings settings) {
m_explorerTypeSettingsFromXml.add(settings);
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_ADD_TYPE_SETTING_1, settings.getName()));
}
if (m_explorerTypeSettings != null) {
// reset the list of all explorer type settings, but not during startup
initExplorerTypeSettings();
}
}
/**
* Adds the list of explorer type settings from the given module.<p>
*
* @param module the module witch contains the explorer type settings to add
*/
public void addExplorerTypeSettings(CmsModule module) {
List explorerTypes = module.getExplorerTypes();
if ((explorerTypes != null) && (explorerTypes.size() > 0)) {
Iterator i = explorerTypes.iterator();
while (i.hasNext()) {
CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings)i.next();
m_explorerTypeSettingsFromModules.add(settings);
if (CmsLog.INIT.isInfoEnabled()) {
CmsLog.INIT.info(Messages.get().getBundle().key(
Messages.INIT_ADD_TYPE_SETTING_1,
settings.getName()));
}
}
// reset the list of all explorer type settings
initExplorerTypeSettings();
}
}
/**
* Adds newly created export point to the workplace configuration.<p>
*
* @param uri the export point uri
* @param destination the export point destination
*/
public void addExportPoint(String uri, String destination) {
CmsExportPoint point = new CmsExportPoint(uri, destination);
m_exportPoints.add(point);
if (CmsLog.INIT.isInfoEnabled() && (point.getDestinationPath() != null)) {
CmsLog.INIT.info(Messages.get().getBundle().key(
Messages.INIT_ADD_EXPORT_POINT_2,
point.getUri(),
point.getDestinationPath()));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -