KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > CmsWorkplaceManager


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsWorkplaceManager.java,v $
3  * Date : $Date: 2006/10/26 12:25:34 $
4  * Version: $Revision: 1.77 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace;
33
34 import org.opencms.configuration.CmsDefaultUserSettings;
35 import org.opencms.db.CmsExportPoint;
36 import org.opencms.db.CmsUserSettings;
37 import org.opencms.db.I_CmsProjectDriver;
38 import org.opencms.file.CmsFolder;
39 import org.opencms.file.CmsObject;
40 import org.opencms.file.CmsProject;
41 import org.opencms.file.CmsPropertyDefinition;
42 import org.opencms.file.CmsUser;
43 import org.opencms.file.types.CmsResourceTypeFolderExtended;
44 import org.opencms.file.types.I_CmsResourceType;
45 import org.opencms.i18n.CmsAcceptLanguageHeaderParser;
46 import org.opencms.i18n.CmsEncoder;
47 import org.opencms.i18n.CmsI18nInfo;
48 import org.opencms.i18n.CmsLocaleComparator;
49 import org.opencms.i18n.CmsLocaleManager;
50 import org.opencms.i18n.I_CmsLocaleHandler;
51 import org.opencms.main.CmsEvent;
52 import org.opencms.main.CmsException;
53 import org.opencms.main.CmsLog;
54 import org.opencms.main.I_CmsEventListener;
55 import org.opencms.main.OpenCms;
56 import org.opencms.module.CmsModule;
57 import org.opencms.module.CmsModuleManager;
58 import org.opencms.security.CmsRole;
59 import org.opencms.security.CmsRoleViolationException;
60 import org.opencms.util.CmsRfsFileViewer;
61 import org.opencms.util.CmsStringUtil;
62 import org.opencms.workplace.editors.CmsEditorDisplayOptions;
63 import org.opencms.workplace.editors.CmsEditorHandler;
64 import org.opencms.workplace.editors.CmsWorkplaceEditorManager;
65 import org.opencms.workplace.editors.I_CmsEditorActionHandler;
66 import org.opencms.workplace.editors.I_CmsEditorHandler;
67 import org.opencms.workplace.editors.directedit.CmsDirectEditDefaultProvider;
68 import org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider;
69 import org.opencms.workplace.explorer.CmsExplorerContextMenu;
70 import org.opencms.workplace.explorer.CmsExplorerTypeAccess;
71 import org.opencms.workplace.explorer.CmsExplorerTypeSettings;
72 import org.opencms.workplace.galleries.A_CmsGallery;
73 import org.opencms.workplace.tools.CmsToolManager;
74
75 import java.io.UnsupportedEncodingException JavaDoc;
76 import java.util.ArrayList JavaDoc;
77 import java.util.Collections JavaDoc;
78 import java.util.HashMap JavaDoc;
79 import java.util.HashSet JavaDoc;
80 import java.util.Iterator JavaDoc;
81 import java.util.List JavaDoc;
82 import java.util.Locale JavaDoc;
83 import java.util.Map JavaDoc;
84 import java.util.Set JavaDoc;
85
86 import javax.servlet.http.HttpServletRequest JavaDoc;
87 import javax.servlet.http.HttpSession JavaDoc;
88
89 import org.apache.commons.logging.Log;
90
91 /**
92  * Manages the global OpenCms workplace settings for all users.<p>
93  *
94  * This class reads the settings from the "opencms.properties" and stores them in member variables.
95  * For each setting one or more get methods are provided.<p>
96  *
97  * @author Andreas Zahner
98  *
99  * @version $Revision: 1.77 $
100  *
101  * @since 6.0.0
102  */

103 public final class CmsWorkplaceManager implements I_CmsLocaleHandler, I_CmsEventListener {
104
105     /** The default encoding for the workplace (UTF-8). */
106     public static final String JavaDoc DEFAULT_WORKPLACE_ENCODING = CmsEncoder.ENCODING_UTF_8;
107
108     /** The id of the "requestedResource" parameter for the OpenCms login form. */
109     public static final String JavaDoc PARAM_LOGIN_REQUESTED_RESOURCE = "requestedResource";
110
111     /** Key name for the session workplace settings. */
112     public static final String JavaDoc SESSION_WORKPLACE_SETTINGS = "__CmsWorkplace.WORKPLACE_SETTINGS";
113
114     /** The log object for this class. */
115     private static final Log LOG = CmsLog.getLog(CmsWorkplaceManager.class);
116
117     /** Indicates if auto-locking of resources is enabled or disabled. */
118     private boolean m_autoLockResources;
119
120     /** The default acces for explorer types. */
121     private CmsExplorerTypeAccess m_defaultAccess;
122
123     /** The configured default locale of the workplace. */
124     private Locale JavaDoc m_defaultLocale;
125
126     /** The default property setting for setting new property values. */
127     private boolean m_defaultPropertiesOnStructure;
128
129     /** The default user seetings. */
130     private CmsDefaultUserSettings m_defaultUserSettings;
131
132     /** The configured dialog handlers. */
133     private Map JavaDoc m_dialogHandler;
134
135     /** The configured direct edit provider. */
136     private I_CmsDirectEditProvider m_directEditProvider;
137
138     /** The edit action handler. */
139     private I_CmsEditorActionHandler m_editorAction;
140
141     /** The workplace editor display options. */
142     private CmsEditorDisplayOptions m_editorDisplayOptions;
143
144     /** The editor handler. */
145     private I_CmsEditorHandler m_editorHandler;
146
147     /** The editor manager. */
148     private CmsWorkplaceEditorManager m_editorManager;
149
150     /** The flag if switching tabs in the advanced property dialog is enabled. */
151     private boolean m_enableAdvancedPropertyTabs;
152
153     /** The configured encoding of the workplace. */
154     private String JavaDoc m_encoding;
155
156     /** The explorer type settings. */
157     private List JavaDoc m_explorerTypeSettings;
158
159     /** The explorer type settings from the configured modules. */
160     private List JavaDoc m_explorerTypeSettingsFromModules;
161
162     /** The explorer type settings from the XML configuration. */
163     private List JavaDoc m_explorerTypeSettingsFromXml;
164
165     /** The explorer type settings as Map with resource type name as key. */
166     private Map JavaDoc m_explorerTypeSettingsMap;
167
168     /** The workplace export points. */
169     private Set JavaDoc m_exportPoints;
170
171     /** Maximum size of an upload file. */
172     private int m_fileMaxUploadSize;
173
174     /** The instance used for reading portions of lines of a file to choose. */
175     private CmsRfsFileViewer m_fileViewSettings;
176
177     /** The configured workplace galleries. */
178     private Map JavaDoc m_galleries;
179
180     /** Contains all folders that should be labled if siblings exist. */
181     private List JavaDoc m_labelSiteFolders;
182
183     /** List of installed workplace locales, soreted ascending. */
184     private List JavaDoc m_locales;
185
186     /** The configured list of localized workplace folders. */
187     private List JavaDoc m_localizedFolders;
188
189     /** The workplace localized messages (mapped to the locales). */
190     private Map JavaDoc m_messages;
191
192     /** The configured multi context menu. */
193     private CmsExplorerContextMenu m_multiContextMenu;
194
195     /** Indicates if the user managemet icon should be displayed in the workplace. */
196     private boolean m_showUserGroupIcon;
197
198     /** The temporary file project used by the editors. */
199     private CmsProject m_tempFileProject;
200
201     /** The tool manager. */
202     private CmsToolManager m_toolManager;
203
204     /** The configured workplace views. */
205     private List JavaDoc m_views;
206
207     /** The workflow settings. */
208     private boolean m_workflowMessage;
209
210     /**
211      * Creates a new instance for the workplace manager, will be called by the workplace configuration manager.<p>
212      */

213     public CmsWorkplaceManager() {
214
215         if (CmsLog.INIT.isInfoEnabled()) {
216             CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_INITIALIZE_START_0));
217         }
218         m_locales = new ArrayList JavaDoc();
219         m_labelSiteFolders = new ArrayList JavaDoc();
220         m_localizedFolders = new ArrayList JavaDoc();
221         m_autoLockResources = true;
222         m_showUserGroupIcon = true;
223         m_dialogHandler = new HashMap JavaDoc();
224         m_views = new ArrayList JavaDoc();
225         m_exportPoints = new HashSet JavaDoc();
226         m_editorHandler = new CmsEditorHandler();
227         m_fileMaxUploadSize = -1;
228         m_fileViewSettings = new CmsRfsFileViewer();
229         m_explorerTypeSettingsFromXml = new ArrayList JavaDoc();
230         m_explorerTypeSettingsFromModules = new ArrayList JavaDoc();
231         m_defaultPropertiesOnStructure = true;
232         m_enableAdvancedPropertyTabs = true;
233         m_defaultUserSettings = new CmsDefaultUserSettings();
234         m_defaultAccess = new CmsExplorerTypeAccess();
235         m_galleries = new HashMap JavaDoc();
236         m_messages = new HashMap JavaDoc();
237         m_workflowMessage = false;
238         m_multiContextMenu = new CmsExplorerContextMenu();
239         m_multiContextMenu.setMultiMenu(true);
240
241         // important to set this to null to avoid unneccessary overhead during configuration phase
242
m_explorerTypeSettings = null;
243     }
244
245     /**
246      * Returns true if the provided request was done by a Workplace user.<p>
247      *
248      * @param req the request to check
249      * @return true if the provided request was done by a Workplace user
250      */

251     public static boolean isWorkplaceUser(HttpServletRequest JavaDoc req) {
252
253         HttpSession JavaDoc session = req.getSession(false);
254         if (session != null) {
255             // if a session is available, check for a workplace configuration
256
return null != session.getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS);
257         }
258         // no session means no workplace use
259
return false;
260     }
261
262     /**
263      * Adds a dialog handler instance to the list of configured dialog handlers.<p>
264      *
265      * @param clazz the instanciated dialog handler to add
266      */

267     public void addDialogHandler(I_CmsDialogHandler clazz) {
268
269         m_dialogHandler.put(clazz.getDialogHandler(), clazz);
270         if (CmsLog.INIT.isInfoEnabled()) {
271             CmsLog.INIT.info(Messages.get().getBundle().key(
272                 Messages.INIT_ADD_DIALOG_HANDLER_2,
273                 clazz.getDialogHandler(),
274                 clazz.getClass().getName()));
275         }
276     }
277
278     /**
279      * Adds an explorer type setting object to the list of type settings.<p>
280      *
281      * @param settings the explorer type settings
282      */

283     public void addExplorerTypeSetting(CmsExplorerTypeSettings settings) {
284
285         m_explorerTypeSettingsFromXml.add(settings);
286         if (CmsLog.INIT.isInfoEnabled()) {
287             CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_ADD_TYPE_SETTING_1, settings.getName()));
288         }
289         if (m_explorerTypeSettings != null) {
290             // reset the list of all explorer type settings, but not during startup
291
initExplorerTypeSettings();
292         }
293     }
294
295     /**
296      * Adds the list of explorer type settings from the given module.<p>
297      *
298      * @param module the module witch contains the explorer type settings to add
299      */

300     public void addExplorerTypeSettings(CmsModule module) {
301
302         List JavaDoc explorerTypes = module.getExplorerTypes();
303         if ((explorerTypes != null) && (explorerTypes.size() > 0)) {
304             Iterator JavaDoc i = explorerTypes.iterator();
305             while (i.hasNext()) {
306                 CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings)i.next();
307                 m_explorerTypeSettingsFromModules.add(settings);
308                 if (CmsLog.INIT.isInfoEnabled()) {
309                     CmsLog.INIT.info(Messages.get().getBundle().key(
310                         Messages.INIT_ADD_TYPE_SETTING_1,
311                         settings.getName()));
312                 }
313             }
314             // reset the list of all explorer type settings
315
initExplorerTypeSettings();
316         }
317     }
318
319     /**
320      * Adds newly created export point to the workplace configuration.<p>
321      *
322      * @param uri the export point uri
323      * @param destination the export point destination
324      */

325     public void addExportPoint(String JavaDoc uri, String JavaDoc destination) {
326
327         CmsExportPoint point = new CmsExportPoint(uri, destination);
328         m_exportPoints.add(point);
329         if (CmsLog.INIT.isInfoEnabled() && (point.getDestinationPath() != null)) {
330             CmsLog.INIT.info(Messages.get().getBundle().key(
331                 Messages.INIT_ADD_EXPORT_POINT_2,
332                 point.getUri(),
333                 point.getDestinationPath()));
334         }
335     }
336
337     /**
338      * Adds a folder to the list of labeled folders.<p>
339      *
340      * @param uri the folder uri to add
341      */

342     public void addLabeledFolder(String JavaDoc uri) {
343
344         m_labelSiteFolders.add(uri);
345         if (CmsLog.INIT.isInfoEnabled()) {
346             CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_LABEL_LINKS_IN_FOLDER_1, uri));
347         }
348     }
349
350     /**
351      * Adds a new folder to the list of localized workplace folders.<p>
352      *
353      * @param uri a new folder to add to the list of localized workplace folders
354      */

355     public void addLocalizedFolder(String JavaDoc uri) {
356
357         m_localizedFolders.add(uri);
358         if (CmsLog.INIT.isInfoEnabled()) {
359             CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_LOCALIZED_1, uri));
360         }
361     }
362
363     /**
364      * Returns if the autolock resources feature is enabled.<p>
365      *
366      * @return true if the autolock resources feature is enabled, otherwise false
367      */

368     public boolean autoLockResources() {
369
370         return m_autoLockResources;
371     }
372
373     /**
374      * Implements the event listener of this class.<p>
375      *
376      * @see org.opencms.main.I_CmsEventListener#cmsEvent(org.opencms.main.CmsEvent)
377      */

378     public void cmsEvent(CmsEvent event) {
379
380         switch (event.getType()) {
381             case I_CmsEventListener.EVENT_CLEAR_CACHES:
382                 // clear the cached message objects
383
m_messages = new HashMap JavaDoc();
384                 if (LOG.isDebugEnabled()) {
385                     LOG.debug(Messages.get().getBundle().key(Messages.LOG_EVENT_CLEAR_CACHES_0));
386                 }
387                 break;
388             default: // no operation
389
}
390     }
391
392     /**
393      * Gets the access object of the type settings.<p>
394      *
395      * @return access object of the type settings
396      */

397     public CmsExplorerTypeAccess getDefaultAccess() {
398
399         return m_defaultAccess;
400     }
401
402     /**
403      * Returns the Workplace default locale.<p>
404      *
405      * @return the Workplace default locale
406      */

407     public Locale JavaDoc getDefaultLocale() {
408
409         return m_defaultLocale;
410     }
411
412     /**
413      * Returns the Workplace default user settings.<p>
414      *
415      * @return the Workplace default user settings
416      */

417     public CmsDefaultUserSettings getDefaultUserSettings() {
418
419         return m_defaultUserSettings;
420     }
421
422     /**
423      * Returns all instanciated dialog handlers for the workplace.<p>
424      *
425      * @return all instanciated dialog handlers for the workplace
426      */

427     public Map JavaDoc getDialogHandler() {
428
429         return m_dialogHandler;
430     }
431
432     /**
433      * Returns the instanciated dialog handler class for the key or null, if there is no mapping for the key.<p>
434      *
435      * @param key the key whose associated value is to be returned
436      * @return the instanciated dialog handler class for the key
437      */

438     public Object JavaDoc getDialogHandler(String JavaDoc key) {
439
440         return m_dialogHandler.get(key);
441     }
442
443     /**
444      * Returns a new instance of the configured direct edit provider.<p>
445      *
446      * @return a new instance of the configured direct edit provider
447      */

448     public I_CmsDirectEditProvider getDirectEditProvider() {
449
450         return m_directEditProvider.newInstance();
451     }
452
453     /**
454      * Returns the instanciated editor action handler class.<p>
455      *
456      * @return the instanciated editor action handler class
457      */

458     public I_CmsEditorActionHandler getEditorActionHandler() {
459
460         return m_editorAction;
461     }
462
463     /**
464      * Returns the instanciated editor display option class.<p>
465      *
466      * @return the instanciated editor display option class
467      */

468     public CmsEditorDisplayOptions getEditorDisplayOptions() {
469
470         return m_editorDisplayOptions;
471     }
472
473     /**
474      * Returns the instanciated editor handler class.<p>
475      *
476      * @return the instanciated editor handler class
477      */

478     public I_CmsEditorHandler getEditorHandler() {
479
480         return m_editorHandler;
481     }
482
483     /**
484      * Returns the configured workplace encoding.<p>
485      *
486      * @return the configured workplace encoding
487      */

488     public String JavaDoc getEncoding() {
489
490         return m_encoding;
491     }
492
493     /**
494      * Returns the explorer type settings for the specified resource type.<p>
495      *
496      * @param type the resource type for which the settings are required
497      * @return the explorer type settings for the specified resource type
498      */

499     public CmsExplorerTypeSettings getExplorerTypeSetting(String JavaDoc type) {
500
501         return (CmsExplorerTypeSettings)m_explorerTypeSettingsMap.get(type);
502     }
503
504     /**
505      * Returns the list of explorer type settings.<p>
506      *
507      * These settings provide information for the new resource dialog and the context menu appearance.<p>
508      *
509      * @return the list of explorer type settings
510      */

511     public List JavaDoc getExplorerTypeSettings() {
512
513         if (m_explorerTypeSettings == null) {
514             // initialize all explorer type settings if not already done
515
initExplorerTypeSettings();
516         }
517
518         return m_explorerTypeSettings;
519     }
520
521     /**
522      * Returns the set of configured export points for the workplace.<p>
523      *
524      * @return the set of configured export points for the workplace
525      */

526     public Set JavaDoc getExportPoints() {
527
528         return m_exportPoints;
529     }
530
531     /**
532      * Returns the value (in bytes) for the maximum file upload size of the current user.<p>
533      *
534      * @param cms the initialized CmsObject
535      * @return the value (in bytes) for the maximum file upload size
536      */

537     public long getFileBytesMaxUploadSize(CmsObject cms) {
538
539         int maxFileSize = getFileMaxUploadSize();
540         long maxFileSizeBytes = maxFileSize * 1024;
541         // check if current user belongs to Admin group, if so no file upload limit
542
if ((maxFileSize <= 0) || cms.hasRole(CmsRole.VFS_MANAGER)) {
543             maxFileSizeBytes = -1;
544         }
545         return maxFileSizeBytes;
546     }
547
548     /**
549      * Returns the value (in kb) for the maximum file upload size.<p>
550      *
551      * @return the value (in kb) for the maximum file upload size
552      */

553     public int getFileMaxUploadSize() {
554
555         return m_fileMaxUploadSize;
556     }
557
558     /**
559      * Returns the system-wide file view settings for the workplace.<p>
560      *
561      * Note that this instance may not modified (invocation of setters) directly or a
562      * <code>{@link org.opencms.main.CmsRuntimeException}</code> will be thrown.
563      * It has to be cloned first and then may be written back to the workplace settings using
564      * method {@link #setFileViewSettings(CmsObject, org.opencms.util.CmsRfsFileViewer)}.
565      *
566      * @return the system-wide file view settings for the workplace
567      */

568     public CmsRfsFileViewer getFileViewSettings() {
569
570         return m_fileViewSettings;
571     }
572
573     /**
574      * Returns a collection of all available galleries.<p>
575      *
576      * The Map has the gallery type name as key and an instance of the gallery class (not completely initialized) as value.<p>
577      *
578      * @return a collection of all available galleries
579      */

580     public Map JavaDoc getGalleries() {
581
582         return m_galleries;
583     }
584
585     /**
586      * @see org.opencms.i18n.I_CmsLocaleHandler#getI18nInfo(javax.servlet.http.HttpServletRequest, org.opencms.file.CmsUser, org.opencms.file.CmsProject, java.lang.String)
587      */

588     public CmsI18nInfo getI18nInfo(HttpServletRequest JavaDoc req, CmsUser user, CmsProject project, String JavaDoc resource) {
589
590         Locale JavaDoc locale = null;
591         // try to read locale from session
592
if (req != null) {
593             // set the request character encoding
594
try {
595                 req.setCharacterEncoding(m_encoding);
596             } catch (UnsupportedEncodingException JavaDoc e) {
597                 // should not ever really happen
598
LOG.error(Messages.get().getBundle().key(Messages.LOG_UNSUPPORTED_ENCODING_SET_1, m_encoding), e);
599             }
600             // read workplace settings
601
HttpSession JavaDoc session = req.getSession(false);
602             if (session != null) {
603                 CmsWorkplaceSettings settings = (CmsWorkplaceSettings)session.getAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS);
604                 if (settings != null) {
605                     locale = settings.getUserSettings().getLocale();
606                 }
607             }
608         }
609
610         if (locale == null) {
611             // no session available, try to read the locale form the user additional info
612
if (!user.isGuestUser()) {
613                 // check user settings only for "real" users
614
CmsUserSettings settings = new CmsUserSettings(user);
615                 locale = settings.getLocale();
616
617             }
618             if (req != null) {
619                 List JavaDoc acceptedLocales = (new CmsAcceptLanguageHeaderParser(req, getDefaultLocale())).getAcceptedLocales();
620                 if ((locale != null) && (!acceptedLocales.contains(locale))) {
621                     acceptedLocales.add(0, locale);
622                 }
623                 locale = OpenCms.getLocaleManager().getFirstMatchingLocale(acceptedLocales, m_locales);
624             }
625
626             // if no locale was found, use the default
627
if (locale == null) {
628                 locale = getDefaultLocale();
629             }
630         }
631
632         return new CmsI18nInfo(locale, m_encoding);
633     }
634
635     /**
636      * Returns a list of site folders which generate labeled links.<p>
637      *
638      * @return a list of site folders which generate labeled links
639      */

640     public List JavaDoc getLabelSiteFolders() {
641
642         return m_labelSiteFolders;
643     }
644
645     /**
646      * Returns the list of available workplace locales, sorted ascending.<p>
647      *
648      * Please note: Be careful not to modify the returned Set as it is not a clone.<p>
649      *
650      * @return the set of available workplace locales
651      */

652     public List JavaDoc getLocales() {
653
654         return m_locales;
655     }
656
657     /**
658      * Returns the configured list of localized workplace folders.<p>
659      *
660      * @return the configured list of localized workplace folders
661      */

662     public List JavaDoc getLocalizedFolders() {
663
664         return m_localizedFolders;
665     }
666
667     /**
668      * Returns the {@link CmsWorkplaceMessages} for the given locale.<p>
669      *
670      * The workplace messages are a collection of resource bundles, containing the messages
671      * for all OpenCms core bundles and of all initialized modules.<p>
672      *
673      * Please note that the message objects are cached internally.
674      * The returned message object should therefore never be modified directly in any way.<p>
675      *
676      * @param locale the locale to get the messages for
677      *
678      * @return the {@link CmsWorkplaceMessages} for the given locale
679      */

680     public CmsWorkplaceMessages getMessages(Locale JavaDoc locale) {
681
682         CmsWorkplaceMessages result = (CmsWorkplaceMessages)m_messages.get(locale);
683         if (result != null) {
684             // messages have already been read
685
return result;
686         }
687
688         // messages have not been read so far
689
synchronized (this) {
690             result = new CmsWorkplaceMessages(locale);
691             m_messages.put(locale, result);
692         }
693         return result;
694     }
695
696     /**
697      * Returns the configured multi context menu to use in the Explorer view.<p>
698      *
699      * @return the configured multi context menu to use in the Explorer view
700      */

701     public CmsExplorerContextMenu getMultiContextMenu() {
702
703         return m_multiContextMenu;
704     }
705
706     /**
707      * Returns the id of the temporary file project required by the editors.<p>
708      *
709      * @return the id of the temporary file project required by the editors
710      */

711     public int getTempFileProjectId() {
712
713         if (m_tempFileProject != null) {
714             return m_tempFileProject.getId();
715         } else {
716             return -1;
717         }
718     }
719
720     /**
721      * Returns the tool manager.<p>
722      *
723      * @return the tool manager
724      */

725     public CmsToolManager getToolManager() {
726
727         if (m_toolManager == null) {
728             m_toolManager = new CmsToolManager();
729         }
730         return m_toolManager;
731     }
732
733     /**
734      * Returns the map of configured workplace views.<p>
735      *
736      * @return the map of configured workplace views
737      */

738     public List JavaDoc getViews() {
739
740         return m_views;
741     }
742
743     /**
744      * Returns the instanciated workplace editor manager class.<p>
745      *
746      * @return the instanciated workplace editor manager class
747      */

748     public CmsWorkplaceEditorManager getWorkplaceEditorManager() {
749
750         return m_editorManager;
751     }
752
753     /**
754      * @see org.opencms.i18n.I_CmsLocaleHandler#initHandler(org.opencms.file.CmsObject)
755      */

756     public void initHandler(CmsObject cms) {
757
758         // initialize the workplace locale set
759
m_locales = initWorkplaceLocales(cms);
760     }
761
762     /**
763      * Initializes the workplace manager with the OpenCms system configuration.<p>
764      *
765      * @param cms an OpenCms context object that must have been initialized with "Admin" permissions
766      *
767      * @throws CmsRoleViolationException if the provided OpenCms user context does
768      * not have <code>{@link CmsRole#WORKPLACE_MANAGER}</code> role permissions
769      * @throws CmsException if something goes wrong
770      */

771     public synchronized void initialize(CmsObject cms) throws CmsException, CmsRoleViolationException {
772
773         try {
774             // ensure that the current user has permissions to initialize the workplace
775
cms.checkRole(CmsRole.WORKPLACE_MANAGER);
776
777             // set the workplace encoding
778
m_encoding = OpenCms.getSystemInfo().getDefaultEncoding();
779
780             // configure direct edit provider with default if not available
781
if (m_directEditProvider == null) {
782                 m_directEditProvider = new CmsDirectEditDefaultProvider();
783             }
784
785             // throw away all currently configured module explorer types
786
m_explorerTypeSettingsFromModules.clear();
787             // now add the additional explorer types found in the modules
788
CmsModuleManager moduleManager = OpenCms.getModuleManager();
789             Iterator JavaDoc j = moduleManager.getModuleNames().iterator();
790             while (j.hasNext()) {
791                 CmsModule module = moduleManager.getModule((String JavaDoc)j.next());
792                 if (module != null) {
793                     addExplorerTypeSettings(module);
794                 }
795             }
796             // initialize the explorer type settings
797
initExplorerTypeSettings();
798             // initialize the workplace views
799
initWorkplaceViews(cms);
800             // initialize the workplace editor manager
801
m_editorManager = new CmsWorkplaceEditorManager(cms);
802             // initialize the locale handler
803
initHandler(cms);
804
805             if (CmsLog.INIT.isInfoEnabled()) {
806                 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_VFS_ACCESS_INITIALIZED_0));
807             }
808             try {
809                 // read the temporary file project
810
m_tempFileProject = cms.readProject(I_CmsProjectDriver.TEMP_FILE_PROJECT_NAME);
811             } catch (CmsException e) {
812                 // during initial setup of OpenCms the temp file project does not yet exist...
813
LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_TEMP_FILE_PROJECT_0));
814             }
815             // create an instance of editor display options
816
m_editorDisplayOptions = new CmsEditorDisplayOptions();
817
818             // throw away all current gallery settings
819
m_galleries.clear();
820             // read out the configured gallery classes
821
j = OpenCms.getResourceManager().getResourceTypes().iterator();
822             while (j.hasNext()) {
823                 I_CmsResourceType resourceType = (I_CmsResourceType)j.next();
824                 if (resourceType instanceof CmsResourceTypeFolderExtended) {
825                     // found a configured extended folder resource type
826
CmsResourceTypeFolderExtended galleryType = (CmsResourceTypeFolderExtended)resourceType;
827                     String JavaDoc folderClassName = galleryType.getFolderClassName();
828                     if (CmsStringUtil.isNotEmpty(folderClassName)) {
829                         // only process this as a gallery if the folder name is not empty
830
try {
831                             // check, if the folder class is a subclass of A_CmsGallery
832
if (A_CmsGallery.class.isAssignableFrom(Class.forName(folderClassName))) {
833                                 // create gallery class instance
834
A_CmsGallery galleryInstance = (A_CmsGallery)Class.forName(folderClassName).newInstance();
835                                 // set gallery folder resource type
836
galleryInstance.setResourceType(galleryType);
837                                 // store the gallery class instance with the type name as lookup key
838
m_galleries.put(galleryType.getTypeName(), galleryInstance);
839                             }
840                         } catch (ClassNotFoundException JavaDoc e) {
841                             LOG.error(e.getLocalizedMessage());
842                         } catch (InstantiationException JavaDoc e) {
843                             LOG.error(e.getLocalizedMessage());
844                         } catch (IllegalAccessException JavaDoc e) {
845                             LOG.error(e.getLocalizedMessage());
846                         }
847                     }
848                 }
849             }
850
851             // configures the tool manager
852
getToolManager().configure(cms);
853
854             // throw away all cached message objects
855
m_messages = new HashMap JavaDoc();
856
857             // register this object as event listener
858
OpenCms.addCmsEventListener(this, new int[] {I_CmsEventListener.EVENT_CLEAR_CACHES});
859
860         } catch (CmsException e) {
861             throw new CmsException(Messages.get().container(Messages.ERR_INITIALIZE_WORKPLACE_0));
862         }
863     }
864
865     /**
866      * Returns the default property editing mode on resources.<p>
867      *
868      * @return the default property editing mode on resources
869      */

870     public boolean isDefaultPropertiesOnStructure() {
871
872         return m_defaultPropertiesOnStructure;
873     }
874
875     /**
876      * Returns if tabs in the advanced property dialog are enabled.<p>
877      *
878      * @return true if tabs should be enabled, otherwise false
879      */

880     public boolean isEnableAdvancedPropertyTabs() {
881
882         return m_enableAdvancedPropertyTabs;
883     }
884
885     /**
886      * Returns if messages should be includes in workflow mails.<p>
887      *
888      * @return true if messages should be includes, otherwise false
889      */

890     public boolean isEnableWorkflowMessages() {
891
892         return m_workflowMessage;
893     }
894
895     /**
896      * Removes the list of explorer type settings from the given module.<p>
897      *
898      * @param module the module witch contains the explorer type settings to remove
899      */

900     public void removeExplorerTypeSettings(CmsModule module) {
901
902         List JavaDoc explorerTypes = module.getExplorerTypes();
903         if ((explorerTypes != null) && (explorerTypes.size() > 0)) {
904             Iterator JavaDoc i = explorerTypes.iterator();
905             while (i.hasNext()) {
906                 CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings)i.next();
907                 if (m_explorerTypeSettingsFromModules.contains(settings)) {
908                     m_explorerTypeSettingsFromModules.remove(settings);
909                     if (CmsLog.INIT.isInfoEnabled()) {
910                         CmsLog.INIT.info(Messages.get().getBundle().key(
911                             Messages.INIT_REMOVE_EXPLORER_TYPE_SETTING_1,
912                             settings.getName()));
913                     }
914                 }
915             }
916             // reset the list of all explorer type settings
917
initExplorerTypeSettings();
918         }
919     }
920
921     /**
922      * Sets if the autolock resources feature is enabled.<p>
923      *
924      * @param value <code>"true"</code> if the autolock resources feature is enabled, otherwise false
925      */

926     public void setAutoLock(String JavaDoc value) {
927
928         m_autoLockResources = Boolean.valueOf(value).booleanValue();
929         if (CmsLog.INIT.isInfoEnabled()) {
930             CmsLog.INIT.info(Messages.get().getBundle().key(
931                 m_autoLockResources ? Messages.INIT_AUTO_LOCK_ENABLED_0 : Messages.INIT_AUTO_LOCK_DISABLED_0));
932         }
933     }
934
935     /**
936      * Sets the access object of the type settings.<p>
937      *
938      * @param access access object
939      */

940     public void setDefaultAccess(CmsExplorerTypeAccess access) {
941
942         m_defaultAccess = access;
943     }
944
945     /**
946      * Sets the Workplace default locale.<p>
947      *
948      * @param locale the locale to set
949      */

950     public void setDefaultLocale(String JavaDoc locale) {
951
952         try {
953             m_defaultLocale = CmsLocaleManager.getLocale(locale);
954         } catch (Exception JavaDoc e) {
955             if (CmsLog.INIT.isWarnEnabled()) {
956                 CmsLog.INIT.warn(Messages.get().getBundle().key(Messages.INIT_NONCRIT_ERROR_0), e);
957             }
958         }
959         if (CmsLog.INIT.isInfoEnabled()) {
960             CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_DEFAULT_LOCALE_1, m_defaultLocale));
961         }
962     }
963
964     /**
965      * Sets the default property editing mode on resources.<p>
966      *
967      * @param defaultPropertiesOnStructure the default property editing mode on resources
968      */

969     public void setDefaultPropertiesOnStructure(String JavaDoc defaultPropertiesOnStructure) {
970
971         m_defaultPropertiesOnStructure = Boolean.valueOf(defaultPropertiesOnStructure).booleanValue();
972         if (CmsLog.INIT.isInfoEnabled()) {
973             CmsLog.INIT.info(Messages.get().getBundle().key(
974                 m_defaultPropertiesOnStructure ? Messages.INIT_PROP_ON_STRUCT_TRUE_0
975                 : Messages.INIT_PROP_ON_STRUCT_FALSE_0));
976         }
977     }
978
979     /**
980      * Sets the Workplace default user settings.<p>
981      *
982      * @param defaultUserSettings the user settings to set
983      */

984     public void setDefaultUserSettings(CmsDefaultUserSettings defaultUserSettings) {
985
986         m_defaultUserSettings = defaultUserSettings;
987
988         if (CmsLog.INIT.isInfoEnabled()) {
989             CmsLog.INIT.info(Messages.get().getBundle().key(
990                 Messages.INIT_DEFAULT_USER_SETTINGS_1,
991                 m_defaultUserSettings));
992         }
993     }
994
995     /**
996      * Sets the direct edit provider.<p>
997      *
998      * @param clazz the direct edit provider to set
999      */

1000    public void setDirectEditProvider(I_CmsDirectEditProvider clazz) {
1001
1002        m_directEditProvider = clazz;
1003        if (CmsLog.INIT.isInfoEnabled()) {
1004            CmsLog.INIT.info(Messages.get().getBundle().key(
1005                Messages.INIT_DIRECT_EDIT_PROVIDER_1,
1006                m_directEditProvider.getClass().getName()));
1007        }
1008    }
1009
1010    /**
1011     * Sets the editor action class.<p>
1012     *
1013     * @param clazz the editor action class to set
1014     */

1015    public void setEditorAction(I_CmsEditorActionHandler clazz) {
1016
1017        m_editorAction = clazz;
1018        if (CmsLog.INIT.isInfoEnabled()) {
1019            CmsLog.INIT.info(Messages.get().getBundle().key(
1020                Messages.INIT_EDITOR_ACTION_CLASS_1,
1021                m_editorAction.getClass().getName()));
1022        }
1023    }
1024
1025    /**
1026     * Sets the editor display option class.<p>
1027     *
1028     * @param clazz the editor display option class to set
1029     */

1030    public void setEditorDisplayOptions(CmsEditorDisplayOptions clazz) {
1031
1032        m_editorDisplayOptions = clazz;
1033        if (CmsLog.INIT.isInfoEnabled()) {
1034            CmsLog.INIT.info(Messages.get().getBundle().key(
1035                Messages.INIT_EDITOR_DISPLAY_OPTS_1,
1036                m_editorAction.getClass().getName()));
1037        }
1038    }
1039
1040    /**
1041     * Sets the editor handler class.<p>
1042     *
1043     * @param clazz the editor handler class to set
1044     */

1045    public void setEditorHandler(I_CmsEditorHandler clazz) {
1046
1047        m_editorHandler = clazz;
1048        if (CmsLog.INIT.isInfoEnabled()) {
1049            CmsLog.INIT.info(Messages.get().getBundle().key(
1050                Messages.INIT_EDITOR_HANDLER_CLASS_1,
1051                m_editorHandler.getClass().getName()));
1052        }
1053    }
1054
1055    /**
1056     * Sets if tabs in the advanced property dialog are enabled.<p>
1057     *
1058     * @param enableAdvancedPropertyTabs true if tabs should be enabled, otherwise false
1059     */

1060    public void setEnableAdvancedPropertyTabs(String JavaDoc enableAdvancedPropertyTabs) {
1061
1062        m_enableAdvancedPropertyTabs = Boolean.valueOf(enableAdvancedPropertyTabs).booleanValue();
1063        if (CmsLog.INIT.isInfoEnabled()) {
1064            CmsLog.INIT.info(Messages.get().getBundle().key(
1065                m_enableAdvancedPropertyTabs ? Messages.INIT_ADV_PROP_DIALOG_SHOW_TABS_0
1066                : Messages.INIT_ADV_PROP_DIALOG_HIDE_TABS_0));
1067        }
1068    }
1069
1070    /**
1071     * Sets the value (in kb) for the maximum file upload size.<p>
1072     *
1073     * @param value the value (in kb) for the maximum file upload size
1074     */

1075    public void setFileMaxUploadSize(String JavaDoc value) {
1076
1077        try {
1078            m_fileMaxUploadSize = Integer.valueOf(value).intValue();
1079        } catch (NumberFormatException JavaDoc e) {
1080            // can usually be ignored
1081
if (LOG.isInfoEnabled()) {
1082                LOG.info(e.getLocalizedMessage());
1083            }
1084            m_fileMaxUploadSize = -1;
1085        }
1086        if (CmsLog.INIT.isInfoEnabled()) {
1087            if (m_fileMaxUploadSize > 0) {
1088                CmsLog.INIT.info(Messages.get().getBundle().key(
1089                    Messages.INIT_MAX_FILE_UPLOAD_SIZE_1,
1090                    new Integer JavaDoc(m_fileMaxUploadSize)));
1091            } else {
1092                CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_MAX_FILE_UPLOAD_SIZE_UNLIMITED_0));
1093            }
1094
1095        }
1096    }
1097
1098    /**
1099     * Sets the system-wide file view settings for the workplace.<p>
1100     *
1101     * @param cms the CmsObject for ensuring security constraints.
1102     *
1103     * @param fileViewSettings the system-wide file view settings for the workplace to set
1104     * @throws CmsRoleViolationException if the current user does not own the administrator role ({@link CmsRole#ADMINISTRATOR})
1105     * */

1106    public void setFileViewSettings(CmsObject cms, CmsRfsFileViewer fileViewSettings) throws CmsRoleViolationException {
1107
1108        if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) {
1109            cms.checkRole(CmsRole.ADMINISTRATOR);
1110        }
1111        m_fileViewSettings = fileViewSettings;
1112        // disallow modifications of this "new original"
1113
m_fileViewSettings.setFrozen(true);
1114    }
1115
1116    /**
1117     * Sets the configured multi context menu to use in the Explorer view.<p>
1118     *
1119     * @param multiContextMenu the configured multi context menu to use in the Explorer view
1120     */

1121    public void setMultiContextMenu(CmsExplorerContextMenu multiContextMenu) {
1122
1123        multiContextMenu.setMultiMenu(true);
1124        m_multiContextMenu = multiContextMenu;
1125    }
1126
1127    /**
1128     * Sets the tool Manager object.<p>
1129     *
1130     * @param toolManager the tool Manager object to set
1131     */

1132    public void setToolManager(CmsToolManager toolManager) {
1133
1134        m_toolManager = toolManager;
1135    }
1136
1137    /**
1138     * Controls if the user/group icon in the administration view should be shown.<p>
1139     *
1140     * @param value <code>"true"</code> if the user/group icon in the administration view should be shown, otherwise false
1141     */

1142    public void setUserManagementEnabled(String JavaDoc value) {
1143
1144        m_showUserGroupIcon = Boolean.valueOf(value).booleanValue();
1145        if (CmsLog.INIT.isInfoEnabled()) {
1146            if (m_showUserGroupIcon) {
1147                CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_USER_MANAGEMENT_ICON_ENABLED_0));
1148            } else {
1149                CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_USER_MANAGEMENT_ICON_DISABLED_0));
1150            }
1151        }
1152    }
1153
1154    /**
1155     * Sets if workflow message emails contain the message text.<p>
1156     *
1157     * @param workflowMessage true if messages should be includes, otherwise false
1158     */

1159    public void setWorkflowMessage(String JavaDoc workflowMessage) {
1160
1161        m_workflowMessage = Boolean.valueOf(workflowMessage).booleanValue();
1162        if (CmsLog.INIT.isInfoEnabled()) {
1163            CmsLog.INIT.info(Messages.get().getBundle().key(
1164                m_workflowMessage ? Messages.INIT_WORKFLOW_MESSAGES_SHOW_MESSAGE_0
1165                : Messages.INIT_WORKFLOW_MESSAGES_HIDE_MESSAGE_0));
1166        }
1167    }
1168
1169    /**
1170     * Returns if the user/group icon in the administration view should be shown.<p>
1171     *
1172     * @return true if the user/group icon in the administration view should be shown, otherwise false
1173     */

1174    public boolean showUserGroupIcon() {
1175
1176        return m_showUserGroupIcon;
1177    }
1178
1179    /**
1180     * Inintializes the configured explorer type settings.<p>
1181     */

1182    private synchronized void initExplorerTypeSettings() {
1183
1184        Map JavaDoc explorerTypeSettingsMap = new HashMap JavaDoc();
1185        List JavaDoc explorerTypeSettings = new ArrayList JavaDoc();
1186
1187        explorerTypeSettings.addAll(m_explorerTypeSettingsFromXml);
1188        explorerTypeSettings.addAll(m_explorerTypeSettingsFromModules);
1189
1190        for (int i = 0; i < explorerTypeSettings.size(); i++) {
1191            CmsExplorerTypeSettings settings = (CmsExplorerTypeSettings)explorerTypeSettings.get(i);
1192            // put the settings in the lookup map
1193
explorerTypeSettingsMap.put(settings.getName(), settings);
1194            try {
1195                // initialize the access control configuration of the explorer type
1196
settings.getAccess().createAccessControlList();
1197            } catch (CmsException e) {
1198                if (CmsLog.INIT.isInfoEnabled()) {
1199                    CmsLog.INIT.info(Messages.get().getBundle().key(
1200                        Messages.INIT_ADD_TYPE_SETTING_FAILED_1,
1201                        settings.getName()), e);
1202                }
1203            }
1204        }
1205        // sort the explorer type settings
1206
Collections.sort(explorerTypeSettings);
1207        // make the settings unmodifiable and store them in the golbal variables
1208
m_explorerTypeSettings = Collections.unmodifiableList(explorerTypeSettings);
1209        m_explorerTypeSettingsMap = Collections.unmodifiableMap(explorerTypeSettingsMap);
1210    }
1211
1212    /**
1213     * Initializes the workplace locale set.<p>
1214     *
1215     * Currently, this is defined by the existence of a special folder
1216     * <code>/system/workplace/locales/{locale-name}/</code>.
1217     * This is likely to change in future implementations.<p>
1218     *
1219     * @param cms an OpenCms context object that must have been initialized with "Admin" permissions
1220     * @return the workplace locale set
1221     */

1222    private List JavaDoc initWorkplaceLocales(CmsObject cms) {
1223
1224        Set JavaDoc locales = new HashSet JavaDoc();
1225        List JavaDoc localeFolders;
1226        try {
1227            localeFolders = cms.getSubFolders(CmsWorkplace.VFS_PATH_LOCALES);
1228        } catch (CmsException e) {
1229            LOG.error(Messages.get().getBundle().key(
1230                Messages.LOG_WORKPLACE_INIT_NO_LOCALES_1,
1231                CmsWorkplace.VFS_PATH_LOCALES));
1232            // can not throw exception here since then OpenCms would not even start in shell mode (runlevel 2)
1233
localeFolders = new ArrayList JavaDoc();
1234        }
1235        Iterator JavaDoc i = localeFolders.iterator();
1236        while (i.hasNext()) {
1237            CmsFolder folder = (CmsFolder)i.next();
1238            Locale JavaDoc locale = CmsLocaleManager.getLocale(folder.getName());
1239            // add locale
1240
locales.add(locale);
1241            // add less specialized locale
1242
locales.add(new Locale JavaDoc(locale.getLanguage(), locale.getCountry()));
1243            // add even less specialized locale
1244
locales.add(new Locale JavaDoc(locale.getLanguage()));
1245        }
1246
1247        // sort the result
1248
ArrayList JavaDoc result = new ArrayList JavaDoc();
1249        result.addAll(locales);
1250        Collections.sort(result, CmsLocaleComparator.getComparator());
1251        return result;
1252    }
1253
1254    /**
1255     * Initializes the available workplace views.<p>
1256     *
1257     * Currently, this is defined by iterating the subfolder of the folder
1258     * <code>/system/workplace/views/</code>.
1259     * These subfolders must have the properties NavPos, NavText and default-file set.<p>
1260     *
1261     * @param cms an OpenCms context object that must have been initialized with "Admin" permissions
1262     * @return the available workplace views
1263     */

1264    private List JavaDoc initWorkplaceViews(CmsObject cms) {
1265
1266        List JavaDoc viewFolders = new ArrayList JavaDoc();
1267        try {
1268            // get the subfolders of the "views" folder
1269
viewFolders = cms.getSubFolders(CmsWorkplace.VFS_PATH_VIEWS);
1270        } catch (CmsException e) {
1271            if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING && LOG.isErrorEnabled()) {
1272                LOG.error(Messages.get().getBundle().key(
1273                    Messages.LOG_WORKPLACE_INIT_NO_VIEWS_1,
1274                    CmsWorkplace.VFS_PATH_VIEWS), e);
1275            }
1276            // can not throw exception here since then OpenCms would not even start in shell mode (runlevel 2)
1277
viewFolders = new ArrayList JavaDoc();
1278        }
1279        m_views = new ArrayList JavaDoc(viewFolders.size());
1280        for (int i = 0; i < viewFolders.size(); i++) {
1281            // loop through all view folders
1282
CmsFolder folder = (CmsFolder)viewFolders.get(i);
1283            String JavaDoc folderPath = cms.getSitePath(folder);
1284            try {
1285                // get view information from folder properties
1286
String JavaDoc order = cms.readPropertyObject(folderPath, CmsPropertyDefinition.PROPERTY_NAVPOS, false).getValue();
1287                String JavaDoc key = cms.readPropertyObject(folderPath, CmsPropertyDefinition.PROPERTY_NAVTEXT, false).getValue();
1288                String JavaDoc viewUri = cms.readPropertyObject(folderPath, CmsPropertyDefinition.PROPERTY_DEFAULT_FILE, false).getValue();
1289                if (viewUri == null) {
1290                    // no view URI found
1291
viewUri = folderPath;
1292                } else if (!viewUri.startsWith("/")) {
1293                    // default file is in current view folder, create absolute path to view URI
1294
viewUri = folderPath + viewUri;
1295                }
1296                if (order == null) {
1297                    // no valid NavPos property value found, use loop count as order value
1298
order = "" + i;
1299                }
1300                Float JavaDoc orderValue;
1301                try {
1302                    // create Float order object
1303
orderValue = Float.valueOf(order);
1304                } catch (NumberFormatException JavaDoc e) {
1305                    // String was not formatted correctly, use loop counter
1306
orderValue = Float.valueOf("" + i);
1307                }
1308                if (key == null) {
1309                    // no language key found, use default String to avoid NullPointerException
1310
key = "View " + i;
1311                    // if no navtext is given do not display the view
1312
continue;
1313                }
1314                // create new view object
1315
CmsWorkplaceView view = new CmsWorkplaceView(key, viewUri, orderValue);
1316                m_views.add(view);
1317                // log the view
1318
if (CmsLog.INIT.isInfoEnabled()) {
1319                    CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_VIEW_1, view.getUri()));
1320                }
1321            } catch (CmsException e) {
1322                // should usually never happen
1323
LOG.error(Messages.get().getBundle().key(Messages.LOG_READING_VIEW_FOLDER_FAILED_1, folderPath), e);
1324            }
1325        }
1326        // sort the views by their order number
1327
Collections.sort(m_views);
1328        return m_views;
1329    }
1330}
Popular Tags