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.gwt.shared; 029 030import org.opencms.util.CmsUUID; 031 032import java.util.Map; 033 034import com.google.gwt.user.client.rpc.IsSerializable; 035 036/** 037 * Runtime data bean for prefetching.<p> 038 * 039 * @since 8.0.0 040 */ 041public class CmsCoreData implements IsSerializable { 042 043 /** A enumeration for the ADE context. */ 044 public enum AdeContext { 045 046 /** Context for classic direct edit provider. */ 047 editprovider, 048 049 /** Context for gallery dialog. */ 050 gallery, 051 052 /** Context for container page. */ 053 pageeditor, 054 055 /** Context for publish dialog. */ 056 publish, 057 058 /** Context for resource info dialog. */ 059 resourceinfo, 060 061 /** Context for sitemap. */ 062 sitemapeditor 063 } 064 065 /** The available client modules. */ 066 public enum ModuleKey { 067 068 /** Container page editor. */ 069 containerpage, 070 071 /** Content editor. */ 072 contenteditor, 073 074 /** Direct edit provider. */ 075 editprovider, 076 077 /** Galleries. */ 078 galleries, 079 080 /** Post upload dialog. */ 081 postupload, 082 083 /** Properties dialog. */ 084 properties, 085 086 /** Publish dialog. */ 087 publish, 088 089 /** Sitemap editor. */ 090 sitemap, 091 092 /** Upload dialog. */ 093 upload 094 } 095 096 /** 097 * Bean class containing info about the current user.<p> 098 */ 099 public static class UserInfo implements IsSerializable { 100 101 /** True if the user is an administrator. */ 102 private boolean m_isAdmin; 103 104 /** True if the user is a category manager. */ 105 private boolean m_isCategoryManager; 106 107 /** True if the user is a template developer. */ 108 private boolean m_isDeveloper; 109 110 /** True if the user is managed. */ 111 private boolean m_isManaged; 112 113 /** True if the user is a workplace user. */ 114 private boolean m_isWorkplaceUser; 115 116 /** The user name. */ 117 private String m_name; 118 119 /** The user icon path. */ 120 private String m_userIcon; 121 122 /** 123 * Creates a new instance.<p> 124 * 125 * @param name the user name 126 * @param userIcon the user icon path 127 * @param isAdmin true if the user is an administrator 128 * @param isDeveloper true if the user is a template developer 129 * @param isCategoryManager true if the user is a category manager 130 * @param isWorkplaceUser true if the user is a workplace user 131 * @param isManaged true if the user is managed 132 */ 133 public UserInfo( 134 String name, 135 String userIcon, 136 boolean isAdmin, 137 boolean isDeveloper, 138 boolean isCategoryManager, 139 boolean isWorkplaceUser, 140 boolean isManaged) { 141 142 m_isDeveloper = isDeveloper; 143 m_isCategoryManager = isCategoryManager; 144 m_isAdmin = isAdmin; 145 m_isManaged = isManaged; 146 m_isWorkplaceUser = isWorkplaceUser; 147 m_name = name; 148 m_userIcon = userIcon; 149 } 150 151 /** 152 * Default constructor, needed for serialization.<p> 153 */ 154 protected UserInfo() { 155 156 // empty 157 } 158 159 /** 160 * Gets the user name.<p> 161 * 162 * @return the user name 163 */ 164 public String getName() { 165 166 return m_name; 167 } 168 169 /** 170 * Returns the user icon path.<p> 171 * 172 * @return the user icon path 173 */ 174 public String getUserIcon() { 175 176 return m_userIcon; 177 } 178 179 /** 180 * Returns true if the user is an administrator.<p> 181 * 182 * @return true if the user is an administrator 183 */ 184 public boolean isAdmin() { 185 186 return m_isAdmin; 187 } 188 189 /** 190 * Returns true if the user is a category manager.<p> 191 * 192 * @return true if the user is a category manager 193 */ 194 public boolean isCategoryManager() { 195 196 return m_isCategoryManager; 197 } 198 199 /** 200 * Returns true if the user is a template developer.<p> 201 * 202 * @return true if the user is a template developer 203 */ 204 public boolean isDeveloper() { 205 206 return m_isDeveloper; 207 } 208 209 /** 210 * Returns if the user is managed.<p> 211 * 212 * @return <code>true</code> if the user is managed 213 */ 214 public boolean isManaged() { 215 216 return m_isManaged; 217 } 218 219 /** 220 * Returns true if the current user is a workplace user.<p> 221 * 222 * @return true if the current user is a workplace user 223 */ 224 public boolean isWorkplaceUser() { 225 226 return m_isWorkplaceUser; 227 } 228 } 229 230 /** Name of the used js variable. */ 231 public static final String DICT_NAME = "org_opencms_gwt"; 232 233 /** The key for the GWT build id property. */ 234 public static final String KEY_GWT_BUILDID = "gwt.buildid"; 235 236 /** The meta element name to the requested module key. */ 237 public static final String META_PARAM_MODULE_KEY = "opencms-module"; 238 239 /** The parameter name for path. */ 240 public static final String PARAM_PATH = "path"; 241 242 /** The parameter name for the return code. */ 243 public static final String PARAM_RETURNCODE = "returncode"; 244 245 /** The time sent from the server when loading the data. */ 246 protected long m_serverTime; 247 248 /** A bean with information about the current user. */ 249 protected UserInfo m_userInfo; 250 251 /** The link to the page displayed in the "about" dialog. */ 252 private String m_aboutLink; 253 254 /** ADE parameters. */ 255 private Map<String, String> m_adeParameters; 256 257 /** The category base folder. */ 258 private String m_categoryBaseFolder; 259 260 /** The XML content editor back-link URL. */ 261 private String m_contentEditorBacklinkUrl; 262 263 /** The XML content editor URL. */ 264 private String m_contentEditorUrl; 265 266 /** The default link to use for opening the workplace. */ 267 private String m_defaultWorkplaceLink; 268 269 /** The embedded dialogs URL. */ 270 private String m_embeddedDialogsUrl; 271 272 /** The mappings of file extensions to resource types. */ 273 private Map<String, String> m_extensionMapping; 274 275 /** The file explorer link. */ 276 private String m_fileExplorerLink; 277 278 /** True if deactivated types should be hidden in the gallery dialog. */ 279 private boolean m_hideDisabledGalleryTypes; 280 281 /** The resource icon mapping. */ 282 private Map<String, String> m_iconMapping; 283 284 /** The show editor help flag. */ 285 private boolean m_isShowEditorHelp; 286 287 /** Keep-alive setting. */ 288 private boolean m_keepAlive; 289 290 /** The current request locale. */ 291 private String m_locale; 292 293 /** The login JSP URL. */ 294 private String m_loginURL; 295 296 /** The current navigation URI. */ 297 private String m_navigationUri; 298 299 /** The project id. */ 300 private CmsUUID m_projectId; 301 302 /** The shared folder. */ 303 private String m_sharedFolder; 304 305 /** The current site root. */ 306 private String m_siteRoot; 307 308 /** The structure id of the resource. */ 309 private CmsUUID m_structureId; 310 311 /** The data for the TinyMCE editor. */ 312 private CmsTinyMCEData m_tinymce; 313 314 /** A flag which indicates whether the toolbar should be shown initially. */ 315 private boolean m_toolbarVisible; 316 317 /** Flag indicating whether upload buttons should be disabled. */ 318 private boolean m_uploadDisabled; 319 320 /** The maximum file size for the upload. */ 321 private long m_uploadFileSizeLimit; 322 323 /** The upload restriction data. */ 324 private CmsUploadRestrictionInfo m_uploadRestriction; 325 326 /** The current uri. */ 327 private String m_uri; 328 329 /** The OpenCms VFS prefix. */ 330 private String m_vfsPrefix; 331 332 /** Flag which indicates whether the user should be warned when editing a reused element. */ 333 private boolean m_warnWhenEditingReusedElement; 334 335 /** The workplaces resources path prefix. */ 336 private String m_workplaceResourcesPrefix; 337 338 /** The current workplace locale. */ 339 private String m_wpLocale; 340 341 /** 342 * Constructor.<p> 343 */ 344 public CmsCoreData() { 345 346 // empty 347 } 348 349 /** 350 * Clone constructor.<p> 351 * 352 * @param clone the instance to clone 353 */ 354 public CmsCoreData(CmsCoreData clone) { 355 356 this( 357 clone.getContentEditorUrl(), 358 clone.getContentEditorBacklinkUrl(), 359 clone.getLoginURL(), 360 clone.getVfsPrefix(), 361 clone.getFileExplorerLink(), 362 clone.getWorkplaceResourcesPrefix(), 363 clone.getEmbeddedDialogsUrl(), 364 clone.getSiteRoot(), 365 clone.getSharedFolder(), 366 clone.getProjectId(), 367 clone.getLocale(), 368 clone.getWpLocale(), 369 clone.getUri(), 370 clone.getNavigationUri(), 371 clone.getStructureId(), 372 clone.getExtensionMapping(), 373 clone.getIconMapping(), 374 clone.getServerTime(), 375 clone.isShowEditorHelp(), 376 clone.isToolbarVisible(), 377 clone.getDefaultWorkplaceLink(), 378 clone.getAboutLink(), 379 clone.getUserInfo(), 380 clone.getUploadFileSizeLimit(), 381 clone.isKeepAlive(), 382 clone.isUploadDisabled(), 383 clone.m_adeParameters, 384 clone.m_uploadRestriction, 385 clone.m_categoryBaseFolder, 386 clone.m_hideDisabledGalleryTypes, 387 clone.m_warnWhenEditingReusedElement); 388 setTinymce(clone.getTinymce()); 389 } 390 391 /** 392 * Constructor.<p> 393 * 394 * @param contentEditorUrl the XML content editor URL 395 * @param contentEditorBacklinkUrl the XML content editor back-link URL 396 * @param loginUrl the login JSP URL 397 * @param vfsPrefix the OpenCms VFS prefix 398 * @param fileExplorerLink the file explorer link 399 * @param workplaceResourcesPrefix the workplace resources path prefix 400 * @param embeddedDialogsUrl the embedded dialogs URL 401 * @param siteRoot the current site root 402 * @param sharedFolder the shared folder 403 * @param projectId the project id 404 * @param locale the current request locale 405 * @param wpLocale the workplace locale 406 * @param uri the current uri 407 * @param structureId the structure id of tbe resource 408 * @param navigationUri the current navigation URI 409 * @param extensionMapping the mappings of file extensions to resource types 410 * @param iconMapping the resource icon mapping 411 * @param serverTime the current time 412 * @param isShowEditorHelp the show editor help flag 413 * @param toolbarVisible a flag to indicate whether the toolbar should be visible initially 414 * @param defaultWorkplaceLink the default link to use for opening the workplace 415 * @param aboutLink the link to the "About" page 416 * @param userInfo information about the current user 417 * @param uploadFileSizeLimit the file upload size limit 418 * @param isKeepAlive the keep-alive mode 419 * @param uploadDisabled true if upload buttons should be disabled 420 * @param adeParameters the map of ADE configuration parameters 421 * @param uploadRestriction the upload restriction data 422 * @param categoryBaseFolder the category base folder 423 * @param hideDisabledGalleryTypes true if deactivated types should be hidden in the gallery dialog 424 * @param warnWhenEditingReusedElement true if a warning dialog should be shown when editing a reused element 425 */ 426 public CmsCoreData( 427 String contentEditorUrl, 428 String contentEditorBacklinkUrl, 429 String loginUrl, 430 String vfsPrefix, 431 String fileExplorerLink, 432 String workplaceResourcesPrefix, 433 String embeddedDialogsUrl, 434 String siteRoot, 435 String sharedFolder, 436 CmsUUID projectId, 437 String locale, 438 String wpLocale, 439 String uri, 440 String navigationUri, 441 CmsUUID structureId, 442 Map<String, String> extensionMapping, 443 Map<String, String> iconMapping, 444 long serverTime, 445 boolean isShowEditorHelp, 446 boolean toolbarVisible, 447 String defaultWorkplaceLink, 448 String aboutLink, 449 UserInfo userInfo, 450 long uploadFileSizeLimit, 451 boolean isKeepAlive, 452 boolean uploadDisabled, 453 Map<String, String> adeParameters, 454 CmsUploadRestrictionInfo uploadRestriction, 455 String categoryBaseFolder, 456 boolean hideDisabledGalleryTypes, 457 boolean warnWhenEditingReusedElement) { 458 459 m_contentEditorUrl = contentEditorUrl; 460 m_contentEditorBacklinkUrl = contentEditorBacklinkUrl; 461 m_loginURL = loginUrl; 462 m_vfsPrefix = vfsPrefix; 463 m_workplaceResourcesPrefix = workplaceResourcesPrefix; 464 m_embeddedDialogsUrl = embeddedDialogsUrl; 465 m_siteRoot = siteRoot; 466 m_projectId = projectId; 467 m_locale = locale; 468 m_wpLocale = wpLocale; 469 m_uri = uri; 470 m_navigationUri = navigationUri; 471 m_extensionMapping = extensionMapping; 472 m_iconMapping = iconMapping; 473 m_serverTime = serverTime; 474 m_isShowEditorHelp = isShowEditorHelp; 475 m_toolbarVisible = toolbarVisible; 476 m_structureId = structureId; 477 m_defaultWorkplaceLink = defaultWorkplaceLink; 478 m_aboutLink = aboutLink; 479 m_userInfo = userInfo; 480 m_uploadFileSizeLimit = uploadFileSizeLimit; 481 m_keepAlive = isKeepAlive; 482 m_adeParameters = adeParameters; 483 m_fileExplorerLink = fileExplorerLink; 484 m_uploadDisabled = uploadDisabled; 485 m_uploadRestriction = uploadRestriction; 486 m_sharedFolder = sharedFolder; 487 m_categoryBaseFolder = categoryBaseFolder; 488 m_hideDisabledGalleryTypes = hideDisabledGalleryTypes; 489 m_warnWhenEditingReusedElement = warnWhenEditingReusedElement; 490 } 491 492 /** 493 * Gets the "About" link.<p> 494 * 495 * @return the "about" link 496 */ 497 public String getAboutLink() { 498 499 return m_aboutLink; 500 } 501 502 /** 503 * Gets the map of ADE configuration parameters.<p> 504 * 505 * @return the ADE configuration parameters 506 */ 507 public Map<String, String> getAdeParameters() { 508 509 return m_adeParameters; 510 } 511 512 /** 513 * Gets the category folder name. 514 * 515 * @return the category folder name 516 */ 517 public String getCategoryBaseFolder() { 518 519 return m_categoryBaseFolder; 520 } 521 522 /** 523 * Returns the XML content editor back-link URL.<p> 524 * 525 * @return the XML content editor back-link URL 526 */ 527 public String getContentEditorBacklinkUrl() { 528 529 return m_contentEditorBacklinkUrl; 530 } 531 532 /** 533 * Returns the XML content editor URL.<p> 534 * 535 * @return the XML content editor URL 536 */ 537 public String getContentEditorUrl() { 538 539 return m_contentEditorUrl; 540 } 541 542 /** 543 * Gets the default link to use for opening the workplace.<p> 544 * 545 * @return the default workplace link 546 */ 547 public String getDefaultWorkplaceLink() { 548 549 return m_defaultWorkplaceLink; 550 } 551 552 /** 553 * Returns the embeddedDialogsUrl.<p> 554 * 555 * @return the embeddedDialogsUrl 556 */ 557 public String getEmbeddedDialogsUrl() { 558 559 return m_embeddedDialogsUrl; 560 } 561 562 /** 563 * Returns the extensionMapping.<p> 564 * 565 * @return the extensionMapping 566 */ 567 public Map<String, String> getExtensionMapping() { 568 569 return m_extensionMapping; 570 } 571 572 /** 573 * Returns the resource icon mapping.<p> 574 * 575 * @return the resource icon mapping 576 */ 577 public Map<String, String> getIconMapping() { 578 579 return m_iconMapping; 580 } 581 582 /** 583 * Returns the current request locale.<p> 584 * 585 * @return the current request locale 586 */ 587 public String getLocale() { 588 589 return m_locale; 590 } 591 592 /** 593 * Returns the login URL.<p> 594 * 595 * @return the login URL 596 */ 597 public String getLoginURL() { 598 599 return m_loginURL; 600 } 601 602 /** 603 * Returns the current navigation (sitemap) URI.<p> 604 * 605 * @return the current navigation URI 606 */ 607 public String getNavigationUri() { 608 609 return m_navigationUri; 610 } 611 612 /** 613 * Gets the project id. 614 * 615 * @return the project id 616 */ 617 public CmsUUID getProjectId() { 618 619 return m_projectId; 620 } 621 622 /** 623 * Returns the time of the server when the data was loaded.<p> 624 * 625 * @return the time of the server when the data was loaded 626 */ 627 public long getServerTime() { 628 629 return m_serverTime; 630 } 631 632 /** 633 * Gets the shared folder. 634 * 635 * @return the shared folder 636 */ 637 public String getSharedFolder() { 638 639 return m_sharedFolder; 640 } 641 642 /** 643 * Returns the current site root.<p> 644 * 645 * @return the current site root 646 */ 647 public String getSiteRoot() { 648 649 return m_siteRoot; 650 } 651 652 /** 653 * Gets the structure id of the current resource.<p> 654 * 655 * @return the structure id of the current resource 656 */ 657 public CmsUUID getStructureId() { 658 659 return m_structureId; 660 } 661 662 /** 663 * Gets the data for the TinyMCE editor.<p> 664 * 665 * @return the data for TinyMCE 666 */ 667 public CmsTinyMCEData getTinymce() { 668 669 // TODO Auto-generated method stub 670 return m_tinymce; 671 } 672 673 /** 674 * Returns the file upload size limit.<p> 675 * 676 * @return the file upload size limit 677 */ 678 public long getUploadFileSizeLimit() { 679 680 return m_uploadFileSizeLimit; 681 } 682 683 /** 684 * Gets the upload restriction data. 685 * 686 * @return the upload restriction data 687 */ 688 public CmsUploadRestrictionInfo getUploadRestriction() { 689 690 return m_uploadRestriction; 691 } 692 693 /** 694 * Returns the current uri.<p> 695 * 696 * @return the current uri 697 */ 698 public String getUri() { 699 700 return m_uri; 701 } 702 703 /** 704 * Gets the information about the current user.<p> 705 * 706 * @return the information about the current user 707 */ 708 public UserInfo getUserInfo() { 709 710 return m_userInfo; 711 } 712 713 /** 714 * Returns the OpenCms VFS prefix.<p> 715 * 716 * @return the OpenCms VFS prefix 717 */ 718 public String getVfsPrefix() { 719 720 return m_vfsPrefix; 721 } 722 723 /** 724 * Returns the workplace resources path prefix.<p> 725 * 726 * @return the workplace resources path prefix 727 */ 728 public String getWorkplaceResourcesPrefix() { 729 730 return m_workplaceResourcesPrefix; 731 } 732 733 /** 734 * Gets the language part of the workplace locale. 735 * 736 * @return the language part of the workplace locale 737 */ 738 public String getWpLanguage() { 739 740 String locale = getWpLocale(); 741 String result = locale; 742 int underscorePos = locale.indexOf("_"); 743 if (underscorePos > -1) { 744 result = locale.substring(0, underscorePos); 745 } 746 return result; 747 } 748 749 /** 750 * Returns the current workplace locale.<p> 751 * 752 * @return the current workplace locale 753 */ 754 public String getWpLocale() { 755 756 return m_wpLocale; 757 } 758 759 /** 760 * Returns true if deactivated types should be hidden in the gallery dialog. 761 * 762 * @return true if deactivated types should be hidden 763 */ 764 public boolean isHideDisabledGalleryTypes() { 765 766 return m_hideDisabledGalleryTypes; 767 } 768 769 /** 770 * Returns true if the session should be kept alive even without user actions.<p> 771 * 772 * @return true if keep-alive mode is active 773 */ 774 public boolean isKeepAlive() { 775 776 return m_keepAlive; 777 } 778 779 /** 780 * Returns the show editor help flag.<p> 781 * 782 * @return the show editor help flag 783 */ 784 public boolean isShowEditorHelp() { 785 786 return m_isShowEditorHelp; 787 } 788 789 /** 790 * Returns true if the toolbar should be visible initially.<p> 791 * 792 * @return true if the toolbar should be visible initially 793 */ 794 public boolean isToolbarVisible() { 795 796 return m_toolbarVisible; 797 } 798 799 /** 800 * Checks if uploads are disabled. 801 * 802 * @return true if uploads are disabled 803 */ 804 public boolean isUploadDisabled() { 805 806 return m_uploadDisabled; 807 808 } 809 810 /** 811 * Checks if a warning dialog should be shown when a reused element is edited. 812 * 813 * @return true if a warning dialog should be shown when editing reused elements 814 */ 815 public boolean isWarnWhenEditingReusedElement() { 816 817 return m_warnWhenEditingReusedElement; 818 } 819 820 /** 821 * Sets the data for the TinyMCE editor.<p> 822 * 823 * @param tinyMceData the data for TinyMCE 824 */ 825 public void setTinymce(CmsTinyMCEData tinyMceData) { 826 827 m_tinymce = tinyMceData; 828 } 829 830 /** 831 * Enables/disables warning dialog when editing reused elements. 832 * 833 * @param warnWhenEditingReusedElement true if a warning dialog should be shown when editing reused elements 834 */ 835 public void setWarnWhenEditingReusedElement(boolean warnWhenEditingReusedElement) { 836 837 m_warnWhenEditingReusedElement = warnWhenEditingReusedElement; 838 } 839 840 /** 841 * Returns the file explorer link prefix. Append resource site path for complete link.<p> 842 * 843 * @return the file explorer link prefix 844 */ 845 protected String getFileExplorerLink() { 846 847 return m_fileExplorerLink; 848 } 849 850 /** 851 * Sets the show editor help flag.<p> 852 * 853 * @param show <code>true</code> to show editor help 854 */ 855 protected void setShowEditorHelp(boolean show) { 856 857 m_isShowEditorHelp = show; 858 } 859}