001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: https://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: https://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.configuration;
029
030import org.opencms.ade.containerpage.shared.CmsCntPageData.ElementDeleteMode;
031import org.opencms.ade.contenteditor.I_CmsContentTranslator;
032import org.opencms.ade.upload.I_CmsUploadRestriction;
033import org.opencms.ade.upload.I_CmsVirusScanner;
034import org.opencms.configuration.preferences.I_CmsPreference;
035import org.opencms.db.CmsExportPoint;
036import org.opencms.file.types.CmsResourceTypeSubsitemapContentFolder;
037import org.opencms.gwt.shared.CmsGwtConstants;
038import org.opencms.main.CmsLog;
039import org.opencms.main.OpenCms;
040import org.opencms.relations.CmsCategoryService;
041import org.opencms.util.CmsRfsFileViewer;
042import org.opencms.util.CmsStringUtil;
043import org.opencms.workplace.CmsAccountInfo;
044import org.opencms.workplace.CmsWorkplaceManager;
045import org.opencms.workplace.CmsWorkplaceUserInfoBlock;
046import org.opencms.workplace.CmsWorkplaceUserInfoEntry;
047import org.opencms.workplace.CmsWorkplaceUserInfoManager;
048import org.opencms.workplace.I_CmsDialogHandler;
049import org.opencms.workplace.editors.I_CmsEditorCssHandler;
050import org.opencms.workplace.editors.I_CmsPreEditorActionDefinition;
051import org.opencms.workplace.explorer.CmsExplorerTypeAccess;
052import org.opencms.workplace.explorer.CmsExplorerTypeSettings;
053import org.opencms.workplace.explorer.CmsIconRule;
054import org.opencms.workplace.tools.CmsToolManager;
055import org.opencms.workplace.tools.CmsToolRootHandler;
056
057import java.util.ArrayList;
058import java.util.Arrays;
059import java.util.Collections;
060import java.util.Iterator;
061import java.util.List;
062import java.util.Map;
063import java.util.Set;
064
065import org.apache.commons.digester3.CallMethodRule;
066import org.apache.commons.digester3.Digester;
067import org.apache.commons.digester3.Rule;
068
069import org.dom4j.Element;
070import org.xml.sax.Attributes;
071
072import com.google.common.base.Function;
073import com.google.common.collect.Multimap;
074import com.google.common.collect.Multimaps;
075
076/**
077 * Import/Export master configuration class.<p>
078 *
079 * @since 6.0.0
080 */
081public class CmsWorkplaceConfiguration extends A_CmsXmlConfiguration {
082
083    /** The name of the attribute addinfo-key for account infos. */
084    public static final String A_ADD_INFO_KEY = "addinfo-key";
085
086    /** The "autosetnavigation" attribute. */
087    public static final String A_AUTOSETNAVIGATION = "autosetnavigation";
088
089    /** The content-translation element. */
090    public static final String N_CONTENT_TRANSLATION = "content-translation";
091
092    /** The "autosettitle" attribute. */
093    public static final String A_AUTOSETTITLE = "autosettitle";
094
095    /** The name of the attribute containing the name of the big icon. */
096    public static final String A_BIGICON = "bigicon";
097
098    /** The name of the attribute containing the name of the big icon style class. */
099    public static final String A_BIGICONSTYLE = "bigiconstyle";
100
101    /** The 'creatable' attribute. */
102    public static final String A_CREATABLE = "creatable";
103
104    /** The 'description' attribute. */
105    public static final String A_DESCRIPTION = "description";
106
107    /** The "displayByRepository" attribute. */
108    public static final String A_DISPLAY_BY_REPOSITORY = "displayByRepository";
109
110    /** The "displayCollapsed" attribute. */
111    public static final String A_DISPLAY_COLLAPSED = "displayCollapsed";
112
113    /** The name of the attribute editable for account infos. */
114    public static final String A_EDITABLE = "editable";
115
116    /** The 'error' attribute. */
117    public static final String A_ERROR = "error";
118
119    /** The name of the attribute for file extensions in icon rules. */
120    public static final String A_EXTENSION = "extension";
121
122    /** The name of the attribute field for account infos. */
123    public static final String A_FIELD = "field";
124
125    /** The "info" attribute. */
126    public static final String A_INFO = "info";
127
128    /** The isview attribute. */
129    public static final String A_ISVIEW = "isview";
130
131    /** The 'leaves-only' attribute for the 'display-categories-in-explorer' element. */
132    public static final String A_LEAVES_ONLY = "leaves-only";
133
134    /** The name pattern attrribute. */
135    public static final String A_NAME_PATTERN = "name-pattern";
136
137    /** The 'widget-config' attribute. */
138    public static final String A_NICE_NAME = "nice-name";
139
140    /** The attribute name of the optional attribute for the user-info node. */
141    public static final String A_OPTIONAL = "optional";
142
143    /** The "page" attribute. */
144    public static final String A_PAGE = "page";
145
146    /** The "params" attribute. */
147    public static final String A_PARAMS = "params";
148
149    /** The "parent" attribute. */
150    public static final String A_PARENT = "parent";
151
152    /** The "path" attribute. */
153    public static final String A_PATH = "path";
154
155    /** The "permissions" attribute. */
156    public static final String A_PERMISSIONS = "permissions";
157
158    /** The "principal" attribute. */
159    public static final String A_PRINCIPAL = "principal";
160
161    /** The "reference" attribute. */
162    public static final String A_REFERENCE = "reference";
163
164    /** The "replace" attribute. */
165    public static final String A_REPLACE = "replace";
166
167    /** The "rule" attribute. */
168    public static final String A_RULE = "rule";
169
170    /** The 'rule-regex' attribute. */
171    public static final String A_RULE_REGEX = "rule-regex";
172
173    /** The "rules" attribute. */
174    public static final String A_RULES = "rules";
175
176    /** The "shownavigation" attribute. */
177    public static final String A_SHOWNAVIGATION = "shownavigation";
178
179    /** The name of the attribute containing the name of the small icon style class. */
180    public static final String A_SMALLICONSTYLE = "smalliconstyle";
181
182    /** The "tab" attribute. */
183    public static final String A_TAB = "tab";
184
185    /** The "target" attribute. */
186    public static final String A_TARGET = "target";
187
188    /** Name of the attribute used to determine order of types in element views. */
189    public static final String A_VIEW_ORDER = "view-order";
190
191    /** The attribute name of the widget attribute for the user-info node. */
192    public static final String A_WIDGET = "widget";
193
194    /** The 'widget-config' attribute. */
195    public static final String A_WIDGET_CONFIG = "widget-config";
196
197    /** The 'with-path' attribute for the 'display-categories-in-explorer' element. */
198    public static final String A_WITH_PATH = "with-path";
199
200    /** The name of the DTD for this configuration. */
201    public static final String CONFIGURATION_DTD_NAME = "opencms-workplace.dtd";
202
203    /** The name of the default XML file for this configuration. */
204    public static final String DEFAULT_XML_FILE_NAME = "opencms-workplace.xml";
205
206    /** Name of the acacia-unlock node. */
207    public static final String N_ACACIA_UNLOCK = "acacia-unlock";
208
209    /** The name of the access control node. */
210    public static final String N_ACCESSCONTROL = "accesscontrol";
211
212    /** The name of the access entry node. */
213    public static final String N_ACCESSENTRY = "accessentry";
214
215    /** The name of the account info node. */
216    public static final String N_ACCOUNTINFO = "account-info";
217
218    /** The name of the account infos node. */
219    public static final String N_ACCOUNTINFOS = "account-infos";
220
221    /** The "allow-element-author-to-work-in-galleries" element */
222    public static final String N_ALLOW_ELEMENT_AUTHOR_TO_WORK_IN_GALLERIES = "allow-element-author-to-work-in-galleries";
223
224    /** The name of the "allow broken relations" node. */
225    public static final String N_ALLOWBROKENRELATIONS = "allowbrokenrelations";
226
227    /** The name of the autolock node. */
228    public static final String N_AUTOLOCK = "autolock";
229
230    /** The name of the background color node. */
231    public static final String N_BACKGROUNDCOLOR = "background-color";
232
233    /** The node name of the buttonstyle node. */
234    public static final String N_BUTTONSTYLE = "buttonstyle";
235
236    /** The name of the category display options node. */
237    public static final String N_CATEGORYDISPLAYOPTIONS = "categorydisplayoptions";
238
239    /** The name of the category folder node. */
240    public static final String N_CATEGORYFOLDER = "categoryfolder";
241
242    /** The name of the color node. */
243    public static final String N_COLOR = "color";
244
245    /** The node name of the datecreated column node. */
246    public static final String N_DATECREATED = "show-datecreated";
247
248    /** The node name of the date expired column node. */
249    public static final String N_DATEEXPIRED = "show-dateexpired";
250
251    /** The node name of the datelastmodified column node. */
252    public static final String N_DATELASTMODIFIED = "show-datelastmodified";
253
254    /** The node name of the date released  column node. */
255    public static final String N_DATERELEASED = "show-datereleased";
256
257    /** The name of the default access control node. */
258    public static final String N_DEFAULTACCESSCONTROL = "defaultaccesscontrol";
259
260    /** The name of the node for the default locale. */
261    public static final String N_DEFAULTLOCALE = "defaultlocale";
262
263    /** The node name of the default preferences node. */
264    public static final String N_DEFAULTPREFERENCES = "default-preferences";
265
266    /** The name of the default properties node. */
267    public static final String N_DEFAULTPROPERTIES = "defaultproperties";
268
269    /** The name of the default properties on structure node. */
270    public static final String N_DEFAULTPROPERTIESONSTRUCTURE = "defaultpropertiesonstructure";
271
272    /** The name of the default property node. */
273    public static final String N_DEFAULTPROPERTY = "defaultproperty";
274
275    /** The name of the element containing the role for users who should be allowed to manage detail pages in the page editor. */
276    public static final String N_DETAIL_PAGE_MANAGEMENT_ROLE = "sitemap-editor-detail-page-management-role";
277
278    /** Individual workplace handler node name. */
279    public static final String N_DIALOGHANDLER = "dialoghandler";
280
281    /** The main workplace handler node name. */
282    public static final String N_DIALOGHANDLERS = "dialoghandlers";
283
284    /** The node name of the dialogs defaultsettings node. */
285    public static final String N_DIALOGSDEFAULTSETTINGS = "dialogs-defaultsettings";
286
287    /** The node name of the dialogs preferences node. */
288    public static final String N_DIALOGSPREFERENCES = "dialogs-preferences";
289
290    /** The node name of the direct edit provider node. */
291    public static final String N_DIRECTEDITPROVIDER = "directeditprovider";
292
293    /** The node name of the directedit style node. */
294    public static final String N_DIRECTEDITSTYLE = "directeditstyle";
295
296    /** The node name of the directpublish node. */
297    public static final String N_DIRECTPUBLISH = "directpublish";
298
299    /** The 'display-categories-in-explorer' element. */
300    public static final String N_DISPLAY_CATEGORIES_IN_EXPLORER = "display-categories-in-explorer";
301
302    /** The name of the edit options node. */
303    public static final String N_EDITOPTIONS = "editoptions";
304
305    /** The node name of the editor node. */
306    public static final String N_EDITOR = "editor";
307
308    /** The element editor-max-locale-buttons. */
309    public static final String N_EDITOR_MAX_LOCALE_BUTTONS = "editor-max-locale-buttons";
310
311    /** The name of the editor action node. */
312    public static final String N_EDITORACTION = "editoraction";
313
314    /** The name of the editor css handler node. */
315    public static final String N_EDITORCSSHANDLER = "editorcsshandler";
316
317    /** The name of the editor css handlers node. */
318    public static final String N_EDITORCSSHANDLERS = "editorcsshandlers";
319
320    /** The node name of the editors general options node. */
321    public static final String N_EDITORGENERALOPTIONS = "editors-generaloptions";
322
323    /** The name of the editor handler node. */
324    public static final String N_EDITORHANDLER = "editorhandler";
325
326    /** The name of the editorprecondition node. */
327    public static final String N_EDITORPRECONDITION = "editorprecondition";
328
329    /** The name of the editorpreconditions node. */
330    public static final String N_EDITORPRECONDITIONS = "editorpreconditions";
331
332    /** The node name of the editors preferences node. */
333    public static final String N_EDITORPREFERENCES = "editors-preferences";
334
335    /** The node name of the editors preferred editors node. */
336    public static final String N_EDITORPREFERREDEDITORS = "editors-preferrededitors";
337
338    /** The element delete mode node name. */
339    public static final String N_ELEMENT_DELETE_MODE = "element-delete-mode";
340
341    /** The name of the "enable advanced property tabs" node. */
342    public static final String N_ENABLEADVANCEDPROPERTYTABS = "enableadvancedpropertytabs";
343
344    /** The subname of the rfsfilesettings/enabled node. */
345    public static final String N_ENABLED = "enabled";
346
347    /** The name of the "user management enabled" node. */
348    public static final String N_ENABLEUSERMGMT = "enableusermanagement";
349
350    /** The node name of the file entries node. */
351    public static final String N_ENTRIES = "entries";
352
353    /** The name of the entry node. */
354    public static final String N_ENTRY = "entry";
355
356    /** The node name of the file entryoptions node. */
357    public static final String N_ENTRYOPTIONS = "entryoptions";
358
359    /** The name of the exclude-pattern node. */
360    public static final String N_EXCLUDEPATTERN = "exclude-pattern";
361
362    /** The name of the expand inherited permissions node. */
363    public static final String N_EXPANDPERMISSIONSINHERITED = "expand-permissionsinherited";
364
365    /** The name of the expand user permissions node. */
366    public static final String N_EXPANDPERMISSIONSUSER = "expand-permissionsuser";
367
368    /** The node name of the explorer displayoptions node. */
369    public static final String N_EXPLORERDISPLAYOPTIONS = "explorer-displayoptions";
370
371    /** The node name of the explorer generaloptions node. */
372    public static final String N_EXPLORERGENERALOPTIONS = "explorer-generaloptions";
373
374    /** The node name of the explorer preferences node. */
375    public static final String N_EXPLORERPREFERENCES = "explorer-preferences";
376
377    /** The name of the explorer type node. */
378    public static final String N_EXPLORERTYPE = "explorertype";
379
380    /** The name of the explorer types node. */
381    public static final String N_EXPLORERTYPES = "explorertypes";
382
383    /** The node name of the file copy node. */
384    public static final String N_FILECOPY = "filecopy";
385
386    /** The node name of the file deletion node. */
387    public static final String N_FILEDELETION = "filedeletion";
388
389    /** The subname of the rfsfilesettings/fileEncoding node. */
390    public static final String N_FILEENCODING = "fileEncoding";
391
392    /** The subname of the rfsfilesettings/filePath node. */
393    public static final String N_FILEPATH = "filePath";
394
395    /** The node name of the start folder node. */
396    public static final String N_FOLDER = "folder";
397
398    /** The node name of the folder copy node. */
399    public static final String N_FOLDERCOPY = "foldercopy";
400
401    /** The node name of the gallery preferences node. */
402    public static final String N_GALLERIESPREFERENCES = "galleries-preferences";
403
404    /** Node name. */
405    public static final String N_GALLERY_DEFAULT_SCOPE = "gallery-default-scope";
406
407    /** The node name of the group-translation node. */
408    public static final String N_GROUP_TRANSLATION = "group-translation";
409
410    /** The node name of the helptext node. */
411    public static final String N_HELPTEXT = "helptext";
412
413    /** The name of the icon rule node. */
414    public static final String N_ICONRULE = "iconrule";
415
416    /** The name of the icon rules node. */
417    public static final String N_ICONRULES = "iconrules";
418
419    /** The node name of the info-block node. */
420    public static final String N_INFOBLOCK = "info-block";
421
422    /** The subname of the rfsfilesettings/isLogfile node. */
423    public static final String N_ISLOGFILE = "isLogfile";
424
425    /** Name of the "keep alive" setting node. */
426    public static final String N_KEEP_ALIVE = "keep-alive";
427
428    /** The node name of the key node. */
429    public static final String N_KEY = "key";
430
431    /** The name of the "labeled folders" node. */
432    public static final String N_LABELEDFOLDERS = "labeledfolders";
433
434    /** The node name of the list all projects node. */
435    public static final String N_LISTALLPROJECTS = "listallprojects";
436
437    /** The node name of the locale node. */
438    public static final String N_LOCALE = "locale";
439
440    /** The name of the "localized folders" node. */
441    public static final String N_LOCALIZEDFOLDERS = "localizedfolders";
442
443    /** The node name of the lockedby column node. */
444    public static final String N_LOCKEDBY = "show-lockedby";
445
446    /** The name of the "max file upload size" node. */
447    public static final String N_MAXUPLOADSIZE = "maxfileuploadsize";
448
449    /** The node name of the navtext column node. */
450    public static final String N_NAVTEXT = "show-navtext";
451
452    /** The name of the "create new folder with index page" node. */
453    public static final String N_NEWFOLDERCREATEINDEXPAGE = "newfolder-createindexpage";
454
455    /** The name of the "create new folder with edit properties" node. */
456    public static final String N_NEWFOLDEREDITPROPERTIES = "newfolder-editproperties";
457
458    /** The name of the new resource node. */
459    public static final String N_NEWRESOURCE = "newresource";
460
461    /** The node name of the permissions column node. */
462    public static final String N_PERMISSIONS = "show-permissions";
463
464    /** The name of the inherit permissions on folder node. */
465    public static final String N_PERMISSIONSINHERITONFOLDER = "permissions-inheritonfolder";
466
467    /** The name of the editor handler node. */
468    public static final String N_POSTUPLOADHANDLER = "postuploadhandler";
469
470    /** The node name for a preference. */
471    public static final String N_PREFERENCE = "preference";
472
473    /** The name of the preference-tab element. */
474    public static final String N_PREFERENCE_TAB = "preference-tab";
475
476    /** The node name of the project node. */
477    public static final String N_PROJECT = "project";
478
479    /** The node name of the publish button appearance node. */
480    public static final String N_PUBLISHBUTTONAPPEARANCE = "publishbuttonappearance";
481
482    /** The node name of the publish notification node. */
483    public static final String N_PUBLISHNOTIFICATION = "publishnotification";
484
485    /** The name of the "publish related resources" node. */
486    public static final String N_PUBLISHRELATEDRESOURCES = "publishrelatedresources";
487
488    /** The node name of the report type node. */
489    public static final String N_REPORTTYPE = "reporttype";
490
491    /** The node name of the gallery upload folder handler node. */
492    public static final String N_REPOSITORY_FOLDER = "repositoryfolder";
493
494    /** The node name of the restrict explorer view node. */
495    public static final String N_RESTRICTEXPLORERVIEW = "restrictexplorerview";
496
497    /** The node name of the rfsfileviewsettings node. */
498    public static final String N_RFSFILEVIEWESETTINGS = "rfsfileviewsettings";
499
500    /** The node name of the root node. */
501    public static final String N_ROOT = "root";
502
503    /** The subname of the rfsfilesettings/rootPath node. */
504    public static final String N_ROOTPATH = "rootPath";
505
506    /** The node name of the roots node. */
507    public static final String N_ROOTS = "roots";
508
509    /** The node name of the searchindex-name node. */
510    public static final String N_SEARCHINDEXNAME = "searchindex-name";
511
512    /** The node name of the searchview-style node. */
513    public static final String N_SEARCHVIEWSTYLE = "searchview-style";
514
515    /** The name of the separator node. */
516    public static final String N_SEPARATOR = "separator";
517
518    /** The node name of the show lock node. */
519    public static final String N_SHOWEXPORTSETTINGS = "showexportsettings";
520
521    /** The node name of the "show file upload button" option. */
522    public static final String N_SHOWFILEUPLOADBUTTON = "show-fileuploadbutton";
523
524    /** The node name of the show lock node. */
525    public static final String N_SHOWLOCK = "showlock";
526
527    /** The node name of the show messages node. */
528    public static final String N_SHOWMESSAGES = "showmessages";
529
530    /** The name of the "create new folder with index page" node. */
531    public static final String N_SHOWUPLOADTYPEDIALOG = "show-uploadtypedialog";
532
533    /** The node name of the size column node. */
534    public static final String N_SIZE = "show-size";
535
536    /** The node name of the galleries start setting node. */
537    public static final String N_STARTGALLERIES = "startgalleries";
538
539    /** The node name of the start gallery node. */
540    public static final String N_STARTGALLERY = "startgallery";
541
542    /** The node name of the state column node. */
543    public static final String N_STATE = "show-state";
544
545    /** The node name for the subsitemap creation mode setting. */
546    public static final String N_SUBSITEMAP_CREATION_MODE = "subsitemap-creation-mode";
547
548    /** The name of the synchronization node. */
549    public static final String N_SYNCHRONIZATION = "synchronization";
550
551    /** The name of the text node. */
552    public static final String N_TEXT = "text";
553
554    /** The node name of the title column node. */
555    public static final String N_TITLE = "show-title";
556
557    /** The node name of the tool-manager node. */
558    public static final String N_TOOLMANAGER = "tool-manager";
559
560    /** The node name of the type column node. */
561    public static final String N_TYPE = "show-type";
562
563    /** The node name for the upload restriction configuration. */
564    public static final String N_UPLOAD_RESTRICTION = "upload-restriction";
565
566    /** The node name of the uploadapplet node. */
567    public static final String N_UPLOADAPPLET = "uploadapplet";
568
569    /** The node name of the uri node. */
570    public static final String N_URI = "uri";
571
572    /** The name of the user-lists node. */
573    public static final String N_USER_LISTS = "user-lists";
574
575    /** The node name of the user created node. */
576    public static final String N_USERCREATED = "show-usercreated";
577
578    /** The node name of the user-info node. */
579    public static final String N_USERINFO = "user-info";
580
581    /** The node name of the user-infos node. */
582    public static final String N_USERINFOS = "user-infos";
583
584    /** The node name of the user lastmodified node. */
585    public static final String N_USERLASTMODIFIED = "show-userlastmodified";
586
587    /** The node name of the virus-scanner node. */
588    public static final String N_VIRUS_SCANNER = "virus-scanner";
589
590    /** The subname of the rfsfilesettings/windowSize node. */
591    public static final String N_WINDOWSIZE = "windowSize";
592
593    /** The node name of the master workplace node. */
594    public static final String N_WORKPLACE = "workplace";
595
596    /** The node name of the workplace general options node. */
597    public static final String N_WORKPLACEGENERALOPTIONS = "workplace-generaloptions";
598
599    /** The node name of the workplace preferences node. */
600    public static final String N_WORKPLACEPREFERENCES = "workplace-preferences";
601
602    /** The node name of the workplace-search node. */
603    public static final String N_WORKPLACESEARCH = "workplace-search";
604
605    /** The node name of the workplace startup settings node. */
606    public static final String N_WORKPLACESTARTUPSETTINGS = "workplace-startupsettings";
607
608    /** The node name of the view node. */
609    public static final String N_WORKPLACEVIEW = "workplaceview";
610
611    /** The name of the xmlcontentautocorrection node. */
612    public static final String N_XMLCONTENTAUTOCORRECTION = "xmlcontentautocorrection";
613
614    /** The elementview attribute. */
615    private static final String A_ELEMENTVIEW = "elementview";
616
617    /** The requiredOnUpload attribute. */
618    private static final String A_REQUIRED_ON_UPLOAD = "requiredOnUpload";
619
620    /** Configuration node name for the role required to edit the sitemap configuration. */
621    private static final String N_SITEMAP_CONFIG_EDIT_ROLE = "sitemap-config-edit-role";
622
623    /** Configuration node name for setting the default value for the 'use formatter keys' in sitemap configurations created with new subsitemap folders. */
624    private static final String N_USE_FORMATTER_KEYS_FOR_NEW_SITES = "use-formatter-keys-for-new-sites";
625
626    /** The configured workplace manager. */
627    private CmsWorkplaceManager m_workplaceManager;
628
629    /**
630     * Adds the explorer type rules to the given digester.<p>
631     *
632     * @param digester the digester to add the rules to
633     */
634    public static void addExplorerTypeXmlRules(Digester digester) {
635
636        //TODO: remove workflow nodes from the dtd, there are just there for compatibility reasons
637
638        // add explorer type settings
639        digester.addObjectCreate("*/" + N_EXPLORERTYPE, CmsExplorerTypeSettings.class);
640        digester.addSetNext("*/" + N_EXPLORERTYPE, "addExplorerTypeSetting");
641
642        digester.addCallMethod("*/" + N_EXPLORERTYPE, "setTypeAttributes", 11);
643        digester.addCallParam("*/" + N_EXPLORERTYPE, 0, A_NAME);
644        digester.addCallParam("*/" + N_EXPLORERTYPE, 1, A_KEY);
645        digester.addCallParam("*/" + N_EXPLORERTYPE, 2, A_ICON);
646        digester.addCallParam("*/" + N_EXPLORERTYPE, 3, A_BIGICON);
647        digester.addCallParam("*/" + N_EXPLORERTYPE, 4, A_SMALLICONSTYLE);
648        digester.addCallParam("*/" + N_EXPLORERTYPE, 5, A_BIGICONSTYLE);
649        digester.addCallParam("*/" + N_EXPLORERTYPE, 6, A_REFERENCE);
650        digester.addCallParam("*/" + N_EXPLORERTYPE, 7, A_ELEMENTVIEW);
651        digester.addCallParam("*/" + N_EXPLORERTYPE, 8, A_ISVIEW);
652        digester.addCallParam("*/" + N_EXPLORERTYPE, 9, A_NAME_PATTERN);
653        digester.addCallParam("*/" + N_EXPLORERTYPE, 10, A_VIEW_ORDER);
654
655        digester.addCallMethod("*/" + N_EXPLORERTYPE + "/" + N_ICONRULES + "/" + N_ICONRULE, "addIconRule", 5);
656        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_ICONRULES + "/" + N_ICONRULE, 0, A_EXTENSION);
657        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_ICONRULES + "/" + N_ICONRULE, 1, A_ICON);
658        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_ICONRULES + "/" + N_ICONRULE, 2, A_BIGICON);
659        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_ICONRULES + "/" + N_ICONRULE, 3, A_SMALLICONSTYLE);
660        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_ICONRULES + "/" + N_ICONRULE, 4, A_BIGICONSTYLE);
661
662        digester.addCallMethod("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, "setCreatable", 1);
663        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, 0, A_CREATABLE);
664        digester.addCallMethod("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, "setNewResourceOrder", 1);
665        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, 0, A_ORDER);
666
667        digester.addCallMethod("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, "setAutoSetNavigation", 1);
668        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, 0, A_AUTOSETNAVIGATION);
669        digester.addCallMethod("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, "setAutoSetTitle", 1);
670        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, 0, A_AUTOSETTITLE);
671        digester.addCallMethod("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, "setInfo", 1);
672        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, 0, A_INFO);
673        digester.addCallMethod("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, "setTitleKey", 1);
674        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_NEWRESOURCE, 0, A_KEY);
675
676        digester.addObjectCreate("*/" + N_EXPLORERTYPE + "/" + N_ACCESSCONTROL, CmsExplorerTypeAccess.class);
677        digester.addSetNext("*/" + N_EXPLORERTYPE + "/" + N_ACCESSCONTROL, "setAccess");
678
679        digester.addCallMethod(
680            "*/" + N_EXPLORERTYPE + "/" + N_ACCESSCONTROL + "/" + N_ACCESSENTRY,
681            "addAccessEntry",
682            2);
683        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_ACCESSCONTROL + "/" + N_ACCESSENTRY, 0, A_PRINCIPAL);
684        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_ACCESSCONTROL + "/" + N_ACCESSENTRY, 1, A_PERMISSIONS);
685
686        digester.addCallMethod(
687            "*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES,
688            "setPropertyDefaults",
689            2);
690        digester.addCallParam("*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES, 0, A_ENABLED);
691        digester.addCallParam(
692            "*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES,
693            1,
694            A_SHOWNAVIGATION);
695
696        digester.addCallMethod(
697            "*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES + "/" + N_PROPERTY,
698            "addProperty",
699            2);
700        digester.addCallParam(
701            "*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES + "/" + N_PROPERTY,
702            0,
703            A_NAME);
704
705        digester.addCallParam(
706            "*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES + "/" + N_PROPERTY,
707            1,
708            A_REQUIRED_ON_UPLOAD);
709
710        digester.addCallMethod(
711            "*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES + "/" + N_DEFAULTPROPERTY,
712            "addProperty",
713            2);
714        digester.addCallParam(
715            "*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES + "/" + N_DEFAULTPROPERTY,
716            0,
717            A_NAME);
718        digester.addCallParam(
719            "*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS + "/" + N_DEFAULTPROPERTIES + "/" + N_DEFAULTPROPERTY,
720            1,
721            A_REQUIRED_ON_UPLOAD);
722
723        digester.addCallMethod("*/" + N_EXPLORERTYPE + "/" + N_EDITOPTIONS, "setEditOptions");
724    }
725
726    /**
727     * Creates the xml output for explorer type nodes.<p>
728     *
729     * @param startNode the startnode to add all rescource types to
730     * @param explorerTypes the list of explorer types
731     * @param module true if the XML tree for the module config should be generated, false otherwise
732     */
733    public static void generateExplorerTypesXml(
734        Element startNode,
735        List<CmsExplorerTypeSettings> explorerTypes,
736        boolean module) {
737
738        // we need the default access node later to check if the explorer type is an individual setting
739        CmsExplorerTypeAccess defaultAccess = null;
740        if (OpenCms.getWorkplaceManager() != null) {
741            defaultAccess = OpenCms.getWorkplaceManager().getDefaultAccess();
742        }
743        // get the menu rule translator to eliminate eventual legacy menu rules
744        Iterator<CmsExplorerTypeSettings> i = explorerTypes.iterator();
745        while (i.hasNext()) {
746            // create an explorer type node
747            CmsExplorerTypeSettings settings = i.next();
748
749            if (settings.isAddititionalModuleExplorerType() == module) {
750                Element explorerTypeElement = startNode.addElement(N_EXPLORERTYPE);
751                explorerTypeElement.addAttribute(A_NAME, settings.getName());
752                explorerTypeElement.addAttribute(A_KEY, settings.getKey());
753                String originalIcon = settings.getOriginalIcon();
754                if (CmsStringUtil.isNotEmpty(originalIcon)) {
755                    explorerTypeElement.addAttribute(A_ICON, settings.getOriginalIcon());
756                }
757                if (CmsStringUtil.isNotEmpty(settings.getBigIcon())) {
758                    explorerTypeElement.addAttribute(A_BIGICON, settings.getBigIcon());
759                }
760                if (CmsStringUtil.isNotEmpty(settings.getSmallIconStyle())) {
761                    explorerTypeElement.addAttribute(A_SMALLICONSTYLE, settings.getSmallIconStyle());
762                }
763                if (CmsStringUtil.isNotEmpty(settings.getBigIconStyle())) {
764                    explorerTypeElement.addAttribute(A_BIGICONSTYLE, settings.getBigIconStyle());
765                }
766
767                if (settings.getReference() != null) {
768                    explorerTypeElement.addAttribute(A_REFERENCE, settings.getReference());
769                }
770
771                if (settings.getElementView() != null) {
772                    explorerTypeElement.addAttribute(A_ELEMENTVIEW, settings.getElementView());
773                }
774
775                if (settings.isView()) {
776                    explorerTypeElement.addAttribute(A_ISVIEW, "true");
777                }
778
779                if (settings.getNamePattern() != null) {
780                    explorerTypeElement.addAttribute(A_NAME_PATTERN, settings.getNamePattern());
781                }
782
783                if (settings.getViewOrder(false) != null) {
784                    explorerTypeElement.addAttribute(A_VIEW_ORDER, "" + settings.getViewOrder(false));
785                }
786
787                // create subnode <newresource>
788                Element newResElement = explorerTypeElement.addElement(N_NEWRESOURCE);
789                newResElement.addAttribute(A_CREATABLE, String.valueOf(settings.isCreatable()));
790                newResElement.addAttribute(A_ORDER, settings.getNewResourceOrder());
791                newResElement.addAttribute(A_AUTOSETNAVIGATION, String.valueOf(settings.isAutoSetNavigation()));
792                newResElement.addAttribute(A_AUTOSETTITLE, String.valueOf(settings.isAutoSetTitle()));
793                newResElement.addAttribute(A_INFO, settings.getInfo());
794                newResElement.addAttribute(A_KEY, settings.getTitleKey());
795                // create subnode <accesscontrol>
796                CmsExplorerTypeAccess access = settings.getAccess();
797                if (access != defaultAccess) {
798                    // don't output the node if this is in fact the default access settings
799                    List<String> accessEntries = new ArrayList<String>(access.getAccessEntries().keySet());
800                    // sort accessEntries
801                    Collections.sort(accessEntries);
802                    if (accessEntries.size() > 0) {
803                        Element accessControlElement = explorerTypeElement.addElement(N_ACCESSCONTROL);
804                        Iterator<String> k = accessEntries.iterator();
805                        while (k.hasNext()) {
806                            String key = k.next();
807                            String value = settings.getAccess().getAccessEntries().get(key);
808                            Element accessEntryElement = accessControlElement.addElement(N_ACCESSENTRY);
809                            accessEntryElement.addAttribute(A_PRINCIPAL, key);
810                            accessEntryElement.addAttribute(A_PERMISSIONS, value);
811                        }
812                    }
813                }
814                // create subnode <editoptions>
815                if (settings.hasEditOptions()) {
816                    Element editOptionsElement = explorerTypeElement.addElement(N_EDITOPTIONS);
817                    Element defaultPropertiesElement = editOptionsElement.addElement(N_DEFAULTPROPERTIES);
818                    defaultPropertiesElement.addAttribute(A_ENABLED, String.valueOf(settings.isPropertiesEnabled()));
819                    defaultPropertiesElement.addAttribute(
820                        A_SHOWNAVIGATION,
821                        String.valueOf(settings.isShowNavigation()));
822                    Iterator<String> m = settings.getProperties().iterator();
823                    while (m.hasNext()) {
824                        Element propElem = defaultPropertiesElement.addElement(N_DEFAULTPROPERTY);
825                        String propName = m.next();
826                        if (settings.isPropertyRequiredOnUpload(propName)) {
827                            propElem.addAttribute(A_REQUIRED_ON_UPLOAD, "true");
828                        }
829                        propElem.addAttribute(A_NAME, propName);
830
831                    }
832                }
833
834                Map<String, CmsIconRule> iconRules = settings.getIconRules();
835                if ((iconRules != null) && !iconRules.isEmpty()) {
836                    Element iconRulesElem = explorerTypeElement.addElement(N_ICONRULES);
837                    for (Map.Entry<String, CmsIconRule> entry : iconRules.entrySet()) {
838                        CmsIconRule rule = entry.getValue();
839                        Element ruleElem = iconRulesElem.addElement(N_ICONRULE);
840                        String icon = rule.getIcon();
841                        String bigIcon = rule.getBigIcon();
842                        String extension = rule.getExtension();
843                        ruleElem.addAttribute(A_EXTENSION, extension);
844                        if (icon != null) {
845                            ruleElem.addAttribute(A_ICON, icon);
846                        }
847                        if (bigIcon != null) {
848                            ruleElem.addAttribute(A_BIGICON, bigIcon);
849                        }
850                        if (rule.getSmallIconStyle() != null) {
851                            ruleElem.addAttribute(A_SMALLICONSTYLE, rule.getSmallIconStyle());
852                        }
853                        if (rule.getBigIconStyle() != null) {
854                            ruleElem.addAttribute(A_BIGICONSTYLE, rule.getBigIconStyle());
855                        }
856                    }
857                }
858
859            }
860        }
861    }
862
863    /**
864     * @see org.opencms.configuration.I_CmsXmlConfiguration#addXmlDigesterRules(org.apache.commons.digester3.Digester)
865     */
866    public void addXmlDigesterRules(Digester digester) {
867
868        // add finish rule
869        digester.addCallMethod("*/" + N_WORKPLACE, "initializeFinished");
870
871        // generic <param> parameter rules
872        digester.addCallMethod(
873            "*/" + I_CmsXmlConfiguration.N_PARAM,
874            I_CmsConfigurationParameterHandler.ADD_PARAMETER_METHOD,
875            2);
876        digester.addCallParam("*/" + I_CmsXmlConfiguration.N_PARAM, 0, I_CmsXmlConfiguration.A_NAME);
877        digester.addCallParam("*/" + I_CmsXmlConfiguration.N_PARAM, 1);
878
879        // creation of the import/export manager
880        digester.addObjectCreate("*/" + N_WORKPLACE, CmsWorkplaceManager.class);
881        // import/export manager finished
882        digester.addSetNext("*/" + N_WORKPLACE, "setWorkplaceManager");
883
884        String path = "*/" + N_WORKPLACE + "/" + N_KEEP_ALIVE;
885        digester.addCallMethod(path, "setKeepAlive", 0);
886
887        // add exclude patterns
888        digester.addCallMethod(
889            "*/" + N_WORKPLACE + "/" + N_SYNCHRONIZATION + "/" + N_EXCLUDEPATTERN,
890            "addSynchronizeExcludePattern",
891            0);
892
893        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_GALLERY_DEFAULT_SCOPE, "setGalleryDefaultScope", 0);
894
895        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_ELEMENT_DELETE_MODE, "setElementDeleteMode", 0);
896
897        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_USER_LISTS, "setUserListMode", 1);
898        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_USER_LISTS, 0, A_MODE);
899
900        // add default locale rule
901        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_DEFAULTLOCALE, "setDefaultLocale", 0);
902
903        // add default properties on structure setting
904        digester.addCallMethod(
905            "*/" + N_WORKPLACE + "/" + N_DEFAULTPROPERTIESONSTRUCTURE,
906            "setDefaultPropertiesOnStructure",
907            0);
908
909        // add default properties on structure setting
910        digester.addCallMethod(
911            "*/" + N_WORKPLACE + "/" + N_ENABLEADVANCEDPROPERTYTABS,
912            "setEnableAdvancedPropertyTabs",
913            0);
914
915        // add category folder rule
916        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_CATEGORYFOLDER, "setCategoryFolder", 0);
917
918        // add category display options
919        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_CATEGORYDISPLAYOPTIONS, "setCategoryDisplayOptions", 2);
920        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_CATEGORYDISPLAYOPTIONS, 0, A_DISPLAY_BY_REPOSITORY);
921        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_CATEGORYDISPLAYOPTIONS, 1, A_DISPLAY_COLLAPSED);
922
923        // add explorer category options
924        digester.addCallMethod(
925            "*/" + N_WORKPLACE + "/" + N_DISPLAY_CATEGORIES_IN_EXPLORER,
926            "setExplorerCategoryOptions",
927            3);
928        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_DISPLAY_CATEGORIES_IN_EXPLORER, 0, A_ENABLED);
929        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_DISPLAY_CATEGORIES_IN_EXPLORER, 1, A_LEAVES_ONLY);
930        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_DISPLAY_CATEGORIES_IN_EXPLORER, 2, A_WITH_PATH);
931
932        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_GROUP_TRANSLATION, "setGroupTranslationClass", 1);
933        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_GROUP_TRANSLATION, 0, A_CLASS);
934
935        // add rules for dialog handlers
936        digester.addObjectCreate(
937            "*/" + N_WORKPLACE + "/" + N_DIALOGHANDLERS + "/" + N_DIALOGHANDLER,
938            CmsConfigurationException.class.getName(),
939            A_CLASS);
940        digester.addSetNext("*/" + N_WORKPLACE + "/" + N_DIALOGHANDLERS + "/" + N_DIALOGHANDLER, "addDialogHandler");
941        digester.addCallMethod(
942            "*/" + N_WORKPLACE + "/" + N_DIALOGHANDLERS + "/" + N_DIALOGHANDLER,
943            I_CmsConfigurationParameterHandler.INIT_CONFIGURATION_METHOD);
944
945        // add rules for editor handler
946        digester.addObjectCreate(
947            "*/" + N_WORKPLACE + "/" + N_EDITORHANDLER,
948            CmsConfigurationException.class.getName(),
949            A_CLASS);
950        digester.addSetNext("*/" + N_WORKPLACE + "/" + N_EDITORHANDLER, "setEditorHandler");
951
952        // add rules for editor handler
953        digester.addObjectCreate(
954            "*/" + N_WORKPLACE + "/" + N_POSTUPLOADHANDLER,
955            A_CLASS,
956            CmsConfigurationException.class);
957        digester.addSetNext("*/" + N_WORKPLACE + "/" + N_POSTUPLOADHANDLER, "setPostUploadHandler");
958
959        // add rules for editor action handler
960        digester.addObjectCreate(
961            "*/" + N_WORKPLACE + "/" + N_EDITORACTION,
962            CmsConfigurationException.class.getName(),
963            A_CLASS);
964        digester.addSetNext("*/" + N_WORKPLACE + "/" + N_EDITORACTION, "setEditorAction");
965
966        // add rules for editor css handler classes
967        digester.addCallMethod(
968            "*/" + N_WORKPLACE + "/" + N_EDITORCSSHANDLERS + "/" + N_EDITORCSSHANDLER,
969            "addEditorCssHandler",
970            1);
971        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_EDITORCSSHANDLERS + "/" + N_EDITORCSSHANDLER, 0, A_CLASS);
972
973        // add rules for pre editor action classes
974        digester.addObjectCreate(
975            "*/" + N_WORKPLACE + "/" + N_EDITORPRECONDITIONS + "/" + N_EDITORPRECONDITION,
976            CmsConfigurationException.class.getName(),
977            A_CLASS);
978        digester.addSetNext(
979            "*/" + N_WORKPLACE + "/" + N_EDITORPRECONDITIONS + "/" + N_EDITORPRECONDITION,
980            "addPreEditorConditionDefinition");
981
982        digester.addCallMethod(
983            "*/" + N_WORKPLACE + "/" + N_EDITORPRECONDITIONS + "/" + N_EDITORPRECONDITION,
984            "setResourceTypeName",
985            1);
986        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_EDITORPRECONDITIONS + "/" + N_EDITORPRECONDITION, 0, A_NAME);
987
988        digester.addCallMethod(
989            "*/" + N_WORKPLACE + "/" + N_EDITORPRECONDITIONS + "/" + N_EDITORPRECONDITION,
990            I_CmsConfigurationParameterHandler.INIT_CONFIGURATION_METHOD);
991
992        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_EDITOR_MAX_LOCALE_BUTTONS, "setEditorMaxLocaleButtons", 0);
993
994        // add rules for direct edit provider
995        digester.addObjectCreate(
996            "*/" + N_WORKPLACE + "/" + N_DIRECTEDITPROVIDER,
997            CmsConfigurationException.class.getName(),
998            A_CLASS);
999        digester.addCallMethod(
1000            "*/" + N_WORKPLACE + "/" + N_DIRECTEDITPROVIDER,
1001            I_CmsConfigurationParameterHandler.INIT_CONFIGURATION_METHOD);
1002        digester.addSetNext("*/" + N_WORKPLACE + "/" + N_DIRECTEDITPROVIDER, "setDirectEditProvider");
1003
1004        // add rules for the workplace export points
1005        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_EXPORTPOINTS + "/" + N_EXPORTPOINT, "addExportPoint", 2);
1006        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_EXPORTPOINTS + "/" + N_EXPORTPOINT, 0, A_URI);
1007        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_EXPORTPOINTS + "/" + N_EXPORTPOINT, 1, A_DESTINATION);
1008
1009        // add autolock rule
1010        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_AUTOLOCK, "setAutoLock", 0);
1011
1012        // acacia-unlock
1013        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_ACACIA_UNLOCK, "setAcaciaUnlock", 0);
1014
1015        // add XML content auto correction rule
1016        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_XMLCONTENTAUTOCORRECTION, "setXmlContentAutoCorrect", 0);
1017
1018        // add user management enabled rule
1019        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_ENABLEUSERMGMT, "setUserManagementEnabled", 0);
1020
1021        // add max file upload size rule
1022        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_MAXUPLOADSIZE, "setFileMaxUploadSize", 0);
1023
1024        // add labeled folders rule
1025        digester.addCallMethod("*/" + N_WORKPLACE + "/" + N_LABELEDFOLDERS + "/" + N_RESOURCE, "addLabeledFolder", 1);
1026        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_LABELEDFOLDERS + "/" + N_RESOURCE, 0, A_URI);
1027
1028        // set the gallery upload folder handler
1029        digester.addObjectCreate(
1030            "*/" + N_WORKPLACE + "/" + N_REPOSITORY_FOLDER,
1031            CmsConfigurationException.class.getName(),
1032            A_CLASS);
1033        digester.addSetNext("*/" + N_WORKPLACE + "/" + N_REPOSITORY_FOLDER, "setRepositoryFolderHandler");
1034
1035        // add localized folders rule
1036        digester.addCallMethod(
1037            "*/" + N_WORKPLACE + "/" + N_LOCALIZEDFOLDERS + "/" + N_RESOURCE,
1038            "addLocalizedFolder",
1039            1);
1040        digester.addCallParam("*/" + N_WORKPLACE + "/" + N_LOCALIZEDFOLDERS + "/" + N_RESOURCE, 0, A_URI);
1041
1042        // add fileViewSettings rules
1043        String xPathPrefix = "*/" + N_RFSFILEVIEWESETTINGS;
1044        digester.addObjectCreate(xPathPrefix, CmsRfsFileViewer.class);
1045        digester.addBeanPropertySetter(xPathPrefix + "/" + N_ROOTPATH);
1046        digester.addBeanPropertySetter(xPathPrefix + "/" + N_FILEPATH);
1047        digester.addBeanPropertySetter(xPathPrefix + "/" + N_ENABLED);
1048        digester.addBeanPropertySetter(xPathPrefix + "/" + N_FILEENCODING);
1049        digester.addBeanPropertySetter(xPathPrefix + "/" + N_ISLOGFILE);
1050        digester.addBeanPropertySetter(xPathPrefix + "/" + N_WINDOWSIZE);
1051
1052        // Cms specific rule similar to SetNextRule with implicit first CmsObject argument (remains null).
1053        digester.addRule(xPathPrefix, new CmsSetNextRule("setFileViewSettings", CmsRfsFileViewer.class));
1054
1055        digester.addRule("*/" + N_WORKPLACE + "/" + N_UPLOAD_RESTRICTION, new Rule() {
1056
1057            @Override
1058            public void begin(String namespace, String name, Attributes attributes) throws Exception {
1059
1060                String className = attributes.getValue(A_CLASS);
1061                Class<? extends I_CmsUploadRestriction> cls = Class.forName(
1062                    className,
1063                    false,
1064                    getClass().getClassLoader()).asSubclass(I_CmsUploadRestriction.class);
1065                digester.push(cls.newInstance());
1066            }
1067
1068            @Override
1069            public void end(String namespace, String name) throws Exception {
1070
1071                I_CmsUploadRestriction restriction = (I_CmsUploadRestriction)digester.pop();
1072                ((CmsWorkplaceManager)digester.peek()).setUploadRestriction(restriction);
1073            }
1074        });
1075
1076        digester.addRule("*/" + N_WORKPLACE + "/" + N_VIRUS_SCANNER, new Rule() {
1077
1078            private boolean m_enabled;
1079
1080            @Override
1081            public void begin(String namespace, String name, Attributes attributes) throws Exception {
1082
1083                String className = attributes.getValue(A_CLASS);
1084                m_enabled = false;
1085                if (className != null) {
1086                    m_enabled = Boolean.parseBoolean(attributes.getValue(A_ENABLED));
1087                    Class<? extends I_CmsVirusScanner> cls = Class.forName(
1088                        className,
1089                        false,
1090                        getClass().getClassLoader()).asSubclass(I_CmsVirusScanner.class);
1091                    digester.push(cls.newInstance());
1092                }
1093            }
1094
1095            @Override
1096            public void end(String namespace, String name) throws Exception {
1097
1098                if (digester.peek() instanceof I_CmsVirusScanner) { // there may be no virus scanner on the stack if the class name was empty or invalid
1099                    I_CmsVirusScanner scanner = (I_CmsVirusScanner)(digester.pop());
1100                    scanner.initConfiguration();
1101                    CmsWorkplaceManager wpMan = ((CmsWorkplaceManager)digester.peek());
1102                    wpMan.setVirusScanner(scanner);
1103                    wpMan.setVirusScannerEnabled(m_enabled);
1104                }
1105            }
1106
1107        });
1108
1109        // add explorer type rules
1110        addExplorerTypeXmlRules(digester);
1111        addDefaultAccessControlRules(digester);
1112        addUserInfoRules(digester);
1113        addAccountInfoRules(digester);
1114        addDefaultPreferencesRules(digester);
1115
1116        addToolManagerRules(digester);
1117        CmsAdditionalLogFolderConfig.ADD_LOG_FOLDER_HELPER.addRules(digester);
1118        digester.addSetNext(
1119            CmsAdditionalLogFolderConfig.ADD_LOG_FOLDER_HELPER.getBasePath(),
1120            "setAdditionalLogFolderConfiguration");
1121
1122        digester.addRule("*/" + N_WORKPLACE + "/" + N_USE_FORMATTER_KEYS_FOR_NEW_SITES, new Rule() {
1123
1124            @Override
1125            public void body(String namespace, String name, String text) throws Exception {
1126
1127                CmsResourceTypeSubsitemapContentFolder.setEnableNewPageFormatByDefault(Boolean.parseBoolean(text));
1128            }
1129        });
1130
1131        digester.addRule("*/" + N_WORKPLACE + "/" + N_SITEMAP_CONFIG_EDIT_ROLE, new Rule() {
1132
1133            @Override
1134            public void body(String namespace, String name, String text) throws Exception {
1135
1136                CmsWorkplaceManager wpManager = (CmsWorkplaceManager)(digester.peek());
1137                wpManager.setSitemapConfigEditRole(text);
1138            }
1139        });
1140
1141        digester.addRule("*/" + N_WORKPLACE + "/" + N_ALLOW_ELEMENT_AUTHOR_TO_WORK_IN_GALLERIES, new Rule() {
1142
1143            @Override
1144            public void body(String namespace, String name, String text) throws Exception {
1145
1146                CmsWorkplaceManager wpManager = (CmsWorkplaceManager)(digester.peek());
1147                wpManager.setAllowElementAuthorToWorkInGalleries(Boolean.valueOf(text).booleanValue());
1148            }
1149        });
1150
1151        digester.addRule("*/" + N_WORKPLACE + "/" + N_DETAIL_PAGE_MANAGEMENT_ROLE, new Rule() {
1152
1153            @Override
1154            public void body(String namespace, String name, String text) throws Exception {
1155
1156                CmsWorkplaceManager wpManager = (CmsWorkplaceManager)(digester.peek());
1157                if (text != null) {
1158                    text = text.trim();
1159                }
1160                wpManager.setSitemapEditorDetailPageManagementRole(text);
1161            }
1162        });
1163
1164        digester.addObjectCreate(
1165            "*/" + N_WORKPLACE + "/" + N_CONTENT_TRANSLATION,
1166            CmsConfigurationException.class.getName(),
1167            A_CLASS);
1168        digester.addSetNext("*/" + N_WORKPLACE + "/" + N_CONTENT_TRANSLATION, "setContentTranslation");
1169
1170    }
1171
1172    /**
1173     * @see org.opencms.configuration.I_CmsXmlConfiguration#generateXml(org.dom4j.Element)
1174     */
1175    public Element generateXml(Element parent) {
1176
1177        // generate workplace node and subnodes
1178        Element workplaceElement = parent.addElement(N_WORKPLACE);
1179        // add default locale
1180        workplaceElement.addElement(N_DEFAULTLOCALE).setText(m_workplaceManager.getDefaultLocale().toString());
1181
1182        // add <localizedfolders> subnode
1183        Element localizedElement = workplaceElement.addElement(N_LOCALIZEDFOLDERS);
1184        Iterator<String> localizedIterator = m_workplaceManager.getLocalizedFolders().iterator();
1185        while (localizedIterator.hasNext()) {
1186            // add <resource uri=""/> element(s)
1187            localizedElement.addElement(N_RESOURCE).addAttribute(A_URI, localizedIterator.next());
1188        }
1189
1190        // add <dialoghandlers> subnode
1191        Element dialogElement = workplaceElement.addElement(N_DIALOGHANDLERS);
1192        Map<String, I_CmsDialogHandler> dialogs = m_workplaceManager.getDialogHandler();
1193        String[] keys = dialogs.keySet().toArray(new String[0]);
1194        Arrays.sort(keys);
1195        for (int j = 0; j < keys.length; j++) {
1196            String name = keys[j];
1197            // add <dialoghandler> subnode with class attribute
1198            Element dialogHandler = dialogElement.addElement(N_DIALOGHANDLER).addAttribute(
1199                A_CLASS,
1200                dialogs.get(name).getClass().getName());
1201            I_CmsDialogHandler daialogHandlerConfig = dialogs.get(name);
1202            CmsParameterConfiguration handlerConfig = daialogHandlerConfig.getConfiguration();
1203            if (handlerConfig != null) {
1204                handlerConfig.appendToXml(dialogHandler);
1205            }
1206        }
1207
1208        // add miscellaneous editor subnodes
1209        workplaceElement.addElement(N_EDITORHANDLER).addAttribute(
1210            A_CLASS,
1211            m_workplaceManager.getEditorHandler().getClass().getName());
1212        workplaceElement.addElement(N_EDITORACTION).addAttribute(
1213            A_CLASS,
1214            m_workplaceManager.getEditorActionHandler().getClass().getName());
1215
1216        if (m_workplaceManager.getPostUploadHandler() != null) {
1217            workplaceElement.addElement(N_POSTUPLOADHANDLER).addAttribute(
1218                A_CLASS,
1219                m_workplaceManager.getPostUploadHandler().getClass().getName());
1220        }
1221
1222        if (m_workplaceManager.getEditorCssHandlers().size() > 0) {
1223            Element editorCssHandlers = workplaceElement.addElement(N_EDITORCSSHANDLERS);
1224            Iterator<I_CmsEditorCssHandler> it = m_workplaceManager.getEditorCssHandlers().iterator();
1225            while (it.hasNext()) {
1226                I_CmsEditorCssHandler current = it.next();
1227                Element handler = editorCssHandlers.addElement(N_EDITORCSSHANDLER);
1228                handler.addAttribute(A_CLASS, current.getClass().getName());
1229            }
1230        }
1231
1232        if (m_workplaceManager.getPreEditorConditionDefinitions().size() > 0) {
1233            Element editorPreActions = workplaceElement.addElement(N_EDITORPRECONDITIONS);
1234            Iterator<I_CmsPreEditorActionDefinition> it = m_workplaceManager.getPreEditorConditionDefinitions().iterator();
1235            while (it.hasNext()) {
1236                I_CmsPreEditorActionDefinition current = it.next();
1237                Element action = editorPreActions.addElement(N_EDITORPRECONDITION);
1238                action.addAttribute(A_NAME, current.getResourceTypeName());
1239                action.addAttribute(A_CLASS, current.getClass().getName());
1240                // get the configuration parameters
1241                CmsParameterConfiguration config = current.getConfiguration();
1242                if ((config != null) && (config.size() > 0)) {
1243                    // append the configuration parameters
1244                    config.appendToXml(action);
1245                }
1246            }
1247        }
1248
1249        Element maxLocaleElem = workplaceElement.addElement(N_EDITOR_MAX_LOCALE_BUTTONS);
1250        maxLocaleElem.setText("" + m_workplaceManager.getEditorMaxLocaleButtons());
1251
1252        I_CmsContentTranslator translator = m_workplaceManager.getContentTranslation(null);
1253        if (translator != null) {
1254            Element translationElement = workplaceElement.addElement(N_CONTENT_TRANSLATION);
1255            translationElement.addAttribute(A_CLASS, translator.getClass().getName());
1256            for (Map.Entry<String, String> entry : translator.getConfiguration().entrySet()) {
1257                Element paramElement = translationElement.addElement(N_PARAM);
1258                paramElement.addAttribute(A_NAME, entry.getKey());
1259                paramElement.setText(entry.getValue());
1260            }
1261        }
1262
1263        I_CmsConfigurationParameterHandler deProvider = m_workplaceManager.getDirectEditProvider();
1264        Element deProviderNode = workplaceElement.addElement(N_DIRECTEDITPROVIDER).addAttribute(
1265            A_CLASS,
1266            deProvider.getClass().getName());
1267        CmsParameterConfiguration deProviderConfig = deProvider.getConfiguration();
1268        if (deProviderConfig != null) {
1269            deProviderConfig.appendToXml(deProviderNode);
1270        }
1271
1272        // add <exportpoints> subnode
1273        Element resourceloadersElement = workplaceElement.addElement(N_EXPORTPOINTS);
1274        Set<CmsExportPoint> points = m_workplaceManager.getExportPoints();
1275        Iterator<CmsExportPoint> exportPoints = points.iterator();
1276        while (exportPoints.hasNext()) {
1277            CmsExportPoint point = exportPoints.next();
1278            resourceloadersElement.addElement(N_EXPORTPOINT).addAttribute(A_URI, point.getUri()).addAttribute(
1279                A_DESTINATION,
1280                point.getConfiguredDestination());
1281        }
1282
1283        // add miscellaneous configuration nodes
1284        workplaceElement.addElement(N_AUTOLOCK).setText(String.valueOf(m_workplaceManager.autoLockResources()));
1285        String acaciaUnlock = m_workplaceManager.getAcaciaUnlock();
1286        if (acaciaUnlock != null) {
1287            workplaceElement.addElement(N_ACACIA_UNLOCK).setText(acaciaUnlock);
1288        }
1289
1290        workplaceElement.addElement(N_XMLCONTENTAUTOCORRECTION).setText(
1291            String.valueOf(m_workplaceManager.isXmlContentAutoCorrect()));
1292        workplaceElement.addElement(N_ENABLEUSERMGMT).setText(String.valueOf(m_workplaceManager.showUserGroupIcon()));
1293        workplaceElement.addElement(N_DEFAULTPROPERTIESONSTRUCTURE).setText(
1294            String.valueOf(m_workplaceManager.isDefaultPropertiesOnStructure()));
1295        workplaceElement.addElement(N_ENABLEADVANCEDPROPERTYTABS).setText(
1296            String.valueOf(m_workplaceManager.isEnableAdvancedPropertyTabs()));
1297
1298        // add <categoryfolder> node
1299        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_workplaceManager.getCategoryFolder())
1300            && !CmsCategoryService.REPOSITORY_BASE_FOLDER.equals(m_workplaceManager.getCategoryFolder())) {
1301            workplaceElement.addElement(N_CATEGORYFOLDER).setText(
1302                String.valueOf(m_workplaceManager.getCategoryFolder()));
1303        }
1304
1305        // add <categorydisplayoptions> node
1306        if (m_workplaceManager.isDisplayCategoriesByRepository()
1307            || m_workplaceManager.isDisplayCategorySelectionCollapsed()) {
1308            Element categoryDisplayOptions = workplaceElement.addElement(N_CATEGORYDISPLAYOPTIONS);
1309            if (m_workplaceManager.isDisplayCategoriesByRepository()) {
1310                categoryDisplayOptions.addAttribute(A_DISPLAY_BY_REPOSITORY, "true");
1311            }
1312            if (m_workplaceManager.isDisplayCategorySelectionCollapsed()) {
1313                categoryDisplayOptions.addAttribute(A_DISPLAY_COLLAPSED, "true");
1314            }
1315        }
1316
1317        Element explorerCategories = workplaceElement.addElement(N_DISPLAY_CATEGORIES_IN_EXPLORER);
1318        explorerCategories.addAttribute(A_ENABLED, "" + m_workplaceManager.isExplorerCategoriesEnabled());
1319        explorerCategories.addAttribute(A_LEAVES_ONLY, "" + m_workplaceManager.isExplorerCategoriesLeavesOnly());
1320        explorerCategories.addAttribute(A_WITH_PATH, "" + m_workplaceManager.isExplorerCategoriesWithPath());
1321
1322        String groupTranslationClass = m_workplaceManager.getGroupTranslationClass();
1323        if (groupTranslationClass != null) {
1324            Element groupTranslationElement = workplaceElement.addElement(N_GROUP_TRANSLATION);
1325            groupTranslationElement.addAttribute(A_CLASS, groupTranslationClass);
1326        }
1327
1328        workplaceElement.addElement(N_MAXUPLOADSIZE).setText(String.valueOf(m_workplaceManager.getFileMaxUploadSize()));
1329
1330        // add <labeledfolders> resource list
1331        Element labeledElement = workplaceElement.addElement(N_LABELEDFOLDERS);
1332        Iterator<String> sitesFolders = m_workplaceManager.getLabelSiteFolders().iterator();
1333        while (sitesFolders.hasNext()) {
1334            labeledElement.addElement(N_RESOURCE).addAttribute(A_URI, sitesFolders.next());
1335        }
1336        // add the <galleryupload> node
1337        workplaceElement.addElement(N_REPOSITORY_FOLDER).addAttribute(
1338            A_CLASS,
1339            m_workplaceManager.getRepositoryFolderHandler().getClass().getName());
1340
1341        // add <rfsfileviewsettings> node
1342        CmsRfsFileViewer viewSettings = m_workplaceManager.getFileViewSettings();
1343        Element fileViewElement = workplaceElement.addElement(N_RFSFILEVIEWESETTINGS);
1344        String rootPath = viewSettings.getRootPath();
1345        if (rootPath != null) {
1346            fileViewElement.addElement(N_ROOTPATH).setText(rootPath);
1347        }
1348        String filePath = viewSettings.getFilePath();
1349        if (filePath != null) {
1350            fileViewElement.addElement(N_FILEPATH).setText(filePath);
1351        }
1352        fileViewElement.addElement(N_ENABLED).setText(String.valueOf(viewSettings.isEnabled()));
1353        fileViewElement.addElement(N_FILEENCODING).setText(viewSettings.getFileEncoding());
1354        fileViewElement.addElement(N_ISLOGFILE).setText(String.valueOf(viewSettings.getIsLogfile()));
1355        fileViewElement.addElement(N_WINDOWSIZE).setText(String.valueOf(viewSettings.getWindowSize()));
1356
1357        // add <explorertypes> node
1358        Element explorerTypesElement = workplaceElement.addElement(N_EXPLORERTYPES);
1359        List<CmsExplorerTypeSettings> explorerTypes = m_workplaceManager.getWorkplaceExplorerTypeSettings();
1360        generateExplorerTypesXml(explorerTypesElement, explorerTypes, false);
1361
1362        // add the <defaultaccesscontrol> node
1363        Element defaultAccessControlElement = explorerTypesElement.addElement(N_DEFAULTACCESSCONTROL);
1364        // create subnode <accesscontrol>
1365        List<String> accessEntries = new ArrayList<String>();
1366        // sort accessEntries
1367        CmsExplorerTypeAccess access = m_workplaceManager.getDefaultAccess();
1368        Iterator<String> iter = access.getAccessEntries().keySet().iterator();
1369        while (iter.hasNext()) {
1370            accessEntries.add(iter.next());
1371        }
1372        Collections.sort(accessEntries);
1373
1374        if (accessEntries.size() > 0) {
1375            Element accessControlElement = defaultAccessControlElement.addElement(N_ACCESSCONTROL);
1376            Iterator<String> k = accessEntries.iterator();
1377
1378            while (k.hasNext()) {
1379                String key = k.next();
1380                String value = m_workplaceManager.getDefaultAccess().getAccessEntries().get(key);
1381                Element accessEntryElement = accessControlElement.addElement(N_ACCESSENTRY);
1382                accessEntryElement.addAttribute(A_PRINCIPAL, key);
1383                accessEntryElement.addAttribute(A_PERMISSIONS, value);
1384            }
1385        }
1386
1387        // add the user-infos node
1388        if (m_workplaceManager.getUserInfoManager() != null) {
1389            Element userInfosElement = workplaceElement.addElement(N_USERINFOS);
1390            Iterator<CmsWorkplaceUserInfoBlock> infoBlocks = m_workplaceManager.getUserInfoManager().getBlocks().iterator();
1391            while (infoBlocks.hasNext()) {
1392                CmsWorkplaceUserInfoBlock block = infoBlocks.next();
1393                Element infoBlockElement = userInfosElement.addElement(N_INFOBLOCK);
1394                infoBlockElement.addAttribute(A_NAME, block.getTitle());
1395
1396                Iterator<CmsWorkplaceUserInfoEntry> itEntries = block.getEntries().iterator();
1397                while (itEntries.hasNext()) {
1398                    CmsWorkplaceUserInfoEntry entry = itEntries.next();
1399                    Element userInfoElement = infoBlockElement.addElement(N_USERINFO);
1400                    userInfoElement.addAttribute(A_KEY, entry.getKey());
1401                    if (entry.getType() != null) {
1402                        userInfoElement.addAttribute(A_TYPE, entry.getType());
1403                    }
1404                    if (entry.getWidget() != null) {
1405                        userInfoElement.addAttribute(A_WIDGET, entry.getWidget());
1406                    }
1407                    if (entry.getParams() != null) {
1408                        userInfoElement.addAttribute(A_PARAMS, entry.getParams());
1409                    }
1410                    if (entry.getOptional() != null) {
1411                        userInfoElement.addAttribute(A_OPTIONAL, entry.getOptional());
1412                    }
1413                }
1414            }
1415        }
1416
1417        List<CmsAccountInfo> accountInfos = m_workplaceManager.getConfiguredAccountInfos();
1418        if (accountInfos != null) {
1419            Element infosElement = workplaceElement.addElement(N_ACCOUNTINFOS);
1420            for (CmsAccountInfo info : accountInfos) {
1421                Element infoElement = infosElement.addElement(N_ACCOUNTINFO);
1422                infoElement.addAttribute(A_FIELD, info.getField().name());
1423                if (info.isAdditionalInfo()) {
1424                    infoElement.addAttribute(A_ADD_INFO_KEY, info.getAddInfoKey());
1425                }
1426                infoElement.addAttribute(A_EDITABLE, Boolean.toString(info.isEditable()));
1427            }
1428        }
1429
1430        // add the <default-preferences> user settings main node
1431        Element defaultPreferences = workplaceElement.addElement(N_DEFAULTPREFERENCES);
1432
1433        Multimap<String, I_CmsPreference> prefsByTab = Multimaps.index(
1434            m_workplaceManager.getDefaultUserSettings().getPreferences().values(),
1435            new Function<I_CmsPreference, String>() {
1436
1437                public String apply(I_CmsPreference input) {
1438
1439                    return input.getTab();
1440                }
1441            });
1442
1443        for (String tabName : new String[] {
1444            CmsGwtConstants.TAB_BASIC,
1445            CmsGwtConstants.TAB_EXTENDED,
1446            CmsGwtConstants.TAB_HIDDEN}) {
1447            Element preferenceTab = defaultPreferences.addElement(N_PREFERENCE_TAB).addAttribute("name", tabName);
1448            for (I_CmsPreference pref : prefsByTab.get(tabName)) {
1449                Element elem = pref.createConfigurationItem();
1450                if (elem != null) {
1451                    preferenceTab.add(elem);
1452                }
1453            }
1454        }
1455
1456        // add the tool-manager node
1457        Element toolManagerElement = workplaceElement.addElement(N_TOOLMANAGER);
1458        Element rootsElement = toolManagerElement.addElement(N_ROOTS);
1459        Iterator<CmsToolRootHandler> it = m_workplaceManager.getToolManager().getToolRoots().iterator();
1460        while (it.hasNext()) {
1461            CmsToolRootHandler root = it.next();
1462            Element rootElement = rootsElement.addElement(N_ROOT);
1463            rootElement.addElement(N_KEY).addText(root.getKey());
1464            rootElement.addElement(N_URI).addText(root.getUri());
1465            rootElement.addElement(N_NAME).addText(root.getName());
1466            rootElement.addElement(N_HELPTEXT).addText(root.getHelpText());
1467        }
1468        String userListsMode = m_workplaceManager.getUserListModeString();
1469        if (userListsMode != null) {
1470            Element userListsElem = workplaceElement.addElement(N_USER_LISTS);
1471            userListsElem.addAttribute(A_MODE, userListsMode);
1472        }
1473
1474        Boolean keepAlive = m_workplaceManager.isKeepAlive(false);
1475        if (keepAlive != null) {
1476            workplaceElement.addElement(N_KEEP_ALIVE).setText(keepAlive.toString());
1477        }
1478
1479        String defaultScope = m_workplaceManager.getGalleryDefaultScopeString();
1480        if (defaultScope != null) {
1481            workplaceElement.addElement(N_GALLERY_DEFAULT_SCOPE).setText(defaultScope);
1482        }
1483        ElementDeleteMode deleteMode = m_workplaceManager.getElementDeleteMode();
1484        if (deleteMode != null) {
1485            workplaceElement.addElement(N_ELEMENT_DELETE_MODE).setText(deleteMode.name());
1486        }
1487
1488        CmsAdditionalLogFolderConfig.ADD_LOG_FOLDER_HELPER.generateXml(
1489            workplaceElement,
1490            m_workplaceManager.getAdditionalLogFolderConfiguration());
1491
1492        boolean useKeysForNewSites = CmsResourceTypeSubsitemapContentFolder.isEnableNewPageFormatByDefault();
1493        workplaceElement.addElement(N_USE_FORMATTER_KEYS_FOR_NEW_SITES).setText("" + useKeysForNewSites);
1494
1495        I_CmsUploadRestriction restriction = m_workplaceManager.getUploadRestriction();
1496        Element uploadRestrictionElem = workplaceElement.addElement(N_UPLOAD_RESTRICTION);
1497        uploadRestrictionElem.addAttribute(A_CLASS, restriction.getClass().getName());
1498        restriction.getConfiguration().appendToXml(uploadRestrictionElem);
1499
1500        I_CmsVirusScanner virusScanner = m_workplaceManager.getVirusScanner();
1501        Element virusScannerElem = workplaceElement.addElement(N_VIRUS_SCANNER);
1502        boolean enabled = false;
1503        if (virusScanner != null) {
1504            virusScannerElem.addAttribute(A_CLASS, virusScanner.getClass().getName());
1505            enabled = m_workplaceManager.isVirusScannerEnabled();
1506            virusScanner.getConfiguration().appendToXml(virusScannerElem);
1507        }
1508        virusScannerElem.addAttribute(A_ENABLED, "" + enabled);
1509
1510        String sitemapConfigEditRole = m_workplaceManager.getSitemapConfigEditRole();
1511        if (sitemapConfigEditRole != null) {
1512            workplaceElement.addElement(N_SITEMAP_CONFIG_EDIT_ROLE).addText(sitemapConfigEditRole);
1513        }
1514
1515        boolean allowElementAuthorToWorkInGalleries = m_workplaceManager.isAllowElementAuthorToWorkInGalleries();
1516        workplaceElement.addElement(N_ALLOW_ELEMENT_AUTHOR_TO_WORK_IN_GALLERIES).addText(
1517            "" + allowElementAuthorToWorkInGalleries);
1518
1519        String detailPageRole = m_workplaceManager.getSitemapEditorDetailPageManagementRole();
1520        if (detailPageRole != null) {
1521            workplaceElement.addElement(N_DETAIL_PAGE_MANAGEMENT_ROLE).addText(detailPageRole);
1522        }
1523
1524        // return the configured node
1525        return workplaceElement;
1526    }
1527
1528    /**
1529     * @see org.opencms.configuration.I_CmsXmlConfiguration#getDtdFilename()
1530     */
1531    public String getDtdFilename() {
1532
1533        return CONFIGURATION_DTD_NAME;
1534    }
1535
1536    /**
1537     * Returns the initialized workplace manager.<p>
1538     *
1539     * @return the initialized workplace manager
1540     */
1541    public CmsWorkplaceManager getWorkplaceManager() {
1542
1543        return m_workplaceManager;
1544    }
1545
1546    /**
1547     * Will be called when configuration of this object is finished.<p>
1548     */
1549    public void initializeFinished() {
1550
1551        if (CmsLog.INIT.isInfoEnabled()) {
1552            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_FINISHED_0));
1553        }
1554    }
1555
1556    /**
1557     * Sets the generated workplace manager.<p>
1558     *
1559     * @param manager the workplace manager to set
1560     */
1561    public void setWorkplaceManager(CmsWorkplaceManager manager) {
1562
1563        m_workplaceManager = manager;
1564        if (CmsLog.INIT.isInfoEnabled()) {
1565            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_INIT_FINISHED_0));
1566        }
1567    }
1568
1569    /**
1570     * Adds the digester rules for account info nodes.<p>
1571     *
1572     * @param digester the digester
1573     */
1574    protected void addAccountInfoRules(Digester digester) {
1575
1576        // add account info
1577        String rulePath = "*/" + N_ACCOUNTINFOS + "/" + N_ACCOUNTINFO;
1578        digester.addCallMethod(rulePath, "addAccountInfo", 3);
1579        digester.addCallParam(rulePath, 0, A_FIELD);
1580        digester.addCallParam(rulePath, 1, A_ADD_INFO_KEY);
1581        digester.addCallParam(rulePath, 2, A_EDITABLE);
1582    }
1583
1584    /**
1585     * Adds the digester rules for the defaultaccesscontrol node.<p>
1586     *
1587     * @param digester the digester object
1588     */
1589    protected void addDefaultAccessControlRules(Digester digester) {
1590
1591        digester.addObjectCreate(
1592            "*/" + N_WORKPLACE + "/" + N_EXPLORERTYPES + "/" + N_DEFAULTACCESSCONTROL + "/" + N_ACCESSCONTROL,
1593            CmsExplorerTypeAccess.class);
1594        digester.addSetNext(
1595            "*/" + N_WORKPLACE + "/" + N_EXPLORERTYPES + "/" + N_DEFAULTACCESSCONTROL + "/" + N_ACCESSCONTROL,
1596            "setDefaultAccess");
1597
1598        digester.addCallMethod(
1599            "*/"
1600                + N_WORKPLACE
1601                + "/"
1602                + N_EXPLORERTYPES
1603                + "/"
1604                + N_DEFAULTACCESSCONTROL
1605                + "/"
1606                + N_ACCESSCONTROL
1607                + "/"
1608                + N_ACCESSENTRY,
1609            "addAccessEntry",
1610            2);
1611        digester.addCallParam(
1612            "*/"
1613                + N_WORKPLACE
1614                + "/"
1615                + N_EXPLORERTYPES
1616                + "/"
1617                + N_DEFAULTACCESSCONTROL
1618                + "/"
1619                + N_ACCESSCONTROL
1620                + "/"
1621                + N_ACCESSENTRY,
1622            0,
1623            A_PRINCIPAL);
1624        digester.addCallParam(
1625            "*/"
1626                + N_WORKPLACE
1627                + "/"
1628                + N_EXPLORERTYPES
1629                + "/"
1630                + N_DEFAULTACCESSCONTROL
1631                + "/"
1632                + N_ACCESSCONTROL
1633                + "/"
1634                + N_ACCESSENTRY,
1635            1,
1636            A_PERMISSIONS);
1637    }
1638
1639    /**
1640     * Adds the digester rules for the default-preferences node.<p>
1641     *
1642     * @param digester the digester object
1643     */
1644    protected void addDefaultPreferencesRules(Digester digester) {
1645
1646        // creation of the default user settings
1647        digester.addObjectCreate("*/" + N_WORKPLACE + "/" + N_DEFAULTPREFERENCES, CmsDefaultUserSettings.class);
1648        digester.addSetNext("*/" + N_WORKPLACE + "/" + N_DEFAULTPREFERENCES, "setDefaultUserSettings");
1649
1650        // TODO: most of these settings are not user dependent, so they should not be stored in the CmsDefaultUserSettings class
1651
1652        // add workplace preferences general options rules
1653        String xPathPrefix = "*/"
1654            + N_WORKPLACE
1655            + "/"
1656            + N_DEFAULTPREFERENCES
1657            + "/"
1658            + N_WORKPLACEPREFERENCES
1659            + "/"
1660            + N_WORKPLACEGENERALOPTIONS;
1661        digester.addCallMethod(xPathPrefix + "/" + N_BUTTONSTYLE, "setWorkplaceButtonStyle", 0);
1662        digester.addCallMethod(xPathPrefix + "/" + N_REPORTTYPE, "setWorkplaceReportType", 0);
1663        digester.addCallMethod(xPathPrefix + "/" + N_UPLOADAPPLET, "setUploadVariant", 0);
1664        digester.addCallMethod(xPathPrefix + "/" + N_LISTALLPROJECTS, "setListAllProjects", 0);
1665        digester.addCallMethod(xPathPrefix + "/" + N_PUBLISHNOTIFICATION, "setShowPublishNotification", 0);
1666        digester.addCallMethod(xPathPrefix + "/" + N_PUBLISHBUTTONAPPEARANCE, "setPublishButtonAppearance", 0);
1667        digester.addCallMethod(xPathPrefix + "/" + N_SHOWFILEUPLOADBUTTON, "setShowFileUploadButton", 0);
1668
1669        // add allow broken relations rule
1670        digester.addCallMethod(xPathPrefix + "/" + N_ALLOWBROKENRELATIONS, "setAllowBrokenRelations", 0);
1671
1672        // add publish related resources rule
1673        digester.addCallMethod(xPathPrefix + "/" + N_PUBLISHRELATEDRESOURCES, "setPublishRelatedResourcesMode", 0);
1674
1675        // add rules for the new folder dialog settings
1676        digester.addCallMethod(xPathPrefix + "/" + N_NEWFOLDEREDITPROPERTIES, "setNewFolderEditProperties", 0);
1677        digester.addCallMethod(xPathPrefix + "/" + N_NEWFOLDERCREATEINDEXPAGE, "setNewFolderCreateIndexPage", 0);
1678        digester.addCallMethod(xPathPrefix + "/" + N_SHOWUPLOADTYPEDIALOG, "setShowUploadTypeDialog", 0);
1679        digester.addCallMethod(xPathPrefix + "/" + N_SUBSITEMAP_CREATION_MODE, "setSubsitemapCreationMode", 0);
1680
1681        // add workplace preferences startup settings rules
1682        xPathPrefix = "*/"
1683            + N_WORKPLACE
1684            + "/"
1685            + N_DEFAULTPREFERENCES
1686            + "/"
1687            + N_WORKPLACEPREFERENCES
1688            + "/"
1689            + N_WORKPLACESTARTUPSETTINGS;
1690        digester.addCallMethod(xPathPrefix + "/" + N_LOCALE, "setLocale", 0);
1691        digester.addCallMethod(xPathPrefix + "/" + N_PROJECT, "setStartProject", 0);
1692        digester.addCallMethod(xPathPrefix + "/" + N_WORKPLACEVIEW, "setStartView", 0);
1693        digester.addCallMethod(xPathPrefix + "/" + N_FOLDER, "setStartFolder", 0);
1694        digester.addCallMethod(xPathPrefix + "/" + N_SITE, "setStartSite", 0);
1695        digester.addCallMethod(xPathPrefix + "/" + N_RESTRICTEXPLORERVIEW, "setRestrictExplorerView", 0);
1696
1697        // add workplace search rules
1698        xPathPrefix = "*/"
1699            + N_WORKPLACE
1700            + "/"
1701            + N_DEFAULTPREFERENCES
1702            + "/"
1703            + N_WORKPLACEPREFERENCES
1704            + "/"
1705            + N_WORKPLACESEARCH;
1706        digester.addCallMethod(xPathPrefix + "/" + N_SEARCHINDEXNAME, "setWorkplaceSearchIndexName", 0);
1707        digester.addCallMethod(xPathPrefix + "/" + N_SEARCHVIEWSTYLE, "setWorkplaceSearchViewStyle", 0);
1708
1709        // add explorer preferences generaloptions rules
1710        xPathPrefix = "*/"
1711            + N_WORKPLACE
1712            + "/"
1713            + N_DEFAULTPREFERENCES
1714            + "/"
1715            + N_EXPLORERPREFERENCES
1716            + "/"
1717            + N_EXPLORERGENERALOPTIONS;
1718        digester.addCallMethod(xPathPrefix + "/" + N_BUTTONSTYLE, "setExplorerButtonStyle", 0);
1719        digester.addCallMethod(xPathPrefix + "/" + N_ENTRIES, "setExplorerFileEntries", 0);
1720        digester.addCallMethod(xPathPrefix + "/" + N_ENTRYOPTIONS, "setExplorerFileEntryOptions", 0);
1721
1722        // add explorer display options rules
1723        xPathPrefix = "*/"
1724            + N_WORKPLACE
1725            + "/"
1726            + N_DEFAULTPREFERENCES
1727            + "/"
1728            + N_EXPLORERPREFERENCES
1729            + "/"
1730            + N_EXPLORERDISPLAYOPTIONS;
1731        digester.addCallMethod(xPathPrefix + "/" + N_TITLE, "setShowExplorerFileTitle", 0);
1732        digester.addCallMethod(xPathPrefix + "/" + N_NAVTEXT, "setShowExplorerFileNavText", 0);
1733        digester.addCallMethod(xPathPrefix + "/" + N_TYPE, "setShowExplorerFileType", 0);
1734        digester.addCallMethod(xPathPrefix + "/" + N_DATELASTMODIFIED, "setShowExplorerFileDateLastModified", 0);
1735        digester.addCallMethod(xPathPrefix + "/" + N_DATECREATED, "setShowExplorerFileDateCreated", 0);
1736        digester.addCallMethod(xPathPrefix + "/" + N_LOCKEDBY, "setShowExplorerFileLockedBy", 0);
1737        digester.addCallMethod(xPathPrefix + "/" + N_PERMISSIONS, "setShowExplorerFilePermissions", 0);
1738        digester.addCallMethod(xPathPrefix + "/" + N_SIZE, "setShowExplorerFileSize", 0);
1739        digester.addCallMethod(xPathPrefix + "/" + N_STATE, "setShowExplorerFileState", 0);
1740        digester.addCallMethod(xPathPrefix + "/" + N_USERLASTMODIFIED, "setShowExplorerFileUserLastModified", 0);
1741        digester.addCallMethod(xPathPrefix + "/" + N_USERCREATED, "setShowExplorerFileUserCreated", 0);
1742        digester.addCallMethod(xPathPrefix + "/" + N_DATERELEASED, "setShowExplorerFileDateReleased", 0);
1743        digester.addCallMethod(xPathPrefix + "/" + N_DATEEXPIRED, "setShowExplorerFileDateExpired", 0);
1744
1745        // add dialog preferences rules
1746        xPathPrefix = "*/"
1747            + N_WORKPLACE
1748            + "/"
1749            + N_DEFAULTPREFERENCES
1750            + "/"
1751            + N_DIALOGSPREFERENCES
1752            + "/"
1753            + N_DIALOGSDEFAULTSETTINGS;
1754        digester.addCallMethod(xPathPrefix + "/" + N_FILECOPY, "setDialogCopyFileMode", 0);
1755        digester.addCallMethod(xPathPrefix + "/" + N_FOLDERCOPY, "setDialogCopyFolderMode", 0);
1756        digester.addCallMethod(xPathPrefix + "/" + N_FILEDELETION, "setDialogDeleteFileMode", 0);
1757        digester.addCallMethod(xPathPrefix + "/" + N_DIRECTPUBLISH, "setDialogPublishSiblings", 0);
1758        digester.addCallMethod(xPathPrefix + "/" + N_SHOWLOCK, "setShowLockDialog", 0);
1759        digester.addCallMethod(xPathPrefix + "/" + N_SHOWEXPORTSETTINGS, "setShowExportSettingsDialog", 0);
1760        digester.addCallMethod(
1761            xPathPrefix + "/" + N_PERMISSIONSINHERITONFOLDER,
1762            "setDialogPermissionsInheritOnFolder",
1763            0);
1764        digester.addCallMethod(
1765            xPathPrefix + "/" + N_EXPANDPERMISSIONSINHERITED,
1766            "setDialogExpandInheritedPermissions",
1767            0);
1768        digester.addCallMethod(xPathPrefix + "/" + N_EXPANDPERMISSIONSUSER, "setDialogExpandUserPermissions", 0);
1769
1770        // add editor generaloptions rules
1771        xPathPrefix = "*/"
1772            + N_WORKPLACE
1773            + "/"
1774            + N_DEFAULTPREFERENCES
1775            + "/"
1776            + N_EDITORPREFERENCES
1777            + "/"
1778            + N_EDITORGENERALOPTIONS;
1779        digester.addCallMethod(xPathPrefix + "/" + N_BUTTONSTYLE, "setEditorButtonStyle", 0);
1780        digester.addCallMethod(xPathPrefix + "/" + N_DIRECTEDITSTYLE, "setDirectEditButtonStyle", 0);
1781
1782        // add editor preferrededitor rules
1783        xPathPrefix = "*/"
1784            + N_WORKPLACE
1785            + "/"
1786            + N_DEFAULTPREFERENCES
1787            + "/"
1788            + N_EDITORPREFERENCES
1789            + "/"
1790            + N_EDITORPREFERREDEDITORS;
1791        digester.addCallMethod(xPathPrefix + "/" + N_EDITOR, "setPreferredEditor", 2);
1792        digester.addCallParam(xPathPrefix + "/" + N_EDITOR, 0, A_TYPE);
1793        digester.addCallParam(xPathPrefix + "/" + N_EDITOR, 1, A_VALUE);
1794
1795        // add startgallery rules
1796        xPathPrefix = "*/"
1797            + N_WORKPLACE
1798            + "/"
1799            + N_DEFAULTPREFERENCES
1800            + "/"
1801            + N_GALLERIESPREFERENCES
1802            + "/"
1803            + N_STARTGALLERIES;
1804        digester.addCallMethod(xPathPrefix + "/" + N_STARTGALLERY, "setStartGallery", 2);
1805        digester.addCallParam(xPathPrefix + "/" + N_STARTGALLERY, 0, A_TYPE);
1806        digester.addCallParam(xPathPrefix + "/" + N_STARTGALLERY, 1, A_PATH);
1807
1808        digester.addRule("*/" + N_WORKPLACE + "/" + N_DEFAULTPREFERENCES + "/preference-tab", new Rule() {
1809
1810            @Override
1811            public void begin(String namespace, String name, Attributes attributes) throws Exception {
1812
1813                getDigester().push(attributes.getValue("name"));
1814            }
1815
1816            @Override
1817            public void end(String namespace, String name) throws Exception {
1818
1819                getDigester().pop();
1820            }
1821        });
1822
1823        String prefPath = "*/" + N_WORKPLACE + "/" + N_DEFAULTPREFERENCES + "/preference-tab/" + N_PREFERENCE;
1824        digester.addRule(prefPath, new CallMethodRule(1, "addPreference", 9));
1825        digester.addCallParam(prefPath, 0, A_NAME);
1826        digester.addCallParam(prefPath, 1, A_VALUE);
1827        digester.addCallParam(prefPath, 2, A_WIDGET);
1828        digester.addCallParam(prefPath, 3, A_WIDGET_CONFIG);
1829        digester.addCallParam(prefPath, 4, A_NICE_NAME);
1830        digester.addCallParam(prefPath, 5, A_DESCRIPTION);
1831        digester.addCallParam(prefPath, 6, A_RULE_REGEX);
1832        digester.addCallParam(prefPath, 7, A_ERROR);
1833        digester.addCallParam(prefPath, 8, 0);
1834    }
1835
1836    /**
1837     * Adds the digester rules for the tool-manager node.<p>
1838     *
1839     * @param digester the digester object
1840     */
1841    protected void addToolManagerRules(Digester digester) {
1842
1843        // add tool-manager
1844        String rulePath = "*/" + N_TOOLMANAGER;
1845        digester.addObjectCreate(rulePath, CmsToolManager.class);
1846        digester.addSetNext(rulePath, "setToolManager");
1847        // add tool-manager roots
1848        rulePath += "/" + N_ROOTS + "/" + N_ROOT;
1849        digester.addObjectCreate(rulePath, CmsToolRootHandler.class);
1850        digester.addSetNext(rulePath, "addToolRoot");
1851        digester.addBeanPropertySetter(rulePath + "/" + N_KEY);
1852        digester.addBeanPropertySetter(rulePath + "/" + N_URI);
1853        digester.addBeanPropertySetter(rulePath + "/" + N_NAME);
1854        digester.addBeanPropertySetter(rulePath + "/" + N_HELPTEXT, "helpText");
1855    }
1856
1857    /**
1858     * Adds the digester rules for the user-infos node.<p>
1859     *
1860     * @param digester the digester object
1861     */
1862    protected void addUserInfoRules(Digester digester) {
1863
1864        // add user additional information
1865        String rulePath = "*/" + N_USERINFOS;
1866        digester.addObjectCreate(rulePath, CmsWorkplaceUserInfoManager.class);
1867        digester.addSetNext(rulePath, "setUserInfoManager");
1868        // create a new block
1869        rulePath += "/" + N_INFOBLOCK;
1870        digester.addObjectCreate(rulePath, CmsWorkplaceUserInfoBlock.class);
1871        // set the title
1872        digester.addCallMethod(rulePath, "setTitle", 1);
1873        digester.addCallParam(rulePath, 0, A_NAME);
1874        // add a new entry
1875        digester.addCallMethod(rulePath + "/" + N_USERINFO, "addEntry", 5);
1876        digester.addCallParam(rulePath + "/" + N_USERINFO, 0, A_KEY);
1877        digester.addCallParam(rulePath + "/" + N_USERINFO, 1, A_TYPE);
1878        digester.addCallParam(rulePath + "/" + N_USERINFO, 2, A_WIDGET);
1879        digester.addCallParam(rulePath + "/" + N_USERINFO, 3, A_PARAMS);
1880        digester.addCallParam(rulePath + "/" + N_USERINFO, 4, A_OPTIONAL);
1881        // add the new created block
1882        digester.addSetNext(rulePath, "addBlock");
1883    }
1884
1885    /**
1886     * @see org.opencms.configuration.A_CmsXmlConfiguration#initMembers()
1887     */
1888    @Override
1889    protected void initMembers() {
1890
1891        setXmlFileName(DEFAULT_XML_FILE_NAME);
1892        if (CmsLog.INIT.isInfoEnabled()) {
1893            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_WORKPLACE_INIT_0));
1894        }
1895    }
1896
1897}