001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (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, 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.ade.containerpage.shared; 029 030import org.opencms.gwt.shared.CmsListInfoBean; 031import org.opencms.gwt.shared.CmsTemplateContextInfo; 032import org.opencms.util.CmsUUID; 033 034import java.util.HashMap; 035import java.util.List; 036import java.util.Map; 037import java.util.Set; 038 039import com.google.gwt.user.client.rpc.IsSerializable; 040 041/** 042 * Convenience class to provide server-side information to the client.<p> 043 * 044 * @since 8.0.0 045 */ 046public final class CmsCntPageData implements IsSerializable { 047 048 /** The element delte modes. */ 049 public enum ElementDeleteMode { 050 /** Don't ask, delete no longer referenced element resources. */ 051 alwaysDelete, 052 /** Don't ask, keep no longer referenced element resources. */ 053 alwaysKeep, 054 /** Ask if no longer referenced element resources should be deleted. Delete is preselected. */ 055 askDelete, 056 /** Ask if no longer referenced element resources should be deleted. Keep is preselected. */ 057 askKeep 058 } 059 060 /** Enum representing the different ways dropping elements on a container page can be handled. */ 061 public enum ElementReuseMode { 062 063 /** The user will be asked whether they want the 'copy' or 'reuse' behavior. */ 064 ask, 065 066 /** The dropped element will be copied, and the container page will link to the copy. */ 067 copy, 068 069 /** The container page will link to the dropped element. */ 070 reuse 071 } 072 073 /** Name of the used dictionary. */ 074 public static final String DICT_NAME = "org_opencms_ade_containerpage"; 075 076 /** Key 'detailElementId' for the detail content id. */ 077 public static final String JSONKEY_DETAIL_ELEMENT_ID = "detailElementId"; 078 079 /** Key 'isDetailOnly' used within the JSON representation of a container object. */ 080 public static final String JSONKEY_DETAILONLY = "isDetailOnly"; 081 082 /** Key 'isDetailView' used within the JSON representation of a container object. */ 083 public static final String JSONKEY_DETAILVIEW = "isDetailView"; 084 085 /** Key 'elementId' for the element id. */ 086 public static final String JSONKEY_ELEMENT_ID = "elementId"; 087 088 /** Key 'elements' used within the JSON representation of a container object. */ 089 public static final String JSONKEY_ELEMENTS = "elements"; 090 091 /** Key 'isDetailViewContainer' used within the JSON representation of a container object. */ 092 public static final String JSONKEY_ISDETAILVIEWCONTAINER = "isDetailViewContainer"; 093 094 /** Key 'maxElements' used within the JSON representation of a container object. */ 095 public static final String JSONKEY_MAXELEMENTS = "maxElements"; 096 097 /** Key 'name' used within the JSON representation of a container object. */ 098 public static final String JSONKEY_NAME = "name"; 099 100 /** JSON key for presets. */ 101 public static final String JSONKEY_PRESETS = "presets"; 102 103 /** Key 'type' used within the JSON representation of a container object. */ 104 public static final String JSONKEY_TYPE = "type"; 105 106 /** Key 'width' used within the JSON representation of a container object. */ 107 public static final String JSONKEY_WIDTH = "width"; 108 109 /** The editor back-link URI. */ 110 private static final String BACKLINK_URI = "/system/modules/org.opencms.ade.containerpage/editor-backlink.html"; 111 112 /** Temporary flag to disable the option to edit settings in content editor. */ 113 private boolean m_allowSettingsInEditor; 114 115 /** The app title to display in the toolbar. */ 116 private String m_appTitle; 117 118 /** The element delete mode. */ 119 private ElementDeleteMode m_deleteMode; 120 121 /** The detail view container resource path. */ 122 private String m_detailContainerPage; 123 124 /** The detail structure id, if available. */ 125 private CmsUUID m_detailId; 126 127 /** The set of names of types for which the current page is registered as a detail page. */ 128 private Set<String> m_detailTypes; 129 130 /** Flag which determines whether small elements should be editable initially. */ 131 private boolean m_editSmallElementsInitially; 132 133 /** The current element view. */ 134 private CmsElementViewInfo m_elementView; 135 136 /** The element views. */ 137 private List<CmsElementViewInfo> m_elementViews; 138 139 /** True if the page is used for model groups. */ 140 private boolean m_isModelGroup; 141 142 /** True if the container page is a model page. */ 143 private boolean m_isModelPage; 144 145 /** The date at which the container page was last modified. */ 146 private long m_lastModified; 147 148 /** The time when the page was loaded. */ 149 private long m_loadTime; 150 151 /** The content locale. */ 152 private String m_locale; 153 154 /** The locale link beans. */ 155 private Map<String, CmsLocaleLinkBean> m_localeLinkBeans; 156 157 /** The lock information, if the page is locked by another user. */ 158 private String m_lockInfo; 159 160 /** The main locale to this page in case it is part of a locale group. */ 161 private String m_mainLocale; 162 163 /** The model group base element id. */ 164 private String m_modelGroupEmenetId; 165 166 /** The reason why the user is not able to edit the current container page. */ 167 private String m_noEditReason; 168 169 /** The online link to the current page. */ 170 private String m_onlineLink; 171 172 /** The current page info. */ 173 private CmsListInfoBean m_pageInfo; 174 175 /** The original request parameters. */ 176 private String m_requestParams; 177 178 /** The element reuse mode. */ 179 private ElementReuseMode m_reuseMode; 180 181 /** The RPC context. */ 182 private CmsContainerPageRpcContext m_rpcContext; 183 184 /** Flag indicating if the current user has the sitemap manager role. */ 185 private boolean m_sitemapManager; 186 187 /** The current sitemap URI. */ 188 private String m_sitemapUri; 189 190 /** The template context information. */ 191 private CmsTemplateContextInfo m_templateContextInfo; 192 193 /** Flag indicating to use the classic XmlContent editor. */ 194 private boolean m_useClassicEditor; 195 196 /** The detail container page id (may be null). */ 197 private CmsUUID m_detailContainerPageId; 198 199 /** Key-value pairs to store in the sessionStorage. */ 200 private Map<String, String> m_sessionStorageData = new HashMap<>(); 201 202 /** Indicates if placement mode is enabled. */ 203 private boolean m_placementModeEnabled; 204 205 /** 206 * Constructor.<p> 207 * 208 * @param onlineLink the online link to the current page 209 * @param noEditReason the reason why the current user is not allowed to edit the current container page 210 * @param requestParams the original request parameters 211 * @param sitemapUri the current sitemap URI 212 * @param sitemapManager if the user has the sitemap manager role 213 * @param detailId the detail resource id, if available 214 * @param detailContainerPage the detail view container resource path 215 * @param detailContainerPageId the detail view container page structure id 216 * @param detailTypes the set of names of types for which this page is registered as detail page 217 * @param lastModified the last modification date of the page 218 * @param lockInfo lock information, if the page is locked by another user 219 * @param pageInfo the current page info 220 * @param locale the content locale 221 * @param useClassicEditor <code>true</code> to use the classic XmlContent editor 222 * @param contextInfo the template context information 223 * @param showSmallElementsInitially flag which controls whether small elements should be shown initially 224 * @param elementViews the element views 225 * @param elementView the current element view 226 * @param reuseMode the element reuse mode 227 * @param deleteMode the element delete mode 228 * @param isModelPage true if this is a model page 229 * @param isModelGroup true if the page is used for model groups 230 * @param modelGroupEmenetId the model group base element id 231 * @param mainLocale the main locale to this page in case it is part of a locale group 232 * @param localeLinkBeans beans for links to other pages in the locale group 233 * @param appTitle the title to display in the toolbar 234 * @param loadTime the current time 235 */ 236 public CmsCntPageData( 237 String onlineLink, 238 String noEditReason, 239 String requestParams, 240 String sitemapUri, 241 boolean sitemapManager, 242 CmsUUID detailId, 243 String detailContainerPage, 244 CmsUUID detailContainerPageId, 245 Set<String> detailTypes, 246 long lastModified, 247 String lockInfo, 248 CmsListInfoBean pageInfo, 249 String locale, 250 boolean useClassicEditor, 251 CmsTemplateContextInfo contextInfo, 252 boolean showSmallElementsInitially, 253 List<CmsElementViewInfo> elementViews, 254 CmsElementViewInfo elementView, 255 ElementReuseMode reuseMode, 256 ElementDeleteMode deleteMode, 257 boolean isModelPage, 258 boolean isModelGroup, 259 String modelGroupEmenetId, 260 String mainLocale, 261 Map<String, CmsLocaleLinkBean> localeLinkBeans, 262 String appTitle, 263 long loadTime) { 264 265 m_onlineLink = onlineLink; 266 m_noEditReason = noEditReason; 267 m_requestParams = requestParams; 268 m_sitemapUri = sitemapUri; 269 m_sitemapManager = sitemapManager; 270 m_lastModified = lastModified; 271 m_lockInfo = lockInfo; 272 m_pageInfo = pageInfo; 273 m_locale = locale; 274 m_detailId = detailId; 275 m_detailContainerPage = detailContainerPage; 276 m_detailContainerPageId = detailContainerPageId; 277 m_detailTypes = detailTypes; 278 m_useClassicEditor = useClassicEditor; 279 m_templateContextInfo = contextInfo; 280 m_editSmallElementsInitially = showSmallElementsInitially; 281 m_elementViews = elementViews; 282 m_elementView = elementView; 283 m_reuseMode = reuseMode; 284 m_deleteMode = deleteMode; 285 m_isModelPage = isModelPage; 286 m_isModelGroup = isModelGroup; 287 m_modelGroupEmenetId = modelGroupEmenetId; 288 m_mainLocale = mainLocale; 289 m_localeLinkBeans = localeLinkBeans; 290 m_appTitle = appTitle; 291 m_loadTime = loadTime; 292 } 293 294 /** 295 * Serialization constructor.<p> 296 */ 297 protected CmsCntPageData() { 298 299 // empty 300 } 301 302 /** 303 * Returns whether editing settings in the content editor is allowed.<p> 304 * 305 * @return <code>true</code> in case editing settings in the content editor is allowed 306 */ 307 public boolean allowSettingsInEditor() { 308 309 return m_allowSettingsInEditor; 310 } 311 312 /** 313 * Gets the title to display in the toolbar.<p> 314 * 315 * @return the title for the toolbar 316 */ 317 public String getAppTitle() { 318 319 return m_appTitle; 320 } 321 322 /** 323 * Returns the xml-content editor back-link URI.<p> 324 * 325 * @return the back-link URI 326 */ 327 public String getBacklinkUri() { 328 329 return BACKLINK_URI; 330 } 331 332 /** 333 * Gets the date at which the page was last modified.<p> 334 * 335 * @return the date at which the page was last modified 336 */ 337 public long getDateLastModified() { 338 339 return m_lastModified; 340 } 341 342 /** 343 * Returns the element delete mode.<p> 344 * 345 * @return the element delete mode 346 */ 347 public ElementDeleteMode getDeleteMode() { 348 349 return m_deleteMode; 350 } 351 352 /** 353 * Returns the detail view container resource path.<p> 354 * 355 * @return the detail view container resource path 356 */ 357 public String getDetailContainerPage() { 358 359 return m_detailContainerPage; 360 } 361 362 /** 363 * Gets the structure id of the detail container page (or null if we are not on on a detail page, or there is no detail container page). 364 * 365 * @return the structure id of the detail container page 366 */ 367 public CmsUUID getDetailContainerPageId() { 368 369 return m_detailContainerPageId; 370 } 371 372 /** 373 * Returns the detail structure id, if available.<p> 374 * 375 * @return the detail structure id 376 */ 377 public CmsUUID getDetailId() { 378 379 return m_detailId; 380 } 381 382 /** 383 * Gets the set of names of types for which the container page is registered as a detail page. 384 * 385 * @return the set of names of detail types 386 */ 387 public Set<String> getDetailTypes() { 388 389 return m_detailTypes; 390 } 391 392 /** 393 * Gets the element reuse mode.<p> 394 * 395 * @return the element reuse mode 396 */ 397 public ElementReuseMode getElementReuseMode() { 398 399 return m_reuseMode; 400 } 401 402 /** 403 * Returns the current element view.<p> 404 * 405 * @return the current element view 406 */ 407 public CmsElementViewInfo getElementView() { 408 409 return m_elementView; 410 } 411 412 /** 413 * Returns the available element views.<p> 414 * 415 * @return the element views 416 */ 417 public List<CmsElementViewInfo> getElementViews() { 418 419 return m_elementViews; 420 } 421 422 /** 423 * Returns the time off page load.<p> 424 * 425 * @return the time stamp 426 */ 427 public long getLoadTime() { 428 429 return m_loadTime; 430 } 431 432 /** 433 * Returns the content locale.<p> 434 * 435 * @return the locale 436 */ 437 public String getLocale() { 438 439 return m_locale; 440 } 441 442 /** 443 * Gets the locale link beans, with localized language names as keys.<p> 444 * 445 * The beans represent links to different locale variants of this page. 446 * 447 * @return the locale link bean map for this 448 */ 449 public Map<String, CmsLocaleLinkBean> getLocaleLinkBeans() { 450 451 return m_localeLinkBeans; 452 } 453 454 /** 455 * Returns the lock information, if the page is locked by another user.<p> 456 * 457 * @return the lock infomation 458 */ 459 public String getLockInfo() { 460 461 return m_lockInfo; 462 } 463 464 /** 465 * Returns the main locale to this page in case it is part of a locale group.<p> 466 * 467 * @return the main locale to this page in case it is part of a locale group 468 */ 469 public String getMainLocale() { 470 471 return m_mainLocale; 472 } 473 474 /** 475 * Returns the model group base element id.<p> 476 * 477 * @return the model group base element id 478 */ 479 public String getModelGroupElementId() { 480 481 return m_modelGroupEmenetId; 482 } 483 484 /** 485 * Returns the no-edit reason.<p> 486 * 487 * @return the no-edit reason, if empty editing is allowed 488 */ 489 public String getNoEditReason() { 490 491 return m_noEditReason; 492 } 493 494 /** 495 * Returns the online link to the current page.<p> 496 * 497 * @return the online link to the current page 498 */ 499 public String getOnlineLink() { 500 501 return m_onlineLink; 502 } 503 504 /** 505 * Returns the current page info.<p> 506 * 507 * @return the current page info 508 */ 509 public CmsListInfoBean getPageInfo() { 510 511 return m_pageInfo; 512 } 513 514 /** 515 * Returns the request parameters.<p> 516 * 517 * @return the request parameters 518 */ 519 public String getRequestParams() { 520 521 return m_requestParams; 522 } 523 524 /** 525 * Gets the RPC context.<p> 526 * 527 * @return the RPC context 528 */ 529 public CmsContainerPageRpcContext getRpcContext() { 530 531 return m_rpcContext; 532 } 533 534 /** 535 * Gets the key-value pairs to store in the session storage of the browser. 536 * 537 * @return the map of entries to store in the session storage 538 */ 539 public Map<String, String> getSessionStorageData() { 540 541 return m_sessionStorageData; 542 } 543 544 /** 545 * Returns the sitemap URI.<p> 546 * 547 * @return the sitemap URI 548 */ 549 public String getSitemapUri() { 550 551 return m_sitemapUri; 552 } 553 554 /** 555 * Gets the template context information.<p> 556 * 557 * @return the template context information 558 */ 559 public CmsTemplateContextInfo getTemplateContextInfo() { 560 561 return m_templateContextInfo; 562 } 563 564 /** 565 * Returns true if small elements should be editable initially.<p> 566 * 567 * @return true if small elements should be editable initially 568 */ 569 public boolean isEditSmallElementsInitially() { 570 571 return m_editSmallElementsInitially; 572 } 573 574 /** 575 * Returns if the page is used for model groups.<p> 576 * 577 * @return true if the page is used for model groups 578 */ 579 public boolean isModelGroup() { 580 581 return m_isModelGroup; 582 } 583 584 /** 585 * True if the container page is a model page.<P> 586 * 587 * @return true if this is a model page 588 */ 589 public boolean isModelPage() { 590 591 return m_isModelPage; 592 } 593 594 /** 595 * Returns true if placement mode is enabled. 596 * 597 * @return true if placement mode is enabled 598 */ 599 public boolean isPlacementModeEnabled() { 600 return m_placementModeEnabled; 601 } 602 603 /** 604 * Returns if the current user has the sitemap manager role.<p> 605 * 606 * @return if the current user has the sitemap manager role 607 */ 608 public boolean isSitemapManager() { 609 610 return m_sitemapManager; 611 } 612 613 /** 614 * Returns if the classic XmlContent editor should be used.<p> 615 * 616 * @return <code>true</code> if the classic XmlContent editor should be used 617 */ 618 public boolean isUseClassicEditor() { 619 620 return m_useClassicEditor; 621 } 622 623 /** 624 * Sets whether editing settings in the content editor is allowed.<p> 625 * 626 * @param allowSettingsInEditor <code>true</code> to set editing settings in the content editor is allowed 627 */ 628 public void setAllowSettingsInEditor(boolean allowSettingsInEditor) { 629 630 m_allowSettingsInEditor = allowSettingsInEditor; 631 } 632 633 /** 634 * Sets the 'placement mode enabled' flag. 635 * 636 * @param placementModeEnabled the new value for the 'placement mode enabled' flag 637 */ 638 public void setPlacementModeEnabled(boolean placementModeEnabled) { 639 m_placementModeEnabled = placementModeEnabled; 640 } 641 642 /** 643 * Sets the RPC context.<p> 644 * 645 * @param context the RPC context 646 */ 647 public void setRpcContext(CmsContainerPageRpcContext context) { 648 649 m_rpcContext = context; 650 } 651 652 /** 653 * Sets the entries to store in the browser's session storage. 654 * 655 * @param sessionStorageData the entries to store in the browser's session storage 656 */ 657 public void setSessionStorageData(Map<String, String> sessionStorageData) { 658 659 m_sessionStorageData = sessionStorageData; 660 } 661 662}