001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH (http://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, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://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.db.CmsUserSettings;
031import org.opencms.file.CmsResource;
032import org.opencms.file.CmsResource.CmsResourceCopyMode;
033import org.opencms.file.CmsResource.CmsResourceDeleteMode;
034import org.opencms.i18n.CmsLocaleManager;
035import org.opencms.main.CmsLog;
036import org.opencms.util.A_CmsModeStringEnumeration;
037import org.opencms.util.CmsStringUtil;
038
039import java.util.Arrays;
040import java.util.Collections;
041import java.util.List;
042
043import org.apache.commons.logging.Log;
044
045/**
046 * Default user workplace settings, used as default values for worklace settings in the
047 * user preferences.<p>
048 * 
049 * @since 6.0.0 
050 */
051public class CmsDefaultUserSettings extends CmsUserSettings {
052
053    /**
054     * Enumeration class for defining the publish related resources mode.<p>
055     */
056    public static final class CmsPublishRelatedResourcesMode extends A_CmsModeStringEnumeration {
057
058        /** Constant for the publish related resources mode, checkbox disabled by default. */
059        protected static final CmsPublishRelatedResourcesMode MODE_FALSE = new CmsPublishRelatedResourcesMode(
060            CmsStringUtil.FALSE);
061
062        /** 
063         * Constant for the publish related resources mode, only {@link org.opencms.security.CmsRole#VFS_MANAGER}s 
064         * may publish resources without publishing the related resources.
065         */
066        protected static final CmsPublishRelatedResourcesMode MODE_FORCE = new CmsPublishRelatedResourcesMode("FORCE");
067
068        /** Constant for the publish related resources mode, checkbox enabled by default. */
069        protected static final CmsPublishRelatedResourcesMode MODE_TRUE = new CmsPublishRelatedResourcesMode(
070            CmsStringUtil.TRUE);
071
072        /** The serial version id. */
073        private static final long serialVersionUID = -2665888243460791770L;
074
075        /**
076         * Default constructor.<p>
077         * 
078         * @param mode string representation
079         */
080        private CmsPublishRelatedResourcesMode(String mode) {
081
082            super(mode);
083        }
084
085        /**
086         * Returns the parsed mode object if the string representation matches, or <code>null</code> if not.<p>
087         * 
088         * @param publishRelatedResourcesMode the string representation to parse
089         * 
090         * @return the parsed mode object
091         */
092        public static CmsPublishRelatedResourcesMode valueOf(String publishRelatedResourcesMode) {
093
094            if (publishRelatedResourcesMode == null) {
095                return null;
096            }
097            if (publishRelatedResourcesMode.equalsIgnoreCase(MODE_FALSE.getMode())) {
098                return MODE_FALSE;
099            }
100            if (publishRelatedResourcesMode.equalsIgnoreCase(MODE_TRUE.getMode())) {
101                return MODE_TRUE;
102            }
103            if (publishRelatedResourcesMode.equalsIgnoreCase(MODE_FORCE.getMode())) {
104                return MODE_FORCE;
105            }
106            return null;
107        }
108    }
109
110    /**
111     * Enum for the subsitemap creation mode.<p>
112     */
113    public enum SubsitemapCreationMode {
114        /** In  this mode, existing folders are converted into subsitemaps. */
115        convert,
116
117        /** In this mode, new subsitemap folders are created, giving the user a choice of which folder type they want to use. */
118        createfolder
119    }
120
121    /** Constant for the publish related resources mode, checkbox disabled by default. */
122    public static final CmsPublishRelatedResourcesMode PUBLISH_RELATED_RESOURCES_MODE_FALSE = CmsPublishRelatedResourcesMode.MODE_FALSE;
123
124    /** 
125     * Constant for the publish related resources mode, only {@link org.opencms.security.CmsRole#VFS_MANAGER}s 
126     * may publish resources without publishing the related resources. 
127     */
128    public static final CmsPublishRelatedResourcesMode PUBLISH_RELATED_RESOURCES_MODE_FORCE = CmsPublishRelatedResourcesMode.MODE_FORCE;
129
130    /** Constant for the publish related resources mode, checkbox enabled by default. */
131    public static final CmsPublishRelatedResourcesMode PUBLISH_RELATED_RESOURCES_MODE_TRUE = CmsPublishRelatedResourcesMode.MODE_TRUE;
132
133    /** Publish button appearance: show always. */
134    public static final String PUBLISHBUTTON_SHOW_ALWAYS = "always";
135
136    /** Publish button appearance: show auto (only if user has publish permissions). */
137    public static final String PUBLISHBUTTON_SHOW_AUTO = "auto";
138
139    /** Publish button appearance: show never. */
140    public static final String PUBLISHBUTTON_SHOW_NEVER = "never";
141
142    /** 
143     * Array of the possible "button styles".
144     * Must be private because of Findbugs rule "MS".
145     */
146    private static final String[] BUTTON_STYLES = {"image", "textimage", "text"};
147
148    /** Array list for fast lookup of "button styles". */
149    public static final List<String> BUTTON_STYLES_LIST = Collections.unmodifiableList(Arrays.asList(BUTTON_STYLES));
150
151    /** Parameter for buttonstyle text & image. */
152    private static final int BUTTONSTYLE_TEXTIMAGE = 1;
153
154    /** Value for preserving siblings in copy dialog settings. */
155    private static final String COPYMODE_PRESERVE = "preservesiblings";
156
157    /** Value for creating a resource in copy dialog settings. */
158    private static final String COPYMODE_RESOURCE = "createresource";
159
160    /** Value for creating a sibling in copy dialog settings. */
161    private static final String COPYMODE_SIBLING = "createsibling";
162
163    /** Value for deleting siblings in delete dialog settings. */
164    private static final String DELETEMODE_DELETE = "deletesiblings";
165
166    /** Value for preserving siblings in delete dialog settings. */
167    private static final String DELETEMODE_PRESERVE = "preservesiblings";
168
169    /** The log object for this class. */
170    private static final Log LOG = CmsLog.getLog(CmsDefaultUserSettings.class);
171
172    /** Value for publishing only resources in publish dialog settings. */
173    private static final String PUBLISHMODE_ONLYRESOURCE = "onlyresource";
174
175    /** Value for publishing siblings in publish dialog settings. */
176    private static final String PUBLISHMODE_SIBLINGS = "allsiblings";
177
178    /** The enable relation deletion flag. */
179    private boolean m_allowBrokenRelations = true;
180
181    /** The publish related resources mode. */
182    private CmsPublishRelatedResourcesMode m_publishRelatedResourcesMode;
183
184    /** The subsitemap creation mode. */
185    private SubsitemapCreationMode m_subsitemapCreationMode;
186
187    /**
188     * Gets the default copy mode when copying a file of the user.<p>
189     * 
190     * @return the default copy mode when copying a file of the user
191     */
192    public String getDialogCopyFileModeString() {
193
194        if (getDialogCopyFileMode() == CmsResource.COPY_AS_NEW) {
195            return COPYMODE_RESOURCE;
196        } else {
197            return COPYMODE_SIBLING;
198        }
199    }
200
201    /**
202     * Gets the default copy mode when copying a folder of the user.<p>
203     * 
204     * @return the default copy mode when copying a folder of the user
205     */
206    public String getDialogCopyFolderModeString() {
207
208        if (getDialogCopyFolderMode() == CmsResource.COPY_AS_NEW) {
209            return COPYMODE_RESOURCE;
210        } else if (getDialogCopyFolderMode() == CmsResource.COPY_AS_SIBLING) {
211            return COPYMODE_SIBLING;
212        } else {
213            return COPYMODE_PRESERVE;
214        }
215    }
216
217    /**
218     * Returns the default setting for file deletion.<p>
219     * 
220     * @return the default setting for file deletion
221     */
222    public String getDialogDeleteFileModeString() {
223
224        if (getDialogDeleteFileMode() == CmsResource.DELETE_REMOVE_SIBLINGS) {
225            return DELETEMODE_DELETE;
226        } else {
227            return DELETEMODE_PRESERVE;
228        }
229    }
230
231    /**
232     * Returns the default setting for expanding inherited permissions in the dialog.<p>
233     * 
234     * @return true if inherited permissions should be expanded, otherwise false
235     * 
236     * @see #getDialogExpandInheritedPermissions()
237     */
238    public String getDialogExpandInheritedPermissionsString() {
239
240        return String.valueOf(getDialogExpandInheritedPermissions());
241    }
242
243    /**
244     * Returns the default setting for expanding the users permissions in the dialog.<p>
245     * 
246     * @return true if the users permissions should be expanded, otherwise false
247     * 
248     * @see #getDialogExpandUserPermissions()
249     */
250    public String getDialogExpandUserPermissionsString() {
251
252        return String.valueOf(getDialogExpandUserPermissions());
253    }
254
255    /**
256     * Returns the default setting for inheriting permissions on folders.<p>
257     * 
258     * @return true if permissions should be inherited on folders, otherwise false
259     */
260    public String getDialogPermissionsInheritOnFolderString() {
261
262        return String.valueOf(getDialogPermissionsInheritOnFolder());
263    }
264
265    /**
266     * Returns the default setting for direct publishing.<p>
267     * 
268     * @return the default setting for direct publishing
269     */
270    public String getDialogPublishSiblingsString() {
271
272        if (getDialogPublishSiblings()) {
273            return PUBLISHMODE_SIBLINGS;
274        } else {
275            return PUBLISHMODE_ONLYRESOURCE;
276        }
277    }
278
279    /**
280     * Determines if the export settings part of the secure/export dialog should be shown.<p>
281     * 
282     * @return true if the export dialog is shown, otherwise false
283     */
284    public String getDialogShowExportSettingsString() {
285
286        return String.valueOf(getDialogShowExportSettings());
287    }
288
289    /**
290     * Determines if the lock dialog should be shown.<p>
291     * 
292     * @return true if the lock dialog is shown, otherwise false
293     */
294    public String getDialogShowLockString() {
295
296        return String.valueOf(getDialogShowLock());
297    }
298
299    /**
300     * Returns a string representation of the direct edit button style.<p>
301     * 
302     * @return string representation of the direct edit button style
303     */
304    public String getDirectEditButtonStyleString() {
305
306        return BUTTON_STYLES[getDirectEditButtonStyle()];
307    }
308
309    /**
310     * Returns a string representation of the editor button style.<p>
311     * 
312     * @return string representation of the editor button style
313     */
314    public String getEditorButtonStyleString() {
315
316        return BUTTON_STYLES[getEditorButtonStyle()];
317    }
318
319    /**
320     * Returns a string representation of the explorer button style.<p>
321     * 
322     * @return string representation of the explorer button style
323     */
324    public String getExplorerButtonStyleString() {
325
326        return BUTTON_STYLES[getExplorerButtonStyle()];
327    }
328
329    /**
330     * Returns a string representation of the list all projects flag.<p>
331     * 
332     * @return string representation of the list all projects flag
333     * 
334     * @see #getListAllProjects()
335     */
336    public String getListAllProjectsString() {
337
338        return String.valueOf(getShowPublishNotification());
339    }
340
341    /**
342     * Returns the publish related resources mode.<p>
343     *
344     * @return the publish related resources mode
345     */
346    public CmsPublishRelatedResourcesMode getPublishRelatedResources() {
347
348        return m_publishRelatedResourcesMode;
349    }
350
351    /**
352     * Returns if the explorer view is restricted to the defined site and folder.<p>
353     * 
354     * @return true if the explorer view is restricted, otherwise false
355     */
356    public String getRestrictExplorerViewString() {
357
358        return String.valueOf(getRestrictExplorerView());
359    }
360
361    /**
362     * Gets if the file creation date should be shown in explorer view.<p>
363     * 
364     * @return <code>"true"</code> if the file creation date should be shown, otherwise <code>"false"</code>
365     */
366    public String getShowExplorerFileDateCreated() {
367
368        return getExplorerSetting(CmsUserSettings.FILELIST_DATE_CREATED);
369    }
370
371    /**
372     * Gets if the file expired by should be shown in explorer view.<p>
373     * 
374     * @return <code>"true"</code> if the file date expired by should be shown, otherwise <code>"false"</code>
375     */
376    public String getShowExplorerFileDateExpired() {
377
378        return getExplorerSetting(CmsUserSettings.FILELIST_DATE_EXPIRED);
379    }
380
381    /**
382     * Gets if the file last modified date should be shown in explorer view.<p>
383     * 
384     * @return <code>"true"</code> if the file last modified date should be shown, otherwise <code>"false"</code>
385     */
386    public String getShowExplorerFileDateLastModified() {
387
388        return getExplorerSetting(CmsUserSettings.FILELIST_DATE_LASTMODIFIED);
389    }
390
391    /**
392     * Gets if the file released by should be shown in explorer view.<p>
393     * 
394     * @return <code>"true"</code> if the file date released by should be shown, otherwise <code>"false"</code>
395     */
396    public String getShowExplorerFileDateReleased() {
397
398        return getExplorerSetting(CmsUserSettings.FILELIST_DATE_RELEASED);
399    }
400
401    /**
402     * Gets if the file locked by should be shown in explorer view.<p>
403     * 
404     * @return <code>"true"</code> if the file locked by should be shown, otherwise <code>"false"</code>
405     */
406    public String getShowExplorerFileLockedBy() {
407
408        return getExplorerSetting(CmsUserSettings.FILELIST_LOCKEDBY);
409    }
410
411    /**
412     * Gets if the file navtext should be shown in explorer view.<p>
413     * 
414     * @return <code>"true"</code> if the file navtext should be shown, otherwise <code>"false"</code>
415     */
416    public String getShowExplorerFileNavText() {
417
418        return getExplorerSetting(CmsUserSettings.FILELIST_NAVTEXT);
419    }
420
421    /**
422     * Gets if the file permissions should be shown in explorer view.<p>
423     * 
424     * @return <code>"true"</code> if the file permissions should be shown, otherwise <code>"false"</code>
425     */
426    public String getShowExplorerFilePermissions() {
427
428        return getExplorerSetting(CmsUserSettings.FILELIST_PERMISSIONS);
429    }
430
431    /**
432     * Gets if the file size should be shown in explorer view.<p>
433     * 
434     * @return <code>"true"</code> if the file size should be shown, otherwise <code>"false"</code>
435     */
436    public String getShowExplorerFileSize() {
437
438        return getExplorerSetting(CmsUserSettings.FILELIST_SIZE);
439    }
440
441    /**
442     * Gets  if the file state should be shown in explorer view.<p>
443     * 
444     * @return <code>"true"</code> if the file state should be shown, otherwise <code>"false"</code>
445     */
446    public String getShowExplorerFileState() {
447
448        return getExplorerSetting(CmsUserSettings.FILELIST_STATE);
449    }
450
451    /**
452     * Gets if the file title should be shown in explorer view.<p>
453     * 
454     * @return  <code>"true"</code> if the file title should be shown, otherwise <code>"false"</code>
455     */
456    public String getShowExplorerFileTitle() {
457
458        return getExplorerSetting(CmsUserSettings.FILELIST_TITLE);
459    }
460
461    /**
462     * Gets if the file type should be shown in explorer view.<p>
463     * 
464     * @return  <code>"true"</code> if the file type should be shown, otherwise <code>"false"</code>
465     */
466    public String getShowExplorerFileType() {
467
468        return getExplorerSetting(CmsUserSettings.FILELIST_TYPE);
469    }
470
471    /**
472     * Gets if the file creator should be shown in explorer view.<p>
473     * 
474     * @return <code>"true"</code> if the file creator should be shown, otherwise <code>"false"</code>
475     */
476    public String getShowExplorerFileUserCreated() {
477
478        return getExplorerSetting(CmsUserSettings.FILELIST_USER_CREATED);
479    }
480
481    /**
482     * Gets if the file last modified by should be shown in explorer view.<p>
483     * 
484     * @return <code>"true"</code> if the file last modified by should be shown, otherwise <code>"false"</code> 
485     */
486    public String getShowExplorerFileUserLastModified() {
487
488        return getExplorerSetting(CmsUserSettings.FILELIST_USER_LASTMODIFIED);
489    }
490
491    /**
492     * Returns a string representation of the show file upload button flag.<p>
493     * 
494     * @return string representation of the show file upload button flag
495     * 
496     * @see #getShowFileUploadButton()
497     */
498    public String getShowFileUploadButtonString() {
499
500        return String.valueOf(getShowFileUploadButton());
501    }
502
503    /**
504     * Returns a string representation of the publish notification flag.<p>
505     * 
506     * @return string representation of the publish notification flag
507     * 
508     * @see #getShowPublishNotification()
509     */
510    public String getShowPublishNotificationString() {
511
512        return String.valueOf(getShowPublishNotification());
513    }
514
515    /**
516     * Gets the subsitemap creation mode to use for the sitemap editor.<p>
517     * 
518     * @return the subsitemap creation mode to use for the sitemap editor 
519     */
520    public SubsitemapCreationMode getSubsitemapCreationMode() {
521
522        return getSubsitemapCreationMode(SubsitemapCreationMode.convert);
523    }
524
525    /**
526     * Gets the subsitemap creation mode, or returns a default value given as a parameter if the mode is not set.<p>
527     * 
528     * @param defaultValue the value to return when the subsitemap creation mode is not set
529     * 
530     * @return the subsitemap creation mode 
531     */
532    public SubsitemapCreationMode getSubsitemapCreationMode(SubsitemapCreationMode defaultValue) {
533
534        if (m_subsitemapCreationMode != null) {
535            return m_subsitemapCreationMode;
536        }
537        return defaultValue;
538    }
539
540    /**
541     * Returns a string representation of the workplace button style.<p>
542     * 
543     * @return string representation of the workplace button style
544     * 
545     * @see #getWorkplaceButtonStyle()
546     */
547    public String getWorkplaceButtonStyleString() {
548
549        return BUTTON_STYLES[getWorkplaceButtonStyle()];
550    }
551
552    /**
553     * Returns if the deletion of relation targets is enabled.<p>
554     *
555     * @return <code>true</code> if the deletion of relation targets is enabled, otherwise <code>false</code>
556     */
557    public boolean isAllowBrokenRelations() {
558
559        return m_allowBrokenRelations;
560    }
561
562    /**
563     * Sets if the deletion of relation targets is enabled.<p>
564     *
565     * @param allowBrokenRelations <code>true</code> if relation deletion should be enabled, otherwise <code>false</code>
566     */
567    public void setAllowBrokenRelations(String allowBrokenRelations) {
568
569        m_allowBrokenRelations = Boolean.valueOf(allowBrokenRelations).booleanValue();
570        if (CmsLog.INIT.isInfoEnabled()) {
571            CmsLog.INIT.info(Messages.get().getBundle().key(
572                m_allowBrokenRelations
573                ? Messages.INIT_RELATION_DELETION_ENABLED_0
574                : Messages.INIT_RELATION_DELETION_DISABLED_0));
575        }
576    }
577
578    /**
579     * Sets the default copy mode when copying a file of the user.<p>
580     * 
581     * @param mode the default copy mode when copying a file of the user
582     */
583    public void setDialogCopyFileMode(String mode) {
584
585        CmsResourceCopyMode copyMode = CmsResource.COPY_AS_NEW;
586        if (mode.equalsIgnoreCase(COPYMODE_SIBLING)) {
587            copyMode = CmsResource.COPY_AS_SIBLING;
588        }
589        setDialogCopyFileMode(copyMode);
590    }
591
592    /**
593     * Sets the default copy mode when copying a folder of the user.<p>
594     * 
595     * @param mode the default copy mode when copying a folder of the user
596     */
597    public void setDialogCopyFolderMode(String mode) {
598
599        CmsResourceCopyMode copyMode = CmsResource.COPY_AS_NEW;
600        if (mode.equalsIgnoreCase(COPYMODE_SIBLING)) {
601            copyMode = CmsResource.COPY_AS_SIBLING;
602        } else if (mode.equalsIgnoreCase(COPYMODE_PRESERVE)) {
603            copyMode = CmsResource.COPY_PRESERVE_SIBLING;
604        }
605        setDialogCopyFolderMode(copyMode);
606    }
607
608    /**
609     * Sets the default setting for file deletion.<p>
610     * 
611     * @param mode the default setting for file deletion
612     */
613    public void setDialogDeleteFileMode(String mode) {
614
615        CmsResourceDeleteMode deleteMode = CmsResource.DELETE_PRESERVE_SIBLINGS;
616        if (mode.equalsIgnoreCase(DELETEMODE_DELETE)) {
617            deleteMode = CmsResource.DELETE_REMOVE_SIBLINGS;
618        }
619        setDialogDeleteFileMode(deleteMode);
620    }
621
622    /**
623     * Sets the default setting for expanding inherited permissions in the dialog.<p>
624     *
625     * @param dialogExpandInheritedPermissions the default setting for expanding inherited permissions in the dialog
626     */
627    public void setDialogExpandInheritedPermissions(String dialogExpandInheritedPermissions) {
628
629        setDialogExpandInheritedPermissions(Boolean.valueOf(dialogExpandInheritedPermissions).booleanValue());
630    }
631
632    /**
633     * Sets the default setting for expanding the users permissions in the dialog.<p>
634     *
635     * @param dialogExpandUserPermissions the default setting for expanding the users permissions in the dialog
636     */
637    public void setDialogExpandUserPermissions(String dialogExpandUserPermissions) {
638
639        setDialogExpandUserPermissions(Boolean.valueOf(dialogExpandUserPermissions).booleanValue());
640    }
641
642    /**
643     * Sets the default setting for inheriting permissions on folders.<p>
644     *
645     * @param dialogPermissionsInheritOnFolder the default setting for inheriting permissions on folders
646     */
647    public void setDialogPermissionsInheritOnFolder(String dialogPermissionsInheritOnFolder) {
648
649        setDialogPermissionsInheritOnFolder(Boolean.valueOf(dialogPermissionsInheritOnFolder).booleanValue());
650    }
651
652    /**
653     * Sets the default setting for direct publishing.<p>
654     * 
655     * @param mode the default setting for direct publishing
656     */
657    public void setDialogPublishSiblings(String mode) {
658
659        boolean publishSiblings = false;
660        if (mode.equalsIgnoreCase(PUBLISHMODE_SIBLINGS)) {
661            publishSiblings = true;
662        }
663        setDialogPublishSiblings(publishSiblings);
664    }
665
666    /**
667     * Sets the style of the direct edit buttons of the user.<p>
668     * 
669     * @param buttonstyle the style of the direct edit buttons of the user
670     */
671    public void setDirectEditButtonStyle(String buttonstyle) {
672
673        int buttonstyleValue = BUTTONSTYLE_TEXTIMAGE;
674        try {
675            if (buttonstyle != null) {
676                buttonstyleValue = BUTTON_STYLES_LIST.indexOf(buttonstyle);
677            }
678        } catch (Exception e) {
679            // do nothing, use the default value
680        }
681        setDirectEditButtonStyle(buttonstyleValue);
682    }
683
684    /**
685     * Sets the style of the editor buttons of the user.<p>
686     * 
687     * @param buttonstyle the style of the editor buttons of the user
688     */
689    public void setEditorButtonStyle(String buttonstyle) {
690
691        int buttonstyleValue = BUTTONSTYLE_TEXTIMAGE;
692        try {
693            if (buttonstyle != null) {
694                buttonstyleValue = BUTTON_STYLES_LIST.indexOf(buttonstyle);
695            }
696        } catch (Exception e) {
697            // do nothing, use the default value
698        }
699        setEditorButtonStyle(buttonstyleValue);
700    }
701
702    /**
703     * Sets the style of the explorer workplace buttons of the user.<p>
704     * 
705     * @param buttonstyle the style of the explorer workplace buttons of the user
706     */
707    public void setExplorerButtonStyle(String buttonstyle) {
708
709        int buttonstyleValue = BUTTONSTYLE_TEXTIMAGE;
710        try {
711            if (buttonstyle != null) {
712                buttonstyleValue = BUTTON_STYLES_LIST.indexOf(buttonstyle);
713            }
714        } catch (Exception e) {
715            // do nothing, use the default value
716        }
717        setExplorerButtonStyle(buttonstyleValue);
718    }
719
720    /**
721     * Sets the number of displayed files per page of the user.<p>
722     * 
723     * @param entries the number of displayed files per page of the user
724     */
725    public void setExplorerFileEntries(String entries) {
726
727        try {
728            setExplorerFileEntries(Integer.parseInt(entries));
729        } catch (Throwable t) {
730            // ignore this exception
731        }
732    }
733
734    /**
735     * Sets if all projects should be shown for the user.<p>
736     * 
737     * @param listAllProjects <code>"true"</code> or <code>"false"</code>
738     */
739    public void setListAllProjects(String listAllProjects) {
740
741        setListAllProjects(Boolean.valueOf(listAllProjects).booleanValue());
742    }
743
744    /**
745     * Sets the workplace locale.<p> 
746     * 
747     * @param locale the workplace language default
748     */
749    public void setLocale(String locale) {
750
751        // set the language     
752        setLocale(CmsLocaleManager.getLocale(locale));
753    }
754
755    /**
756     * Digester support method for configuration if the "create index page" checkbox in the new folder 
757     * dialog should be initially be checked or not. <p>
758     * 
759     * The given <code>String</code> value is interpreted as a {@link Boolean} by the means 
760     * of <code>{@link Boolean#valueOf(String)}</code>. <p>
761     * 
762     * @param booleanValue a <code>String</code> that is interpred as a {@link Boolean} by the means 
763     *      of <code>{@link Boolean#valueOf(String)}</code> 
764     */
765    public void setNewFolderCreateIndexPage(String booleanValue) {
766
767        setNewFolderCreateIndexPage(Boolean.valueOf(booleanValue));
768    }
769
770    /**
771     * Digester support method for configuration if the "edit properties" checkbox in the new folder 
772     * dialog should be initially be checked or not. <p>
773     * 
774     * The given <code>String</code> value is interpreted as a {@link Boolean} by the means 
775     * of <code>{@link Boolean#valueOf(String)}</code>. <p>
776     * 
777     * @param booleanValue a <code>String</code> that is interpreted as a <code> {@link Boolean}</code> 
778     *      by the means of <code>{@link Boolean#valueOf(String)}</code> 
779     */
780    public void setNewFolderEditProperties(String booleanValue) {
781
782        setNewFolderEditPropertes(Boolean.valueOf(booleanValue));
783    }
784
785    /**
786     * Sets the publish related resources mode.<p>
787     *
788     * @param publishRelatedResourcesMode the publish related resources mode to set
789     */
790    public void setPublishRelatedResourcesMode(String publishRelatedResourcesMode) {
791
792        m_publishRelatedResourcesMode = CmsPublishRelatedResourcesMode.valueOf(publishRelatedResourcesMode);
793        if ((m_publishRelatedResourcesMode != null) && CmsLog.INIT.isInfoEnabled()) {
794            CmsLog.INIT.info(Messages.get().getBundle().key(
795                Messages.INIT_PUBLISH_RELATED_RESOURCES_MODE_1,
796                m_publishRelatedResourcesMode.toString()));
797        }
798    }
799
800    /**
801     * Sets if the explorer view is restricted to the defined site and folder.<p>
802     * 
803     * @param restrict true if the explorer view is restricted, otherwise false
804     */
805    public void setRestrictExplorerView(String restrict) {
806
807        setRestrictExplorerView(Boolean.valueOf(restrict).booleanValue());
808    }
809
810    /**
811     * Sets if the file creation date should be shown in explorer view.<p>
812     * 
813     * @param show true if the file creation date should be shown, otherwise false
814     */
815    public void setShowExplorerFileDateCreated(String show) {
816
817        setShowExplorerFileDateCreated(Boolean.valueOf(show).booleanValue());
818    }
819
820    /**
821     * Sets if the file expire date should be shown in explorer view.<p>
822     * 
823     * @param show true if the file expire date should be shown, otherwise false
824     */
825    public void setShowExplorerFileDateExpired(String show) {
826
827        setShowExplorerFileDateExpired(Boolean.valueOf(show).booleanValue());
828    }
829
830    /**
831     * Sets if the file last modified date should be shown in explorer view.<p>
832     * 
833     * @param show true if the file last modified date should be shown, otherwise false
834     */
835    public void setShowExplorerFileDateLastModified(String show) {
836
837        setShowExplorerFileDateLastModified(Boolean.valueOf(show).booleanValue());
838    }
839
840    /**
841     * Sets if the file release date should be shown in explorer view.<p>
842     * 
843     * @param show true if the file release date should be shown, otherwise false
844     */
845    public void setShowExplorerFileDateReleased(String show) {
846
847        setShowExplorerFileDateReleased(Boolean.valueOf(show).booleanValue());
848    }
849
850    /**
851     * Sets if the file locked by should be shown in explorer view.<p>
852     * 
853     * @param show true if the file locked by should be shown, otherwise false
854     */
855    public void setShowExplorerFileLockedBy(String show) {
856
857        setShowExplorerFileLockedBy(Boolean.valueOf(show).booleanValue());
858    }
859
860    /**
861     * Sets if the file navtext should be shown in explorer view.<p>
862     * 
863     * @param show true if the file locked by should be shown, otherwise false
864     */
865    public void setShowExplorerFileNavText(String show) {
866
867        setShowExplorerFileNavText(Boolean.valueOf(show).booleanValue());
868    }
869
870    /**
871     * Sets if the file permissions should be shown in explorer view.<p>
872     * 
873     * @param show true if the file permissions should be shown, otherwise false
874     */
875    public void setShowExplorerFilePermissions(String show) {
876
877        setShowExplorerFilePermissions(Boolean.valueOf(show).booleanValue());
878    }
879
880    /**
881     * Sets if the file size should be shown in explorer view.<p>
882     * 
883     * @param show true if the file size should be shown, otherwise false
884     */
885    public void setShowExplorerFileSize(String show) {
886
887        setShowExplorerFileSize(Boolean.valueOf(show).booleanValue());
888    }
889
890    /**
891     * Sets if the file state should be shown in explorer view.<p>
892     * 
893     * @param show true if the state size should be shown, otherwise false
894     */
895    public void setShowExplorerFileState(String show) {
896
897        setShowExplorerFileState(Boolean.valueOf(show).booleanValue());
898    }
899
900    /**
901     * Sets if the file title should be shown in explorer view.<p>
902     * 
903     * @param show true if the file title should be shown, otherwise false
904     */
905    public void setShowExplorerFileTitle(String show) {
906
907        setShowExplorerFileTitle(Boolean.valueOf(show).booleanValue());
908    }
909
910    /**
911     * Sets if the file type should be shown in explorer view.<p>
912     * 
913     * @param show true if the file type should be shown, otherwise false
914     */
915    public void setShowExplorerFileType(String show) {
916
917        setShowExplorerFileType(Boolean.valueOf(show).booleanValue());
918    }
919
920    /**
921     * Sets if the file creator should be shown in explorer view.<p>
922     * 
923     * @param show true if the file creator should be shown, otherwise false
924     */
925    public void setShowExplorerFileUserCreated(String show) {
926
927        setShowExplorerFileUserCreated(Boolean.valueOf(show).booleanValue());
928    }
929
930    /**
931     * Sets if the file last modified by should be shown in explorer view.<p>
932     * 
933     * @param show true if the file last modified by should be shown, otherwise false
934     */
935    public void setShowExplorerFileUserLastModified(String show) {
936
937        setShowExplorerFileUserLastModified(Boolean.valueOf(show).booleanValue());
938    }
939
940    /**
941     *  Sets if the export part of the secure/export dialog should be shown.<p>
942     * 
943     * @param mode true if the export dialog should be shown, otherwise false
944     */
945    public void setShowExportSettingsDialog(String mode) {
946
947        setDialogShowExportSettings(Boolean.valueOf(mode).booleanValue());
948    }
949
950    /**
951     * Controls whether to display a file upload icon or not.<p>
952     * 
953     * @param flag <code>"true"</code> or <code>"false"</code> to flag the use of the file upload button
954     */
955    public void setShowFileUploadButton(String flag) {
956
957        setShowFileUploadButton(Boolean.valueOf(flag).booleanValue());
958    }
959
960    /**
961     *  Sets if the lock dialog should be shown.<p>
962     * 
963     * @param mode true if the lock dialog should be shown, otherwise false
964     */
965    public void setShowLockDialog(String mode) {
966
967        setDialogShowLock(Boolean.valueOf(mode).booleanValue());
968    }
969
970    /**
971     * Sets if the publish notification should be shown for the user.<p>
972     * 
973     * @param notification <code>"true"</code> or <code>"false"</code> to flag the notification
974     */
975    public void setShowPublishNotification(String notification) {
976
977        // set if the publish notification should be shown
978        setShowPublishNotification(Boolean.valueOf(notification).booleanValue());
979    }
980
981    /**
982     * Digester support method for configuration if the resource type selection checkbox should 
983     * show up when uploading a new file in non-applet mode.<p>
984     * 
985     * The given <code>String</code> value is interpreted as a {@link Boolean} by the means 
986     * of <code>{@link Boolean#valueOf(String)}</code>. <p>
987     * 
988     * @param booleanValue a <code>String</code> that is interpreted as a {@link Boolean} by the means 
989     *      of <code>{@link Boolean#valueOf(String)}</code> 
990     */
991    public void setShowUploadTypeDialog(String booleanValue) {
992
993        setShowUploadTypeDialog(Boolean.valueOf(booleanValue));
994    }
995
996    /**
997     * Sets the subsitemap creation mode.<p>
998     * 
999     * @param mode the string value of the subsitemap creation mode 
1000     */
1001    public void setSubsitemapCreationMode(String mode) {
1002
1003        try {
1004            m_subsitemapCreationMode = SubsitemapCreationMode.valueOf(mode);
1005        } catch (Exception e) {
1006            LOG.warn("Invalid value for subsitemap creation mode was ignored: " + mode);
1007        }
1008    }
1009
1010    /**
1011     * Sets the style of the workplace buttons of the user.<p>
1012     * 
1013     * @param buttonstyle the style of the workplace buttons of the user
1014     */
1015    public void setWorkplaceButtonStyle(String buttonstyle) {
1016
1017        int buttonstyleValue = BUTTONSTYLE_TEXTIMAGE;
1018        try {
1019            if (buttonstyle != null) {
1020                buttonstyleValue = BUTTON_STYLES_LIST.indexOf(buttonstyle);
1021            }
1022        } catch (Exception e) {
1023            // do nothing, use the default value
1024        }
1025        setWorkplaceButtonStyle(buttonstyleValue);
1026    }
1027
1028    /**
1029     * Sets the style of the workplace search default view.<p>
1030     * 
1031     * @param viewStyle the style of the workplace search default view 
1032     */
1033    public void setWorkplaceSearchViewStyle(String viewStyle) {
1034
1035        setWorkplaceSearchViewStyle(CmsSearchResultStyle.valueOf(viewStyle));
1036    }
1037
1038    /**
1039     * Checks if  a specific explorer setting depending is set.<p>
1040     * 
1041     * @param setting the settings constant value for the explorer settings
1042     * @return <code>"true"</code> if the explorer setting is set, otherwise <code>"false"</code>
1043     */
1044    private String getExplorerSetting(int setting) {
1045
1046        return String.valueOf((getExplorerSettings() & setting) > 0);
1047    }
1048}