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 /** 203 * Constructor.<p> 204 * 205 * @param onlineLink the online link to the current page 206 * @param noEditReason the reason why the current user is not allowed to edit the current container page 207 * @param requestParams the original request parameters 208 * @param sitemapUri the current sitemap URI 209 * @param sitemapManager if the user has the sitemap manager role 210 * @param detailId the detail resource id, if available 211 * @param detailContainerPage the detail view container resource path 212 * @param detailContainerPageId the detail view container page structure id 213 * @param detailTypes the set of names of types for which this page is registered as detail page 214 * @param lastModified the last modification date of the page 215 * @param lockInfo lock information, if the page is locked by another user 216 * @param pageInfo the current page info 217 * @param locale the content locale 218 * @param useClassicEditor <code>true</code> to use the classic XmlContent editor 219 * @param contextInfo the template context information 220 * @param showSmallElementsInitially flag which controls whether small elements should be shown initially 221 * @param elementViews the element views 222 * @param elementView the current element view 223 * @param reuseMode the element reuse mode 224 * @param deleteMode the element delete mode 225 * @param isModelPage true if this is a model page 226 * @param isModelGroup true if the page is used for model groups 227 * @param modelGroupEmenetId the model group base element id 228 * @param mainLocale the main locale to this page in case it is part of a locale group 229 * @param localeLinkBeans beans for links to other pages in the locale group 230 * @param appTitle the title to display in the toolbar 231 * @param loadTime the current time 232 */ 233 public CmsCntPageData( 234 String onlineLink, 235 String noEditReason, 236 String requestParams, 237 String sitemapUri, 238 boolean sitemapManager, 239 CmsUUID detailId, 240 String detailContainerPage, 241 CmsUUID detailContainerPageId, 242 Set<String> detailTypes, 243 long lastModified, 244 String lockInfo, 245 CmsListInfoBean pageInfo, 246 String locale, 247 boolean useClassicEditor, 248 CmsTemplateContextInfo contextInfo, 249 boolean showSmallElementsInitially, 250 List<CmsElementViewInfo> elementViews, 251 CmsElementViewInfo elementView, 252 ElementReuseMode reuseMode, 253 ElementDeleteMode deleteMode, 254 boolean isModelPage, 255 boolean isModelGroup, 256 String modelGroupEmenetId, 257 String mainLocale, 258 Map<String, CmsLocaleLinkBean> localeLinkBeans, 259 String appTitle, 260 long loadTime) { 261 262 m_onlineLink = onlineLink; 263 m_noEditReason = noEditReason; 264 m_requestParams = requestParams; 265 m_sitemapUri = sitemapUri; 266 m_sitemapManager = sitemapManager; 267 m_lastModified = lastModified; 268 m_lockInfo = lockInfo; 269 m_pageInfo = pageInfo; 270 m_locale = locale; 271 m_detailId = detailId; 272 m_detailContainerPage = detailContainerPage; 273 m_detailContainerPageId = detailContainerPageId; 274 m_detailTypes = detailTypes; 275 m_useClassicEditor = useClassicEditor; 276 m_templateContextInfo = contextInfo; 277 m_editSmallElementsInitially = showSmallElementsInitially; 278 m_elementViews = elementViews; 279 m_elementView = elementView; 280 m_reuseMode = reuseMode; 281 m_deleteMode = deleteMode; 282 m_isModelPage = isModelPage; 283 m_isModelGroup = isModelGroup; 284 m_modelGroupEmenetId = modelGroupEmenetId; 285 m_mainLocale = mainLocale; 286 m_localeLinkBeans = localeLinkBeans; 287 m_appTitle = appTitle; 288 m_loadTime = loadTime; 289 } 290 291 /** 292 * Serialization constructor.<p> 293 */ 294 protected CmsCntPageData() { 295 296 // empty 297 } 298 299 /** 300 * Returns whether editing settings in the content editor is allowed.<p> 301 * 302 * @return <code>true</code> in case editing settings in the content editor is allowed 303 */ 304 public boolean allowSettingsInEditor() { 305 306 return m_allowSettingsInEditor; 307 } 308 309 /** 310 * Gets the title to display in the toolbar.<p> 311 * 312 * @return the title for the toolbar 313 */ 314 public String getAppTitle() { 315 316 return m_appTitle; 317 } 318 319 /** 320 * Returns the xml-content editor back-link URI.<p> 321 * 322 * @return the back-link URI 323 */ 324 public String getBacklinkUri() { 325 326 return BACKLINK_URI; 327 } 328 329 /** 330 * Gets the date at which the page was last modified.<p> 331 * 332 * @return the date at which the page was last modified 333 */ 334 public long getDateLastModified() { 335 336 return m_lastModified; 337 } 338 339 /** 340 * Returns the element delete mode.<p> 341 * 342 * @return the element delete mode 343 */ 344 public ElementDeleteMode getDeleteMode() { 345 346 return m_deleteMode; 347 } 348 349 /** 350 * Returns the detail view container resource path.<p> 351 * 352 * @return the detail view container resource path 353 */ 354 public String getDetailContainerPage() { 355 356 return m_detailContainerPage; 357 } 358 359 /** 360 * 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). 361 * 362 * @return the structure id of the detail container page 363 */ 364 public CmsUUID getDetailContainerPageId() { 365 366 return m_detailContainerPageId; 367 } 368 369 /** 370 * Returns the detail structure id, if available.<p> 371 * 372 * @return the detail structure id 373 */ 374 public CmsUUID getDetailId() { 375 376 return m_detailId; 377 } 378 379 /** 380 * Gets the set of names of types for which the container page is registered as a detail page. 381 * 382 * @return the set of names of detail types 383 */ 384 public Set<String> getDetailTypes() { 385 386 return m_detailTypes; 387 } 388 389 /** 390 * Gets the element reuse mode.<p> 391 * 392 * @return the element reuse mode 393 */ 394 public ElementReuseMode getElementReuseMode() { 395 396 return m_reuseMode; 397 } 398 399 /** 400 * Returns the current element view.<p> 401 * 402 * @return the current element view 403 */ 404 public CmsElementViewInfo getElementView() { 405 406 return m_elementView; 407 } 408 409 /** 410 * Returns the available element views.<p> 411 * 412 * @return the element views 413 */ 414 public List<CmsElementViewInfo> getElementViews() { 415 416 return m_elementViews; 417 } 418 419 /** 420 * Returns the time off page load.<p> 421 * 422 * @return the time stamp 423 */ 424 public long getLoadTime() { 425 426 return m_loadTime; 427 } 428 429 /** 430 * Returns the content locale.<p> 431 * 432 * @return the locale 433 */ 434 public String getLocale() { 435 436 return m_locale; 437 } 438 439 /** 440 * Gets the locale link beans, with localized language names as keys.<p> 441 * 442 * The beans represent links to different locale variants of this page. 443 * 444 * @return the locale link bean map for this 445 */ 446 public Map<String, CmsLocaleLinkBean> getLocaleLinkBeans() { 447 448 return m_localeLinkBeans; 449 } 450 451 /** 452 * Returns the lock information, if the page is locked by another user.<p> 453 * 454 * @return the lock infomation 455 */ 456 public String getLockInfo() { 457 458 return m_lockInfo; 459 } 460 461 /** 462 * Returns the main locale to this page in case it is part of a locale group.<p> 463 * 464 * @return the main locale to this page in case it is part of a locale group 465 */ 466 public String getMainLocale() { 467 468 return m_mainLocale; 469 } 470 471 /** 472 * Returns the model group base element id.<p> 473 * 474 * @return the model group base element id 475 */ 476 public String getModelGroupElementId() { 477 478 return m_modelGroupEmenetId; 479 } 480 481 /** 482 * Returns the no-edit reason.<p> 483 * 484 * @return the no-edit reason, if empty editing is allowed 485 */ 486 public String getNoEditReason() { 487 488 return m_noEditReason; 489 } 490 491 /** 492 * Returns the online link to the current page.<p> 493 * 494 * @return the online link to the current page 495 */ 496 public String getOnlineLink() { 497 498 return m_onlineLink; 499 } 500 501 /** 502 * Returns the current page info.<p> 503 * 504 * @return the current page info 505 */ 506 public CmsListInfoBean getPageInfo() { 507 508 return m_pageInfo; 509 } 510 511 /** 512 * Returns the request parameters.<p> 513 * 514 * @return the request parameters 515 */ 516 public String getRequestParams() { 517 518 return m_requestParams; 519 } 520 521 /** 522 * Gets the RPC context.<p> 523 * 524 * @return the RPC context 525 */ 526 public CmsContainerPageRpcContext getRpcContext() { 527 528 return m_rpcContext; 529 } 530 531 /** 532 * Gets the key-value pairs to store in the session storage of the browser. 533 * 534 * @return the map of entries to store in the session storage 535 */ 536 public Map<String, String> getSessionStorageData() { 537 538 return m_sessionStorageData; 539 } 540 541 /** 542 * Returns the sitemap URI.<p> 543 * 544 * @return the sitemap URI 545 */ 546 public String getSitemapUri() { 547 548 return m_sitemapUri; 549 } 550 551 /** 552 * Gets the template context information.<p> 553 * 554 * @return the template context information 555 */ 556 public CmsTemplateContextInfo getTemplateContextInfo() { 557 558 return m_templateContextInfo; 559 } 560 561 /** 562 * Returns true if small elements should be editable initially.<p> 563 * 564 * @return true if small elements should be editable initially 565 */ 566 public boolean isEditSmallElementsInitially() { 567 568 return m_editSmallElementsInitially; 569 } 570 571 /** 572 * Returns if the page is used for model groups.<p> 573 * 574 * @return true if the page is used for model groups 575 */ 576 public boolean isModelGroup() { 577 578 return m_isModelGroup; 579 } 580 581 /** 582 * True if the container page is a model page.<P> 583 * 584 * @return true if this is a model page 585 */ 586 public boolean isModelPage() { 587 588 return m_isModelPage; 589 } 590 591 /** 592 * Returns if the current user has the sitemap manager role.<p> 593 * 594 * @return if the current user has the sitemap manager role 595 */ 596 public boolean isSitemapManager() { 597 598 return m_sitemapManager; 599 } 600 601 /** 602 * Returns if the classic XmlContent editor should be used.<p> 603 * 604 * @return <code>true</code> if the classic XmlContent editor should be used 605 */ 606 public boolean isUseClassicEditor() { 607 608 return m_useClassicEditor; 609 } 610 611 /** 612 * Sets whether editing settings in the content editor is allowed.<p> 613 * 614 * @param allowSettingsInEditor <code>true</code> to set editing settings in the content editor is allowed 615 */ 616 public void setAllowSettingsInEditor(boolean allowSettingsInEditor) { 617 618 m_allowSettingsInEditor = allowSettingsInEditor; 619 } 620 621 /** 622 * Sets the RPC context.<p> 623 * 624 * @param context the RPC context 625 */ 626 public void setRpcContext(CmsContainerPageRpcContext context) { 627 628 m_rpcContext = context; 629 } 630 631 /** 632 * Sets the entries to store in the browser's session storage. 633 * 634 * @param sessionStorageData the entries to store in the browser's session storage 635 */ 636 public void setSessionStorageData(Map<String, String> sessionStorageData) { 637 638 m_sessionStorageData = sessionStorageData; 639 } 640 641}