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, 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.ade.sitemap.shared;
029
030import org.opencms.gwt.shared.CmsContextMenuEntryBean;
031import org.opencms.gwt.shared.CmsListInfoBean;
032import org.opencms.gwt.shared.property.CmsClientProperty;
033import org.opencms.gwt.shared.property.CmsClientTemplateBean;
034import org.opencms.util.CmsUUID;
035import org.opencms.xml.content.CmsXmlContentProperty;
036
037import java.util.List;
038import java.util.Map;
039
040import com.google.gwt.user.client.rpc.IsSerializable;
041
042/**
043 * Sitemap initialization data bean for prefetching.<p>
044 *
045 * @since 8.0
046 */
047public class CmsSitemapData implements IsSerializable {
048
049    /** The sitemap editor modes. */
050    public enum EditorMode {
051        /** The categories mode. */
052        categories,
053        /** Locale comparison mode. */
054        compareLocales,
055        /** The galleries mode. */
056        galleries,
057        /** The model page mode. */
058        modelpages,
059
060        /** The navigation mode. */
061        navigation,
062
063        /** The VFS mode. */
064        vfs;
065    }
066
067    /** Name of the used js variable. */
068    public static final String DICT_NAME = "org_opencms_ade_sitemap";
069
070    /** The URL of the JSP used to import aliases. */
071    private String m_aliasImportUrl;
072
073    /** Enables/disables creation of nested galleries in galleries view. */
074    private boolean m_allowCreateNestedGalleries;
075
076    /** The list of property names. */
077    private List<String> m_allPropertyNames;
078
079    /** Flag to indicate whether the user can open the alias editor. */
080    private boolean m_canEditAliases;
081
082    /** Flag to indicate whether detail pages can be edited. */
083    private boolean m_canEditDetailPages;
084
085    /** Flag indicating whether the user has permissions to manage detail pages via the sitemap editor. */
086    private boolean m_canManageDetailPages;
087
088    /** Flag indicating whether user is category manager. */
089    private boolean m_categoryManager;
090
091    /** The clipboard data. */
092    private CmsSitemapClipboardData m_clipboardData;
093
094    /** The sitemap context menu entries. */
095    private List<CmsContextMenuEntryBean> m_contextMenuEntries;
096
097    /** A flag which controls whether a new folder should be created for subsitemaps. */
098    private boolean m_createNewFolderForSubsitemap;
099
100    /** The default gallery parent folder. */
101    private String m_defaultGalleryFolder;
102
103    /** The default info bean for new elements. **/
104    private CmsNewResourceInfo m_defaultNewElementInfo;
105
106    /** The detail page table. */
107    private CmsDetailPageTable m_detailPageTable;
108
109    /** Flag to control the display of the toolbar. */
110    private boolean m_displayToolbar;
111
112    /** The editor mode. */
113    private EditorMode m_editorMode;
114
115    /** The export RFS prefix. */
116    private String m_exportRfsPrefix;
117
118    /** Flag indicating whether user is gallery manager. */
119    private boolean m_galleryManager;
120
121    /** A flag which indicates whether the site which contains the sitemap is a secure site. */
122    private boolean m_isSecure;
123
124    /** Flag which controls if the 'locale compare mode' should be available. */
125    private boolean m_localeComparisonEnabled;
126
127    /** The maximum sitemap depth. */
128    private int m_maxDepth;
129
130    /** The new element information. */
131    private List<CmsNewResourceInfo> m_newElementInfos;
132
133    /** The new navigation level element info. */
134    private CmsNewResourceInfo m_newNavigatioLevelElementInfo;
135
136    /** The new redirect element info. */
137    private CmsNewResourceInfo m_newRedirectElementInfo;
138
139    /** The reason why the current sitemap is not editable. */
140    private String m_noEditReason;
141
142    /** The path at which the sitemap should be opened, or null. */
143    private String m_openPath;
144
145    /** The properties of the root's parent. */
146    private Map<String, CmsClientProperty> m_parentProperties;
147
148    /** The path to the parent sitemap or <code>null</code>. */
149    private String m_parentSitemap;
150
151    /** The sitemap properties. */
152    private Map<String, CmsXmlContentProperty> m_properties;
153
154    /** The resource type information. */
155    private List<CmsNewResourceInfo> m_resourceTypeInfos;
156
157    /** The return page code. */
158    private String m_returnCode;
159
160    /** The sitemap root. */
161    private CmsClientSitemapEntry m_root;
162
163    /** The show model edit confirm dialog flag. */
164    private boolean m_showModelEditConfirm;
165
166    /** The list info beans for possible sitemap folder types. */
167    private List<CmsListInfoBean> m_sitemapFolderTypeInfos;
168
169    /** The sitemap info. */
170    private CmsSitemapInfo m_sitemapInfo;
171
172    /** The structure id of the site root. */
173    private CmsUUID m_siteRootId;
174
175    /** The available templates. */
176    private Map<String, CmsClientTemplateBean> m_templates;
177
178    /**
179     * Constructor.<p>
180     */
181    public CmsSitemapData() {
182
183        // empty
184    }
185
186    /**
187     * Constructor.<p>
188     *
189     * @param templates the available templates
190     * @param properties the properties
191     * @param clipboardData the clipboard data
192     * @param contextMenuEntries the sitemap context menu entries
193     * @param parentProperties the root entry's parent's inherited properties
194     * @param allPropNames the names of all properties
195     * @param exportRfsPrefix the export RFS prefix
196     * @param isSecure true if there is a secure server configuration for the site which contains the sitemap
197     * @param noEditReason the reason why the current sitemap is not editable
198     * @param displayToolbar the flag to control the display of the toolbar
199     * @param defaultNewElementInfo the type of the container page resource
200     * @param newElementInfos the new element information
201     * @param newRedirectElementInfo the new redirect element info
202     * @param newNavigationLevelElementInfo the new navigation level element info
203     * @param sitemapInfo the sitemap info bean
204     * @param parentSitemap the path to the parent sitemap or <code>null</code>
205     * @param root the sitemap root
206     * @param openPath the path at which the sitemap should be opened
207     * @param maxDepth the maximum sitemap depth
208     * @param detailPageTable the detail page table
209     * @param resourceTypeInfos the resource type information for the detail pages
210     * @param returnCode return page code
211     * @param canEditDetailPages flag to indicate whether detail pages can be edited
212     * @param aliasImportUrl the URL of the JSP used to import aliases
213     * @param canEditAliases flag to indicate whether the current user can edit the alias table
214     * @param createNewFoldersForSubsitemaps flag to control whether new folders should be created for subsitemaps
215     * @param galleryManager true if the user is a gallery manager
216     * @param categoryManager true if the user is a category manager
217     * @param subsitemapTypeInfos the type information beans for the available subsitemap folder types
218     * @param editorMode the editor mode
219     * @param defaultGalleryFolder default gallery parent folder
220     * @param showModelEditConfirm the show model edit confirm dialog flag
221     */
222    public CmsSitemapData(
223        Map<String, CmsClientTemplateBean> templates,
224        Map<String, CmsXmlContentProperty> properties,
225        CmsSitemapClipboardData clipboardData,
226        List<CmsContextMenuEntryBean> contextMenuEntries,
227        Map<String, CmsClientProperty> parentProperties,
228        List<String> allPropNames,
229        String exportRfsPrefix,
230        boolean isSecure,
231        String noEditReason,
232        boolean displayToolbar,
233        CmsNewResourceInfo defaultNewElementInfo,
234        List<CmsNewResourceInfo> newElementInfos,
235        CmsNewResourceInfo newRedirectElementInfo,
236        CmsNewResourceInfo newNavigationLevelElementInfo,
237        CmsSitemapInfo sitemapInfo,
238        String parentSitemap,
239        CmsClientSitemapEntry root,
240        String openPath,
241        int maxDepth,
242        CmsDetailPageTable detailPageTable,
243        List<CmsNewResourceInfo> resourceTypeInfos,
244        String returnCode,
245        boolean canEditDetailPages,
246        String aliasImportUrl,
247        boolean canEditAliases,
248        boolean createNewFoldersForSubsitemaps,
249        boolean galleryManager,
250        boolean categoryManager,
251        List<CmsListInfoBean> subsitemapTypeInfos,
252        EditorMode editorMode,
253        String defaultGalleryFolder,
254        boolean showModelEditConfirm) {
255
256        m_templates = templates;
257        m_properties = properties;
258        m_clipboardData = clipboardData;
259        m_contextMenuEntries = contextMenuEntries;
260        m_noEditReason = noEditReason;
261        m_displayToolbar = displayToolbar;
262        m_defaultNewElementInfo = defaultNewElementInfo;
263        m_sitemapInfo = sitemapInfo;
264        m_parentSitemap = parentSitemap;
265        m_parentProperties = parentProperties;
266        m_root = root;
267        m_openPath = openPath;
268        m_exportRfsPrefix = exportRfsPrefix;
269        m_isSecure = isSecure;
270        m_maxDepth = maxDepth;
271        m_detailPageTable = detailPageTable;
272        m_resourceTypeInfos = resourceTypeInfos;
273        m_canEditDetailPages = canEditDetailPages;
274        m_allPropertyNames = allPropNames;
275        m_returnCode = returnCode;
276        m_newElementInfos = newElementInfos;
277        m_newRedirectElementInfo = newRedirectElementInfo;
278        m_newNavigatioLevelElementInfo = newNavigationLevelElementInfo;
279        m_aliasImportUrl = aliasImportUrl;
280        m_canEditAliases = canEditAliases;
281        m_createNewFolderForSubsitemap = createNewFoldersForSubsitemaps;
282        m_galleryManager = galleryManager;
283        m_categoryManager = categoryManager;
284        m_sitemapFolderTypeInfos = subsitemapTypeInfos;
285        m_editorMode = editorMode;
286        m_defaultGalleryFolder = defaultGalleryFolder;
287        m_showModelEditConfirm = showModelEditConfirm;
288    }
289
290    /**
291     * Checks whether the current user can edit the aliases.<p>
292     *
293     * @return true if the current user can edit the aliases
294     */
295    public boolean canEditAliases() {
296
297        return m_canEditAliases;
298
299    }
300
301    /**
302     * Returns true if the detail pages can be edited.
303     *
304     * @return true if the detail pages can be edited
305     */
306    public boolean canEditDetailPages() {
307
308        return m_canEditDetailPages && (m_resourceTypeInfos != null) && !m_resourceTypeInfos.isEmpty();
309    }
310
311    /**
312     * Flag which indicates whether the user has a sufficient role for managing detail pages.
313     *
314     * @return true if the user has a sufficient role for managing detail pages
315     */
316    public boolean canManagetDetailPages() {
317
318        return m_canManageDetailPages;
319    }
320
321    /**
322     * Gets the URL of the JSP used to import aliases.<p>
323     *
324     * @return the alias import URL
325     */
326    public String getAliasImportUrl() {
327
328        return m_aliasImportUrl;
329    }
330
331    /**
332     * Returns the names of all properties.<p>
333     *
334     * @return the names of all properties
335     */
336    public List<String> getAllPropertyNames() {
337
338        return m_allPropertyNames;
339    }
340
341    /**
342     * Returns the clipboard data.<p>
343     *
344     * @return the clipboard data
345     */
346    public CmsSitemapClipboardData getClipboardData() {
347
348        return m_clipboardData;
349    }
350
351    /**
352     * Returns the sitemap context menu entries.<p>
353     *
354     * @return the sitemap context menu entries
355     */
356    public List<CmsContextMenuEntryBean> getContextMenuEntries() {
357
358        return m_contextMenuEntries;
359    }
360
361    /**
362     * Returns the default gallery parent folder.<p>
363     *
364     * @return the default gallery parent folder
365     */
366    public String getDefaultGalleryFolder() {
367
368        return m_defaultGalleryFolder;
369    }
370
371    /**
372     * Returns the type of the container page resource.<p>
373     *
374     * @return the type of the container page resource
375     */
376    public CmsNewResourceInfo getDefaultNewElementInfo() {
377
378        return m_defaultNewElementInfo;
379    }
380
381    /**
382     * Gets the detail page table.
383     *
384     * @return the detail page table
385     */
386    public CmsDetailPageTable getDetailPageTable() {
387
388        return m_detailPageTable;
389    }
390
391    /**
392     * Returns the editor mode.<p>
393     *
394     * @return the editor mode
395     */
396    public EditorMode getEditorMode() {
397
398        return m_editorMode;
399    }
400
401    /**
402     * Returns the export RFS prefix.<p>
403     *
404     * @return the export RFS prefix
405     */
406    public String getExportRfsPrefix() {
407
408        return m_exportRfsPrefix;
409    }
410
411    /**
412     * Returns the maximum sitemap depth.<p>
413     *
414     * @return the maximum sitemap depth
415     */
416    public int getMaxDepth() {
417
418        return m_maxDepth;
419    }
420
421    /**
422     * Returns the new element information.<p>
423     *
424     * @return the new element information
425     */
426    public List<CmsNewResourceInfo> getNewElementInfos() {
427
428        return m_newElementInfos;
429    }
430
431    /**
432     * Returns the new navigation level element info.<p>
433     *
434     * @return the new navigation level element info
435     */
436    public CmsNewResourceInfo getNewNavigationLevelElementInfo() {
437
438        return m_newNavigatioLevelElementInfo;
439    }
440
441    /**
442     * Returns the new redirect element info.<p>
443     *
444     * @return the new redirect element info
445     */
446    public CmsNewResourceInfo getNewRedirectElementInfo() {
447
448        return m_newRedirectElementInfo;
449    }
450
451    /**
452     * Gets the new resource info with a given structure id.<p>
453     *
454     * @param id the structure id
455     *
456     * @return the new resource info with the given id
457     */
458    public CmsNewResourceInfo getNewResourceInfoById(CmsUUID id) {
459
460        if (m_newElementInfos != null) {
461            for (CmsNewResourceInfo info : m_newElementInfos) {
462                if (info.getCopyResourceId().equals(id)) {
463                    return info;
464                }
465            }
466        }
467        return null;
468    }
469
470    /**
471     * Returns the reason why the current sitemap is not editable.<p>
472     *
473     * @return the reason why the current sitemap is not editable
474     */
475    public String getNoEditReason() {
476
477        return m_noEditReason;
478    }
479
480    /**
481     * Gets the path at which the sitemap should be opened (may be null).<p>
482     *
483     * @return the path at which the sitemap should be opened
484     */
485    public String getOpenPath() {
486
487        return m_openPath;
488    }
489
490    /**
491     * Returns the properties of the sitemap root's parent.<p>
492     *
493     * @return the properties of the sitemap root'S parent
494     */
495    public Map<String, CmsClientProperty> getParentProperties() {
496
497        return m_parentProperties;
498    }
499
500    /**
501     * Returns the path to the parent sitemap or <code>null</code>.<p>
502     *
503     * @return the path to the parent sitemap or <code>null</code>
504     */
505    public String getParentSitemap() {
506
507        return m_parentSitemap;
508    }
509
510    /**
511     * Returns the properties.<p>
512     *
513     * @return the properties
514     */
515    public Map<String, CmsXmlContentProperty> getProperties() {
516
517        return m_properties;
518    }
519
520    /**
521     * Gets the resource type info beans for the detail pages.<p>
522     *
523     * @return the resource type info beans for the detail pages
524     */
525    public List<CmsNewResourceInfo> getResourceTypeInfos() {
526
527        return m_resourceTypeInfos;
528    }
529
530    /**
531     * Returns the return page code.<p>
532     *
533     * @return the return page code
534     */
535    public String getReturnCode() {
536
537        return m_returnCode;
538    }
539
540    /**
541     * Returns the sitemap root.<p>
542     *
543     * @return the sitemap root
544     */
545    public CmsClientSitemapEntry getRoot() {
546
547        return m_root;
548    }
549
550    /**
551     * Returns the sitemap info.<p>
552     *
553     * @return the sitemap info
554     */
555    public CmsSitemapInfo getSitemapInfo() {
556
557        return m_sitemapInfo;
558    }
559
560    /**
561     * Gets the structure id of the site root.<p>
562     *
563     * @return the structure id of the site root
564     */
565    public CmsUUID getSiteRootId() {
566
567        return m_siteRootId;
568    }
569
570    /**
571     * Returns the list info beans for the available sitemap folder types.<p>
572     *
573     * @return the list info beans for the available sitemap folder types
574     */
575    public List<CmsListInfoBean> getSubsitemapFolderTypeInfos() {
576
577        return m_sitemapFolderTypeInfos;
578    }
579
580    /**
581     * Returns the available templates.<p>
582     *
583     * @return the available templates
584     */
585    public Map<String, CmsClientTemplateBean> getTemplates() {
586
587        return m_templates;
588    }
589
590    /**
591     * Checks if creation of nested galleries is allowed.
592     *
593     * @return true if creation of nested galleries is allowed
594     */
595    public boolean isAllowCreateNestedGalleries() {
596
597        return m_allowCreateNestedGalleries;
598    }
599
600    /**
601     * Returns if the current user has the category manager role.<p>
602     *
603     * @return if the current user has the category manager role
604     */
605    public boolean isCategoryManager() {
606
607        return m_categoryManager;
608    }
609
610    /**
611     * Returns true if new folders should be created for subsitemaps.<p>
612     *
613     * @return true if new folders should be created for subsitemaps
614     */
615    public boolean isCreateNewFoldersForSubsitemaps() {
616
617        return m_createNewFolderForSubsitemap;
618    }
619
620    /**
621     * Checks if to display the toolbar.<p>
622     *
623     * @return <code>true</code> if to display the toolbar
624     */
625    public boolean isDisplayToolbar() {
626
627        return m_displayToolbar;
628    }
629
630    /**
631     * Returns if the current user has the gallery manager role.<p>
632     *
633     * @return if the current user has the gallery manager role
634     */
635    public boolean isGalleryManager() {
636
637        return m_galleryManager;
638    }
639
640    /**
641     * Returns true if the locale compare mode is enabled.<p>
642     *
643     * @return true if the locale compare mode is enabled
644     */
645    public boolean isLocaleComparisonEnabled() {
646
647        return m_localeComparisonEnabled;
648    }
649
650    /**
651     * Returns true if there is a secure server configured for the site which contains the sitemap.<p>
652     *
653     * @return true if there is a secure server configured for the site which contains the sitemap
654     */
655    public boolean isSecure() {
656
657        return m_isSecure;
658    }
659
660    /**
661     * Returns the show model edit confirm dialog flag.<p>
662     *
663     * @return the show model edit confirm dialog flag
664     */
665    public boolean isShowModelEditConfirm() {
666
667        return m_showModelEditConfirm;
668    }
669
670    /**
671     * Enable or disable option for creating nested galleries.
672     *
673     * @param allowCreateNestedGalleries true if nested galleries are allowed
674     */
675    public void setAllowCreateNestedGalleries(boolean allowCreateNestedGalleries) {
676
677        m_allowCreateNestedGalleries = allowCreateNestedGalleries;
678    }
679
680    /**
681     * Sets whether the user can manage detail pages.
682     *
683     * @param canManageDetailPages true if the user can manage detail pages
684     */
685    public void setCanManageDetailPages(boolean canManageDetailPages) {
686
687        m_canManageDetailPages = canManageDetailPages;
688    }
689
690    /**
691     * Sets the 'locale comparison mode enabled' flag.<p>
692     *
693     * @param enabled the new flag value
694     */
695    public void setLocaleComparisonEnabled(boolean enabled) {
696
697        m_localeComparisonEnabled = enabled;
698    }
699
700    /**
701     * Sets the new element infos.<p>
702     *
703     * @param newElementInfos the new element infos
704     */
705    public void setNewElementInfos(List<CmsNewResourceInfo> newElementInfos) {
706
707        m_newElementInfos = newElementInfos;
708    }
709
710    /**
711     * Sets the return page code.<p>
712     *
713     * @param returnCode the return page code to set
714     */
715    public void setReturnCode(String returnCode) {
716
717        m_returnCode = returnCode;
718    }
719
720    /**
721     * Sets the site root structure id .<p>
722     *
723     * @param id the site root id
724     */
725    public void setSiteRootId(CmsUUID id) {
726
727        m_siteRootId = id;
728    }
729
730}