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 /** The workplaces resources path prefix. */ 333 private String m_workplaceResourcesPrefix; 334 335 /** The current workplace locale. */ 336 private String m_wpLocale; 337 338 /** 339 * Constructor.<p> 340 */ 341 public CmsCoreData() { 342 343 // empty 344 } 345 346 /** 347 * Clone constructor.<p> 348 * 349 * @param clone the instance to clone 350 */ 351 public CmsCoreData(CmsCoreData clone) { 352 353 this( 354 clone.getContentEditorUrl(), 355 clone.getContentEditorBacklinkUrl(), 356 clone.getLoginURL(), 357 clone.getVfsPrefix(), 358 clone.getFileExplorerLink(), 359 clone.getWorkplaceResourcesPrefix(), 360 clone.getEmbeddedDialogsUrl(), 361 clone.getSiteRoot(), 362 clone.getSharedFolder(), 363 clone.getProjectId(), 364 clone.getLocale(), 365 clone.getWpLocale(), 366 clone.getUri(), 367 clone.getNavigationUri(), 368 clone.getStructureId(), 369 clone.getExtensionMapping(), 370 clone.getIconMapping(), 371 clone.getServerTime(), 372 clone.isShowEditorHelp(), 373 clone.isToolbarVisible(), 374 clone.getDefaultWorkplaceLink(), 375 clone.getAboutLink(), 376 clone.getUserInfo(), 377 clone.getUploadFileSizeLimit(), 378 clone.isKeepAlive(), 379 clone.isUploadDisabled(), 380 clone.m_adeParameters, 381 clone.m_uploadRestriction, 382 clone.m_categoryBaseFolder, 383 clone.m_hideDisabledGalleryTypes); 384 setTinymce(clone.getTinymce()); 385 } 386 387 /** 388 * Constructor.<p> 389 * 390 * @param contentEditorUrl the XML content editor URL 391 * @param contentEditorBacklinkUrl the XML content editor back-link URL 392 * @param loginUrl the login JSP URL 393 * @param vfsPrefix the OpenCms VFS prefix 394 * @param fileExplorerLink the file explorer link 395 * @param workplaceResourcesPrefix the workplace resources path prefix 396 * @param embeddedDialogsUrl the embedded dialogs URL 397 * @param siteRoot the current site root 398 * @param sharedFolder the shared folder 399 * @param projectId the project id 400 * @param locale the current request locale 401 * @param wpLocale the workplace locale 402 * @param uri the current uri 403 * @param structureId the structure id of tbe resource 404 * @param navigationUri the current navigation URI 405 * @param extensionMapping the mappings of file extensions to resource types 406 * @param iconMapping the resource icon mapping 407 * @param serverTime the current time 408 * @param isShowEditorHelp the show editor help flag 409 * @param toolbarVisible a flag to indicate whether the toolbar should be visible initially 410 * @param defaultWorkplaceLink the default link to use for opening the workplace 411 * @param aboutLink the link to the "About" page 412 * @param userInfo information about the current user 413 * @param uploadFileSizeLimit the file upload size limit 414 * @param isKeepAlive the keep-alive mode 415 * @param uploadDisabled true if upload buttons should be disabled 416 * @param adeParameters the map of ADE configuration parameters 417 * @param uploadRestriction the upload restriction data 418 * @param categoryBaseFolder the category base folder 419 * @param hideDisabledGalleryTypes true if deactivated types should be hidden in the gallery dialog 420 */ 421 public CmsCoreData( 422 String contentEditorUrl, 423 String contentEditorBacklinkUrl, 424 String loginUrl, 425 String vfsPrefix, 426 String fileExplorerLink, 427 String workplaceResourcesPrefix, 428 String embeddedDialogsUrl, 429 String siteRoot, 430 String sharedFolder, 431 CmsUUID projectId, 432 String locale, 433 String wpLocale, 434 String uri, 435 String navigationUri, 436 CmsUUID structureId, 437 Map<String, String> extensionMapping, 438 Map<String, String> iconMapping, 439 long serverTime, 440 boolean isShowEditorHelp, 441 boolean toolbarVisible, 442 String defaultWorkplaceLink, 443 String aboutLink, 444 UserInfo userInfo, 445 long uploadFileSizeLimit, 446 boolean isKeepAlive, 447 boolean uploadDisabled, 448 Map<String, String> adeParameters, 449 CmsUploadRestrictionInfo uploadRestriction, 450 String categoryBaseFolder, 451 boolean hideDisabledGalleryTypes) { 452 453 m_contentEditorUrl = contentEditorUrl; 454 m_contentEditorBacklinkUrl = contentEditorBacklinkUrl; 455 m_loginURL = loginUrl; 456 m_vfsPrefix = vfsPrefix; 457 m_workplaceResourcesPrefix = workplaceResourcesPrefix; 458 m_embeddedDialogsUrl = embeddedDialogsUrl; 459 m_siteRoot = siteRoot; 460 m_projectId = projectId; 461 m_locale = locale; 462 m_wpLocale = wpLocale; 463 m_uri = uri; 464 m_navigationUri = navigationUri; 465 m_extensionMapping = extensionMapping; 466 m_iconMapping = iconMapping; 467 m_serverTime = serverTime; 468 m_isShowEditorHelp = isShowEditorHelp; 469 m_toolbarVisible = toolbarVisible; 470 m_structureId = structureId; 471 m_defaultWorkplaceLink = defaultWorkplaceLink; 472 m_aboutLink = aboutLink; 473 m_userInfo = userInfo; 474 m_uploadFileSizeLimit = uploadFileSizeLimit; 475 m_keepAlive = isKeepAlive; 476 m_adeParameters = adeParameters; 477 m_fileExplorerLink = fileExplorerLink; 478 m_uploadDisabled = uploadDisabled; 479 m_uploadRestriction = uploadRestriction; 480 m_sharedFolder = sharedFolder; 481 m_categoryBaseFolder = categoryBaseFolder; 482 m_hideDisabledGalleryTypes = hideDisabledGalleryTypes; 483 } 484 485 /** 486 * Gets the "About" link.<p> 487 * 488 * @return the "about" link 489 */ 490 public String getAboutLink() { 491 492 return m_aboutLink; 493 } 494 495 /** 496 * Gets the map of ADE configuration parameters.<p> 497 * 498 * @return the ADE configuration parameters 499 */ 500 public Map<String, String> getAdeParameters() { 501 502 return m_adeParameters; 503 } 504 505 /** 506 * Gets the category folder name. 507 * 508 * @return the category folder name 509 */ 510 public String getCategoryBaseFolder() { 511 512 return m_categoryBaseFolder; 513 } 514 515 /** 516 * Returns the XML content editor back-link URL.<p> 517 * 518 * @return the XML content editor back-link URL 519 */ 520 public String getContentEditorBacklinkUrl() { 521 522 return m_contentEditorBacklinkUrl; 523 } 524 525 /** 526 * Returns the XML content editor URL.<p> 527 * 528 * @return the XML content editor URL 529 */ 530 public String getContentEditorUrl() { 531 532 return m_contentEditorUrl; 533 } 534 535 /** 536 * Gets the default link to use for opening the workplace.<p> 537 * 538 * @return the default workplace link 539 */ 540 public String getDefaultWorkplaceLink() { 541 542 return m_defaultWorkplaceLink; 543 } 544 545 /** 546 * Returns the embeddedDialogsUrl.<p> 547 * 548 * @return the embeddedDialogsUrl 549 */ 550 public String getEmbeddedDialogsUrl() { 551 552 return m_embeddedDialogsUrl; 553 } 554 555 /** 556 * Returns the extensionMapping.<p> 557 * 558 * @return the extensionMapping 559 */ 560 public Map<String, String> getExtensionMapping() { 561 562 return m_extensionMapping; 563 } 564 565 /** 566 * Returns the resource icon mapping.<p> 567 * 568 * @return the resource icon mapping 569 */ 570 public Map<String, String> getIconMapping() { 571 572 return m_iconMapping; 573 } 574 575 /** 576 * Returns the current request locale.<p> 577 * 578 * @return the current request locale 579 */ 580 public String getLocale() { 581 582 return m_locale; 583 } 584 585 /** 586 * Returns the login URL.<p> 587 * 588 * @return the login URL 589 */ 590 public String getLoginURL() { 591 592 return m_loginURL; 593 } 594 595 /** 596 * Returns the current navigation (sitemap) URI.<p> 597 * 598 * @return the current navigation URI 599 */ 600 public String getNavigationUri() { 601 602 return m_navigationUri; 603 } 604 605 /** 606 * Gets the project id. 607 * 608 * @return the project id 609 */ 610 public CmsUUID getProjectId() { 611 612 return m_projectId; 613 } 614 615 /** 616 * Returns the time of the server when the data was loaded.<p> 617 * 618 * @return the time of the server when the data was loaded 619 */ 620 public long getServerTime() { 621 622 return m_serverTime; 623 } 624 625 /** 626 * Gets the shared folder. 627 * 628 * @return the shared folder 629 */ 630 public String getSharedFolder() { 631 632 return m_sharedFolder; 633 } 634 635 /** 636 * Returns the current site root.<p> 637 * 638 * @return the current site root 639 */ 640 public String getSiteRoot() { 641 642 return m_siteRoot; 643 } 644 645 /** 646 * Gets the structure id of the current resource.<p> 647 * 648 * @return the structure id of the current resource 649 */ 650 public CmsUUID getStructureId() { 651 652 return m_structureId; 653 } 654 655 /** 656 * Gets the data for the TinyMCE editor.<p> 657 * 658 * @return the data for TinyMCE 659 */ 660 public CmsTinyMCEData getTinymce() { 661 662 // TODO Auto-generated method stub 663 return m_tinymce; 664 } 665 666 /** 667 * Returns the file upload size limit.<p> 668 * 669 * @return the file upload size limit 670 */ 671 public long getUploadFileSizeLimit() { 672 673 return m_uploadFileSizeLimit; 674 } 675 676 /** 677 * Gets the upload restriction data. 678 * 679 * @return the upload restriction data 680 */ 681 public CmsUploadRestrictionInfo getUploadRestriction() { 682 683 return m_uploadRestriction; 684 } 685 686 /** 687 * Returns the current uri.<p> 688 * 689 * @return the current uri 690 */ 691 public String getUri() { 692 693 return m_uri; 694 } 695 696 /** 697 * Gets the information about the current user.<p> 698 * 699 * @return the information about the current user 700 */ 701 public UserInfo getUserInfo() { 702 703 return m_userInfo; 704 } 705 706 /** 707 * Returns the OpenCms VFS prefix.<p> 708 * 709 * @return the OpenCms VFS prefix 710 */ 711 public String getVfsPrefix() { 712 713 return m_vfsPrefix; 714 } 715 716 /** 717 * Returns the workplace resources path prefix.<p> 718 * 719 * @return the workplace resources path prefix 720 */ 721 public String getWorkplaceResourcesPrefix() { 722 723 return m_workplaceResourcesPrefix; 724 } 725 726 /** 727 * Gets the language part of the workplace locale. 728 * 729 * @return the language part of the workplace locale 730 */ 731 public String getWpLanguage() { 732 733 String locale = getWpLocale(); 734 String result = locale; 735 int underscorePos = locale.indexOf("_"); 736 if (underscorePos > -1) { 737 result = locale.substring(0, underscorePos); 738 } 739 return result; 740 } 741 742 /** 743 * Returns the current workplace locale.<p> 744 * 745 * @return the current workplace locale 746 */ 747 public String getWpLocale() { 748 749 return m_wpLocale; 750 } 751 752 /** 753 * Returns true if deactivated types should be hidden in the gallery dialog. 754 * 755 * @return true if deactivated types should be hidden 756 */ 757 public boolean isHideDisabledGalleryTypes() { 758 759 return m_hideDisabledGalleryTypes; 760 } 761 762 /** 763 * Returns true if the session should be kept alive even without user actions.<p> 764 * 765 * @return true if keep-alive mode is active 766 */ 767 public boolean isKeepAlive() { 768 769 return m_keepAlive; 770 } 771 772 /** 773 * Returns the show editor help flag.<p> 774 * 775 * @return the show editor help flag 776 */ 777 public boolean isShowEditorHelp() { 778 779 return m_isShowEditorHelp; 780 } 781 782 /** 783 * Returns true if the toolbar should be visible initially.<p> 784 * 785 * @return true if the toolbar should be visible initially 786 */ 787 public boolean isToolbarVisible() { 788 789 return m_toolbarVisible; 790 } 791 792 /** 793 * Checks if uploads are disabled. 794 * 795 * @return true if uploads are disabled 796 */ 797 public boolean isUploadDisabled() { 798 799 return m_uploadDisabled; 800 801 } 802 803 /** 804 * Sets the data for the TinyMCE editor.<p> 805 * 806 * @param tinyMceData the data for TinyMCE 807 */ 808 public void setTinymce(CmsTinyMCEData tinyMceData) { 809 810 m_tinymce = tinyMceData; 811 } 812 813 /** 814 * Returns the file explorer link prefix. Append resource site path for complete link.<p> 815 * 816 * @return the file explorer link prefix 817 */ 818 protected String getFileExplorerLink() { 819 820 return m_fileExplorerLink; 821 } 822 823 /** 824 * Sets the show editor help flag.<p> 825 * 826 * @param show <code>true</code> to show editor help 827 */ 828 protected void setShowEditorHelp(boolean show) { 829 830 m_isShowEditorHelp = show; 831 } 832}