Source Code Cross Referenced for CmsWorkplaceManager.java in  » Content-Management-System » opencms » org » opencms » workplace » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » opencms » org.opencms.workplace 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsWorkplaceManager.java,v $
0003:         * Date   : $Date: 2008-02-28 10:39:04 $
0004:         * Version: $Revision: 1.89 $
0005:         *
0006:         * This library is part of OpenCms -
0007:         * the Open Source Content Management System
0008:         *
0009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
0010:         *
0011:         * This library is free software; you can redistribute it and/or
0012:         * modify it under the terms of the GNU Lesser General Public
0013:         * License as published by the Free Software Foundation; either
0014:         * version 2.1 of the License, or (at your option) any later version.
0015:         *
0016:         * This library is distributed in the hope that it will be useful,
0017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0019:         * Lesser General Public License for more details.
0020:         *
0021:         * For further information about Alkacon Software GmbH, please see the
0022:         * company website: http://www.alkacon.com
0023:         *
0024:         * For further information about OpenCms, please see the
0025:         * project website: http://www.opencms.org
0026:         * 
0027:         * You should have received a copy of the GNU Lesser General Public
0028:         * License along with this library; if not, write to the Free Software
0029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0030:         */
0031:
0032:        package org.opencms.workplace;
0033:
0034:        import org.opencms.configuration.CmsDefaultUserSettings;
0035:        import org.opencms.db.CmsExportPoint;
0036:        import org.opencms.db.CmsUserSettings;
0037:        import org.opencms.db.I_CmsProjectDriver;
0038:        import org.opencms.file.CmsFolder;
0039:        import org.opencms.file.CmsObject;
0040:        import org.opencms.file.CmsProject;
0041:        import org.opencms.file.CmsPropertyDefinition;
0042:        import org.opencms.file.CmsResource;
0043:        import org.opencms.file.CmsResourceFilter;
0044:        import org.opencms.file.CmsUser;
0045:        import org.opencms.file.CmsVfsResourceNotFoundException;
0046:        import org.opencms.file.types.CmsResourceTypeFolderExtended;
0047:        import org.opencms.file.types.I_CmsResourceType;
0048:        import org.opencms.i18n.CmsAcceptLanguageHeaderParser;
0049:        import org.opencms.i18n.CmsEncoder;
0050:        import org.opencms.i18n.CmsI18nInfo;
0051:        import org.opencms.i18n.CmsLocaleComparator;
0052:        import org.opencms.i18n.CmsLocaleManager;
0053:        import org.opencms.i18n.I_CmsLocaleHandler;
0054:        import org.opencms.main.CmsEvent;
0055:        import org.opencms.main.CmsException;
0056:        import org.opencms.main.CmsLog;
0057:        import org.opencms.main.I_CmsEventListener;
0058:        import org.opencms.main.OpenCms;
0059:        import org.opencms.module.CmsModule;
0060:        import org.opencms.module.CmsModuleManager;
0061:        import org.opencms.security.CmsPermissionSet;
0062:        import org.opencms.security.CmsPermissionViolationException;
0063:        import org.opencms.security.CmsRole;
0064:        import org.opencms.security.CmsRoleViolationException;
0065:        import org.opencms.security.I_CmsPrincipal;
0066:        import org.opencms.util.CmsRfsFileViewer;
0067:        import org.opencms.util.CmsStringUtil;
0068:        import org.opencms.util.CmsUUID;
0069:        import org.opencms.workplace.editors.CmsEditorDisplayOptions;
0070:        import org.opencms.workplace.editors.CmsEditorHandler;
0071:        import org.opencms.workplace.editors.CmsWorkplaceEditorManager;
0072:        import org.opencms.workplace.editors.I_CmsEditorActionHandler;
0073:        import org.opencms.workplace.editors.I_CmsEditorCssHandler;
0074:        import org.opencms.workplace.editors.I_CmsEditorHandler;
0075:        import org.opencms.workplace.editors.I_CmsPreEditorActionDefinition;
0076:        import org.opencms.workplace.editors.directedit.CmsDirectEditDefaultProvider;
0077:        import org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider;
0078:        import org.opencms.workplace.explorer.CmsExplorerContextMenu;
0079:        import org.opencms.workplace.explorer.CmsExplorerTypeAccess;
0080:        import org.opencms.workplace.explorer.CmsExplorerTypeSettings;
0081:        import org.opencms.workplace.explorer.menu.CmsMenuRule;
0082:        import org.opencms.workplace.galleries.A_CmsGallery;
0083:        import org.opencms.workplace.tools.CmsToolManager;
0084:
0085:        import java.io.UnsupportedEncodingException;
0086:        import java.util.ArrayList;
0087:        import java.util.Collections;
0088:        import java.util.HashMap;
0089:        import java.util.HashSet;
0090:        import java.util.Iterator;
0091:        import java.util.List;
0092:        import java.util.Locale;
0093:        import java.util.Map;
0094:        import java.util.Set;
0095:
0096:        import javax.servlet.http.HttpServletRequest;
0097:        import javax.servlet.http.HttpSession;
0098:
0099:        import org.apache.commons.logging.Log;
0100:
0101:        /**
0102:         * Manages the global OpenCms workplace settings for all users.<p>
0103:         * 
0104:         * This class reads the settings from the "opencms.properties" and stores them in member variables.
0105:         * For each setting one or more get methods are provided.<p>
0106:         * 
0107:         * @author Andreas Zahner 
0108:         * 
0109:         * @version $Revision: 1.89 $ 
0110:         * 
0111:         * @since 6.0.0 
0112:         */
0113:        public final class CmsWorkplaceManager implements  I_CmsLocaleHandler,
0114:                I_CmsEventListener {
0115:
0116:            /** The default encoding for the workplace (UTF-8). */
0117:            public static final String DEFAULT_WORKPLACE_ENCODING = CmsEncoder.ENCODING_UTF_8;
0118:
0119:            /** The id of the "requestedResource" parameter for the OpenCms login form. */
0120:            public static final String PARAM_LOGIN_REQUESTED_RESOURCE = "requestedResource";
0121:
0122:            /** Key name for the session workplace settings. */
0123:            public static final String SESSION_WORKPLACE_SETTINGS = "__CmsWorkplace.WORKPLACE_SETTINGS";
0124:
0125:            /** The log object for this class. */
0126:            private static final Log LOG = CmsLog
0127:                    .getLog(CmsWorkplaceManager.class);
0128:
0129:            /** The admin cms context. */
0130:            private CmsObject m_adminCms;
0131:
0132:            /** Indicates if auto-locking of resources is enabled or disabled. */
0133:            private boolean m_autoLockResources;
0134:
0135:            /** The customized workplace foot. */
0136:            private CmsWorkplaceCustomFoot m_customFoot;
0137:
0138:            /** The default access for explorer types. */
0139:            private CmsExplorerTypeAccess m_defaultAccess;
0140:
0141:            /** The configured default locale of the workplace. */
0142:            private Locale m_defaultLocale;
0143:
0144:            /** The default property setting for setting new property values. */
0145:            private boolean m_defaultPropertiesOnStructure;
0146:
0147:            /** The default user settings. */
0148:            private CmsDefaultUserSettings m_defaultUserSettings;
0149:
0150:            /** The configured dialog handlers. */
0151:            private Map m_dialogHandler;
0152:
0153:            /** The configured direct edit provider. */
0154:            private I_CmsDirectEditProvider m_directEditProvider;
0155:
0156:            /** The edit action handler. */
0157:            private I_CmsEditorActionHandler m_editorAction;
0158:
0159:            private List m_editorCssHandlers;
0160:
0161:            /** The workplace editor display options. */
0162:            private CmsEditorDisplayOptions m_editorDisplayOptions;
0163:
0164:            /** The editor handler. */
0165:            private I_CmsEditorHandler m_editorHandler;
0166:
0167:            /** The editor manager. */
0168:            private CmsWorkplaceEditorManager m_editorManager;
0169:
0170:            /** The flag if switching tabs in the advanced property dialog is enabled. */
0171:            private boolean m_enableAdvancedPropertyTabs;
0172:
0173:            /** The configured encoding of the workplace. */
0174:            private String m_encoding;
0175:
0176:            /** The explorer type settings. */
0177:            private List m_explorerTypeSettings;
0178:
0179:            /** The explorer type settings from the configured modules. */
0180:            private List m_explorerTypeSettingsFromModules;
0181:
0182:            /** The explorer type settings from the XML configuration. */
0183:            private List m_explorerTypeSettingsFromXml;
0184:
0185:            /** The explorer type settings as Map with resource type name as key. */
0186:            private Map m_explorerTypeSettingsMap;
0187:
0188:            /** The workplace export points. */
0189:            private Set m_exportPoints;
0190:
0191:            /** Maximum size of an upload file. */
0192:            private int m_fileMaxUploadSize;
0193:
0194:            /** The instance used for reading portions of lines of a file to choose. */
0195:            private CmsRfsFileViewer m_fileViewSettings;
0196:
0197:            /** The configured workplace galleries. */
0198:            private Map m_galleries;
0199:
0200:            /** Contains all folders that should be labeled if siblings exist. */
0201:            private List m_labelSiteFolders;
0202:
0203:            /** List of installed workplace locales, sorted ascending. */
0204:            private List m_locales;
0205:
0206:            /** The configured list of localized workplace folders. */
0207:            private List m_localizedFolders;
0208:
0209:            /** The configured list of menu rule sets. */
0210:            private List m_menuRules;
0211:
0212:            /** The configured menu rule sets as Map with the rule name as key. */
0213:            private Map m_menuRulesMap;
0214:
0215:            /** The workplace localized messages (mapped to the locales). */
0216:            private Map m_messages;
0217:
0218:            /** The configured multi context menu. */
0219:            private CmsExplorerContextMenu m_multiContextMenu;
0220:
0221:            /** The condition definitions for the resource types  which are triggered before opening the editor. */
0222:            private List m_preEditorConditionDefinitions;
0223:
0224:            /** Indicates if the user management icon should be displayed in the workplace. */
0225:            private boolean m_showUserGroupIcon;
0226:
0227:            /** The temporary file project used by the editors. */
0228:            private CmsProject m_tempFileProject;
0229:
0230:            /** The tool manager. */
0231:            private CmsToolManager m_toolManager;
0232:
0233:            /** The user additional information configuration. */
0234:            private CmsWorkplaceUserInfoManager m_userInfoManager;
0235:
0236:            /** The configured workplace views. */
0237:            private List m_views;
0238:
0239:            /** The XML content auto correction flag. */
0240:            private boolean m_xmlContentAutoCorrect;
0241:
0242:            /**
0243:             * Creates a new instance for the workplace manager, will be called by the workplace configuration manager.<p>
0244:             */
0245:            public CmsWorkplaceManager() {
0246:
0247:                if (CmsLog.INIT.isInfoEnabled()) {
0248:                    CmsLog.INIT.info(Messages.get().getBundle().key(
0249:                            Messages.INIT_WORKPLACE_INITIALIZE_START_0));
0250:                }
0251:                m_locales = new ArrayList();
0252:                m_labelSiteFolders = new ArrayList();
0253:                m_localizedFolders = new ArrayList();
0254:                m_autoLockResources = true;
0255:                m_xmlContentAutoCorrect = true;
0256:                m_showUserGroupIcon = true;
0257:                m_dialogHandler = new HashMap();
0258:                m_views = new ArrayList();
0259:                m_exportPoints = new HashSet();
0260:                m_editorHandler = new CmsEditorHandler();
0261:                m_fileMaxUploadSize = -1;
0262:                m_fileViewSettings = new CmsRfsFileViewer();
0263:                m_explorerTypeSettingsFromXml = new ArrayList();
0264:                m_explorerTypeSettingsFromModules = new ArrayList();
0265:                m_defaultPropertiesOnStructure = true;
0266:                m_enableAdvancedPropertyTabs = true;
0267:                m_defaultUserSettings = new CmsDefaultUserSettings();
0268:                m_defaultAccess = new CmsExplorerTypeAccess();
0269:                m_galleries = new HashMap();
0270:                m_menuRules = new ArrayList();
0271:                m_menuRulesMap = new HashMap();
0272:                m_messages = new HashMap();
0273:                m_multiContextMenu = new CmsExplorerContextMenu();
0274:                m_multiContextMenu.setMultiMenu(true);
0275:                m_preEditorConditionDefinitions = new ArrayList();
0276:                m_editorCssHandlers = new ArrayList();
0277:                m_customFoot = new CmsWorkplaceCustomFoot();
0278:
0279:                // important to set this to null to avoid unnecessary overhead during configuration phase
0280:                m_explorerTypeSettings = null;
0281:            }
0282:
0283:            /**
0284:             * Returns true if the provided request was done by a Workplace user.<p>
0285:             * 
0286:             * @param req the request to check
0287:             * 
0288:             * @return true if the provided request was done by a Workplace user
0289:             */
0290:            public static boolean isWorkplaceUser(HttpServletRequest req) {
0291:
0292:                HttpSession session = req.getSession(false);
0293:                if (session != null) {
0294:                    // if a session is available, check for a workplace configuration
0295:                    return (null != session
0296:                            .getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS));
0297:                }
0298:                // no session means no workplace use
0299:                return false;
0300:            }
0301:
0302:            /**
0303:             * Adds a dialog handler instance to the list of configured dialog handlers.<p>
0304:             * 
0305:             * @param clazz the instantiated dialog handler to add
0306:             */
0307:            public void addDialogHandler(I_CmsDialogHandler clazz) {
0308:
0309:                m_dialogHandler.put(clazz.getDialogHandler(), clazz);
0310:                if (CmsLog.INIT.isInfoEnabled()) {
0311:                    CmsLog.INIT.info(Messages.get().getBundle().key(
0312:                            Messages.INIT_ADD_DIALOG_HANDLER_2,
0313:                            clazz.getDialogHandler(),
0314:                            clazz.getClass().getName()));
0315:                }
0316:            }
0317:
0318:            /**
0319:             * Adds an editor CSS handler class to the list of handlers.<p>
0320:             * 
0321:             * @param editorCssHandlerClassName full class name of the css handler class
0322:             */
0323:            public void addEditorCssHandler(String editorCssHandlerClassName) {
0324:
0325:                try {
0326:                    I_CmsEditorCssHandler editorCssHandler = (I_CmsEditorCssHandler) Class
0327:                            .forName(editorCssHandlerClassName).newInstance();
0328:                    m_editorCssHandlers.add(editorCssHandler);
0329:                    if (CmsLog.INIT.isInfoEnabled()) {
0330:                        CmsLog.INIT.info(Messages.get().getBundle().key(
0331:                                Messages.INIT_EDITOR_CSSHANDLER_CLASS_1,
0332:                                editorCssHandlerClassName));
0333:                    }
0334:                } catch (Exception e) {
0335:                    LOG.error(Messages.get().getBundle().key(
0336:                            Messages.LOG_INVALID_EDITOR_CSSHANDLER_1,
0337:                            editorCssHandlerClassName), e);
0338:                }
0339:            }
0340:
0341:            /**
0342:             * Adds an editor CSS handler class at the first position of the list of handlers.<p>
0343:             * 
0344:             * @param editorCssHandlerClassName full class name of the css handler class
0345:             */
0346:            public void addEditorCssHandlerToHead(
0347:                    String editorCssHandlerClassName) {
0348:
0349:                try {
0350:                    I_CmsEditorCssHandler editorCssHandler = (I_CmsEditorCssHandler) Class
0351:                            .forName(editorCssHandlerClassName).newInstance();
0352:
0353:                    List editorCssHandlers = new ArrayList();
0354:                    editorCssHandlers.add(editorCssHandler);
0355:                    editorCssHandlers.addAll(m_editorCssHandlers);
0356:
0357:                    m_editorCssHandlers = editorCssHandlers;
0358:
0359:                    if (CmsLog.INIT.isInfoEnabled()) {
0360:                        CmsLog.INIT.info(Messages.get().getBundle().key(
0361:                                Messages.INIT_EDITOR_CSSHANDLER_CLASS_1,
0362:                                editorCssHandlerClassName));
0363:                    }
0364:                } catch (Exception e) {
0365:                    LOG.error(Messages.get().getBundle().key(
0366:                            Messages.LOG_INVALID_EDITOR_CSSHANDLER_1,
0367:                            editorCssHandlerClassName), e);
0368:                }
0369:            }
0370:
0371:            /** 
0372:             * Adds an explorer type setting object to the list of type settings.<p>
0373:             * 
0374:             * @param settings the explorer type settings
0375:             */
0376:            public void addExplorerTypeSetting(CmsExplorerTypeSettings settings) {
0377:
0378:                m_explorerTypeSettingsFromXml.add(settings);
0379:                if (CmsLog.INIT.isInfoEnabled()) {
0380:                    CmsLog.INIT.info(Messages.get().getBundle().key(
0381:                            Messages.INIT_ADD_TYPE_SETTING_1,
0382:                            settings.getName()));
0383:                }
0384:                if (m_explorerTypeSettings != null) {
0385:                    // reset the list of all explorer type settings, but not during startup
0386:                    initExplorerTypeSettings();
0387:                }
0388:            }
0389:
0390:            /** 
0391:             * Adds the list of explorer type settings from the given module.<p>
0392:             * 
0393:             * @param module the module witch contains the explorer type settings to add
0394:             */
0395:            public void addExplorerTypeSettings(CmsModule module) {
0396:
0397:                List explorerTypes = module.getExplorerTypes();
0398:                if ((explorerTypes != null) && (explorerTypes.size() > 0)) {
0399:                    Iterator i = explorerTypes.iterator();
0400:                    while (i.hasNext()) {
0401:                        CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings) i
0402:                                .next();
0403:                        if (m_explorerTypeSettingsFromModules
0404:                                .contains(settings)) {
0405:                            m_explorerTypeSettingsFromModules.remove(settings);
0406:                        }
0407:                        m_explorerTypeSettingsFromModules.add(settings);
0408:                        if (CmsLog.INIT.isInfoEnabled()) {
0409:                            CmsLog.INIT.info(Messages.get().getBundle().key(
0410:                                    Messages.INIT_ADD_TYPE_SETTING_1,
0411:                                    settings.getName()));
0412:                        }
0413:                    }
0414:                    // reset the list of all explorer type settings
0415:                    initExplorerTypeSettings();
0416:                }
0417:            }
0418:
0419:            /**
0420:             * Adds newly created export point to the workplace configuration.<p>
0421:             * 
0422:             * @param uri the export point uri
0423:             * @param destination the export point destination
0424:             */
0425:            public void addExportPoint(String uri, String destination) {
0426:
0427:                CmsExportPoint point = new CmsExportPoint(uri, destination);
0428:                m_exportPoints.add(point);
0429:                if (CmsLog.INIT.isInfoEnabled()
0430:                        && (point.getDestinationPath() != null)) {
0431:                    CmsLog.INIT.info(Messages.get().getBundle().key(
0432:                            Messages.INIT_ADD_EXPORT_POINT_2, point.getUri(),
0433:                            point.getDestinationPath()));
0434:                }
0435:            }
0436:
0437:            /**
0438:             * Adds a folder to the list of labeled folders.<p>
0439:             * 
0440:             * @param uri the folder uri to add
0441:             */
0442:            public void addLabeledFolder(String uri) {
0443:
0444:                m_labelSiteFolders.add(uri);
0445:                if (CmsLog.INIT.isInfoEnabled()) {
0446:                    CmsLog.INIT.info(Messages.get().getBundle().key(
0447:                            Messages.INIT_LABEL_LINKS_IN_FOLDER_1, uri));
0448:                }
0449:            }
0450:
0451:            /**
0452:             * Adds a new folder to the list of localized workplace folders.<p>
0453:             * 
0454:             * @param uri a new folder to add to the list of localized workplace folders
0455:             */
0456:            public void addLocalizedFolder(String uri) {
0457:
0458:                m_localizedFolders.add(uri);
0459:                if (CmsLog.INIT.isInfoEnabled()) {
0460:                    CmsLog.INIT.info(Messages.get().getBundle().key(
0461:                            Messages.INIT_WORKPLACE_LOCALIZED_1, uri));
0462:                }
0463:            }
0464:
0465:            /**
0466:             * Adds a menu rule set from the workplace configuration to the configured menu rules.<p>
0467:             * 
0468:             * @param menuRule the menu rule to add
0469:             */
0470:            public void addMenuRule(CmsMenuRule menuRule) {
0471:
0472:                if (CmsLog.INIT.isInfoEnabled()) {
0473:                    CmsLog.INIT.info(Messages.get().getBundle().key(
0474:                            Messages.INIT_ADD_MENURULE_1, menuRule.getName()));
0475:                }
0476:                m_menuRules.add(menuRule);
0477:            }
0478:
0479:            /**
0480:             * Adds a condition definition class for a given resource type glass name that is triggered before opening the editor.<p>
0481:             * 
0482:             * @param resourceTypeName the name of the resource type
0483:             * @param preEditorConditionDefinitionClassName full class name of the condition definition class
0484:             */
0485:            public void addPreEditorConditionDefinition(
0486:                    String resourceTypeName,
0487:                    String preEditorConditionDefinitionClassName) {
0488:
0489:                try {
0490:                    I_CmsPreEditorActionDefinition preEditorCondition = (I_CmsPreEditorActionDefinition) Class
0491:                            .forName(preEditorConditionDefinitionClassName)
0492:                            .newInstance();
0493:                    preEditorCondition.setResourceTypeName(resourceTypeName);
0494:                    m_preEditorConditionDefinitions.add(preEditorCondition);
0495:                    if (CmsLog.INIT.isInfoEnabled()) {
0496:                        CmsLog.INIT.info(Messages.get().getBundle().key(
0497:                                Messages.INIT_EDITOR_PRE_ACTION_2,
0498:                                preEditorConditionDefinitionClassName,
0499:                                resourceTypeName));
0500:                    }
0501:                } catch (Exception e) {
0502:                    LOG.error(Messages.get().getBundle().key(
0503:                            Messages.LOG_INVALID_EDITOR_PRE_ACTION_1,
0504:                            preEditorConditionDefinitionClassName), e);
0505:                }
0506:            }
0507:
0508:            /**
0509:             * Returns if the autolock resources feature is enabled.<p>
0510:             * 
0511:             * @return true if the autolock resources feature is enabled, otherwise false
0512:             */
0513:            public boolean autoLockResources() {
0514:
0515:                return m_autoLockResources;
0516:            }
0517:
0518:            /**
0519:             * Implements the event listener of this class.<p>
0520:             * 
0521:             * @see org.opencms.main.I_CmsEventListener#cmsEvent(org.opencms.main.CmsEvent)
0522:             */
0523:            public void cmsEvent(CmsEvent event) {
0524:
0525:                switch (event.getType()) {
0526:                case I_CmsEventListener.EVENT_CLEAR_CACHES:
0527:                    // clear the cached message objects
0528:                    m_messages = new HashMap();
0529:                    m_editorDisplayOptions.clearCache();
0530:                    if (LOG.isDebugEnabled()) {
0531:                        LOG.debug(Messages.get().getBundle().key(
0532:                                Messages.LOG_EVENT_CLEAR_CACHES_0));
0533:                    }
0534:                    break;
0535:                default: // no operation
0536:                }
0537:            }
0538:
0539:            /**
0540:             * Creates a temporary file which is needed while working in an editor with preview option.<p>
0541:             * 
0542:             * @param cms the cms context
0543:             * @param resourceName the name of the resource to copy
0544:             * @param currentProjectId the id of the project to work with
0545:             * 
0546:             * @return the file name of the temporary file
0547:             * 
0548:             * @throws CmsException if something goes wrong
0549:             */
0550:            public String createTempFile(CmsObject cms, String resourceName,
0551:                    CmsUUID currentProjectId) throws CmsException {
0552:
0553:                // check that the current user has write permissions
0554:                if (!cms.hasPermissions(cms.readResource(resourceName,
0555:                        CmsResourceFilter.ALL), CmsPermissionSet.ACCESS_WRITE)) {
0556:                    throw new CmsPermissionViolationException(
0557:                            org.opencms.db.Messages.get().container(
0558:                                    org.opencms.db.Messages.ERR_PERM_DENIED_2,
0559:                                    resourceName, "w"));
0560:                }
0561:
0562:                // initialize admin cms context
0563:                CmsObject adminCms = getAdminCms(cms);
0564:
0565:                // generate the filename of the temporary file
0566:                String temporaryFilename = CmsWorkplace
0567:                        .getTemporaryFileName(resourceName);
0568:
0569:                // check if the temporary file is already present
0570:                if (adminCms.existsResource(temporaryFilename,
0571:                        CmsResourceFilter.ALL)) {
0572:                    // delete old temporary file
0573:                    if (!cms.getLock(temporaryFilename).isUnlocked()) {
0574:                        // steal lock
0575:                        cms.changeLock(temporaryFilename);
0576:                    } else {
0577:                        // lock resource to current user
0578:                        cms.lockResource(temporaryFilename);
0579:                    }
0580:                    cms.deleteResource(temporaryFilename,
0581:                            CmsResource.DELETE_PRESERVE_SIBLINGS);
0582:                }
0583:
0584:                try {
0585:                    // switch to the temporary file project
0586:                    adminCms.getRequestContext().setCurrentProject(
0587:                            cms.readProject(getTempFileProjectId()));
0588:                    // copy the file to edit to a temporary file
0589:                    adminCms.copyResource(resourceName, temporaryFilename,
0590:                            CmsResource.COPY_AS_NEW);
0591:                } finally {
0592:                    // switch back to current project
0593:                    adminCms.getRequestContext().setCurrentProject(
0594:                            cms.readProject(currentProjectId));
0595:                }
0596:
0597:                try {
0598:                    // switch to the temporary file project
0599:                    cms.getRequestContext().setCurrentProject(
0600:                            cms.readProject(OpenCms.getWorkplaceManager()
0601:                                    .getTempFileProjectId()));
0602:                    // lock the temporary file
0603:                    cms.changeLock(temporaryFilename);
0604:                    // touch the temporary file
0605:                    cms.setDateLastModified(temporaryFilename, System
0606:                            .currentTimeMillis(), false);
0607:                    // set the temporary file flag
0608:                    CmsResource tempFile = cms.readResource(temporaryFilename,
0609:                            CmsResourceFilter.ALL);
0610:                    int flags = tempFile.getFlags();
0611:                    if ((flags & CmsResource.FLAG_TEMPFILE) == 0) {
0612:                        flags += CmsResource.FLAG_TEMPFILE;
0613:                    }
0614:                    cms.chflags(temporaryFilename, flags);
0615:                    // remove eventual release & expiration date from temporary file to make preview in editor work
0616:                    cms.setDateReleased(temporaryFilename,
0617:                            CmsResource.DATE_RELEASED_DEFAULT, false);
0618:                    cms.setDateExpired(temporaryFilename,
0619:                            CmsResource.DATE_EXPIRED_DEFAULT, false);
0620:                    // remove visibility permissions for everybody on temporary file if possible
0621:                    if (cms.hasPermissions(tempFile,
0622:                            CmsPermissionSet.ACCESS_CONTROL)) {
0623:                        cms.chacc(temporaryFilename,
0624:                                I_CmsPrincipal.PRINCIPAL_GROUP, OpenCms
0625:                                        .getDefaultUsers().getGroupUsers(),
0626:                                "-v");
0627:                        cms.chacc(temporaryFilename,
0628:                                I_CmsPrincipal.PRINCIPAL_GROUP, OpenCms
0629:                                        .getDefaultUsers()
0630:                                        .getGroupProjectmanagers(), "-v");
0631:                    }
0632:                } finally {
0633:                    // switch back to current project
0634:                    cms.getRequestContext().setCurrentProject(
0635:                            cms.readProject(currentProjectId));
0636:                }
0637:
0638:                return temporaryFilename;
0639:            }
0640:
0641:            /**
0642:             * Returns the customized workplace foot.<p>
0643:             * 
0644:             * @return the customized workplace foot
0645:             */
0646:            public CmsWorkplaceCustomFoot getCustomFoot() {
0647:
0648:                return m_customFoot;
0649:            }
0650:
0651:            /**
0652:             * Gets the access object of the type settings.<p>
0653:             * 
0654:             * @return access object of the type settings
0655:             */
0656:            public CmsExplorerTypeAccess getDefaultAccess() {
0657:
0658:                return m_defaultAccess;
0659:            }
0660:
0661:            /**
0662:             * Returns the Workplace default locale.<p>
0663:             * 
0664:             * @return  the Workplace default locale
0665:             */
0666:            public Locale getDefaultLocale() {
0667:
0668:                return m_defaultLocale;
0669:            }
0670:
0671:            /**
0672:             * Returns the Workplace default user settings.<p>
0673:             * 
0674:             * @return  the Workplace default user settings
0675:             */
0676:            public CmsDefaultUserSettings getDefaultUserSettings() {
0677:
0678:                return m_defaultUserSettings;
0679:            }
0680:
0681:            /**
0682:             * Returns all instantiated dialog handlers for the workplace.<p>
0683:             * 
0684:             * @return all instantiated dialog handlers for the workplace
0685:             */
0686:            public Map getDialogHandler() {
0687:
0688:                return m_dialogHandler;
0689:            }
0690:
0691:            /**
0692:             * Returns the instantiated dialog handler class for the key or null, if there is no mapping for the key.<p>
0693:             *  
0694:             * @param key the key whose associated value is to be returned
0695:             * 
0696:             * @return the instantiated dialog handler class for the key
0697:             */
0698:            public Object getDialogHandler(String key) {
0699:
0700:                return m_dialogHandler.get(key);
0701:            }
0702:
0703:            /**
0704:             * Returns a new instance of the configured direct edit provider.<p>
0705:             * 
0706:             * @return a new instance of the configured direct edit provider
0707:             */
0708:            public I_CmsDirectEditProvider getDirectEditProvider() {
0709:
0710:                return m_directEditProvider.newInstance();
0711:            }
0712:
0713:            /**
0714:             * Returns the instantiated editor action handler class.<p>
0715:             * 
0716:             * @return the instantiated editor action handler class
0717:             */
0718:            public I_CmsEditorActionHandler getEditorActionHandler() {
0719:
0720:                return m_editorAction;
0721:            }
0722:
0723:            /**
0724:             * Returns the instantiated editor CSS handler classes.<p>
0725:             * 
0726:             * @return the instantiated editor CSS handler classes
0727:             */
0728:            public List getEditorCssHandlers() {
0729:
0730:                return m_editorCssHandlers;
0731:            }
0732:
0733:            /**
0734:             * Returns the instantiated editor display option class.<p>
0735:             * 
0736:             * @return the instantiated editor display option class
0737:             */
0738:            public CmsEditorDisplayOptions getEditorDisplayOptions() {
0739:
0740:                return m_editorDisplayOptions;
0741:            }
0742:
0743:            /**
0744:             * Returns the instantiated editor handler class.<p>
0745:             * 
0746:             * @return the instantiated editor handler class
0747:             */
0748:            public I_CmsEditorHandler getEditorHandler() {
0749:
0750:                return m_editorHandler;
0751:            }
0752:
0753:            /**
0754:             * Returns the configured workplace encoding.<p>
0755:             * 
0756:             * @return the configured workplace encoding
0757:             */
0758:            public String getEncoding() {
0759:
0760:                return m_encoding;
0761:            }
0762:
0763:            /**
0764:             * Returns the explorer type settings for the specified resource type.<p>
0765:             * 
0766:             * @param type the resource type for which the settings are required
0767:             * 
0768:             * @return the explorer type settings for the specified resource type
0769:             */
0770:            public CmsExplorerTypeSettings getExplorerTypeSetting(String type) {
0771:
0772:                return (CmsExplorerTypeSettings) m_explorerTypeSettingsMap
0773:                        .get(type);
0774:            }
0775:
0776:            /**
0777:             * Returns the list of explorer type settings.<p>
0778:             * 
0779:             * These settings provide information for the new resource dialog and the context menu appearance.<p>
0780:             * 
0781:             * @return the list of explorer type settings
0782:             */
0783:            public List getExplorerTypeSettings() {
0784:
0785:                if (m_explorerTypeSettings == null) {
0786:                    // initialize all explorer type settings if not already done
0787:                    initExplorerTypeSettings();
0788:                }
0789:
0790:                return m_explorerTypeSettings;
0791:            }
0792:
0793:            /**
0794:             * Returns the set of configured export points for the workplace.<p>
0795:             *
0796:             * @return the set of configured export points for the workplace
0797:             */
0798:            public Set getExportPoints() {
0799:
0800:                return m_exportPoints;
0801:            }
0802:
0803:            /**
0804:             * Returns the value (in bytes) for the maximum file upload size of the current user.<p>
0805:             * 
0806:             * @param cms the initialized CmsObject
0807:             * 
0808:             * @return the value (in bytes) for the maximum file upload size
0809:             */
0810:            public long getFileBytesMaxUploadSize(CmsObject cms) {
0811:
0812:                int maxFileSize = getFileMaxUploadSize();
0813:                long maxFileSizeBytes = maxFileSize * 1024;
0814:                // check if current user belongs to Admin group, if so no file upload limit
0815:                if ((maxFileSize <= 0)
0816:                        || OpenCms.getRoleManager().hasRole(cms,
0817:                                CmsRole.VFS_MANAGER)) {
0818:                    maxFileSizeBytes = -1;
0819:                }
0820:                return maxFileSizeBytes;
0821:            }
0822:
0823:            /**
0824:             * Returns the value (in kb) for the maximum file upload size.<p>
0825:             * 
0826:             * @return the value (in kb) for the maximum file upload size
0827:             */
0828:            public int getFileMaxUploadSize() {
0829:
0830:                return m_fileMaxUploadSize;
0831:            }
0832:
0833:            /**
0834:             * Returns the system-wide file view settings for the workplace.<p>
0835:             * 
0836:             * Note that this instance may not modified (invocation of setters) directly or a
0837:             * <code>{@link org.opencms.main.CmsRuntimeException}</code> will be thrown.<p>
0838:             * 
0839:             * It has to be cloned first and then may be written back to the workplace settings using 
0840:             * method {@link #setFileViewSettings(CmsObject, org.opencms.util.CmsRfsFileViewer)}.<p>
0841:             * 
0842:             * @return the system-wide file view settings for the workplace
0843:             */
0844:            public CmsRfsFileViewer getFileViewSettings() {
0845:
0846:                return m_fileViewSettings;
0847:            }
0848:
0849:            /**
0850:             * Returns a collection of all available galleries.<p>
0851:             * 
0852:             * The Map has the gallery type name as key and an instance of the 
0853:             * gallery class (not completely initialized) as value.<p>
0854:             * 
0855:             * @return a collection of all available galleries
0856:             */
0857:            public Map getGalleries() {
0858:
0859:                return m_galleries;
0860:            }
0861:
0862:            /**
0863:             * @see org.opencms.i18n.I_CmsLocaleHandler#getI18nInfo(javax.servlet.http.HttpServletRequest, org.opencms.file.CmsUser, org.opencms.file.CmsProject, java.lang.String)
0864:             */
0865:            public CmsI18nInfo getI18nInfo(HttpServletRequest req,
0866:                    CmsUser user, CmsProject project, String resource) {
0867:
0868:                Locale locale = null;
0869:                // try to read locale from session
0870:                if (req != null) {
0871:                    // set the request character encoding
0872:                    try {
0873:                        req.setCharacterEncoding(m_encoding);
0874:                    } catch (UnsupportedEncodingException e) {
0875:                        // should not ever really happen
0876:                        LOG.error(Messages.get().getBundle().key(
0877:                                Messages.LOG_UNSUPPORTED_ENCODING_SET_1,
0878:                                m_encoding), e);
0879:                    }
0880:                    // read workplace settings
0881:                    HttpSession session = req.getSession(false);
0882:                    if (session != null) {
0883:                        CmsWorkplaceSettings settings = (CmsWorkplaceSettings) session
0884:                                .getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS);
0885:                        if (settings != null) {
0886:                            locale = settings.getUserSettings().getLocale();
0887:                        }
0888:                    }
0889:                }
0890:
0891:                if (locale == null) {
0892:                    // no session available, try to read the locale form the user additional info
0893:                    if (!user.isGuestUser()) {
0894:                        // check user settings only for "real" users
0895:                        CmsUserSettings settings = new CmsUserSettings(user);
0896:                        locale = settings.getLocale();
0897:
0898:                    }
0899:                    if (req != null) {
0900:                        List acceptedLocales = (new CmsAcceptLanguageHeaderParser(
0901:                                req, getDefaultLocale())).getAcceptedLocales();
0902:                        if ((locale != null)
0903:                                && (!acceptedLocales.contains(locale))) {
0904:                            acceptedLocales.add(0, locale);
0905:                        }
0906:                        locale = OpenCms.getLocaleManager()
0907:                                .getFirstMatchingLocale(acceptedLocales,
0908:                                        m_locales);
0909:                    }
0910:
0911:                    // if no locale was found, use the default
0912:                    if (locale == null) {
0913:                        locale = getDefaultLocale();
0914:                    }
0915:                }
0916:
0917:                return new CmsI18nInfo(locale, m_encoding);
0918:            }
0919:
0920:            /**
0921:             * Returns a list of site folders which generate labeled links.<p>
0922:             * 
0923:             * @return a list of site folders which generate labeled links
0924:             */
0925:            public List getLabelSiteFolders() {
0926:
0927:                return m_labelSiteFolders;
0928:            }
0929:
0930:            /**
0931:             * Returns the list of available workplace locales, sorted ascending.<p>
0932:             * 
0933:             * Please note: Be careful not to modify the returned Set as it is not a clone.<p>
0934:             * 
0935:             * @return the set of available workplace locales
0936:             */
0937:            public List getLocales() {
0938:
0939:                return m_locales;
0940:            }
0941:
0942:            /**
0943:             * Returns the configured list of localized workplace folders.<p>
0944:             * 
0945:             * @return the configured list of localized workplace folders
0946:             */
0947:            public List getLocalizedFolders() {
0948:
0949:                return m_localizedFolders;
0950:            }
0951:
0952:            /**
0953:             * Returns the menu rule set with the given name.<p>
0954:             * 
0955:             * If no rule set with the specified name is found, <code>null</code> is returned.<p>
0956:             * 
0957:             * @param ruleName the name of the rule set to get
0958:             * 
0959:             * @return the menu rule set with the given name
0960:             */
0961:            public CmsMenuRule getMenuRule(String ruleName) {
0962:
0963:                return (CmsMenuRule) m_menuRulesMap.get(ruleName);
0964:            }
0965:
0966:            /**
0967:             * Returns the configured menu rule sets.<p>
0968:             * 
0969:             * @return the configured menu rule sets
0970:             */
0971:            public List getMenuRules() {
0972:
0973:                return m_menuRules;
0974:            }
0975:
0976:            /**
0977:             * Returns the configured menu rule sets as Map.<p>
0978:             * 
0979:             * @return the configured menu rule sets as Map
0980:             */
0981:            public Map getMenuRulesMap() {
0982:
0983:                return m_menuRulesMap;
0984:            }
0985:
0986:            /**
0987:             * Returns the {@link CmsWorkplaceMessages} for the given locale.<p>
0988:             * 
0989:             * The workplace messages are a collection of resource bundles, containing the messages 
0990:             * for all OpenCms core bundles and of all initialized modules.<p>
0991:             * 
0992:             * Please note that the message objects are cached internally. 
0993:             * The returned message object should therefore never be modified directly in any way.<p>
0994:             * 
0995:             * @param locale the locale to get the messages for
0996:             * 
0997:             * @return the {@link CmsWorkplaceMessages} for the given locale
0998:             */
0999:            public CmsWorkplaceMessages getMessages(Locale locale) {
1000:
1001:                CmsWorkplaceMessages result = (CmsWorkplaceMessages) m_messages
1002:                        .get(locale);
1003:                if (result != null) {
1004:                    // messages have already been read
1005:                    return result;
1006:                }
1007:
1008:                // messages have not been read so far
1009:                synchronized (this ) {
1010:                    result = new CmsWorkplaceMessages(locale);
1011:                    m_messages.put(locale, result);
1012:                }
1013:                return result;
1014:            }
1015:
1016:            /**
1017:             * Returns the configured multi context menu to use in the Explorer view.<p>
1018:             * 
1019:             * @return the configured multi context menu to use in the Explorer view
1020:             */
1021:            public CmsExplorerContextMenu getMultiContextMenu() {
1022:
1023:                return m_multiContextMenu;
1024:            }
1025:
1026:            /**
1027:             * Returns the condition definition for the given resource type that is triggered before opening the editor.<p>
1028:             * 
1029:             * @param resourceType the resource type 
1030:             * 
1031:             * @return the condition definition for the given resource type class name or null if none is found
1032:             */
1033:            public I_CmsPreEditorActionDefinition getPreEditorConditionDefinition(
1034:                    I_CmsResourceType resourceType) {
1035:
1036:                Iterator i = m_preEditorConditionDefinitions.iterator();
1037:                I_CmsPreEditorActionDefinition result = null;
1038:                int matchResult = -1;
1039:                while (i.hasNext()) {
1040:                    I_CmsPreEditorActionDefinition currentDefinition = (I_CmsPreEditorActionDefinition) i
1041:                            .next();
1042:                    if (resourceType.getClass().isInstance(
1043:                            currentDefinition.getResourceType())) {
1044:                        // now determine the match count...
1045:                        int matchDistance = 0;
1046:                        Class super Class = resourceType.getClass();
1047:                        while (true) {
1048:                            // check if a super class is present
1049:                            if (super Class == null) {
1050:                                break;
1051:                            }
1052:                            if (super Class.getName().equals(
1053:                                    currentDefinition.getResourceType()
1054:                                            .getClass().getName())) {
1055:                                break;
1056:                            }
1057:                            matchDistance += 1;
1058:                            super Class = super Class.getSuperclass();
1059:                        }
1060:                        if (matchResult != -1) {
1061:                            if (matchDistance < matchResult) {
1062:                                matchResult = matchDistance;
1063:                                result = currentDefinition;
1064:                            }
1065:                        } else {
1066:                            matchResult = matchDistance;
1067:                            result = currentDefinition;
1068:                        }
1069:                    }
1070:                }
1071:                return result;
1072:            }
1073:
1074:            /**
1075:             * Returns the condition definitions for the different resource 
1076:             * types which are triggered before opening the editor.<p>
1077:             * 
1078:             * @return the condition definitions
1079:             */
1080:            public List getPreEditorConditionDefinitions() {
1081:
1082:                return m_preEditorConditionDefinitions;
1083:            }
1084:
1085:            /**
1086:             * Returns the id of the temporary file project required by the editors.<p>
1087:             * 
1088:             * @return the id of the temporary file project required by the editors
1089:             */
1090:            public CmsUUID getTempFileProjectId() {
1091:
1092:                if (m_tempFileProject != null) {
1093:                    return m_tempFileProject.getUuid();
1094:                } else {
1095:                    return null;
1096:                }
1097:            }
1098:
1099:            /**
1100:             * Returns the tool manager.<p>
1101:             * 
1102:             * @return the tool manager
1103:             */
1104:            public CmsToolManager getToolManager() {
1105:
1106:                if (m_toolManager == null) {
1107:                    m_toolManager = new CmsToolManager();
1108:                }
1109:                return m_toolManager;
1110:            }
1111:
1112:            /**
1113:             * Returns the user additional information configuration Manager.<p>
1114:             *
1115:             * @return the user additional information configuration manager
1116:             */
1117:            public CmsWorkplaceUserInfoManager getUserInfoManager() {
1118:
1119:                return m_userInfoManager;
1120:            }
1121:
1122:            /**
1123:             * Returns the map of configured workplace views.<p>
1124:             * 
1125:             * @return the map of configured workplace views
1126:             */
1127:            public List getViews() {
1128:
1129:                return m_views;
1130:            }
1131:
1132:            /**
1133:             * Returns the instantiated workplace editor manager class.<p>
1134:             * 
1135:             * @return the instantiated workplace editor manager class
1136:             */
1137:            public CmsWorkplaceEditorManager getWorkplaceEditorManager() {
1138:
1139:                return m_editorManager;
1140:            }
1141:
1142:            /**
1143:             * @see org.opencms.i18n.I_CmsLocaleHandler#initHandler(org.opencms.file.CmsObject)
1144:             */
1145:            public void initHandler(CmsObject cms) {
1146:
1147:                // initialize the workplace locale set
1148:                m_locales = initWorkplaceLocales(cms);
1149:            }
1150:
1151:            /**
1152:             * Initializes the workplace manager with the OpenCms system configuration.<p>
1153:             * 
1154:             * @param cms an OpenCms context object that must have been initialized with "Admin" permissions
1155:             * 
1156:             * @throws CmsRoleViolationException if the provided OpenCms user context does 
1157:             *      not have <code>{@link CmsRole#WORKPLACE_MANAGER}</code> role permissions
1158:             * @throws CmsException if something goes wrong
1159:             */
1160:            public synchronized void initialize(CmsObject cms)
1161:                    throws CmsException, CmsRoleViolationException {
1162:
1163:                try {
1164:                    // ensure that the current user has permissions to initialize the workplace
1165:                    OpenCms.getRoleManager().checkRole(cms,
1166:                            CmsRole.WORKPLACE_MANAGER);
1167:
1168:                    // set the workplace encoding
1169:                    try {
1170:                        // workplace encoding is set on the workplace parent folder /system/workplace/ 
1171:                        CmsResource wpFolderRes = cms
1172:                                .readResource(CmsWorkplace.VFS_PATH_WORKPLACE);
1173:                        m_encoding = CmsLocaleManager.getResourceEncoding(cms,
1174:                                wpFolderRes);
1175:                    } catch (CmsVfsResourceNotFoundException e) {
1176:                        // workplace parent folder could not be read - use configured default encoding
1177:                        m_encoding = OpenCms.getSystemInfo()
1178:                                .getDefaultEncoding();
1179:                    }
1180:
1181:                    // configure direct edit provider with default if not available
1182:                    if (m_directEditProvider == null) {
1183:                        m_directEditProvider = new CmsDirectEditDefaultProvider();
1184:                    }
1185:
1186:                    // throw away all currently configured module explorer types
1187:                    m_explorerTypeSettingsFromModules.clear();
1188:                    // now add the additional explorer types found in the modules
1189:                    CmsModuleManager moduleManager = OpenCms.getModuleManager();
1190:                    Iterator j = moduleManager.getModuleNames().iterator();
1191:                    while (j.hasNext()) {
1192:                        CmsModule module = moduleManager.getModule((String) j
1193:                                .next());
1194:                        if (module != null) {
1195:                            addExplorerTypeSettings(module);
1196:                        }
1197:                    }
1198:                    // initialize the menu rules
1199:                    initMenuRules();
1200:                    // initialize the explorer type settings
1201:                    initExplorerTypeSettings();
1202:                    // initialize the workplace views
1203:                    initWorkplaceViews(cms);
1204:                    // initialize the workplace editor manager
1205:                    m_editorManager = new CmsWorkplaceEditorManager(cms);
1206:                    // initialize the locale handler
1207:                    initHandler(cms);
1208:
1209:                    if (CmsLog.INIT.isInfoEnabled()) {
1210:                        CmsLog.INIT.info(Messages.get().getBundle().key(
1211:                                Messages.INIT_VFS_ACCESS_INITIALIZED_0));
1212:                    }
1213:                    try {
1214:                        // read the temporary file project
1215:                        m_tempFileProject = cms
1216:                                .readProject(I_CmsProjectDriver.TEMP_FILE_PROJECT_NAME);
1217:                    } catch (CmsException e) {
1218:                        // during initial setup of OpenCms the temp file project does not yet exist...
1219:                        LOG.error(Messages.get().getBundle().key(
1220:                                Messages.LOG_NO_TEMP_FILE_PROJECT_0));
1221:                    }
1222:                    // create an instance of editor display options
1223:                    m_editorDisplayOptions = new CmsEditorDisplayOptions();
1224:
1225:                    // throw away all current gallery settings
1226:                    m_galleries.clear();
1227:                    // read out the configured gallery classes
1228:                    j = OpenCms.getResourceManager().getResourceTypes()
1229:                            .iterator();
1230:                    while (j.hasNext()) {
1231:                        I_CmsResourceType resourceType = (I_CmsResourceType) j
1232:                                .next();
1233:                        if (resourceType instanceof  CmsResourceTypeFolderExtended) {
1234:                            // found a configured extended folder resource type
1235:                            CmsResourceTypeFolderExtended galleryType = (CmsResourceTypeFolderExtended) resourceType;
1236:                            String folderClassName = galleryType
1237:                                    .getFolderClassName();
1238:                            if (CmsStringUtil.isNotEmpty(folderClassName)) {
1239:                                // only process this as a gallery if the folder name is not empty
1240:                                try {
1241:                                    // check, if the folder class is a subclass of A_CmsGallery
1242:                                    if (A_CmsGallery.class
1243:                                            .isAssignableFrom(Class
1244:                                                    .forName(folderClassName))) {
1245:                                        // create gallery class instance
1246:                                        A_CmsGallery galleryInstance = (A_CmsGallery) Class
1247:                                                .forName(folderClassName)
1248:                                                .newInstance();
1249:                                        // set gallery folder resource type
1250:                                        galleryInstance
1251:                                                .setResourceType(galleryType);
1252:                                        // store the gallery class instance with the type name as lookup key
1253:                                        m_galleries
1254:                                                .put(galleryType.getTypeName(),
1255:                                                        galleryInstance);
1256:                                    }
1257:                                } catch (ClassNotFoundException e) {
1258:                                    LOG.error(e.getLocalizedMessage());
1259:                                } catch (InstantiationException e) {
1260:                                    LOG.error(e.getLocalizedMessage());
1261:                                } catch (IllegalAccessException e) {
1262:                                    LOG.error(e.getLocalizedMessage());
1263:                                }
1264:                            }
1265:                        }
1266:                    }
1267:
1268:                    // configures the tool manager
1269:                    getToolManager().configure(cms);
1270:
1271:                    // throw away all cached message objects
1272:                    m_messages = new HashMap();
1273:
1274:                    // register this object as event listener
1275:                    OpenCms
1276:                            .addCmsEventListener(
1277:                                    this ,
1278:                                    new int[] { I_CmsEventListener.EVENT_CLEAR_CACHES });
1279:                } catch (CmsException e) {
1280:                    if (LOG.isErrorEnabled()) {
1281:                        LOG.error(e.getLocalizedMessage(), e);
1282:                    }
1283:                    throw new CmsException(Messages.get().container(
1284:                            Messages.ERR_INITIALIZE_WORKPLACE_0));
1285:                }
1286:                m_adminCms = cms;
1287:            }
1288:
1289:            /**
1290:             * Returns the default property editing mode on resources.<p>
1291:             *
1292:             * @return the default property editing mode on resources
1293:             */
1294:            public boolean isDefaultPropertiesOnStructure() {
1295:
1296:                return m_defaultPropertiesOnStructure;
1297:            }
1298:
1299:            /**
1300:             * Returns if tabs in the advanced property dialog are enabled.<p>
1301:             *
1302:             * @return <code>true</code> if tabs should be enabled, otherwise <code>false</code>
1303:             */
1304:            public boolean isEnableAdvancedPropertyTabs() {
1305:
1306:                return m_enableAdvancedPropertyTabs;
1307:            }
1308:
1309:            /**
1310:             * Returns if XML content is automatically corrected when opened with the editor.<p>
1311:             * 
1312:             * @return <code>true</code> if XML content is automatically corrected when opened with the editor, otherwise <code>false</code>
1313:             */
1314:            public boolean isXmlContentAutoCorrect() {
1315:
1316:                return m_xmlContentAutoCorrect;
1317:            }
1318:
1319:            /** 
1320:             * Removes the list of explorer type settings from the given module.<p>
1321:             * 
1322:             * @param module the module witch contains the explorer type settings to remove
1323:             */
1324:            public void removeExplorerTypeSettings(CmsModule module) {
1325:
1326:                List explorerTypes = module.getExplorerTypes();
1327:                if ((explorerTypes != null) && (explorerTypes.size() > 0)) {
1328:                    Iterator i = explorerTypes.iterator();
1329:                    while (i.hasNext()) {
1330:                        CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings) i
1331:                                .next();
1332:                        if (m_explorerTypeSettingsFromModules
1333:                                .contains(settings)) {
1334:                            m_explorerTypeSettingsFromModules.remove(settings);
1335:                            if (CmsLog.INIT.isInfoEnabled()) {
1336:                                CmsLog.INIT
1337:                                        .info(Messages
1338:                                                .get()
1339:                                                .getBundle()
1340:                                                .key(
1341:                                                        Messages.INIT_REMOVE_EXPLORER_TYPE_SETTING_1,
1342:                                                        settings.getName()));
1343:                            }
1344:                        }
1345:                    }
1346:                    // reset the list of all explorer type settings
1347:                    initExplorerTypeSettings();
1348:                }
1349:            }
1350:
1351:            /**
1352:             * Sets if the autolock resources feature is enabled.<p>
1353:             * 
1354:             * @param value <code>"true"</code> if the autolock resources feature is enabled, otherwise false
1355:             */
1356:            public void setAutoLock(String value) {
1357:
1358:                m_autoLockResources = Boolean.valueOf(value).booleanValue();
1359:                if (CmsLog.INIT.isInfoEnabled()) {
1360:                    CmsLog.INIT
1361:                            .info(Messages
1362:                                    .get()
1363:                                    .getBundle()
1364:                                    .key(
1365:                                            m_autoLockResources ? Messages.INIT_AUTO_LOCK_ENABLED_0
1366:                                                    : Messages.INIT_AUTO_LOCK_DISABLED_0));
1367:                }
1368:            }
1369:
1370:            /**
1371:             * Sets the customized workplace foot.<p>
1372:             * 
1373:             * @param footCustom the customized workplace foot
1374:             */
1375:            public void setCustomFoot(CmsWorkplaceCustomFoot footCustom) {
1376:
1377:                m_customFoot = footCustom;
1378:            }
1379:
1380:            /**
1381:             * Sets the access object of the type settings.<p>
1382:             * 
1383:             * @param access access object
1384:             */
1385:            public void setDefaultAccess(CmsExplorerTypeAccess access) {
1386:
1387:                m_defaultAccess = access;
1388:            }
1389:
1390:            /**
1391:             * Sets the Workplace default locale.<p>
1392:             * 
1393:             * @param locale the locale to set
1394:             */
1395:            public void setDefaultLocale(String locale) {
1396:
1397:                try {
1398:                    m_defaultLocale = CmsLocaleManager.getLocale(locale);
1399:                } catch (Exception e) {
1400:                    if (CmsLog.INIT.isWarnEnabled()) {
1401:                        CmsLog.INIT.warn(Messages.get().getBundle().key(
1402:                                Messages.INIT_NONCRIT_ERROR_0), e);
1403:                    }
1404:                }
1405:                if (CmsLog.INIT.isInfoEnabled()) {
1406:                    CmsLog.INIT.info(Messages.get().getBundle().key(
1407:                            Messages.INIT_DEFAULT_LOCALE_1, m_defaultLocale));
1408:                }
1409:            }
1410:
1411:            /**
1412:             * Sets the default property editing mode on resources.<p>
1413:             *
1414:             * @param defaultPropertiesOnStructure the default property editing mode on resources
1415:             */
1416:            public void setDefaultPropertiesOnStructure(
1417:                    String defaultPropertiesOnStructure) {
1418:
1419:                m_defaultPropertiesOnStructure = Boolean.valueOf(
1420:                        defaultPropertiesOnStructure).booleanValue();
1421:                if (CmsLog.INIT.isInfoEnabled()) {
1422:                    CmsLog.INIT
1423:                            .info(Messages
1424:                                    .get()
1425:                                    .getBundle()
1426:                                    .key(
1427:                                            m_defaultPropertiesOnStructure ? Messages.INIT_PROP_ON_STRUCT_TRUE_0
1428:                                                    : Messages.INIT_PROP_ON_STRUCT_FALSE_0));
1429:                }
1430:            }
1431:
1432:            /**
1433:             * Sets the Workplace default user settings.<p>
1434:             * 
1435:             * @param defaultUserSettings the user settings to set
1436:             */
1437:            public void setDefaultUserSettings(
1438:                    CmsDefaultUserSettings defaultUserSettings) {
1439:
1440:                m_defaultUserSettings = defaultUserSettings;
1441:
1442:                if (CmsLog.INIT.isInfoEnabled()) {
1443:                    CmsLog.INIT.info(Messages.get().getBundle().key(
1444:                            Messages.INIT_DEFAULT_USER_SETTINGS_1,
1445:                            m_defaultUserSettings.getClass().getName()));
1446:                }
1447:            }
1448:
1449:            /**
1450:             * Sets the direct edit provider.<p>
1451:             * 
1452:             * @param clazz the direct edit provider to set
1453:             */
1454:            public void setDirectEditProvider(I_CmsDirectEditProvider clazz) {
1455:
1456:                m_directEditProvider = clazz;
1457:                if (CmsLog.INIT.isInfoEnabled()) {
1458:                    CmsLog.INIT.info(Messages.get().getBundle().key(
1459:                            Messages.INIT_DIRECT_EDIT_PROVIDER_1,
1460:                            m_directEditProvider.getClass().getName()));
1461:                }
1462:            }
1463:
1464:            /**
1465:             * Sets the editor action class.<p>
1466:             * 
1467:             * @param clazz the editor action class to set
1468:             */
1469:            public void setEditorAction(I_CmsEditorActionHandler clazz) {
1470:
1471:                m_editorAction = clazz;
1472:                if (CmsLog.INIT.isInfoEnabled()) {
1473:                    CmsLog.INIT.info(Messages.get().getBundle().key(
1474:                            Messages.INIT_EDITOR_ACTION_CLASS_1,
1475:                            m_editorAction.getClass().getName()));
1476:                }
1477:            }
1478:
1479:            /**
1480:             * Sets the editor display option class.<p>
1481:             * 
1482:             * @param clazz the editor display option class to set
1483:             */
1484:            public void setEditorDisplayOptions(CmsEditorDisplayOptions clazz) {
1485:
1486:                m_editorDisplayOptions = clazz;
1487:                if (CmsLog.INIT.isInfoEnabled()) {
1488:                    CmsLog.INIT.info(Messages.get().getBundle().key(
1489:                            Messages.INIT_EDITOR_DISPLAY_OPTS_1,
1490:                            m_editorAction.getClass().getName()));
1491:                }
1492:            }
1493:
1494:            /**
1495:             * Sets the editor handler class.<p>
1496:             * 
1497:             * @param clazz the editor handler class to set
1498:             */
1499:            public void setEditorHandler(I_CmsEditorHandler clazz) {
1500:
1501:                m_editorHandler = clazz;
1502:                if (CmsLog.INIT.isInfoEnabled()) {
1503:                    CmsLog.INIT.info(Messages.get().getBundle().key(
1504:                            Messages.INIT_EDITOR_HANDLER_CLASS_1,
1505:                            m_editorHandler.getClass().getName()));
1506:                }
1507:            }
1508:
1509:            /**
1510:             * Sets if tabs in the advanced property dialog are enabled.<p>
1511:             *
1512:             * @param enableAdvancedPropertyTabs true if tabs should be enabled, otherwise false
1513:             */
1514:            public void setEnableAdvancedPropertyTabs(
1515:                    String enableAdvancedPropertyTabs) {
1516:
1517:                m_enableAdvancedPropertyTabs = Boolean.valueOf(
1518:                        enableAdvancedPropertyTabs).booleanValue();
1519:                if (CmsLog.INIT.isInfoEnabled()) {
1520:                    CmsLog.INIT
1521:                            .info(Messages
1522:                                    .get()
1523:                                    .getBundle()
1524:                                    .key(
1525:                                            m_enableAdvancedPropertyTabs ? Messages.INIT_ADV_PROP_DIALOG_SHOW_TABS_0
1526:                                                    : Messages.INIT_ADV_PROP_DIALOG_HIDE_TABS_0));
1527:                }
1528:            }
1529:
1530:            /**
1531:             * Sets the value (in kb) for the maximum file upload size.<p>
1532:             * 
1533:             * @param value the value (in kb) for the maximum file upload size
1534:             */
1535:            public void setFileMaxUploadSize(String value) {
1536:
1537:                try {
1538:                    m_fileMaxUploadSize = Integer.valueOf(value).intValue();
1539:                } catch (NumberFormatException e) {
1540:                    // can usually be ignored
1541:                    if (LOG.isInfoEnabled()) {
1542:                        LOG.info(e.getLocalizedMessage());
1543:                    }
1544:                    m_fileMaxUploadSize = -1;
1545:                }
1546:                if (CmsLog.INIT.isInfoEnabled()) {
1547:                    if (m_fileMaxUploadSize > 0) {
1548:                        CmsLog.INIT.info(Messages.get().getBundle().key(
1549:                                Messages.INIT_MAX_FILE_UPLOAD_SIZE_1,
1550:                                new Integer(m_fileMaxUploadSize)));
1551:                    } else {
1552:                        CmsLog.INIT
1553:                                .info(Messages
1554:                                        .get()
1555:                                        .getBundle()
1556:                                        .key(
1557:                                                Messages.INIT_MAX_FILE_UPLOAD_SIZE_UNLIMITED_0));
1558:                    }
1559:
1560:                }
1561:            }
1562:
1563:            /**
1564:             * Sets the system-wide file view settings for the workplace.<p>
1565:             * 
1566:             * @param cms the CmsObject for ensuring security constraints. 
1567:             * 
1568:             * @param fileViewSettings the system-wide file view settings for the workplace to set 
1569:             * 
1570:             * @throws CmsRoleViolationException if the current user does not own the administrator role ({@link CmsRole#ROOT_ADMIN})  
1571:             * */
1572:            public void setFileViewSettings(CmsObject cms,
1573:                    CmsRfsFileViewer fileViewSettings)
1574:                    throws CmsRoleViolationException {
1575:
1576:                if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) {
1577:                    OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN);
1578:                }
1579:                m_fileViewSettings = fileViewSettings;
1580:                // disallow modifications of this "new original"
1581:                m_fileViewSettings.setFrozen(true);
1582:            }
1583:
1584:            /**
1585:             * Sets the configured multi context menu to use in the Explorer view.<p>
1586:             * 
1587:             * @param multiContextMenu the configured multi context menu to use in the Explorer view
1588:             */
1589:            public void setMultiContextMenu(
1590:                    CmsExplorerContextMenu multiContextMenu) {
1591:
1592:                multiContextMenu.setMultiMenu(true);
1593:                m_multiContextMenu = multiContextMenu;
1594:            }
1595:
1596:            /**
1597:             * Sets the tool Manager object.<p>
1598:             *
1599:             * @param toolManager the tool Manager object to set
1600:             */
1601:            public void setToolManager(CmsToolManager toolManager) {
1602:
1603:                m_toolManager = toolManager;
1604:            }
1605:
1606:            /**
1607:             * Sets the user additional information configuration manager.<p>
1608:             *
1609:             * @param userInfoManager the manager to set
1610:             */
1611:            public void setUserInfoManager(
1612:                    CmsWorkplaceUserInfoManager userInfoManager) {
1613:
1614:                m_userInfoManager = userInfoManager;
1615:            }
1616:
1617:            /**
1618:             * Controls if the user/group icon in the administration view should be shown.<p>
1619:             * 
1620:             * @param value <code>"true"</code> if the user/group icon in the administration view should be shown, otherwise false
1621:             */
1622:            public void setUserManagementEnabled(String value) {
1623:
1624:                m_showUserGroupIcon = Boolean.valueOf(value).booleanValue();
1625:                if (CmsLog.INIT.isInfoEnabled()) {
1626:                    if (m_showUserGroupIcon) {
1627:                        CmsLog.INIT.info(Messages.get().getBundle().key(
1628:                                Messages.INIT_USER_MANAGEMENT_ICON_ENABLED_0));
1629:                    } else {
1630:                        CmsLog.INIT.info(Messages.get().getBundle().key(
1631:                                Messages.INIT_USER_MANAGEMENT_ICON_DISABLED_0));
1632:                    }
1633:                }
1634:            }
1635:
1636:            /**
1637:             * Sets the auto correction of XML contents when they are opened with the editor.<p>
1638:             * 
1639:             * @param xmlContentAutoCorrect if "true", the content will be corrected without notification, otherwise a confirmation is needed
1640:             */
1641:            public void setXmlContentAutoCorrect(String xmlContentAutoCorrect) {
1642:
1643:                m_xmlContentAutoCorrect = Boolean
1644:                        .valueOf(xmlContentAutoCorrect).booleanValue();
1645:                if (CmsLog.INIT.isInfoEnabled()) {
1646:                    CmsLog.INIT
1647:                            .info(Messages
1648:                                    .get()
1649:                                    .getBundle()
1650:                                    .key(
1651:                                            m_xmlContentAutoCorrect ? Messages.INIT_XMLCONTENT_AUTOCORRECT_ENABLED_0
1652:                                                    : Messages.INIT_XMLCONTENT_AUTOCORRECT_DISABLED_0));
1653:                }
1654:            }
1655:
1656:            /**
1657:             * Returns if the user/group icon in the administration view should be shown.<p>
1658:             * 
1659:             * @return true if the user/group icon in the administration view should be shown, otherwise false
1660:             */
1661:            public boolean showUserGroupIcon() {
1662:
1663:                return m_showUserGroupIcon;
1664:            }
1665:
1666:            /**
1667:             * Creates a copy of the admin cms object which is initialize with the data of the current cms object.<p>
1668:             * 
1669:             * @param cms the current cms object
1670:             * @return the new admin cms object
1671:             * 
1672:             * @throws CmsException if something goes wrong
1673:             */
1674:            private CmsObject getAdminCms(CmsObject cms) throws CmsException {
1675:
1676:                CmsObject adminCms = OpenCms.initCmsObject(m_adminCms);
1677:                adminCms.getRequestContext().setSiteRoot(
1678:                        cms.getRequestContext().getSiteRoot());
1679:                adminCms.getRequestContext().setRequestTime(
1680:                        cms.getRequestContext().getRequestTime());
1681:                adminCms.getRequestContext().setCurrentProject(
1682:                        cms.getRequestContext().currentProject());
1683:                adminCms.getRequestContext().setEncoding(
1684:                        cms.getRequestContext().getEncoding());
1685:                adminCms.getRequestContext().setUri(
1686:                        cms.getRequestContext().getUri());
1687:                return adminCms;
1688:            }
1689:
1690:            /**
1691:             * Initializes the configured explorer type settings.<p>
1692:             */
1693:            private synchronized void initExplorerTypeSettings() {
1694:
1695:                Map explorerTypeSettingsMap = new HashMap();
1696:                List explorerTypeSettings = new ArrayList();
1697:
1698:                if (m_defaultAccess.getAccessControlList() == null) {
1699:                    try {
1700:                        // initialize the default access control configuration
1701:                        m_defaultAccess
1702:                                .createAccessControlList(CmsExplorerTypeAccess.PRINCIPAL_DEFAULT);
1703:                    } catch (CmsException e) {
1704:                        if (CmsLog.INIT.isInfoEnabled()) {
1705:                            CmsLog.INIT
1706:                                    .info(
1707:                                            Messages
1708:                                                    .get()
1709:                                                    .getBundle()
1710:                                                    .key(
1711:                                                            Messages.INIT_ADD_TYPE_SETTING_FAILED_1,
1712:                                                            CmsExplorerTypeAccess.PRINCIPAL_DEFAULT),
1713:                                            e);
1714:                        }
1715:                    }
1716:                }
1717:
1718:                explorerTypeSettings.addAll(m_explorerTypeSettingsFromXml);
1719:                explorerTypeSettings.addAll(m_explorerTypeSettingsFromModules);
1720:
1721:                for (int i = 0; i < explorerTypeSettings.size(); i++) {
1722:                    CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings) explorerTypeSettings
1723:                            .get(i);
1724:                    // put the settings in the lookup map
1725:                    explorerTypeSettingsMap.put(settings.getName(), settings);
1726:                    if (getDefaultAccess() == settings.getAccess()) {
1727:                        continue;
1728:                    }
1729:                    try {
1730:                        // initialize the access control configuration of the explorer type
1731:                        settings.getAccess().createAccessControlList(
1732:                                settings.getName());
1733:                    } catch (CmsException e) {
1734:                        if (CmsLog.INIT.isInfoEnabled()) {
1735:                            CmsLog.INIT.info(Messages.get().getBundle().key(
1736:                                    Messages.INIT_ADD_TYPE_SETTING_FAILED_1,
1737:                                    settings.getName()), e);
1738:                        }
1739:                    }
1740:                }
1741:                // sort the explorer type settings
1742:                Collections.sort(explorerTypeSettings);
1743:                // make the settings unmodifiable and store them in the global variables
1744:                m_explorerTypeSettings = Collections
1745:                        .unmodifiableList(explorerTypeSettings);
1746:                m_explorerTypeSettingsMap = Collections
1747:                        .unmodifiableMap(explorerTypeSettingsMap);
1748:            }
1749:
1750:            /**
1751:             * Initializes the configured menu rule sets.<p>
1752:             */
1753:            private void initMenuRules() {
1754:
1755:                Iterator i = m_menuRules.iterator();
1756:                while (i.hasNext()) {
1757:                    CmsMenuRule currentRule = (CmsMenuRule) i.next();
1758:                    // freeze the current rule set
1759:                    currentRule.freeze();
1760:                    // put the rule set to the Map with the name as key
1761:                    m_menuRulesMap.put(currentRule.getName(), currentRule);
1762:                }
1763:            }
1764:
1765:            /**
1766:             * Initializes the workplace locale set.<p>
1767:             * 
1768:             * Currently, this is defined by the existence of a special folder 
1769:             * <code>/system/workplace/locales/{locale-name}/</code>.
1770:             * This is likely to change in future implementations.<p>
1771:             * 
1772:             * @param cms an OpenCms context object that must have been initialized with "Admin" permissions
1773:             * 
1774:             * @return the workplace locale set
1775:             */
1776:            private List initWorkplaceLocales(CmsObject cms) {
1777:
1778:                Set locales = new HashSet();
1779:                List localeFolders;
1780:                try {
1781:                    localeFolders = cms
1782:                            .getSubFolders(CmsWorkplace.VFS_PATH_LOCALES);
1783:                } catch (CmsException e) {
1784:                    LOG.error(Messages.get().getBundle().key(
1785:                            Messages.LOG_WORKPLACE_INIT_NO_LOCALES_1,
1786:                            CmsWorkplace.VFS_PATH_LOCALES));
1787:                    // can not throw exception here since then OpenCms would not even start in shell mode (runlevel 2)
1788:                    localeFolders = new ArrayList();
1789:                }
1790:                Iterator i = localeFolders.iterator();
1791:                while (i.hasNext()) {
1792:                    CmsFolder folder = (CmsFolder) i.next();
1793:                    Locale locale = CmsLocaleManager
1794:                            .getLocale(folder.getName());
1795:                    // add locale
1796:                    locales.add(locale);
1797:                    // add less specialized locale
1798:                    locales.add(new Locale(locale.getLanguage(), locale
1799:                            .getCountry()));
1800:                    // add even less specialized locale            
1801:                    locales.add(new Locale(locale.getLanguage()));
1802:                }
1803:
1804:                // sort the result
1805:                ArrayList result = new ArrayList();
1806:                result.addAll(locales);
1807:                Collections.sort(result, CmsLocaleComparator.getComparator());
1808:                return result;
1809:            }
1810:
1811:            /**
1812:             * Initializes the available workplace views.<p>
1813:             * 
1814:             * Currently, this is defined by iterating the subfolder of the folder 
1815:             * <code>/system/workplace/views/</code>.
1816:             * These subfolders must have the properties NavPos, NavText and default-file set.<p>
1817:             * 
1818:             * @param cms an OpenCms context object that must have been initialized with "Admin" permissions
1819:             * @return the available workplace views
1820:             */
1821:            private List initWorkplaceViews(CmsObject cms) {
1822:
1823:                List viewFolders;
1824:                try {
1825:                    // get the subfolders of the "views" folder
1826:                    viewFolders = cms
1827:                            .getSubFolders(CmsWorkplace.VFS_PATH_VIEWS);
1828:                } catch (CmsException e) {
1829:                    if ((OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING)
1830:                            && LOG.isErrorEnabled()) {
1831:                        LOG.error(Messages.get().getBundle().key(
1832:                                Messages.LOG_WORKPLACE_INIT_NO_VIEWS_1,
1833:                                CmsWorkplace.VFS_PATH_VIEWS), e);
1834:                    }
1835:                    // can not throw exception here since then OpenCms would not even start in shell mode (runlevel 2)
1836:                    viewFolders = new ArrayList();
1837:                }
1838:                m_views = new ArrayList(viewFolders.size());
1839:                for (int i = 0; i < viewFolders.size(); i++) {
1840:                    // loop through all view folders
1841:                    CmsFolder folder = (CmsFolder) viewFolders.get(i);
1842:                    String folderPath = cms.getSitePath(folder);
1843:                    try {
1844:                        // get view information from folder properties
1845:                        String order = cms.readPropertyObject(folderPath,
1846:                                CmsPropertyDefinition.PROPERTY_NAVPOS, false)
1847:                                .getValue();
1848:                        String key = cms.readPropertyObject(folderPath,
1849:                                CmsPropertyDefinition.PROPERTY_NAVTEXT, false)
1850:                                .getValue();
1851:                        String viewUri = cms.readPropertyObject(folderPath,
1852:                                CmsPropertyDefinition.PROPERTY_DEFAULT_FILE,
1853:                                false).getValue();
1854:                        if (viewUri == null) {
1855:                            // no view URI found
1856:                            viewUri = folderPath;
1857:                        } else if (!viewUri.startsWith("/")) {
1858:                            // default file is in current view folder, create absolute path to view URI
1859:                            viewUri = folderPath + viewUri;
1860:                        }
1861:                        if (order == null) {
1862:                            // no valid NavPos property value found, use loop count as order value
1863:                            order = "" + i;
1864:                        }
1865:                        Float orderValue;
1866:                        try {
1867:                            // create Float order object
1868:                            orderValue = Float.valueOf(order);
1869:                        } catch (NumberFormatException e) {
1870:                            // String was not formatted correctly, use loop counter
1871:                            orderValue = Float.valueOf("" + i);
1872:                        }
1873:                        if (key == null) {
1874:                            // no language key found, use default String to avoid NullPointerException
1875:                            key = "View " + i;
1876:                            // if no navtext is given do not display the view
1877:                            continue;
1878:                        }
1879:                        // create new view object
1880:                        CmsWorkplaceView view = new CmsWorkplaceView(key,
1881:                                viewUri, orderValue);
1882:                        m_views.add(view);
1883:                        // log the view
1884:                        if (CmsLog.INIT.isInfoEnabled()) {
1885:                            CmsLog.INIT.info(Messages.get().getBundle().key(
1886:                                    Messages.INIT_WORKPLACE_VIEW_1,
1887:                                    view.getUri()));
1888:                        }
1889:                    } catch (CmsException e) {
1890:                        // should usually never happen
1891:                        LOG.error(Messages.get().getBundle().key(
1892:                                Messages.LOG_READING_VIEW_FOLDER_FAILED_1,
1893:                                folderPath), e);
1894:                    }
1895:                }
1896:                // sort the views by their order number
1897:                Collections.sort(m_views);
1898:                return m_views;
1899:            }
1900:
1901:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.